@splinetool/runtime 1.12.98 → 2.0.2

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 (365) hide show
  1. package/README.md +195 -22
  2. package/build/boolean.js +406 -2
  3. package/build/boolean.js.br +0 -0
  4. package/build/boolean.js.gz +0 -0
  5. package/build/boolean.wasm +0 -0
  6. package/build/boolean.wasm.br +0 -0
  7. package/build/boolean.wasm.gz +0 -0
  8. package/build/gaussian-splat-compression.js.br +0 -0
  9. package/build/gaussian-splat-compression.js.gz +0 -0
  10. package/build/hana-ui.js +4299 -0
  11. package/build/hana-ui.js.br +0 -0
  12. package/build/hana-ui.js.gz +0 -0
  13. package/build/hana-ui.wasm +0 -0
  14. package/build/hana-ui.wasm.br +0 -0
  15. package/build/hana-ui.wasm.gz +0 -0
  16. package/build/howler.js.br +0 -0
  17. package/build/howler.js.gz +0 -0
  18. package/build/navmesh.js.br +0 -0
  19. package/build/navmesh.js.gz +0 -0
  20. package/build/navmesh.wasm +0 -0
  21. package/build/navmesh.wasm.br +0 -0
  22. package/build/navmesh.wasm.gz +0 -0
  23. package/build/opentype.js.br +0 -0
  24. package/build/opentype.js.gz +0 -0
  25. package/build/physics.js +1 -1
  26. package/build/physics.js.br +0 -0
  27. package/build/physics.js.gz +0 -0
  28. package/build/physics.wasm +0 -0
  29. package/build/physics.wasm.br +0 -0
  30. package/build/physics.wasm.gz +0 -0
  31. package/build/process.js +2 -2
  32. package/build/process.js.br +0 -0
  33. package/build/process.js.gz +0 -0
  34. package/build/process.wasm +0 -0
  35. package/build/process.wasm.br +0 -0
  36. package/build/process.wasm.gz +0 -0
  37. package/build/runtime-DRACOLoader-TQHJ6SJB.js +1 -0
  38. package/build/runtime-DRACOLoader-TQHJ6SJB.js.br +0 -0
  39. package/build/runtime-DRACOLoader-TQHJ6SJB.js.gz +0 -0
  40. package/build/runtime-Perfs-KMJFDYHU.js +1 -0
  41. package/build/runtime-Perfs-KMJFDYHU.js.br +0 -0
  42. package/build/runtime-Perfs-KMJFDYHU.js.gz +0 -0
  43. package/build/runtime-aiAssistant-XJVJ7TQB.js +1 -0
  44. package/build/runtime-aiAssistant-XJVJ7TQB.js.br +0 -0
  45. package/build/runtime-aiAssistant-XJVJ7TQB.js.gz +0 -0
  46. package/build/runtime-apiServices-KAO5SQJZ.js +1 -0
  47. package/build/runtime-apiServices-KAO5SQJZ.js.br +0 -0
  48. package/build/runtime-apiServices-KAO5SQJZ.js.gz +0 -0
  49. package/build/runtime-audio-Y3GYW4YQ.js +1 -0
  50. package/build/runtime-audio-Y3GYW4YQ.js.br +0 -0
  51. package/build/runtime-audio-Y3GYW4YQ.js.gz +0 -0
  52. package/build/runtime-bloom-XRHHZNNT.js +1 -0
  53. package/build/runtime-bloom-XRHHZNNT.js.br +0 -0
  54. package/build/runtime-bloom-XRHHZNNT.js.gz +0 -0
  55. package/build/runtime-brightnessContrast-RHV6X2Z4.js +1 -0
  56. package/build/runtime-brightnessContrast-RHV6X2Z4.js.br +0 -0
  57. package/build/runtime-brightnessContrast-RHV6X2Z4.js.gz +0 -0
  58. package/build/runtime-chromaticAberration-LSGAMQAK.js +1 -0
  59. package/build/runtime-chromaticAberration-LSGAMQAK.js.br +0 -0
  60. package/build/runtime-chromaticAberration-LSGAMQAK.js.gz +0 -0
  61. package/build/runtime-chunk-2SYZJBYJ.js +1 -0
  62. package/build/runtime-chunk-2SYZJBYJ.js.br +0 -0
  63. package/build/runtime-chunk-2SYZJBYJ.js.gz +0 -0
  64. package/build/runtime-chunk-2Y73BLCY.js +1 -0
  65. package/build/runtime-chunk-2Y73BLCY.js.br +0 -0
  66. package/build/runtime-chunk-2Y73BLCY.js.gz +0 -0
  67. package/build/runtime-chunk-4KZXQGUQ.js +1 -0
  68. package/build/runtime-chunk-4KZXQGUQ.js.br +0 -0
  69. package/build/runtime-chunk-4KZXQGUQ.js.gz +0 -0
  70. package/build/runtime-chunk-4YV3EXSU.js +1 -0
  71. package/build/runtime-chunk-4YV3EXSU.js.br +0 -0
  72. package/build/runtime-chunk-4YV3EXSU.js.gz +0 -0
  73. package/build/runtime-chunk-A2LYIKKC.js +1 -0
  74. package/build/runtime-chunk-A2LYIKKC.js.br +0 -0
  75. package/build/runtime-chunk-A2LYIKKC.js.gz +0 -0
  76. package/build/runtime-chunk-BJVCOW72.js +1 -0
  77. package/build/runtime-chunk-BJVCOW72.js.br +0 -0
  78. package/build/runtime-chunk-BJVCOW72.js.gz +0 -0
  79. package/build/runtime-chunk-CTHMLYOZ.js +1 -0
  80. package/build/runtime-chunk-CTHMLYOZ.js.br +0 -0
  81. package/build/runtime-chunk-CTHMLYOZ.js.gz +0 -0
  82. package/build/runtime-chunk-CVUJ3GMH.js +1 -0
  83. package/build/runtime-chunk-CVUJ3GMH.js.br +0 -0
  84. package/build/runtime-chunk-CVUJ3GMH.js.gz +0 -0
  85. package/build/runtime-chunk-DZNU62CT.js +1 -0
  86. package/build/runtime-chunk-DZNU62CT.js.br +0 -0
  87. package/build/runtime-chunk-DZNU62CT.js.gz +0 -0
  88. package/build/runtime-chunk-E6JCDSXC.js +1 -0
  89. package/build/runtime-chunk-E6JCDSXC.js.br +0 -0
  90. package/build/runtime-chunk-E6JCDSXC.js.gz +0 -0
  91. package/build/runtime-chunk-EOV2DL2V.js +1 -0
  92. package/build/runtime-chunk-EOV2DL2V.js.br +0 -0
  93. package/build/runtime-chunk-EOV2DL2V.js.gz +0 -0
  94. package/build/runtime-chunk-FF5REN2J.js +1 -0
  95. package/build/runtime-chunk-FF5REN2J.js.br +0 -0
  96. package/build/runtime-chunk-FF5REN2J.js.gz +0 -0
  97. package/build/runtime-chunk-FQNSP44B.js +1 -0
  98. package/build/runtime-chunk-FQNSP44B.js.br +0 -0
  99. package/build/runtime-chunk-FQNSP44B.js.gz +0 -0
  100. package/build/runtime-chunk-FTVQTRM7.js +1 -0
  101. package/build/runtime-chunk-FTVQTRM7.js.br +0 -0
  102. package/build/runtime-chunk-FTVQTRM7.js.gz +0 -0
  103. package/build/runtime-chunk-GFTBNL2W.js +1 -0
  104. package/build/runtime-chunk-GFTBNL2W.js.br +0 -0
  105. package/build/runtime-chunk-GFTBNL2W.js.gz +0 -0
  106. package/build/runtime-chunk-HJS3VFEN.js +1 -0
  107. package/build/runtime-chunk-HJS3VFEN.js.br +0 -0
  108. package/build/runtime-chunk-HJS3VFEN.js.gz +0 -0
  109. package/build/runtime-chunk-HL3PBPHE.js +1 -0
  110. package/build/runtime-chunk-HL3PBPHE.js.br +0 -0
  111. package/build/runtime-chunk-HL3PBPHE.js.gz +0 -0
  112. package/build/runtime-chunk-I47C4XJU.js +1 -0
  113. package/build/runtime-chunk-I47C4XJU.js.br +0 -0
  114. package/build/runtime-chunk-I47C4XJU.js.gz +0 -0
  115. package/build/runtime-chunk-JFYHGEDN.js +1 -0
  116. package/build/runtime-chunk-JFYHGEDN.js.br +0 -0
  117. package/build/runtime-chunk-JFYHGEDN.js.gz +0 -0
  118. package/build/runtime-chunk-K4FLB6Y7.js +1 -0
  119. package/build/runtime-chunk-K4FLB6Y7.js.br +0 -0
  120. package/build/runtime-chunk-K4FLB6Y7.js.gz +0 -0
  121. package/build/runtime-chunk-KGZNRID6.js +1 -0
  122. package/build/runtime-chunk-KGZNRID6.js.br +1 -0
  123. package/build/runtime-chunk-KGZNRID6.js.gz +0 -0
  124. package/build/runtime-chunk-LSURXI4Y.js +1 -0
  125. package/build/runtime-chunk-LSURXI4Y.js.br +2 -0
  126. package/build/runtime-chunk-LSURXI4Y.js.gz +0 -0
  127. package/build/runtime-chunk-MBBODDV7.js +1 -0
  128. package/build/runtime-chunk-MBBODDV7.js.br +0 -0
  129. package/build/runtime-chunk-MBBODDV7.js.gz +0 -0
  130. package/build/runtime-chunk-ML3Z74BL.js +1 -0
  131. package/build/runtime-chunk-ML3Z74BL.js.br +0 -0
  132. package/build/runtime-chunk-ML3Z74BL.js.gz +0 -0
  133. package/build/runtime-chunk-MM75L5X4.js +1 -0
  134. package/build/runtime-chunk-MM75L5X4.js.br +0 -0
  135. package/build/runtime-chunk-MM75L5X4.js.gz +0 -0
  136. package/build/runtime-chunk-MRUNX43X.js +1 -0
  137. package/build/runtime-chunk-MRUNX43X.js.br +0 -0
  138. package/build/runtime-chunk-MRUNX43X.js.gz +0 -0
  139. package/build/runtime-chunk-N2ZRGNPR.js +1 -0
  140. package/build/runtime-chunk-N2ZRGNPR.js.br +0 -0
  141. package/build/runtime-chunk-N2ZRGNPR.js.gz +0 -0
  142. package/build/runtime-chunk-NBYTQLIB.js +1 -0
  143. package/build/runtime-chunk-NBYTQLIB.js.br +0 -0
  144. package/build/runtime-chunk-NBYTQLIB.js.gz +0 -0
  145. package/build/runtime-chunk-NSD7DU3P.js +1 -0
  146. package/build/runtime-chunk-NSD7DU3P.js.br +0 -0
  147. package/build/runtime-chunk-NSD7DU3P.js.gz +0 -0
  148. package/build/runtime-chunk-NTUTXO7Q.js +1 -0
  149. package/build/runtime-chunk-NTUTXO7Q.js.br +0 -0
  150. package/build/runtime-chunk-NTUTXO7Q.js.gz +0 -0
  151. package/build/runtime-chunk-OEXC34HT.js +1 -0
  152. package/build/runtime-chunk-OEXC34HT.js.br +0 -0
  153. package/build/runtime-chunk-OEXC34HT.js.gz +0 -0
  154. package/build/runtime-chunk-OFPUAZKY.js +1 -0
  155. package/build/runtime-chunk-OFPUAZKY.js.br +0 -0
  156. package/build/runtime-chunk-OFPUAZKY.js.gz +0 -0
  157. package/build/runtime-chunk-OLJVVNDS.js +1 -0
  158. package/build/runtime-chunk-OLJVVNDS.js.br +0 -0
  159. package/build/runtime-chunk-OLJVVNDS.js.gz +0 -0
  160. package/build/runtime-chunk-OW6T4XFV.js +1 -0
  161. package/build/runtime-chunk-OW6T4XFV.js.br +0 -0
  162. package/build/runtime-chunk-OW6T4XFV.js.gz +0 -0
  163. package/build/runtime-chunk-P2XISQYQ.js +1 -0
  164. package/build/runtime-chunk-P2XISQYQ.js.br +0 -0
  165. package/build/runtime-chunk-P2XISQYQ.js.gz +0 -0
  166. package/build/runtime-chunk-P3254QGK.js +1 -0
  167. package/build/runtime-chunk-P3254QGK.js.br +0 -0
  168. package/build/runtime-chunk-P3254QGK.js.gz +0 -0
  169. package/build/runtime-chunk-PPLLJM75.js +1 -0
  170. package/build/runtime-chunk-PPLLJM75.js.br +0 -0
  171. package/build/runtime-chunk-PPLLJM75.js.gz +0 -0
  172. package/build/runtime-chunk-QHPFAHXN.js +1 -0
  173. package/build/runtime-chunk-QHPFAHXN.js.br +0 -0
  174. package/build/runtime-chunk-QHPFAHXN.js.gz +0 -0
  175. package/build/runtime-chunk-QZ35BPGB.js +1 -0
  176. package/build/runtime-chunk-QZ35BPGB.js.br +0 -0
  177. package/build/runtime-chunk-QZ35BPGB.js.gz +0 -0
  178. package/build/runtime-chunk-R43XZP65.js +1 -0
  179. package/build/runtime-chunk-R43XZP65.js.br +0 -0
  180. package/build/runtime-chunk-R43XZP65.js.gz +0 -0
  181. package/build/runtime-chunk-RAX4YJZF.js +1 -0
  182. package/build/runtime-chunk-RAX4YJZF.js.br +0 -0
  183. package/build/runtime-chunk-RAX4YJZF.js.gz +0 -0
  184. package/build/runtime-chunk-RQ3ZQR4P.js +1 -0
  185. package/build/runtime-chunk-RQ3ZQR4P.js.br +0 -0
  186. package/build/runtime-chunk-RQ3ZQR4P.js.gz +0 -0
  187. package/build/runtime-chunk-SKLNU6XK.js +1 -0
  188. package/build/runtime-chunk-SKLNU6XK.js.br +0 -0
  189. package/build/runtime-chunk-SKLNU6XK.js.gz +0 -0
  190. package/build/runtime-chunk-T53JMQSH.js +1 -0
  191. package/build/runtime-chunk-T53JMQSH.js.br +0 -0
  192. package/build/runtime-chunk-T53JMQSH.js.gz +0 -0
  193. package/build/runtime-chunk-TDCFE5IE.js +1 -0
  194. package/build/runtime-chunk-TDCFE5IE.js.br +0 -0
  195. package/build/runtime-chunk-TDCFE5IE.js.gz +0 -0
  196. package/build/runtime-chunk-TU4KDRKR.js +1 -0
  197. package/build/runtime-chunk-TU4KDRKR.js.br +0 -0
  198. package/build/runtime-chunk-TU4KDRKR.js.gz +0 -0
  199. package/build/runtime-chunk-TZCHGFVF.js +1 -0
  200. package/build/runtime-chunk-TZCHGFVF.js.br +3 -0
  201. package/build/runtime-chunk-TZCHGFVF.js.gz +0 -0
  202. package/build/runtime-chunk-USXMESRF.js +1 -0
  203. package/build/runtime-chunk-USXMESRF.js.br +0 -0
  204. package/build/runtime-chunk-USXMESRF.js.gz +0 -0
  205. package/build/runtime-chunk-VAVYZ35B.js +1 -0
  206. package/build/runtime-chunk-VAVYZ35B.js.br +0 -0
  207. package/build/runtime-chunk-VAVYZ35B.js.gz +0 -0
  208. package/build/runtime-chunk-VGN7YHB7.js +1 -0
  209. package/build/runtime-chunk-VGN7YHB7.js.br +0 -0
  210. package/build/runtime-chunk-VGN7YHB7.js.gz +0 -0
  211. package/build/runtime-chunk-VRVV54WH.js +1 -0
  212. package/build/runtime-chunk-VRVV54WH.js.br +0 -0
  213. package/build/runtime-chunk-VRVV54WH.js.gz +0 -0
  214. package/build/runtime-chunk-WSJURWOC.js +1 -0
  215. package/build/runtime-chunk-WSJURWOC.js.br +0 -0
  216. package/build/runtime-chunk-WSJURWOC.js.gz +0 -0
  217. package/build/runtime-chunk-Y3BMDVJ7.js +1 -0
  218. package/build/runtime-chunk-Y3BMDVJ7.js.br +0 -0
  219. package/build/runtime-chunk-Y3BMDVJ7.js.gz +0 -0
  220. package/build/runtime-chunk-YXATXASV.js +1 -0
  221. package/build/runtime-chunk-YXATXASV.js.br +1 -0
  222. package/build/runtime-chunk-YXATXASV.js.gz +0 -0
  223. package/build/runtime-chunk-Z5OH244S.js +1 -0
  224. package/build/runtime-chunk-Z5OH244S.js.br +0 -0
  225. package/build/runtime-chunk-Z5OH244S.js.gz +0 -0
  226. package/build/runtime-classicRuntime-AMAXBOXT.js +1 -0
  227. package/build/runtime-classicRuntime-AMAXBOXT.js.br +0 -0
  228. package/build/runtime-classicRuntime-AMAXBOXT.js.gz +0 -0
  229. package/build/runtime-cloners-4W3AOAQX.js +1 -0
  230. package/build/runtime-cloners-4W3AOAQX.js.br +1 -0
  231. package/build/runtime-cloners-4W3AOAQX.js.gz +0 -0
  232. package/build/runtime-collisionBVH-KXZNWTEK.js +1 -0
  233. package/build/runtime-collisionBVH-KXZNWTEK.js.br +0 -0
  234. package/build/runtime-collisionBVH-KXZNWTEK.js.gz +0 -0
  235. package/build/runtime-components-EPAMFKSB.js +1 -0
  236. package/build/runtime-components-EPAMFKSB.js.br +0 -0
  237. package/build/runtime-components-EPAMFKSB.js.gz +0 -0
  238. package/build/runtime-conditional-3A423CXW.js +1 -0
  239. package/build/runtime-conditional-3A423CXW.js.br +0 -0
  240. package/build/runtime-conditional-3A423CXW.js.gz +0 -0
  241. package/build/runtime-createDestroy-HLHRAAC4.js +1 -0
  242. package/build/runtime-createDestroy-HLHRAAC4.js.br +0 -0
  243. package/build/runtime-createDestroy-HLHRAAC4.js.gz +0 -0
  244. package/build/runtime-depthOfField-BBWDHJYP.js +1 -0
  245. package/build/runtime-depthOfField-BBWDHJYP.js.br +0 -0
  246. package/build/runtime-depthOfField-BBWDHJYP.js.gz +0 -0
  247. package/build/runtime-dragDrop-K6LWK7FL.js +1 -0
  248. package/build/runtime-dragDrop-K6LWK7FL.js.br +0 -0
  249. package/build/runtime-dragDrop-K6LWK7FL.js.gz +0 -0
  250. package/build/runtime-fxBloom-IGFV4KJD.js +1 -0
  251. package/build/runtime-fxBloom-IGFV4KJD.js.br +0 -0
  252. package/build/runtime-fxBloom-IGFV4KJD.js.gz +0 -0
  253. package/build/runtime-fxDepthOfField-WX7WD3K4.js +1 -0
  254. package/build/runtime-fxDepthOfField-WX7WD3K4.js.br +0 -0
  255. package/build/runtime-fxDepthOfField-WX7WD3K4.js.gz +0 -0
  256. package/build/runtime-gameControls-ZJUUKNHM.js +1 -0
  257. package/build/runtime-gameControls-ZJUUKNHM.js.br +0 -0
  258. package/build/runtime-gameControls-ZJUUKNHM.js.gz +0 -0
  259. package/build/runtime-hair-AGUMVL55.js +1 -0
  260. package/build/runtime-hair-AGUMVL55.js.br +3 -0
  261. package/build/runtime-hair-AGUMVL55.js.gz +0 -0
  262. package/build/runtime-hueSaturation-X3HAZK2G.js +1 -0
  263. package/build/runtime-hueSaturation-X3HAZK2G.js.br +0 -0
  264. package/build/runtime-hueSaturation-X3HAZK2G.js.gz +0 -0
  265. package/build/runtime-mergeStaticGeometries-AOGKOEBX.js +1 -0
  266. package/build/runtime-mergeStaticGeometries-AOGKOEBX.js.br +0 -0
  267. package/build/runtime-mergeStaticGeometries-AOGKOEBX.js.gz +0 -0
  268. package/build/runtime-miscActions-L7BIGLEB.js +1 -0
  269. package/build/runtime-miscActions-L7BIGLEB.js.br +0 -0
  270. package/build/runtime-miscActions-L7BIGLEB.js.gz +0 -0
  271. package/build/runtime-mouseHover-BI5SRQSQ.js +1 -0
  272. package/build/runtime-mouseHover-BI5SRQSQ.js.br +0 -0
  273. package/build/runtime-mouseHover-BI5SRQSQ.js.gz +0 -0
  274. package/build/runtime-navmesh-UJTUAHXM.js +1 -0
  275. package/build/runtime-navmesh-UJTUAHXM.js.br +0 -0
  276. package/build/runtime-navmesh-UJTUAHXM.js.gz +0 -0
  277. package/build/runtime-noise-UF5CMIO3.js +1 -0
  278. package/build/runtime-noise-UF5CMIO3.js.br +0 -0
  279. package/build/runtime-noise-UF5CMIO3.js.gz +0 -0
  280. package/build/runtime-particles-W7YEQWJI.js +1 -0
  281. package/build/runtime-particles-W7YEQWJI.js.br +0 -0
  282. package/build/runtime-particles-W7YEQWJI.js.gz +0 -0
  283. package/build/runtime-paths-CK327WCT.js +1 -0
  284. package/build/runtime-paths-CK327WCT.js.br +0 -0
  285. package/build/runtime-paths-CK327WCT.js.gz +0 -0
  286. package/build/runtime-pixelation-QFSF4L6X.js +1 -0
  287. package/build/runtime-pixelation-QFSF4L6X.js.br +0 -0
  288. package/build/runtime-pixelation-QFSF4L6X.js.gz +0 -0
  289. package/build/runtime-resize-RUUW4IXW.js +1 -0
  290. package/build/runtime-resize-RUUW4IXW.js.br +0 -0
  291. package/build/runtime-resize-RUUW4IXW.js.gz +0 -0
  292. package/build/runtime-sceneTransition-7AG4A4P5.js +1 -0
  293. package/build/runtime-sceneTransition-7AG4A4P5.js.br +0 -0
  294. package/build/runtime-sceneTransition-7AG4A4P5.js.gz +0 -0
  295. package/build/runtime-scroll-MNQPPLQL.js +1 -0
  296. package/build/runtime-scroll-MNQPPLQL.js.br +0 -0
  297. package/build/runtime-scroll-MNQPPLQL.js.gz +0 -0
  298. package/build/runtime-shapeBlends-IP5LZ63L.js +1 -0
  299. package/build/runtime-shapeBlends-IP5LZ63L.js.br +0 -0
  300. package/build/runtime-shapeBlends-IP5LZ63L.js.gz +0 -0
  301. package/build/runtime-text-5RIKJ4US.js +1 -0
  302. package/build/runtime-text-5RIKJ4US.js.br +0 -0
  303. package/build/runtime-text-5RIKJ4US.js.gz +0 -0
  304. package/build/runtime-textInputs-YBGYTAMD.js +1 -0
  305. package/build/runtime-textInputs-YBGYTAMD.js.br +0 -0
  306. package/build/runtime-textInputs-YBGYTAMD.js.gz +0 -0
  307. package/build/runtime-timeline-32GBWMFJ.js +1 -0
  308. package/build/runtime-timeline-32GBWMFJ.js.br +0 -0
  309. package/build/runtime-timeline-32GBWMFJ.js.gz +0 -0
  310. package/build/runtime-tracking-2BXFBQQY.js +1 -0
  311. package/build/runtime-tracking-2BXFBQQY.js.br +0 -0
  312. package/build/runtime-tracking-2BXFBQQY.js.gz +0 -0
  313. package/build/runtime-transitions-6PZW2QIW.js +1 -0
  314. package/build/runtime-transitions-6PZW2QIW.js.br +0 -0
  315. package/build/runtime-transitions-6PZW2QIW.js.gz +0 -0
  316. package/build/runtime-ui2d-VEQUBXIE.js +1 -0
  317. package/build/runtime-ui2d-VEQUBXIE.js.br +0 -0
  318. package/build/runtime-ui2d-VEQUBXIE.js.gz +0 -0
  319. package/build/runtime-updater-3ELP7WMM.js +1 -0
  320. package/build/runtime-updater-3ELP7WMM.js.br +1 -0
  321. package/build/runtime-updater-3ELP7WMM.js.gz +0 -0
  322. package/build/runtime-variables-U36KPJ5V.js +1 -0
  323. package/build/runtime-variables-U36KPJ5V.js.br +0 -0
  324. package/build/runtime-variables-U36KPJ5V.js.gz +0 -0
  325. package/build/runtime-vectorShapes-4HPEEN3B.js +1 -0
  326. package/build/runtime-vectorShapes-4HPEEN3B.js.br +0 -0
  327. package/build/runtime-vectorShapes-4HPEEN3B.js.gz +0 -0
  328. package/build/runtime-video-TZNR7MEM.js +1 -0
  329. package/build/runtime-video-TZNR7MEM.js.br +0 -0
  330. package/build/runtime-video-TZNR7MEM.js.gz +0 -0
  331. package/build/runtime-vignette-3KJD4P5D.js +1 -0
  332. package/build/runtime-vignette-3KJD4P5D.js.br +0 -0
  333. package/build/runtime-vignette-3KJD4P5D.js.gz +0 -0
  334. package/build/runtime-webgpu-YNY4OXCZ.js +1 -0
  335. package/build/runtime-webgpu-YNY4OXCZ.js.br +0 -0
  336. package/build/runtime-webgpu-YNY4OXCZ.js.gz +0 -0
  337. package/build/runtime.cjs +6283 -4577
  338. package/build/runtime.js +1 -8186
  339. package/build/runtime.js.br +0 -0
  340. package/build/runtime.js.gz +0 -0
  341. package/build/runtime.standalone.js +1 -0
  342. package/build/runtime.standalone.js.br +0 -0
  343. package/build/runtime.standalone.js.gz +0 -0
  344. package/build/runtime.standalone.webgl.js +1 -0
  345. package/build/runtime.standalone.webgl.js.br +0 -0
  346. package/build/runtime.standalone.webgl.js.gz +0 -0
  347. package/build/runtime.standalone.webgpu.js +1 -0
  348. package/build/runtime.standalone.webgpu.js.br +0 -0
  349. package/build/runtime.standalone.webgpu.js.gz +0 -0
  350. package/build/runtime.standalone.webgpu.micro.js +1 -0
  351. package/build/runtime.standalone.webgpu.micro.js.br +0 -0
  352. package/build/runtime.standalone.webgpu.micro.js.gz +0 -0
  353. package/build/runtime.standalone.webgpu.min.js +1 -0
  354. package/build/runtime.standalone.webgpu.min.js.br +0 -0
  355. package/build/runtime.standalone.webgpu.min.js.gz +0 -0
  356. package/build/sky-alto.png +0 -0
  357. package/build/sky-cirrus.png +0 -0
  358. package/build/smaa-area.png +0 -0
  359. package/build/smaa-node-area.png +0 -0
  360. package/build/smaa-node-search.png +0 -0
  361. package/build/smaa-search.png +0 -0
  362. package/build/snippets/hana-82e9eb82a79dead4/js-imports.js +93 -0
  363. package/package.json +104 -89
  364. package/runtime.d.ts +301 -2
  365. package/build/ui.js +0 -3
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,s=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,n=(e,t)=>()=>(e&&(t=e(e=0)),t),o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,i)=>{for(var r in i)t(e,r,{get:i[r],enumerable:!0})},h=(n,o,l)=>(l=null!=n?e(s(n)):{},((e,s,n,o)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let n of r(s))!a.call(e,n)&&void 0!==n&&t(e,n,{get:()=>s[n],enumerable:!(o=i(s,n))||o.enumerable});return e})(!o&&n&&n.__esModule?l:t(l,"default",{value:n,enumerable:!0}),n)),u=(e,i,r)=>(((e,i,r)=>{i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r})(e,"symbol"!=typeof i?i+"":i,r),r);function d(e,t){return new Hr[e](t)}function c(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function p(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function m(...e){let t="THREE."+e.shift();Yr?Yr("log",t,...e):console.log(t,...e)}function g(e){let t=e[0];if("string"==typeof t&&t.startsWith("TSL:")){let t=e[1];t&&t.isStackTrace?e[0]+=" "+t.getLocation():e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function f(...e){let t="THREE."+(e=g(e)).shift();if(Yr)Yr("warn",t,...e);else{let i=e[0];i&&i.isStackTrace?console.warn(i.getError(t)):console.warn(t,...e)}}function y(...e){let t="THREE."+(e=g(e)).shift();if(Yr)Yr("error",t,...e);else{let i=e[0];i&&i.isStackTrace?console.error(i.getError(t)):console.error(t,...e)}}function v(...e){let t=e.join(" ");t in $r||($r[t]=!0,f(...e))}function b(){let e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(Zr[255&e]+Zr[e>>8&255]+Zr[e>>16&255]+Zr[e>>24&255]+"-"+Zr[255&t]+Zr[t>>8&255]+"-"+Zr[t>>16&15|64]+Zr[t>>24&255]+"-"+Zr[63&i|128]+Zr[i>>8&255]+"-"+Zr[i>>16&255]+Zr[i>>24&255]+Zr[255&r]+Zr[r>>8&255]+Zr[r>>16&255]+Zr[r>>24&255]).toLowerCase()}function x(e,t,i){return Math.max(t,Math.min(i,e))}function w(e,t){return(e%t+t)%t}function _(e,t,i,r,s){return r+(e-t)*(s-r)/(i-t)}function S(e,t,i){return e!==t?(i-e)/(t-e):0}function M(e,t,i){return(1-i)*e+i*t}function T(e,t,i,r){return M(e,t,1-Math.exp(-i*r))}function C(e,t=1){return t-Math.abs(w(e,2*t)-t)}function A(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)}function N(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)}function P(e,t){return e+Math.floor(Math.random()*(t-e+1))}function R(e,t){return e+Math.random()*(t-e)}function E(e){return e*(.5-Math.random())}function O(e){void 0!==e&&(Jr=e);let t=Jr+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}function B(e){return e*Qr}function V(e){return e*es}function D(e){return!(e&e-1)&&0!==e}function I(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function L(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function z(e,t,i,r,s){let a=Math.cos,n=Math.sin,o=a(i/2),l=n(i/2),h=a((t+r)/2),u=n((t+r)/2),d=a((t-r)/2),c=n((t-r)/2),p=a((r-t)/2),m=n((r-t)/2);switch(s){case"XYX":e.set(o*u,l*d,l*c,o*h);break;case"YZY":e.set(l*c,o*u,l*d,o*h);break;case"ZXZ":e.set(l*d,l*c,o*u,o*h);break;case"XZX":e.set(o*u,l*m,l*p,o*h);break;case"YXY":e.set(l*p,o*u,l*m,o*h);break;case"ZYZ":e.set(l*m,l*p,o*u,o*h);break;default:f("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function k(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function U(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function F(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function j(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function G(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap?fs.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(f("Texture: Unable to serialize Texture."),{})}function W(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}function q(e,t,i,r,s){for(let a=0,n=e.length-3;a<=n;a+=3){Ia.fromArray(e,a);let n=s.x*Math.abs(Ia.x)+s.y*Math.abs(Ia.y)+s.z*Math.abs(Ia.z),o=t.dot(Ia),l=i.dot(Ia),h=r.dot(Ia);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>n)return!1}return!0}function H(e){Math.abs(e)>65504&&f("DataUtils.toHalfFloat(): Value out of range."),e=x(e,-65504,65504),La.floatView[0]=e;let t=La.uint32View[0],i=t>>23&511;return La.baseTable[i]+((8388607&t)>>La.shiftTable[i])}function $(e){let t=e>>10;return La.uint32View[0]=La.mantissaTable[La.offsetTable[t]+(1023&e)]+La.exponentTable[t],La.floatView[0]}function Y(e,t,i,r,s,a){fn.subVectors(e,i).addScalar(.5).multiply(r),void 0!==s?(yn.x=a*fn.x-s*fn.y,yn.y=s*fn.x+a*fn.y):yn.copy(fn),e.copy(t),e.x+=yn.x,e.y+=yn.y,e.applyMatrix4(vn)}function X(e,t,i,r,s,a,n,o,l,h){e.getVertexPosition(o,kn),e.getVertexPosition(l,Un),e.getVertexPosition(h,Fn);let u=function(e,t,i,r,s,a,n,o){let l;if(l=t.side===We?r.intersectTriangle(n,a,s,!0,o):r.intersectTriangle(s,a,n,t.side===Ge,o),null===l)return null;qn.copy(o),qn.applyMatrix4(e.matrixWorld);let h=i.ray.origin.distanceTo(qn);return h<i.near||h>i.far?null:{distance:h,point:qn.clone(),object:e}}(e,t,i,r,kn,Un,Fn,Wn);if(u){let e=new ns;_a.getBarycoord(Wn,kn,Un,Fn,e),s&&(u.uv=_a.getInterpolatedAttribute(s,o,l,h,e,new rs)),a&&(u.uv1=_a.getInterpolatedAttribute(a,o,l,h,e,new rs)),n&&(u.normal=_a.getInterpolatedAttribute(n,o,l,h,e,new ns),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:o,b:l,c:h,normal:new ns,materialIndex:0};_a.getNormal(kn,Un,Fn,t.normal),u.face=t,u.barycoord=e}return u}function K(e,t,i,r,s,a,n){let o=e.geometry.attributes.position;if(bo.fromBufferAttribute(o,s),xo.fromBufferAttribute(o,a),i.distanceSqToSegment(bo,xo,Mo,To)>r)return;Mo.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(Mo);return l<t.near||l>t.far?void 0:{distance:l,point:To.clone().applyMatrix4(e.matrixWorld),index:n,face:null,faceIndex:null,barycoord:null,object:e}}function Z(){let e=0,t=0,i=0,r=0;function s(s,a,n,o){e=s,t=n,i=-3*s+3*a-2*n-o,r=2*s-2*a+n+o}return{initCatmullRom:function(e,t,i,r,a){s(t,i,a*(i-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,i,r,a,n,o){let l=(t-e)/a-(i-e)/(a+n)+(i-t)/n,h=(i-t)/n-(r-t)/(n+o)+(r-i)/o;l*=n,h*=n,s(t,i,l,h)},calc:function(s){let a=s*s;return e+t*s+i*a+r*(a*s)}}}function J(e,t,i,r,s){let a=.5*(r-t),n=.5*(s-i),o=e*e;return(2*i-2*r+a+n)*(e*o)+(-3*i+3*r-2*a-n)*o+a*e+i}function Q(e,t,i,r){return function(e,t){let i=1-e;return i*i*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,i)+function(e,t){return e*e*t}(e,r)}function ee(e,t,i,r,s){return function(e,t){let i=1-e;return i*i*i*t}(e,t)+function(e,t){let i=1-e;return 3*i*i*e*t}(e,i)+function(e,t){return 3*(1-e)*e*e*t}(e,r)+function(e,t){return e*e*e*t}(e,s)}function te(e,t,i,r,s){let a;if(s===function(e,t,i,r){let s=0;for(let a=t,n=i-r;a<i;a+=r)s+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return s}(e,t,i,r)>0)for(let s=t;s<i;s+=r)a=Se(s/r|0,e[s],e[s+1],a);else for(let s=i-r;s>=t;s-=r)a=Se(s/r|0,e[s],e[s+1],a);return a&&ye(a,a.next)&&(Me(a),a=a.next),a}function ie(e,t){if(!e)return e;t||(t=e);let i,r=e;do{if(i=!1,r.steiner||!ye(r,r.next)&&0!==fe(r.prev,r,r.next))r=r.next;else{if(Me(r),r=t=r.prev,r===r.next)break;i=!0}}while(i||r!==t);return t}function re(e,t,i,r,s,a,n){if(!e)return;!n&&a&&function(e,t,i,r){let s=e;do{0===s.z&&(s.z=de(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,function(e){let t,i=1;do{let r,s=e;e=null;let a=null;for(t=0;s;){t++;let n=s,o=0;for(let e=0;e<i&&(o++,n=n.nextZ,n);e++);let l=i;for(;o>0||l>0&&n;)0!==o&&(0===l||!n||s.z<=n.z)?(r=s,s=s.nextZ,o--):(r=n,n=n.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;s=n}a.nextZ=null,i*=2}while(t>1)}(s)}(e,r,s,a);let o=e;for(;e.prev!==e.next;){let l=e.prev,h=e.next;if(a?ae(e,r,s,a):se(e))t.push(l.i,e.i,h.i),Me(e),e=h.next,o=h.next;else if((e=h)===o){n?1===n?re(e=ne(ie(e),t),t,i,r,s,a,2):2===n&&oe(e,t,i,r,s,a):re(ie(e),t,i,r,s,a,1);break}}}function se(e){let t=e.prev,i=e,r=e.next;if(fe(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,u=Math.min(s,a,n),d=Math.min(o,l,h),c=Math.max(s,a,n),p=Math.max(o,l,h),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=c&&m.y>=d&&m.y<=p&&me(s,o,a,l,n,h,m.x,m.y)&&fe(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function ae(e,t,i,r){let s=e.prev,a=e,n=e.next;if(fe(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,u=s.y,d=a.y,c=n.y,p=Math.min(o,l,h),m=Math.min(u,d,c),g=Math.max(o,l,h),f=Math.max(u,d,c),y=de(p,m,t,i,r),v=de(g,f,t,i,r),b=e.prevZ,x=e.nextZ;for(;b&&b.z>=y&&x&&x.z<=v;){if(b.x>=p&&b.x<=g&&b.y>=m&&b.y<=f&&b!==s&&b!==n&&me(o,u,l,d,h,c,b.x,b.y)&&fe(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=p&&x.x<=g&&x.y>=m&&x.y<=f&&x!==s&&x!==n&&me(o,u,l,d,h,c,x.x,x.y)&&fe(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=g&&b.y>=m&&b.y<=f&&b!==s&&b!==n&&me(o,u,l,d,h,c,b.x,b.y)&&fe(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=g&&x.y>=m&&x.y<=f&&x!==s&&x!==n&&me(o,u,l,d,h,c,x.x,x.y)&&fe(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function ne(e,t){let i=e;do{let r=i.prev,s=i.next.next;!ye(r,s)&&ve(r,i,i.next,s)&&we(r,s)&&we(s,r)&&(t.push(r.i,i.i,s.i),Me(i),Me(i.next),i=e=s),i=i.next}while(i!==e);return ie(i)}function oe(e,t,i,r,s,a){let n=e;do{let e=n.next.next;for(;e!==n.prev;){if(n.i!==e.i&&ge(n,e)){let o=_e(n,e);return n=ie(n,n.next),o=ie(o,o.next),re(n,t,i,r,s,a,0),void re(o,t,i,r,s,a,0)}e=e.next}n=n.next}while(n!==e)}function le(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function he(e,t){let i=function(e,t){let i,r=t,s=e.x,a=e.y,n=-1/0;if(ye(e,r))return r;do{if(ye(e,r.next))return r.next;if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){let e=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=s&&e>n&&(n=e,i=r.x<r.next.x?r:r.next,e===s))return i}r=r.next}while(r!==t);if(!i)return null;let o=i,l=i.x,h=i.y,u=1/0;r=i;do{if(s>=r.x&&r.x>=l&&s!==r.x&&pe(a<h?s:n,a,l,h,a<h?n:s,a,r.x,r.y)){let t=Math.abs(a-r.y)/(s-r.x);we(r,e)&&(t<u||t===u&&(r.x>i.x||r.x===i.x&&ue(i,r)))&&(i=r,u=t)}r=r.next}while(r!==o);return i}(e,t);if(!i)return t;let r=_e(i,e);return ie(r,r.next),ie(i,i.next)}function ue(e,t){return fe(e.prev,e,t.prev)<0&&fe(t.next,e,e.next)<0}function de(e,t,i,r,s){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ce(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function pe(e,t,i,r,s,a,n,o){return(s-n)*(t-o)>=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function me(e,t,i,r,s,a,n,o){return!(e===n&&t===o)&&pe(e,t,i,r,s,a,n,o)}function ge(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&ve(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(we(e,t)&&we(t,e)&&function(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do{i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(fe(e.prev,e,t.prev)||fe(e,t.prev,t))||ye(e,t)&&fe(e.prev,e,e.next)>0&&fe(t.prev,t,t.next)>0)}function fe(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function ye(e,t){return e.x===t.x&&e.y===t.y}function ve(e,t,i,r){let s=xe(fe(e,t,i)),a=xe(fe(e,t,r)),n=xe(fe(i,r,e)),o=xe(fe(i,r,t));return!!(s!==a&&n!==o||0===s&&be(e,i,t)||0===a&&be(e,r,t)||0===n&&be(i,e,r)||0===o&&be(i,t,r))}function be(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function xe(e){return e>0?1:e<0?-1:0}function we(e,t){return fe(e.prev,e,e.next)<0?fe(e,t,e.next)>=0&&fe(e,e.prev,t)>=0:fe(e,t,e.prev)<0||fe(e,e.next,t)<0}function _e(e,t){let i=Te(e.i,e.x,e.y),r=Te(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function Se(e,t,i,r){let s=Te(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Me(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Te(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ce(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Ae(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}function Ne(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function Pe(e,t){return e&&e.constructor!==t?"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e):e}function Re(e){let t=e.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort(function(t,i){return e[t]-e[i]}),i}function Ee(e,t,i){let r=e.length,s=new e.constructor(r);for(let a=0,n=0;n!==r;++a){let r=i[a]*t;for(let i=0;i!==t;++i)s[n++]=e[r+i]}return s}function Oe(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Bl;case"vector":case"vector2":case"vector3":case"vector4":return Ll;case"color":return Ol;case"quaternion":return Dl;case"bool":case"boolean":return El;case"string":return Il}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){let t=[],i=[];(function(e,t,i,r){let s=1,a=e[0];for(;void 0!==a&&void 0===a[r];)a=e[s++];if(void 0===a)return;let n=a[r];if(void 0!==n)if(Array.isArray(n))do{n=a[r],void 0!==n&&(t.push(a.time),i.push(...n)),a=e[s++]}while(void 0!==a);else if(void 0!==n.toArray)do{n=a[r],void 0!==n&&(t.push(a.time),n.toArray(i,i.length)),a=e[s++]}while(void 0!==a);else do{n=a[r],void 0!==n&&(t.push(a.time),i.push(n)),a=e[s++]}while(void 0!==a)})(e.keys,t,i,"value"),e.times=t,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}function Be(e){try{let t=e.slice(e.indexOf(":")+1);return"blob:"===new URL(t).protocol}catch{return!1}}function Ve(e,t){return e.distance-t.distance}function De(e,t,i,r){let s=!0;if(e.layers.test(t.layers)&&!1===e.raycast(t,i)&&(s=!1),!0===s&&!0===r){let r=e.children;for(let e=0,s=r.length;e<s;e++)De(r[e],t,i,!0)}}function Ie(e,t,i,r,s,a,n){ou.set(s,a,n).unproject(r);let o=t[e];if(void 0!==o){let e=i.getAttribute("position");for(let t=0,i=o.length;t<i;t++)e.setXYZ(o[t],ou.x,ou.y,ou.z)}}var Le,ze,ke,Ue,Fe,je,Ge,We,qe,He,$e,Ye,Xe,Ke,Ze,Je,Qe,et,tt,it,rt,st,at,nt,ot,lt,ht,ut,dt,ct,pt,mt,gt,ft,yt,vt,bt,xt,wt,_t,St,Mt,Tt,Ct,At,Nt,Pt,Rt,Et,Ot,Bt,Vt,Dt,It,Lt,zt,kt,Ut,Ft,jt,Gt,Wt,qt,Ht,$t,Yt,Xt,Kt,Zt,Jt,Qt,ei,ti,ii,ri,si,ai,ni,oi,li,hi,ui,di,ci,pi,mi,gi,fi,yi,vi,bi,xi,wi,_i,Si,Mi,Ti,Ci,Ai,Ni,Pi,Ri,Ei,Oi,Bi,Vi,Di,Ii,Li,zi,ki,Ui,Fi,ji,Gi,Wi,qi,Hi,$i,Yi,Xi,Ki,Zi,Ji,Qi,er,tr,ir,rr,sr,ar,nr,or,lr,hr,ur,dr,cr,pr,mr,gr,fr,yr,vr,br,xr,wr,_r,Sr,Mr,Tr,Cr,Ar,Nr,Pr,Rr,Er,Or,Br,Vr,Dr,Ir,Lr,zr,kr,Ur,Fr,jr,Gr,Wr,qr,Hr,$r,Yr,Xr,Kr,Zr,Jr,Qr,es,ts,is,rs,ss,as,ns,os,ls,hs,us,ds,cs,ps,ms,gs,fs,ys,vs,bs,xs,ws,_s,Ss,Ms,Ts,Cs,As,Ns,Ps,Rs,Es,Os,Bs,Vs,Ds,Is,Ls,zs,ks,Us,Fs,js,Gs,Ws,qs,Hs,$s,Ys,Xs,Ks,Zs,Js,Qs,ea,ta,ia,ra,sa,aa,na,oa,la,ha,ua,da,ca,pa,ma,ga,fa,ya,va,ba,xa,wa,_a,Sa,Ma,Ta,Ca,Aa,Na,Pa,Ra,Ea,Oa,Ba,Va,Da,Ia,La,za,ka,Ua,Fa,ja,Ga,Wa,qa,Ha,$a,Ya,Xa,Ka,Za,Ja,Qa,en,tn,rn,sn,an,nn,on,ln,hn,un,dn,cn,pn,mn,gn,fn,yn,vn,bn,xn,wn,_n,Sn,Mn,Tn,Cn,An,Nn,Pn,Rn,En,On,Bn,Vn,Dn,In,Ln,zn,kn,Un,Fn,jn,Gn,Wn,qn,Hn,$n,Yn,Xn,Kn,Zn,Jn,Qn,eo,to,io,ro,so,ao,no,oo,lo,ho,uo,co,po,mo,go,fo,yo,vo,bo,xo,wo,_o,So,Mo,To,Co,Ao,No,Po,Ro,Eo,Oo,Bo,Vo,Do,Io,Lo,zo,ko,Uo,Fo,jo,Go,Wo,qo,Ho,$o,Yo,Xo,Ko,Zo,Jo,Qo,el,tl,il,rl,sl,al,nl,ol,ll,hl,ul,dl,cl,pl,ml,gl,fl,yl,vl,bl,xl,wl,_l,Sl,Ml,Tl,Cl,Al,Nl,Pl,Rl,El,Ol,Bl,Vl,Dl,Il,Ll,zl,kl,Ul,Fl,jl,Gl,Wl,ql,Hl,$l,Yl,Xl,Kl,Zl,Jl,Ql,eh,th,ih,rh,sh,ah,nh,oh,lh,hh,uh,dh,ch,ph,mh,gh,fh,yh,vh,bh,xh,wh,_h,Sh,Mh,Th,Ch,Ah,Nh,Ph,Rh,Eh,Oh,Bh,Vh,Dh,Ih,Lh,zh,kh,Uh,Fh,jh,Gh,Wh,qh,Hh,$h,Yh,Xh,Kh,Zh,Jh,Qh,eu,tu,iu,ru,su,au,nu,ou,lu,hu,uu,du,cu,pu,mu,gu,fu,yu,vu,bu,xu,wu,_u,Su,Mu=n(()=>{Le="185",ze={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ke=0,Ue=1,Fe=2,je=3,Ge=0,We=1,qe=2,He=0,$e=1,Ye=2,Xe=3,Ke=4,Ze=5,Je=6,Qe=100,et=101,tt=102,it=103,rt=104,st=200,at=201,nt=202,ot=203,lt=204,ht=205,ut=206,dt=207,ct=208,pt=209,mt=210,gt=0,ft=1,yt=2,vt=3,bt=4,xt=5,wt=6,_t=7,St=0,Mt=1,Tt=2,Ct=0,At=1,Nt=2,Pt=3,Rt=4,Et=6,Ot=7,Bt=300,Vt=301,Dt=302,It=303,Lt=304,zt=306,kt=1e3,Ut=1001,Ft=1002,jt=1003,Gt=1004,Wt=1005,qt=1006,Ht=1007,$t=1008,Yt=1008,Xt=1009,Kt=1010,Zt=1011,Jt=1012,Qt=1013,ei=1014,ti=1015,ii=1016,ri=1017,si=1018,ai=1020,ni=35902,oi=35899,li=1021,hi=1022,ui=1023,di=1026,ci=1027,pi=1028,mi=1029,gi=1030,fi=1031,yi=1032,vi=1033,bi=33776,xi=33777,wi=33778,_i=33779,Si=36196,Mi=37492,Ti=37496,Ci=37488,Ai=37489,Ni=37490,Pi=37491,Ri=37808,Ei=37809,Oi=37810,Bi=37811,Vi=37812,Di=37813,Ii=37814,Li=37815,zi=37816,ki=37817,Ui=37818,Fi=37819,ji=37820,Gi=37821,Wi=36492,qi=36494,Hi=36495,$i=36283,Yi=36284,Xi=36285,Ki=36286,Zi=2200,Ji=2201,Qi=2202,er=2300,tr=2301,ir=2302,rr=2400,sr=2401,ar=2402,nr=0,or=1,lr="",hr="srgb",ur="srgb-linear",dr="linear",cr="srgb",pr="",mr="rg",gr="ga",fr=0,yr=7680,vr=7681,br=7682,xr=7683,wr=34055,_r=34056,Sr=5386,Mr=512,Tr=513,Cr=514,Ar=515,Nr=516,Pr=517,Rr=518,Er=519,Or=512,Br=513,Vr=514,Dr=515,Ir=516,Lr=517,zr=518,kr=519,Ur=35044,Fr=35048,jr=2e3,Gr=2001,Wr={COMPUTE:"compute",RENDER:"render"},qr={TEXTURE_COMPARE:"depthTextureCompare"},Hr={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array},$r={},Yr=null,Xr={[gt]:ft,[yt]:wt,[bt]:_t,[vt]:xt,[ft]:gt,[wt]:yt,[_t]:bt,[xt]:vt},Kr=class{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return void 0!==i&&void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){let i=this._listeners;if(void 0===i)return;let r=i[e];if(void 0!==r){let e=r.indexOf(t);-1!==e&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(void 0===t)return;let i=t[e.type];if(void 0!==i){e.target=this;let t=i.slice(0);for(let i=0,r=t.length;i<r;i++)t[i].call(this,e);e.target=null}}},Zr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Jr=1234567,Qr=Math.PI/180,es=180/Math.PI,ts={DEG2RAD:Qr,RAD2DEG:es,generateUUID:b,clamp:x,euclideanModulo:w,mapLinear:_,inverseLerp:S,lerp:M,damp:T,pingpong:C,smoothstep:A,smootherstep:N,randInt:P,randFloat:R,randFloatSpread:E,seededRandom:O,degToRad:B,radToDeg:V,isPowerOfTwo:D,ceilPowerOfTwo:I,floorPowerOfTwo:L,setQuaternionFromProperEuler:z,normalize:U,denormalize:k},is=class{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=x(this.x,e.x,t.x),this.y=x(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=x(this.x,e,t),this.y=x(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(x(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(x(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},rs=is,is.prototype.isVector2=!0,ss=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,n){let o=i[r+0],l=i[r+1],h=i[r+2],u=i[r+3],d=s[a+0],c=s[a+1],p=s[a+2],m=s[a+3];if(u!==m||o!==d||l!==c||h!==p){let e=o*d+l*c+h*p+u*m;e<0&&(d=-d,c=-c,p=-p,m=-m,e=-e);let t=1-n;if(e<.9995){let i=Math.acos(e),r=Math.sin(i);t=Math.sin(t*i)/r,o=o*t+d*(n=Math.sin(n*i)/r),l=l*t+c*n,h=h*t+p*n,u=u*t+m*n}else{o=o*t+d*n,l=l*t+c*n,h=h*t+p*n,u=u*t+m*n;let e=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=e,l*=e,h*=e,u*=e}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,r,s,a){let n=i[r],o=i[r+1],l=i[r+2],h=i[r+3],u=s[a],d=s[a+1],c=s[a+2],p=s[a+3];return e[t]=n*p+h*u+o*c-l*d,e[t+1]=o*p+h*d+l*u-n*c,e[t+2]=l*p+h*c+n*d-o*u,e[t+3]=h*p-n*u-o*d-l*c,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,s=e._z,a=e._order,n=Math.cos,o=Math.sin,l=n(i/2),h=n(r/2),u=n(s/2),d=o(i/2),c=o(r/2),p=o(s/2);switch(a){case"XYZ":this._x=d*h*u+l*c*p,this._y=l*c*u-d*h*p,this._z=l*h*p+d*c*u,this._w=l*h*u-d*c*p;break;case"YXZ":this._x=d*h*u+l*c*p,this._y=l*c*u-d*h*p,this._z=l*h*p-d*c*u,this._w=l*h*u+d*c*p;break;case"ZXY":this._x=d*h*u-l*c*p,this._y=l*c*u+d*h*p,this._z=l*h*p+d*c*u,this._w=l*h*u-d*c*p;break;case"ZYX":this._x=d*h*u-l*c*p,this._y=l*c*u+d*h*p,this._z=l*h*p-d*c*u,this._w=l*h*u+d*c*p;break;case"YZX":this._x=d*h*u+l*c*p,this._y=l*c*u+d*h*p,this._z=l*h*p-d*c*u,this._w=l*h*u-d*c*p;break;case"XZY":this._x=d*h*u-l*c*p,this._y=l*c*u-d*h*p,this._z=l*h*p+d*c*u,this._w=l*h*u+d*c*p;break;default:f("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],n=t[5],o=t[9],l=t[2],h=t[6],u=t[10],d=i+n+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(h-o)*e,this._y=(s-l)*e,this._z=(a-r)*e}else if(i>n&&i>u){let e=2*Math.sqrt(1+i-n-u);this._w=(h-o)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(s+l)/e}else if(n>u){let e=2*Math.sqrt(1+n-i-u);this._w=(s-l)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(o+h)/e}else{let e=2*Math.sqrt(1+u-i-n);this._w=(a-r)/e,this._x=(s+l)/e,this._y=(o+h)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(x(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(0===i)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,a=e._w,n=t._x,o=t._y,l=t._z,h=t._w;return this._x=i*h+a*n+r*l-s*o,this._y=r*h+a*o+s*n-i*l,this._z=s*h+a*l+i*o-r*n,this._w=a*h-i*n-r*o-s*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,s=e._z,a=e._w,n=this.dot(e);n<0&&(i=-i,r=-r,s=-s,a=-a,n=-n);let o=1-t;if(n<.9995){let e=Math.acos(n),l=Math.sin(e);o=Math.sin(o*e)/l,t=Math.sin(t*e)/l,this._x=this._x*o+i*t,this._y=this._y*o+r*t,this._z=this._z*o+s*t,this._w=this._w*o+a*t,this._onChangeCallback()}else this._x=this._x*o+i*t,this._y=this._y*o+r*t,this._z=this._z*o+s*t,this._w=this._w*o+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},as=class{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ls.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ls.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,n=e.z,o=e.w,l=2*(a*r-n*i),h=2*(n*t-s*r),u=2*(s*i-a*t);return this.x=t+o*l+a*u-n*h,this.y=i+o*h+n*l-s*u,this.z=r+o*u+s*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=x(this.x,e.x,t.x),this.y=x(this.y,e.y,t.y),this.z=x(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=x(this.x,e,t),this.y=x(this.y,e,t),this.z=x(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(x(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,a=t.x,n=t.y,o=t.z;return this.x=r*o-s*n,this.y=s*a-i*o,this.z=i*n-r*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return os.copy(this).projectOnVector(e),this.sub(os)}reflect(e){return this.sub(os.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(x(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=2*Math.random()-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ns=as,as.prototype.isVector3=!0,os=new ns,ls=new ss,us=hs=class{constructor(e,t,i,r,s,a,n,o,l){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,i,r,s,a,n,o,l)}set(e,t,i,r,s,a,n,o,l){let h=this.elements;return h[0]=e,h[1]=r,h[2]=n,h[3]=t,h[4]=s,h[5]=o,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,a=i[0],n=i[3],o=i[6],l=i[1],h=i[4],u=i[7],d=i[2],c=i[5],p=i[8],m=r[0],g=r[3],f=r[6],y=r[1],v=r[4],b=r[7],x=r[2],w=r[5],_=r[8];return s[0]=a*m+n*y+o*x,s[3]=a*g+n*v+o*w,s[6]=a*f+n*b+o*_,s[1]=l*m+h*y+u*x,s[4]=l*g+h*v+u*w,s[7]=l*f+h*b+u*_,s[2]=d*m+c*y+p*x,s[5]=d*g+c*v+p*w,s[8]=d*f+c*b+p*_,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8];return t*a*h-t*n*l-i*s*h+i*n*o+r*s*l-r*a*o}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8],u=h*a-n*l,d=n*o-h*s,c=l*s-a*o,p=t*u+i*d+r*c;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*l-h*i)*m,e[2]=(n*i-r*a)*m,e[3]=d*m,e[4]=(h*t-r*o)*m,e[5]=(r*s-n*t)*m,e[6]=c*m,e[7]=(i*o-l*t)*m,e[8]=(a*t-i*s)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,n){let o=Math.cos(s),l=Math.sin(s);return this.set(i*o,i*l,-i*(o*a+l*n)+a+e,-r*l,r*o,-r*(-l*a+o*n)+n+t,0,0,1),this}scale(e,t){return v("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ds.makeScale(e,t)),this}rotate(e){return v("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ds.makeRotation(-e)),this}translate(e,t){return v("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ds.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}},hs.prototype.isMatrix3=!0,ds=new us,cs=(new us).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ps=(new us).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),ms=function(){let e={enabled:!1,workingColorSpace:ur,spaces:{},convert:function(e,t,i){return!1===this.enabled||t===i||!t||!i||(this.spaces[t].transfer===cr&&(e.r=F(e.r),e.g=F(e.g),e.b=F(e.b)),this.spaces[t].primaries!==this.spaces[i].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===cr&&(e.r=j(e.r),e.g=j(e.g),e.b=j(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===lr?dr:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,i){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,i){return v("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(t,i)},toWorkingColorSpace:function(t,i){return v("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(t,i)}},t=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[ur]:{primaries:t,whitePoint:r,transfer:dr,toXYZ:cs,fromXYZ:ps,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:hr},outputColorSpaceConfig:{drawingBufferColorSpace:hr}},[hr]:{primaries:t,whitePoint:r,transfer:cr,toXYZ:cs,fromXYZ:ps,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:hr}}}),e}(),fs=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{void 0===gs&&(gs=p("canvas")),gs.width=e.width,gs.height=e.height;let t=gs.getContext("2d");e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),i=gs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=p("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let e=0;e<s.length;e++)s[e]=255*F(s[e]/255);return i.putImageData(r,0,0),t}if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*F(t[e]/255)):t[e]=F(t[e]);return{data:t,width:e.width,height:e.height}}return f("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},ys=0,vs=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ys++}),this.uuid=b(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(null!==r){let e;if(Array.isArray(r)){e=[];for(let t=0,i=r.length;t<i;t++)r[t].isDataTexture?e.push(G(r[t].image)):e.push(G(r[t]))}else e=G(r);i.url=e}return t||(e.images[this.uuid]=i),i}},bs=0,xs=new ns,(ws=class extends Kr{constructor(e=ws.DEFAULT_IMAGE,t=ws.DEFAULT_MAPPING,i=Ut,r=Ut,s=qt,a=$t,n=ui,o=Xt,l=ws.DEFAULT_ANISOTROPY,h=lr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:bs++}),this.uuid=b(),this.name="",this.source=new vs(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=n,this.internalFormat=null,this.type=o,this.offset=new rs(0,0),this.repeat=new rs(1,1),this.center=new rs(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new us,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(xs).x}get height(){return this.source.getSize(xs).y}get depth(){return this.source.getSize(xs).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let i=e[t];if(void 0===i){f(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];void 0!==r?r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i:f(`Texture.setValues(): property '${t}' does not exist.`)}}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];let i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Bt)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case kt:e.x=e.x-Math.floor(e.x);break;case Ut:e.x=e.x<0?0:1;break;case Ft:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case kt:e.y=e.y-Math.floor(e.y);break;case Ut:e.y=e.y<0?0:1;break;case Ft:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}).DEFAULT_IMAGE=null,ws.DEFAULT_MAPPING=Bt,ws.DEFAULT_ANISOTROPY=1,_s=class{constructor(e=0,t=0,i=0,r=1){this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,a=e.elements,n=a[0],o=a[4],l=a[8],h=a[1],u=a[5],d=a[9],c=a[2],p=a[6],m=a[10];if(Math.abs(o-h)<.01&&Math.abs(l-c)<.01&&Math.abs(d-p)<.01){if(Math.abs(o+h)<.1&&Math.abs(l+c)<.1&&Math.abs(d+p)<.1&&Math.abs(n+u+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let e=(n+1)/2,a=(u+1)/2,g=(m+1)/2,f=(o+h)/4,y=(l+c)/4,v=(d+p)/4;return e>a&&e>g?e<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(e),r=f/i,s=y/i):a>g?a<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(a),i=f/r,s=v/r):g<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(g),i=y/s,r=v/s),this.set(i,r,s,t),this}let g=Math.sqrt((p-d)*(p-d)+(l-c)*(l-c)+(h-o)*(h-o));return Math.abs(g)<.001&&(g=1),this.x=(p-d)/g,this.y=(l-c)/g,this.z=(h-o)/g,this.w=Math.acos((n+u+m-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=x(this.x,e.x,t.x),this.y=x(this.y,e.y,t.y),this.z=x(this.z,e.z,t.z),this.w=x(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=x(this.x,e,t),this.y=x(this.y,e,t),this.z=x(this.z,e,t),this.w=x(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(x(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Ss=_s,_s.prototype.isVector4=!0,Ms=class extends Kr{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Ss(0,0,e,t),this.scissorTest=!1,this.viewport=new Ss(0,0,e,t),this.textures=[];let r={width:e,height:t,depth:i.depth},s=new ws(r),a=i.count;for(let e=0;e<a;e++)this.textures[e]=s.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:qt,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==e.mapping&&(t.mapping=e.mapping),void 0!==e.wrapS&&(t.wrapS=e.wrapS),void 0!==e.wrapT&&(t.wrapT=e.wrapT),void 0!==e.wrapR&&(t.wrapR=e.wrapR),void 0!==e.magFilter&&(t.magFilter=e.magFilter),void 0!==e.minFilter&&(t.minFilter=e.minFilter),void 0!==e.format&&(t.format=e.format),void 0!==e.type&&(t.type=e.type),void 0!==e.anisotropy&&(t.anisotropy=e.anisotropy),void 0!==e.colorSpace&&(t.colorSpace=e.colorSpace),void 0!==e.flipY&&(t.flipY=e.flipY),void 0!==e.generateMipmaps&&(t.generateMipmaps=e.generateMipmaps),void 0!==e.internalFormat&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==e&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,!0!==this.textures[r].isData3DTexture&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new vs(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ts=class extends ws{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=jt,this.minFilter=jt,this.wrapR=Ut,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},As=Cs=class{constructor(e,t,i,r,s,a,n,o,l,h,u,d,c,p,m,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,i,r,s,a,n,o,l,h,u,d,c,p,m,g)}set(e,t,i,r,s,a,n,o,l,h,u,d,c,p,m,g){let f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=s,f[5]=a,f[9]=n,f[13]=o,f[2]=l,f[6]=h,f[10]=u,f[14]=d,f[3]=c,f[7]=p,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Cs).fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return 0===this.determinantAffine()?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(0===e.determinantAffine())return this.identity();let t=this.elements,i=e.elements,r=1/Ns.setFromMatrixColumn(e,0).length(),s=1/Ns.setFromMatrixColumn(e,1).length(),a=1/Ns.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),n=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(s),u=Math.sin(s);if("XYZ"===e.order){let e=a*h,i=a*u,r=n*h,s=n*u;t[0]=o*h,t[4]=-o*u,t[8]=l,t[1]=i+r*l,t[5]=e-s*l,t[9]=-n*o,t[2]=s-e*l,t[6]=r+i*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*h,i=o*u,r=l*h,s=l*u;t[0]=e+s*n,t[4]=r*n-i,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-n,t[2]=i*n-r,t[6]=s+e*n,t[10]=a*o}else if("ZXY"===e.order){let e=o*h,i=o*u,r=l*h,s=l*u;t[0]=e-s*n,t[4]=-a*u,t[8]=r+i*n,t[1]=i+r*n,t[5]=a*h,t[9]=s-e*n,t[2]=-a*l,t[6]=n,t[10]=a*o}else if("ZYX"===e.order){let e=a*h,i=a*u,r=n*h,s=n*u;t[0]=o*h,t[4]=r*l-i,t[8]=e*l+s,t[1]=o*u,t[5]=s*l+e,t[9]=i*l-r,t[2]=-l,t[6]=n*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,i=a*l,r=n*o,s=n*l;t[0]=o*h,t[4]=s-e*u,t[8]=r*u+i,t[1]=u,t[5]=a*h,t[9]=-n*h,t[2]=-l*h,t[6]=i*u+r,t[10]=e-s*u}else if("XZY"===e.order){let e=a*o,i=a*l,r=n*o,s=n*l;t[0]=o*h,t[4]=-u,t[8]=l*h,t[1]=e*u+s,t[5]=a*h,t[9]=i*u-r,t[2]=r*u-i,t[6]=n*h,t[10]=s*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Rs,e,Es)}lookAt(e,t,i){let r=this.elements;return Vs.subVectors(e,t),0===Vs.lengthSq()&&(Vs.z=1),Vs.normalize(),Os.crossVectors(i,Vs),0===Os.lengthSq()&&(1===Math.abs(i.z)?Vs.x+=1e-4:Vs.z+=1e-4,Vs.normalize(),Os.crossVectors(i,Vs)),Os.normalize(),Bs.crossVectors(Vs,Os),r[0]=Os.x,r[4]=Bs.x,r[8]=Vs.x,r[1]=Os.y,r[5]=Bs.y,r[9]=Vs.y,r[2]=Os.z,r[6]=Bs.z,r[10]=Vs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,a=i[0],n=i[4],o=i[8],l=i[12],h=i[1],u=i[5],d=i[9],c=i[13],p=i[2],m=i[6],g=i[10],f=i[14],y=i[3],v=i[7],b=i[11],x=i[15],w=r[0],_=r[4],S=r[8],M=r[12],T=r[1],C=r[5],A=r[9],N=r[13],P=r[2],R=r[6],E=r[10],O=r[14],B=r[3],V=r[7],D=r[11],I=r[15];return s[0]=a*w+n*T+o*P+l*B,s[4]=a*_+n*C+o*R+l*V,s[8]=a*S+n*A+o*E+l*D,s[12]=a*M+n*N+o*O+l*I,s[1]=h*w+u*T+d*P+c*B,s[5]=h*_+u*C+d*R+c*V,s[9]=h*S+u*A+d*E+c*D,s[13]=h*M+u*N+d*O+c*I,s[2]=p*w+m*T+g*P+f*B,s[6]=p*_+m*C+g*R+f*V,s[10]=p*S+m*A+g*E+f*D,s[14]=p*M+m*N+g*O+f*I,s[3]=y*w+v*T+b*P+x*B,s[7]=y*_+v*C+b*R+x*V,s[11]=y*S+v*A+b*E+x*D,s[15]=y*M+v*N+b*O+x*I,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],n=e[5],o=e[9],l=e[13],h=e[2],u=e[6],d=e[10],c=e[14],p=e[3],m=e[7],g=e[11],f=e[15],y=o*c-l*d,v=n*c-l*u,b=n*d-o*u,x=a*c-l*h,w=a*d-o*h,_=a*u-n*h;return t*(m*y-g*v+f*b)-i*(p*y-g*x+f*w)+r*(p*v-m*x+f*_)-s*(p*b-m*w+g*_)}determinantAffine(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[1],a=e[5],n=e[9],o=e[2],l=e[6],h=e[10];return t*(a*h-n*l)-i*(s*h-n*o)+r*(s*l-a*o)}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8],u=e[9],d=e[10],c=e[11],p=e[12],m=e[13],g=e[14],f=e[15],y=t*n-i*a,v=t*o-r*a,b=t*l-s*a,x=i*o-r*n,w=i*l-s*n,_=r*l-s*o,S=h*m-u*p,M=h*g-d*p,T=h*f-c*p,C=u*g-d*m,A=u*f-c*m,N=d*f-c*g,P=y*N-v*A+b*C+x*T-w*M+_*S;if(0===P)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/P;return e[0]=(n*N-o*A+l*C)*R,e[1]=(r*A-i*N-s*C)*R,e[2]=(m*_-g*w+f*x)*R,e[3]=(d*w-u*_-c*x)*R,e[4]=(o*T-a*N-l*M)*R,e[5]=(t*N-r*T+s*M)*R,e[6]=(g*b-p*_-f*v)*R,e[7]=(h*_-d*b+c*v)*R,e[8]=(a*A-n*T+l*S)*R,e[9]=(i*T-t*A-s*S)*R,e[10]=(p*w-m*b+f*y)*R,e[11]=(u*b-h*w-c*y)*R,e[12]=(n*M-a*C-o*S)*R,e[13]=(t*C-i*M+r*S)*R,e[14]=(m*v-p*x-g*y)*R,e[15]=(h*x-u*v+d*y)*R,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,n=e.y,o=e.z,l=s*a,h=s*n;return this.set(l*a+i,l*n-r*o,l*o+r*n,0,l*n+r*o,h*n+i,h*o-r*a,0,l*o-r*n,h*o+r*a,s*o*o+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,a=t._y,n=t._z,o=t._w,l=s+s,h=a+a,u=n+n,d=s*l,c=s*h,p=s*u,m=a*h,g=a*u,f=n*u,y=o*l,v=o*h,b=o*u,x=i.x,w=i.y,_=i.z;return r[0]=(1-(m+f))*x,r[1]=(c+b)*x,r[2]=(p-v)*x,r[3]=0,r[4]=(c-b)*w,r[5]=(1-(d+f))*w,r[6]=(g+y)*w,r[7]=0,r[8]=(p+v)*_,r[9]=(g-y)*_,r[10]=(1-(d+m))*_,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let s=this.determinantAffine();if(0===s)return i.set(1,1,1),t.identity(),this;let a=Ns.set(r[0],r[1],r[2]).length(),n=Ns.set(r[4],r[5],r[6]).length(),o=Ns.set(r[8],r[9],r[10]).length();s<0&&(a=-a),Ps.copy(this);let l=1/a,h=1/n,u=1/o;return Ps.elements[0]*=l,Ps.elements[1]*=l,Ps.elements[2]*=l,Ps.elements[4]*=h,Ps.elements[5]*=h,Ps.elements[6]*=h,Ps.elements[8]*=u,Ps.elements[9]*=u,Ps.elements[10]*=u,t.setFromRotationMatrix(Ps),i.x=a,i.y=n,i.z=o,this}makePerspective(e,t,i,r,s,a,n=jr,o=!1){let l,h,u=this.elements,d=2*s/(t-e),c=2*s/(i-r),p=(t+e)/(t-e),m=(i+r)/(i-r);if(o)l=s/(a-s),h=a*s/(a-s);else if(n===jr)l=-(a+s)/(a-s),h=-2*a*s/(a-s);else{if(n!==Gr)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+n);l=-a/(a-s),h=-a*s/(a-s)}return u[0]=d,u[4]=0,u[8]=p,u[12]=0,u[1]=0,u[5]=c,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=l,u[14]=h,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,i,r,s,a,n=jr,o=!1){let l,h,u=this.elements,d=2/(t-e),c=2/(i-r),p=-(t+e)/(t-e),m=-(i+r)/(i-r);if(o)l=1/(a-s),h=a/(a-s);else if(n===jr)l=-2/(a-s),h=-(a+s)/(a-s);else{if(n!==Gr)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+n);l=-1/(a-s),h=-s/(a-s)}return u[0]=d,u[4]=0,u[8]=0,u[12]=p,u[1]=0,u[5]=c,u[9]=0,u[13]=m,u[2]=0,u[6]=0,u[10]=l,u[14]=h,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},Cs.prototype.isMatrix4=!0,Ns=new ns,Ps=new As,Rs=new ns(0,0,0),Es=new ns(1,1,1),Os=new ns,Bs=new ns,Vs=new ns,Ds=new As,Is=new ss,(Ls=class{constructor(e=0,t=0,i=0,r=Ls.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],a=r[4],n=r[8],o=r[1],l=r[5],h=r[9],u=r[2],d=r[6],c=r[10];switch(t){case"XYZ":this._y=Math.asin(x(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(-h,c),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-x(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(n,c),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(x(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,c),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,s));break;case"ZYX":this._y=Math.asin(-x(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,c),this._z=Math.atan2(o,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(x(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(n,c));break;case"XZY":this._z=Math.asin(-x(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(n,s)):(this._x=Math.atan2(-h,c),this._y=0);break;default:f("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Ds.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ds,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Is.setFromEuler(this),this.setFromQuaternion(Is,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}).DEFAULT_ORDER="XYZ",zs=class{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return 0!==(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}},ks=0,Us=new ns,Fs=new ss,js=new As,Gs=new ns,Ws=new ns,qs=new ns,Hs=new ss,$s=new ns(1,0,0),Ys=new ns(0,1,0),Xs=new ns(0,0,1),Ks={type:"added"},Zs={type:"removed"},Js={type:"childadded",child:null},Qs={type:"childremoved",child:null},(ea=class extends Kr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ks++}),this.uuid=b(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ea.DEFAULT_UP.clone();let e=new ns,t=new Ls,i=new ss,r=new ns(1,1,1);t._onChange(function(){i.setFromEuler(t,!1)}),i._onChange(function(){t.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new As},normalMatrix:{value:new us}}),this.matrix=new As,this.matrixWorld=new As,this.matrixAutoUpdate=ea.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ea.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new zs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Fs.setFromAxisAngle(e,t),this.quaternion.multiply(Fs),this}rotateOnWorldAxis(e,t){return Fs.setFromAxisAngle(e,t),this.quaternion.premultiply(Fs),this}rotateX(e){return this.rotateOnAxis($s,e)}rotateY(e){return this.rotateOnAxis(Ys,e)}rotateZ(e){return this.rotateOnAxis(Xs,e)}translateOnAxis(e,t){return Us.copy(e).applyQuaternion(this.quaternion),this.position.add(Us.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($s,e)}translateY(e){return this.translateOnAxis(Ys,e)}translateZ(e){return this.translateOnAxis(Xs,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(js.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Gs.copy(e):Gs.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Ws.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?js.lookAt(Ws,Gs,this.up):js.lookAt(Gs,Ws,this.up),this.quaternion.setFromRotationMatrix(js),r&&(js.extractRotation(r.matrixWorld),Fs.setFromRotationMatrix(js),this.quaternion.premultiply(Fs.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(y("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ks),Js.child=e,this.dispatchEvent(Js),Js.child=null):y("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Zs),Qs.child=e,this.dispatchEvent(Qs),Qs.child=null),this}removeFromParent(){let e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),js.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),js.multiply(e.parent.matrixWorld)),e.applyMatrix4(js),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ks),Js.child=e,this.dispatchEvent(Js),Js.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let r=this.children[i].getObjectByProperty(e,t);if(void 0!==r)return r}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ws,e,qs),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ws,Hs,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(null!==e){let t=e.x,i=e.y,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*i-s[8]*r,s[13]+=i-s[1]*t-s[5]*i-s[9]*r,s[14]+=r-s[2]*t-s[6]*i-s[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){let r=this.parent;if(!0===e&&null!==r&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),!0===t){let e=this.children;for(let t=0,r=e.length;t<r;t++)e[t].updateWorldMatrix(!1,!0,i)}}toJSON(e){let t=void 0===e||"string"==typeof e,i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let r={};function s(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),!1!==this.static&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),null!==this.pivot&&(r.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(r.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(r.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(r.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let i=t.shapes;if(Array.isArray(i))for(let t=0,r=i.length;t<r;t++){let r=i[t];s(e.shapes,r)}else s(e.shapes,i)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){let t=[];for(let i=0,r=this.material.length;i<r;i++)t.push(s(e.materials,this.material[i]));r.material=t}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let i=this.animations[t];r.animations.push(s(e.animations,i))}}if(t){let t=a(e.geometries),r=a(e.materials),s=a(e.textures),n=a(e.images),o=a(e.shapes),l=a(e.skeletons),h=a(e.animations),u=a(e.nodes);t.length>0&&(i.geometries=t),r.length>0&&(i.materials=r),s.length>0&&(i.textures=s),n.length>0&&(i.images=n),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),h.length>0&&(i.animations=h),u.length>0&&(i.nodes=u)}return i.object=r,i;function a(e){let t=[];for(let i in e){let r=e[i];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=null!==e.pivot?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){let i=e.children[t];this.add(i.clone())}return this}}).DEFAULT_UP=new ns(0,1,0),ea.DEFAULT_MATRIX_AUTO_UPDATE=!0,ea.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0,ta=class extends ea{constructor(){super(),this.isGroup=!0,this.type="Group"}},ia={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ra={h:0,s:0,l:0},sa={h:0,s:0,l:0},aa=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(void 0===t&&void 0===i){let t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=hr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,ms.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=ms.workingColorSpace){return this.r=e,this.g=t,this.b=i,ms.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=ms.workingColorSpace){if(e=w(e,1),t=x(t,0,1),i=x(i,0,1),0===t)this.r=this.g=this.b=i;else{let r=i<=.5?i*(1+t):i+t-i*t,s=2*i-r;this.r=W(s,r,e+1/3),this.g=W(s,r,e),this.b=W(s,r,e-1/3)}return ms.colorSpaceToWorking(this,r),this}setStyle(e,t=hr){function i(t){void 0!==t&&parseFloat(t)<1&&f("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,a=r[1],n=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:f("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let i=r[1],s=i.length;if(3===s)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(6===s)return this.setHex(parseInt(i,16),t);f("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=hr){let i=ia[e.toLowerCase()];return void 0!==i?this.setHex(i,t):f("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=F(e.r),this.g=F(e.g),this.b=F(e.b),this}copyLinearToSRGB(e){return this.r=j(e.r),this.g=j(e.g),this.b=j(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=hr){return ms.workingToColorSpace(na.copy(this),e),65536*Math.round(x(255*na.r,0,255))+256*Math.round(x(255*na.g,0,255))+Math.round(x(255*na.b,0,255))}getHexString(e=hr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ms.workingColorSpace){ms.workingToColorSpace(na.copy(this),t);let i,r,s=na.r,a=na.g,n=na.b,o=Math.max(s,a,n),l=Math.min(s,a,n),h=(l+o)/2;if(l===o)i=0,r=0;else{let e=o-l;switch(r=h<=.5?e/(o+l):e/(2-o-l),o){case s:i=(a-n)/e+(a<n?6:0);break;case a:i=(n-s)/e+2;break;case n:i=(s-a)/e+4}i/=6}return e.h=i,e.s=r,e.l=h,e}getRGB(e,t=ms.workingColorSpace){return ms.workingToColorSpace(na.copy(this),t),e.r=na.r,e.g=na.g,e.b=na.b,e}getStyle(e=hr){ms.workingToColorSpace(na.copy(this),e);let t=na.r,i=na.g,r=na.b;return e!==hr?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*i)},${Math.round(255*r)})`}offsetHSL(e,t,i){return this.getHSL(ra),this.setHSL(ra.h+e,ra.s+t,ra.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(ra),e.getHSL(sa);let i=M(ra.h,sa.h,t),r=M(ra.s,sa.s,t),s=M(ra.l,sa.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},na=new aa,aa.NAMES=ia,oa=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new aa(e),this.near=t,this.far=i}clone(){return new oa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},la=class extends ea{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ls,this.environmentIntensity=1,this.environmentRotation=new Ls,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},ha=new ns,ua=new ns,da=new ns,ca=new ns,pa=new ns,ma=new ns,ga=new ns,fa=new ns,ya=new ns,va=new ns,ba=new Ss,xa=new Ss,wa=new Ss,_a=class{constructor(e=new ns,t=new ns,i=new ns){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),ha.subVectors(e,t),r.cross(ha);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){ha.subVectors(r,t),ua.subVectors(i,t),da.subVectors(e,t);let a=ha.dot(ha),n=ha.dot(ua),o=ha.dot(da),l=ua.dot(ua),h=ua.dot(da),u=a*l-n*n;if(0===u)return s.set(0,0,0),null;let d=1/u,c=(l*o-n*h)*d,p=(a*h-n*o)*d;return s.set(1-c-p,p,c)}static containsPoint(e,t,i,r){return null!==this.getBarycoord(e,t,i,r,ca)&&ca.x>=0&&ca.y>=0&&ca.x+ca.y<=1}static getInterpolation(e,t,i,r,s,a,n,o){return null===this.getBarycoord(e,t,i,r,ca)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(s,ca.x),o.addScaledVector(a,ca.y),o.addScaledVector(n,ca.z),o)}static getInterpolatedAttribute(e,t,i,r,s,a){return ba.setScalar(0),xa.setScalar(0),wa.setScalar(0),ba.fromBufferAttribute(e,t),xa.fromBufferAttribute(e,i),wa.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ba,s.x),a.addScaledVector(xa,s.y),a.addScaledVector(wa,s.z),a}static isFrontFacing(e,t,i,r){return ha.subVectors(i,t),ua.subVectors(e,t),ha.cross(ua).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ha.subVectors(this.c,this.b),ua.subVectors(this.a,this.b),.5*ha.cross(ua).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return _a.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return _a.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return _a.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return _a.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _a.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i,r,s=this.a,a=this.b,n=this.c;pa.subVectors(a,s),ma.subVectors(n,s),fa.subVectors(e,s);let o=pa.dot(fa),l=ma.dot(fa);if(o<=0&&l<=0)return t.copy(s);ya.subVectors(e,a);let h=pa.dot(ya),u=ma.dot(ya);if(h>=0&&u<=h)return t.copy(a);let d=o*u-h*l;if(d<=0&&o>=0&&h<=0)return i=o/(o-h),t.copy(s).addScaledVector(pa,i);va.subVectors(e,n);let c=pa.dot(va),p=ma.dot(va);if(p>=0&&c<=p)return t.copy(n);let m=c*l-o*p;if(m<=0&&l>=0&&p<=0)return r=l/(l-p),t.copy(s).addScaledVector(ma,r);let g=h*p-c*u;if(g<=0&&u-h>=0&&c-p>=0)return ga.subVectors(n,a),r=(u-h)/(u-h+(c-p)),t.copy(a).addScaledVector(ga,r);let f=1/(g+m+d);return i=m*f,r=d*f,t.copy(s).addScaledVector(pa,i).addScaledVector(ma,r)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Sa=class{constructor(e=new ns(1/0,1/0,1/0),t=new ns(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Ta.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Ta.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Ta.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(void 0!==i){let r=i.getAttribute("position");if(!0===t&&void 0!==r&&!0!==e.isInstancedMesh)for(let t=0,i=r.count;t<i;t++)!0===e.isMesh?e.getVertexPosition(t,Ta):Ta.fromBufferAttribute(r,t),Ta.applyMatrix4(e.matrixWorld),this.expandByPoint(Ta);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),Ca.copy(e.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),Ca.copy(i.boundingBox)),Ca.applyMatrix4(e.matrixWorld),this.union(Ca)}let r=e.children;for(let e=0,i=r.length;e<i;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ta),Ta.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ba),Va.subVectors(this.max,Ba),Aa.subVectors(e.a,Ba),Na.subVectors(e.b,Ba),Pa.subVectors(e.c,Ba),Ra.subVectors(Na,Aa),Ea.subVectors(Pa,Na),Oa.subVectors(Aa,Pa);let t=[0,-Ra.z,Ra.y,0,-Ea.z,Ea.y,0,-Oa.z,Oa.y,Ra.z,0,-Ra.x,Ea.z,0,-Ea.x,Oa.z,0,-Oa.x,-Ra.y,Ra.x,0,-Ea.y,Ea.x,0,-Oa.y,Oa.x,0];return!(!q(t,Aa,Na,Pa,Va)||(t=[1,0,0,0,1,0,0,0,1],!q(t,Aa,Na,Pa,Va)))&&(Da.crossVectors(Ra,Ea),t=[Da.x,Da.y,Da.z],q(t,Aa,Na,Pa,Va))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ta).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Ta).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Ma[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ma[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ma[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ma[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ma[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ma[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ma[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ma[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ma)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Ma=[new ns,new ns,new ns,new ns,new ns,new ns,new ns,new ns],Ta=new ns,Ca=new Sa,Aa=new ns,Na=new ns,Pa=new ns,Ra=new ns,Ea=new ns,Oa=new ns,Ba=new ns,Va=new ns,Da=new ns,Ia=new ns,La=function(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),s=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[256|e]=32768,s[e]=24,s[256|e]=24):t<-14?(r[e]=1024>>-t-14,r[256|e]=1024>>-t-14|32768,s[e]=-t-1,s[256|e]=-t-1):t<=15?(r[e]=t+15<<10,r[256|e]=t+15<<10|32768,s[e]=13,s[256|e]=13):t<128?(r[e]=31744,r[256|e]=64512,s[e]=24,s[256|e]=24):(r[e]=31744,r[256|e]=64512,s[e]=13,s[256|e]=13)}let a=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,i=0;for(;!(8388608&t);)t<<=1,i-=8388608;t&=-8388609,i+=947912704,a[e]=t|i}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)n[e]=e<<23;n[31]=1199570944,n[32]=2147483648;for(let e=33;e<63;++e)n[e]=2147483648+(e-32<<23);n[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:a,exponentTable:n,offsetTable:o}}(),za=class{static toHalfFloat(e){return H(e)}static fromHalfFloat(e){return $(e)}},ka=new ns,Ua=new rs,Fa=0,ja=class extends Kr{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Fa++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=i,this.usage=Ur,this.updateRanges=[],this.gpuType=ti,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,i=this.count;t<i;t++)Ua.fromBufferAttribute(this,t),Ua.applyMatrix3(e),this.setXY(t,Ua.x,Ua.y);else if(3===this.itemSize)for(let t=0,i=this.count;t<i;t++)ka.fromBufferAttribute(this,t),ka.applyMatrix3(e),this.setXYZ(t,ka.x,ka.y,ka.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ka.fromBufferAttribute(this,t),ka.applyMatrix4(e),this.setXYZ(t,ka.x,ka.y,ka.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ka.fromBufferAttribute(this,t),ka.applyNormalMatrix(e),this.setXYZ(t,ka.x,ka.y,ka.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ka.fromBufferAttribute(this,t),ka.transformDirection(e),this.setXYZ(t,ka.x,ka.y,ka.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=k(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=U(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=k(t,this.array)),t}setX(e,t){return this.normalized&&(t=U(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=k(t,this.array)),t}setY(e,t){return this.normalized&&(t=U(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=k(t,this.array)),t}setZ(e,t){return this.normalized&&(t=U(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=k(t,this.array)),t}setW(e,t){return this.normalized&&(t=U(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=U(t,this.array),i=U(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=U(t,this.array),i=U(i,this.array),r=U(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=U(t,this.array),i=U(i,this.array),r=U(r,this.array),s=U(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Ur&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}},Ga=class extends ja{constructor(e,t,i){super(new Uint16Array(e),t,i)}},Wa=class extends ja{constructor(e,t,i){super(new Uint32Array(e),t,i)}},qa=class extends ja{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=$(this.array[e*this.itemSize]);return this.normalized&&(t=k(t,this.array)),t}setX(e,t){return this.normalized&&(t=U(t,this.array)),this.array[e*this.itemSize]=H(t),this}getY(e){let t=$(this.array[e*this.itemSize+1]);return this.normalized&&(t=k(t,this.array)),t}setY(e,t){return this.normalized&&(t=U(t,this.array)),this.array[e*this.itemSize+1]=H(t),this}getZ(e){let t=$(this.array[e*this.itemSize+2]);return this.normalized&&(t=k(t,this.array)),t}setZ(e,t){return this.normalized&&(t=U(t,this.array)),this.array[e*this.itemSize+2]=H(t),this}getW(e){let t=$(this.array[e*this.itemSize+3]);return this.normalized&&(t=k(t,this.array)),t}setW(e,t){return this.normalized&&(t=U(t,this.array)),this.array[e*this.itemSize+3]=H(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=U(t,this.array),i=U(i,this.array)),this.array[e+0]=H(t),this.array[e+1]=H(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=U(t,this.array),i=U(i,this.array),r=U(r,this.array)),this.array[e+0]=H(t),this.array[e+1]=H(i),this.array[e+2]=H(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=U(t,this.array),i=U(i,this.array),r=U(r,this.array),s=U(s,this.array)),this.array[e+0]=H(t),this.array[e+1]=H(i),this.array[e+2]=H(r),this.array[e+3]=H(s),this}},Ha=class extends ja{constructor(e,t,i){super(new Float32Array(e),t,i)}},$a=new Sa,Ya=new ns,Xa=new ns,Ka=class{constructor(e=new ns,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;void 0!==t?i.copy(t):$a.setFromPoints(e).getCenter(i);let r=0;for(let t=0,s=e.length;t<s;t++)r=Math.max(r,i.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ya.subVectors(e,this.center);let t=Ya.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),i=.5*(e-this.radius);this.center.addScaledVector(Ya,i/e),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Xa.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ya.copy(e.center).add(Xa)),this.expandByPoint(Ya.copy(e.center).sub(Xa))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Za=0,Ja=new As,Qa=new ea,en=new ns,tn=new Sa,rn=new Sa,sn=new ns,an=class extends Kr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Za++}),this.uuid=b(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(function(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}(e)?Wa:Ga)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(void 0!==i){let t=(new us).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}let r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Ja.makeRotationFromQuaternion(e),this.applyMatrix4(Ja),this}rotateX(e){return Ja.makeRotationX(e),this.applyMatrix4(Ja),this}rotateY(e){return Ja.makeRotationY(e),this.applyMatrix4(Ja),this}rotateZ(e){return Ja.makeRotationZ(e),this.applyMatrix4(Ja),this}translate(e,t,i){return Ja.makeTranslation(e,t,i),this.applyMatrix4(Ja),this}scale(e,t,i){return Ja.makeScale(e,t,i),this.applyMatrix4(Ja),this}lookAt(e){return Qa.lookAt(e),Qa.updateMatrix(),this.applyMatrix4(Qa.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(en).negate(),this.translate(en.x,en.y,en.z),this}setFromPoints(e){let t=this.getAttribute("position");if(void 0===t){let t=[];for(let i=0,r=e.length;i<r;i++){let r=e[i];t.push(r.x,r.y,r.z||0)}this.setAttribute("position",new Ha(t,3))}else{let i=Math.min(e.length,t.count);for(let r=0;r<i;r++){let i=e[r];t.setXYZ(r,i.x,i.y,i.z||0)}e.length>t.count&&f("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Sa);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return y("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new ns(-1/0,-1/0,-1/0),new ns(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){let i=t[e];tn.setFromBufferAttribute(i),this.morphTargetsRelative?(sn.addVectors(this.boundingBox.min,tn.min),this.boundingBox.expandByPoint(sn),sn.addVectors(this.boundingBox.max,tn.max),this.boundingBox.expandByPoint(sn)):(this.boundingBox.expandByPoint(tn.min),this.boundingBox.expandByPoint(tn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&y('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ka);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return y("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new ns,1/0);if(e){let i=this.boundingSphere.center;if(tn.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){let i=t[e];rn.setFromBufferAttribute(i),this.morphTargetsRelative?(sn.addVectors(tn.min,rn.min),tn.expandByPoint(sn),sn.addVectors(tn.max,rn.max),tn.expandByPoint(sn)):(tn.expandByPoint(rn.min),tn.expandByPoint(rn.max))}tn.getCenter(i);let r=0;for(let t=0,s=e.count;t<s;t++)sn.fromBufferAttribute(e,t),r=Math.max(r,i.distanceToSquared(sn));if(t)for(let s=0,a=t.length;s<a;s++){let a=t[s],n=this.morphTargetsRelative;for(let t=0,s=a.count;t<s;t++)sn.fromBufferAttribute(a,t),n&&(en.fromBufferAttribute(e,t),sn.add(en)),r=Math.max(r,i.distanceToSquared(sn))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&y('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void y("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");let i=t.position,r=t.normal,s=t.uv,a=this.getAttribute("tangent");(void 0===a||a.count!==i.count)&&(a=new ja(new Float32Array(4*i.count),4),this.setAttribute("tangent",a));let n=[],o=[];for(let e=0;e<i.count;e++)n[e]=new ns,o[e]=new ns;let l=new ns,h=new ns,u=new ns,d=new rs,c=new rs,p=new rs,m=new ns,g=new ns;function f(e,t,r){l.fromBufferAttribute(i,e),h.fromBufferAttribute(i,t),u.fromBufferAttribute(i,r),d.fromBufferAttribute(s,e),c.fromBufferAttribute(s,t),p.fromBufferAttribute(s,r),h.sub(l),u.sub(l),c.sub(d),p.sub(d);let a=1/(c.x*p.y-p.x*c.y);!isFinite(a)||(m.copy(h).multiplyScalar(p.y).addScaledVector(u,-c.y).multiplyScalar(a),g.copy(u).multiplyScalar(c.x).addScaledVector(h,-p.x).multiplyScalar(a),n[e].add(m),n[t].add(m),n[r].add(m),o[e].add(g),o[t].add(g),o[r].add(g))}let v=this.groups;0===v.length&&(v=[{start:0,count:e.count}]);for(let t=0,i=v.length;t<i;++t){let i=v[t],r=i.start;for(let t=r,s=r+i.count;t<s;t+=3)f(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let b=new ns,x=new ns,w=new ns,_=new ns;function S(e){w.fromBufferAttribute(r,e),_.copy(w);let t=n[e];b.copy(t),b.sub(w.multiplyScalar(w.dot(t))).normalize(),x.crossVectors(_,t);let i=x.dot(o[e])<0?-1:1;a.setXYZW(e,b.x,b.y,b.z,i)}for(let t=0,i=v.length;t<i;++t){let i=v[t],r=i.start;for(let t=r,s=r+i.count;t<s;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(void 0!==t){let i=this.getAttribute("normal");if(void 0===i||i.count!==t.count)i=new ja(new Float32Array(3*t.count),3),this.setAttribute("normal",i);else for(let e=0,t=i.count;e<t;e++)i.setXYZ(e,0,0,0);let r=new ns,s=new ns,a=new ns,n=new ns,o=new ns,l=new ns,h=new ns,u=new ns;if(e)for(let d=0,c=e.count;d<c;d+=3){let c=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,c),s.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),n.fromBufferAttribute(i,c),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,m),n.add(h),o.add(h),l.add(h),i.setXYZ(c,n.x,n.y,n.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let e=0,n=t.count;e<n;e+=3)r.fromBufferAttribute(t,e+0),s.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),i.setXYZ(e+0,h.x,h.y,h.z),i.setXYZ(e+1,h.x,h.y,h.z),i.setXYZ(e+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)sn.fromBufferAttribute(e,t),sn.normalize(),e.setXYZ(t,sn.x,sn.y,sn.z)}toNonIndexed(){function e(e,t){let i=e.array,r=e.itemSize,s=e.normalized,a=new i.constructor(t.length*r),n=0,o=0;for(let s=0,l=t.length;s<l;s++){n=e.isInterleavedBufferAttribute?t[s]*e.data.stride+e.offset:t[s]*r;for(let e=0;e<r;e++)a[o++]=i[n++]}return new ja(a,r,s)}if(null===this.index)return f("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new an,i=this.index.array,r=this.attributes;for(let s in r){let a=e(r[s],i);t.setAttribute(s,a)}let s=this.morphAttributes;for(let r in s){let a=[],n=s[r];for(let t=0,r=n.length;t<r;t++){let r=e(n[t],i);a.push(r)}t.morphAttributes[r]=a}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let e=0,i=a.length;e<i;e++){let i=a[e];t.addGroup(i.start,i.count,i.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=void 0!==this.parameters&&!0===this._transformed?"BufferGeometry":this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters&&!0!==this._transformed){let t=this.parameters;for(let i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let t in i){let r=i[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},s=!1;for(let t in this.morphAttributes){let i=this.morphAttributes[t],a=[];for(let t=0,r=i.length;t<r;t++){let r=i[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let n=this.boundingSphere;return null!==n&&(e.data.boundingSphere=n.toJSON()),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;null!==i&&this.setIndex(i.clone());let r=e.attributes;for(let e in r){let i=r[e];this.setAttribute(e,i.clone(t))}let s=e.morphAttributes;for(let e in s){let i=[],r=s[e];for(let e=0,s=r.length;e<s;e++)i.push(r[e].clone(t));this.morphAttributes[e]=i}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let n=e.boundingBox;null!==n&&(this.boundingBox=n.clone());let o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}},nn=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Ur,this.updateRanges=[],this.version=0,this.uuid=b()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=b()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=b()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},on=new ns,ln=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)on.fromBufferAttribute(this,t),on.applyMatrix4(e),this.setXYZ(t,on.x,on.y,on.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)on.fromBufferAttribute(this,t),on.applyNormalMatrix(e),this.setXYZ(t,on.x,on.y,on.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)on.fromBufferAttribute(this,t),on.transformDirection(e),this.setXYZ(t,on.x,on.y,on.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=k(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=U(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=U(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=U(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=U(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=U(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=k(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=k(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=k(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=k(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=U(t,this.array),i=U(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=U(t,this.array),i=U(i,this.array),r=U(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=U(t,this.array),i=U(i,this.array),r=U(r,this.array),s=U(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(void 0===e){m("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let t=0;t<this.count;t++){let i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return new ja(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ln(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){m("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let t=0;t<this.count;t++){let i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},hn=0,un=class extends Kr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:hn++}),this.uuid=b(),this.name="",this.type="Material",this.blending=$e,this.side=Ge,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=lt,this.blendDst=ht,this.blendEquation=Qe,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new aa(0,0,0),this.blendAlpha=0,this.depthFunc=vt,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Er,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=yr,this.stencilZFail=yr,this.stencilZPass=yr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let i=e[t];if(void 0===i){f(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];void 0!==r?r&&r.isColor?r.set(i):r&&r.isVector2&&i&&i.isVector2||r&&r.isEuler&&i&&i.isEuler||r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i:f(`Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function r(e){let t=[];for(let i in e){let r=e[i];delete r.metadata,t.push(r)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),void 0!==this.dispersion&&(i.dispersion=this.dispersion),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==$e&&(i.blending=this.blending),this.side!==Ge&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),this.blendSrc!==lt&&(i.blendSrc=this.blendSrc),this.blendDst!==ht&&(i.blendDst=this.blendDst),this.blendEquation!==Qe&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==vt&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Er&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==yr&&(i.stencilFail=this.stencilFail),this.stencilZFail!==yr&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==yr&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!1===this.allowOverride&&(i.allowOverride=!1),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),t){let t=r(e.textures),s=r(e.images);t.length>0&&(i.textures=t),s.length>0&&(i.images=s)}return i}fromJSON(e,t){if(void 0!==e.uuid&&(this.uuid=e.uuid),void 0!==e.name&&(this.name=e.name),void 0!==e.color&&void 0!==this.color&&this.color.setHex(e.color),void 0!==e.roughness&&(this.roughness=e.roughness),void 0!==e.metalness&&(this.metalness=e.metalness),void 0!==e.sheen&&(this.sheen=e.sheen),void 0!==e.sheenColor&&(this.sheenColor=(new aa).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(this.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==this.emissive&&this.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==this.specular&&this.specular.setHex(e.specular),void 0!==e.specularIntensity&&(this.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==this.specularColor&&this.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(this.shininess=e.shininess),void 0!==e.clearcoat&&(this.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(this.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.dispersion&&(this.dispersion=e.dispersion),void 0!==e.iridescence&&(this.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(this.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(this.transmission=e.transmission),void 0!==e.thickness&&(this.thickness=e.thickness),void 0!==e.attenuationDistance&&(this.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==this.attenuationColor&&this.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(this.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(this.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(this.fog=e.fog),void 0!==e.flatShading&&(this.flatShading=e.flatShading),void 0!==e.blending&&(this.blending=e.blending),void 0!==e.combine&&(this.combine=e.combine),void 0!==e.side&&(this.side=e.side),void 0!==e.shadowSide&&(this.shadowSide=e.shadowSide),void 0!==e.opacity&&(this.opacity=e.opacity),void 0!==e.transparent&&(this.transparent=e.transparent),void 0!==e.alphaTest&&(this.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(this.alphaHash=e.alphaHash),void 0!==e.depthFunc&&(this.depthFunc=e.depthFunc),void 0!==e.depthTest&&(this.depthTest=e.depthTest),void 0!==e.depthWrite&&(this.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(this.colorWrite=e.colorWrite),void 0!==e.blendSrc&&(this.blendSrc=e.blendSrc),void 0!==e.blendDst&&(this.blendDst=e.blendDst),void 0!==e.blendEquation&&(this.blendEquation=e.blendEquation),void 0!==e.blendSrcAlpha&&(this.blendSrcAlpha=e.blendSrcAlpha),void 0!==e.blendDstAlpha&&(this.blendDstAlpha=e.blendDstAlpha),void 0!==e.blendEquationAlpha&&(this.blendEquationAlpha=e.blendEquationAlpha),void 0!==e.blendColor&&void 0!==this.blendColor&&this.blendColor.setHex(e.blendColor),void 0!==e.blendAlpha&&(this.blendAlpha=e.blendAlpha),void 0!==e.stencilWriteMask&&(this.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(this.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(this.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(this.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(this.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(this.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(this.stencilZPass=e.stencilZPass),void 0!==e.stencilWrite&&(this.stencilWrite=e.stencilWrite),void 0!==e.wireframe&&(this.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(this.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(this.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(this.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(this.rotation=e.rotation),void 0!==e.linewidth&&(this.linewidth=e.linewidth),void 0!==e.dashSize&&(this.dashSize=e.dashSize),void 0!==e.gapSize&&(this.gapSize=e.gapSize),void 0!==e.scale&&(this.scale=e.scale),void 0!==e.polygonOffset&&(this.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(this.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(this.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(this.dithering=e.dithering),void 0!==e.alphaToCoverage&&(this.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(this.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(this.forceSinglePass=e.forceSinglePass),void 0!==e.allowOverride&&(this.allowOverride=e.allowOverride),void 0!==e.visible&&(this.visible=e.visible),void 0!==e.toneMapped&&(this.toneMapped=e.toneMapped),void 0!==e.userData&&(this.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),void 0!==e.size&&(this.size=e.size),void 0!==e.sizeAttenuation&&(this.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(this.map=t[e.map]||null),void 0!==e.matcap&&(this.matcap=t[e.matcap]||null),void 0!==e.alphaMap&&(this.alphaMap=t[e.alphaMap]||null),void 0!==e.bumpMap&&(this.bumpMap=t[e.bumpMap]||null),void 0!==e.bumpScale&&(this.bumpScale=e.bumpScale),void 0!==e.normalMap&&(this.normalMap=t[e.normalMap]||null),void 0!==e.normalMapType&&(this.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),this.normalScale=(new rs).fromArray(t)}return void 0!==e.displacementMap&&(this.displacementMap=t[e.displacementMap]||null),void 0!==e.displacementScale&&(this.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(this.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(this.roughnessMap=t[e.roughnessMap]||null),void 0!==e.metalnessMap&&(this.metalnessMap=t[e.metalnessMap]||null),void 0!==e.emissiveMap&&(this.emissiveMap=t[e.emissiveMap]||null),void 0!==e.emissiveIntensity&&(this.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(this.specularMap=t[e.specularMap]||null),void 0!==e.specularIntensityMap&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),void 0!==e.specularColorMap&&(this.specularColorMap=t[e.specularColorMap]||null),void 0!==e.envMap&&(this.envMap=t[e.envMap]||null),void 0!==e.envMapRotation&&this.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(this.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(this.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(this.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(this.lightMap=t[e.lightMap]||null),void 0!==e.lightMapIntensity&&(this.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(this.aoMap=t[e.aoMap]||null),void 0!==e.aoMapIntensity&&(this.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(this.gradientMap=t[e.gradientMap]||null),void 0!==e.clearcoatMap&&(this.clearcoatMap=t[e.clearcoatMap]||null),void 0!==e.clearcoatRoughnessMap&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),void 0!==e.clearcoatNormalMap&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),void 0!==e.clearcoatNormalScale&&(this.clearcoatNormalScale=(new rs).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(this.iridescenceMap=t[e.iridescenceMap]||null),void 0!==e.iridescenceThicknessMap&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),void 0!==e.transmissionMap&&(this.transmissionMap=t[e.transmissionMap]||null),void 0!==e.thicknessMap&&(this.thicknessMap=t[e.thicknessMap]||null),void 0!==e.anisotropyMap&&(this.anisotropyMap=t[e.anisotropyMap]||null),void 0!==e.sheenColorMap&&(this.sheenColorMap=t[e.sheenColorMap]||null),void 0!==e.sheenRoughnessMap&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(null!==t){let e=t.length;i=new Array(e);for(let r=0;r!==e;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}},dn=class extends un{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new aa(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},pn=new ns,mn=new ns,gn=new ns,fn=new rs,yn=new rs,vn=new As,bn=new ns,xn=new ns,wn=new ns,_n=new rs,Sn=new rs,Mn=new rs,Tn=class extends ea{constructor(e=new dn){if(super(),this.isSprite=!0,this.type="Sprite",void 0===cn){cn=new an;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new nn(e,5);cn.setIndex([0,1,2,0,2,3]),cn.setAttribute("position",new ln(t,3,0,!1)),cn.setAttribute("uv",new ln(t,2,3,!1))}this.geometry=cn,this.material=e,this.center=new rs(.5,.5),this.count=1}raycast(e,t){null===e.camera&&y('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),mn.setFromMatrixScale(this.matrixWorld),vn.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),gn.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&mn.multiplyScalar(-gn.z);let i,r,s=this.material.rotation;0!==s&&(r=Math.cos(s),i=Math.sin(s));let a=this.center;Y(bn.set(-.5,-.5,0),gn,a,mn,i,r),Y(xn.set(.5,-.5,0),gn,a,mn,i,r),Y(wn.set(.5,.5,0),gn,a,mn,i,r),_n.set(0,0),Sn.set(1,0),Mn.set(1,1);let n=e.ray.intersectTriangle(bn,xn,wn,!1,pn);if(null===n&&(Y(xn.set(-.5,.5,0),gn,a,mn,i,r),Sn.set(0,1),n=e.ray.intersectTriangle(bn,wn,xn,!1,pn),null===n))return;let o=e.ray.origin.distanceTo(pn);o<e.near||o>e.far||t.push({distance:o,point:pn.clone(),uv:_a.getInterpolation(pn,bn,xn,wn,_n,Sn,Mn,new rs),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}},Cn=new ns,An=new ns,Nn=new ns,Pn=new ns,Rn=new ns,En=new ns,On=new ns,Bn=class{constructor(e=new ns,t=new ns(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Cn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Cn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Cn.copy(this.origin).addScaledVector(this.direction,t),Cn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){An.copy(e).add(t).multiplyScalar(.5),Nn.copy(t).sub(e).normalize(),Pn.copy(this.origin).sub(An);let s,a,n,o,l=.5*e.distanceTo(t),h=-this.direction.dot(Nn),u=Pn.dot(this.direction),d=-Pn.dot(Nn),c=Pn.lengthSq(),p=Math.abs(1-h*h);if(p>0)if(s=h*d-u,a=h*u-d,o=l*p,s>=0)if(a>=-o)if(a<=o){let e=1/p;s*=e,a*=e,n=s*(s+h*a+2*u)+a*(h*s+a+2*d)+c}else a=l,s=Math.max(0,-(h*a+u)),n=-s*s+a*(a+2*d)+c;else a=-l,s=Math.max(0,-(h*a+u)),n=-s*s+a*(a+2*d)+c;else a<=-o?(s=Math.max(0,-(-h*l+u)),a=s>0?-l:Math.min(Math.max(-l,-d),l),n=-s*s+a*(a+2*d)+c):a<=o?(s=0,a=Math.min(Math.max(-l,-d),l),n=a*(a+2*d)+c):(s=Math.max(0,-(h*l+u)),a=s>0?l:Math.min(Math.max(-l,-d),l),n=-s*s+a*(a+2*d)+c);else a=h>0?-l:l,s=Math.max(0,-(h*a+u)),n=-s*s+a*(a+2*d)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,s),r&&r.copy(An).addScaledVector(Nn,a),n}intersectSphere(e,t){Cn.subVectors(e.center,this.origin);let i=Cn.dot(this.direction),r=Cn.dot(Cn)-i*i,s=e.radius*e.radius;if(r>s)return null;let a=Math.sqrt(s-r),n=i-a,o=i+a;return o<0?null:n<0?this.at(o,t):this.at(n,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,n,o,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(i=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),u>=0?(n=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u):(n=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u),i>o||n>r)||((n>i||i!=i)&&(i=n),(o<r||r!=r)&&(r=o),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return null!==this.intersectBox(e,Cn)}intersectTriangle(e,t,i,r,s){Rn.subVectors(t,e),En.subVectors(i,e),On.crossVectors(Rn,En);let a,n=this.direction.dot(On);if(n>0){if(r)return null;a=1}else{if(!(n<0))return null;a=-1,n=-n}Pn.subVectors(this.origin,e);let o=a*this.direction.dot(En.crossVectors(Pn,En));if(o<0)return null;let l=a*this.direction.dot(Rn.cross(Pn));if(l<0||o+l>n)return null;let h=-a*Pn.dot(On);return h<0?null:this.at(h/n,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}},Vn=class extends un{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new aa(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ls,this.combine=St,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Dn=new As,In=new Bn,Ln=new Ka,zn=new ns,kn=new ns,Un=new ns,Fn=new ns,jn=new ns,Gn=new ns,Wn=new ns,qn=new ns,Hn=class extends ea{constructor(e=new an,t=new Vn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){let t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let n=this.morphTargetInfluences;if(s&&n){Gn.set(0,0,0);for(let i=0,r=s.length;i<r;i++){let r=n[i],o=s[i];0!==r&&(jn.fromBufferAttribute(o,e),a?Gn.addScaledVector(jn,r):Gn.addScaledVector(jn.sub(t),r))}t.add(Gn)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;void 0!==r&&(null===i.boundingSphere&&i.computeBoundingSphere(),Ln.copy(i.boundingSphere),Ln.applyMatrix4(s),In.copy(e.ray).recast(e.near),(!1!==Ln.containsPoint(In.origin)||!(null===In.intersectSphere(Ln,zn)||In.origin.distanceToSquared(zn)>(e.far-e.near)**2))&&(Dn.copy(s).invert(),In.copy(e.ray).applyMatrix4(Dn),(null===i.boundingBox||!1!==In.intersectsBox(i.boundingBox))&&this._computeIntersections(e,t,In)))}_computeIntersections(e,t,i){let r,s=this.geometry,a=this.material,n=s.index,o=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,c=s.drawRange;if(null!==n)if(Array.isArray(a))for(let s=0,o=d.length;s<o;s++){let o=d[s],p=a[o.materialIndex];for(let s=Math.max(o.start,c.start),a=Math.min(n.count,Math.min(o.start+o.count,c.start+c.count));s<a;s+=3)r=X(this,p,e,i,l,h,u,n.getX(s),n.getX(s+1),n.getX(s+2)),r&&(r.faceIndex=Math.floor(s/3),r.face.materialIndex=o.materialIndex,t.push(r))}else for(let s=Math.max(0,c.start),o=Math.min(n.count,c.start+c.count);s<o;s+=3)r=X(this,a,e,i,l,h,u,n.getX(s),n.getX(s+1),n.getX(s+2)),r&&(r.faceIndex=Math.floor(s/3),t.push(r));else if(void 0!==o)if(Array.isArray(a))for(let s=0,n=d.length;s<n;s++){let n=d[s],p=a[n.materialIndex];for(let s=Math.max(n.start,c.start),a=Math.min(o.count,Math.min(n.start+n.count,c.start+c.count));s<a;s+=3)r=X(this,p,e,i,l,h,u,s,s+1,s+2),r&&(r.faceIndex=Math.floor(s/3),r.face.materialIndex=n.materialIndex,t.push(r))}else for(let s=Math.max(0,c.start),n=Math.min(o.count,c.start+c.count);s<n;s+=3)r=X(this,a,e,i,l,h,u,s,s+1,s+2),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}},$n=class extends ea{constructor(){super(),this.isBone=!0,this.type="Bone"}},Yn=class extends ws{constructor(e=null,t=1,i=1,r,s,a,n,o,l=jt,h=jt,u,d){super(null,a,n,o,l,h,r,s,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Xn=new As,Kn=new As,Zn=class{constructor(e=[],t=[]){this.uuid=b(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){f("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new As)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new As;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let s=e[r]?e[r].matrixWorld:Kn;Xn.multiplyMatrices(s,t[r]),Xn.toArray(i,16*r)}null!==r&&(r.needsUpdate=!0)}clone(){return new Zn(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=4*Math.ceil(e/4),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Yn(t,e,e,ui,ti);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let i=this.bones[t];if(i.name===e)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let r=e.bones[i],s=t[r];void 0===s&&(f("Skeleton: No bone found with UUID:",r),s=new $n),this.bones.push(s),this.boneInverses.push((new As).fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let s=t[r];e.bones.push(s.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},Jn=class extends ja{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Qn=new As,eo=new As,to=[],io=new Sa,ro=new As,so=new Hn,ao=new Ka,no=class extends Hn{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Jn(new Float32Array(16*i),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<i;e++)this.setMatrixAt(e,ro)}computeBoundingBox(){let e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new Sa),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qn),io.copy(e.boundingBox).applyMatrix4(Qn),this.boundingBox.union(io)}computeBoundingSphere(){let e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new Ka),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Qn),ao.copy(e.boundingSphere).applyMatrix4(Qn),this.boundingSphere.union(ao)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.morphTexture&&(this.morphTexture=e.morphTexture.clone()),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return null===this.instanceColor?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,16*e)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=e*(i.length+1)+1;for(let e=0;e<i.length;e++)i[e]=r[s+e]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(so.geometry=this.geometry,so.material=this.material,void 0!==so.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),ao.copy(this.boundingSphere),ao.applyMatrix4(i),!1!==e.ray.intersectsSphere(ao)))for(let s=0;s<r;s++){this.getMatrixAt(s,Qn),eo.multiplyMatrices(i,Qn),so.matrixWorld=eo,so.raycast(e,to);for(let e=0,i=to.length;e<i;e++){let i=to[e];i.instanceId=s,i.object=this,t.push(i)}to.length=0}}setColorAt(e,t){return null===this.instanceColor&&(this.instanceColor=new Jn(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),t.toArray(this.instanceColor.array,3*e),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,16*e),this}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;null===this.morphTexture&&(this.morphTexture=new Yn(new Float32Array(r*this.count),r,this.count,pi,ti));let s=this.morphTexture.source.data.data,a=0;for(let e=0;e<i.length;e++)a+=i[e];let n=this.geometry.morphTargetsRelative?1:1-a,o=r*e;return s[o]=n,s.set(i,o+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}},oo=new ns,lo=new ns,ho=new us,uo=class{constructor(e=new ns(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=oo.subVectors(i,t).cross(lo.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){let r=e.delta(oo),s=this.normal.dot(r);if(0===s)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/s;return!0===i&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||ho.getNormalMatrix(e),r=this.coplanarPoint(oo).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}},co=new Ka,po=new rs(.5,.5),mo=new ns,go=class{constructor(e=new uo,t=new uo,i=new uo,r=new uo,s=new uo,a=new uo){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){let n=this.planes;return n[0].copy(e),n[1].copy(t),n[2].copy(i),n[3].copy(r),n[4].copy(s),n[5].copy(a),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=jr,i=!1){let r=this.planes,s=e.elements,a=s[0],n=s[1],o=s[2],l=s[3],h=s[4],u=s[5],d=s[6],c=s[7],p=s[8],m=s[9],g=s[10],f=s[11],y=s[12],v=s[13],b=s[14],x=s[15];if(r[0].setComponents(l-a,c-h,f-p,x-y).normalize(),r[1].setComponents(l+a,c+h,f+p,x+y).normalize(),r[2].setComponents(l+n,c+u,f+m,x+v).normalize(),r[3].setComponents(l-n,c-u,f-m,x-v).normalize(),i)r[4].setComponents(o,d,g,b).normalize(),r[5].setComponents(l-o,c-d,f-g,x-b).normalize();else if(r[4].setComponents(l-o,c-d,f-g,x-b).normalize(),t===jr)r[5].setComponents(l+o,c+d,f+g,x+b).normalize();else{if(t!==Gr)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);r[5].setComponents(o,d,g,b).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),co.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),co.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(co)}intersectsSprite(e){co.center.set(0,0,0);let t=po.distanceTo(e.center);return co.radius=.7071067811865476+t,co.applyMatrix4(e.matrixWorld),this.intersectsSphere(co)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(mo.x=r.normal.x>0?e.max.x:e.min.x,mo.y=r.normal.y>0?e.max.y:e.min.y,mo.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(mo)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}},fo=new As,yo=class{constructor(){this.coordinateSystem=jr,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,i=this._frustums;for(let e=0;e<t.length;e++){let r=t[e];fo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),void 0===i[e]&&(i[e]=new go),i[e].setFromProjectionMatrix(fo,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}intersectsObject(e){let t=this._frustums;for(let i=0;i<this._count;i++)if(t[i].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let i=0;i<this._count;i++)if(t[i].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let i=0;i<this._count;i++)if(t[i].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let i=0;i<this._count;i++)if(t[i].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let i=0;i<this._count;i++)if(t[i].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,i=e._frustums;for(let r=0;r<e._count;r++)void 0===t[r]&&(t[r]=new go),t[r].copy(i[r]);return this._count=e._count,this}clone(){return(new yo).copy(this)}},vo=class extends un{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new aa(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},bo=new ns,xo=new ns,wo=new As,_o=new Bn,So=new Ka,Mo=new ns,To=new ns,Co=class extends ea{constructor(e=new an,t=new vo){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(null===e.index){let t=e.attributes.position,i=[0];for(let e=1,r=t.count;e<r;e++)bo.fromBufferAttribute(t,e-1),xo.fromBufferAttribute(t,e),i[e]=i[e-1],i[e]+=bo.distanceTo(xo);e.setAttribute("lineDistance",new Ha(i,1))}else f("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),So.copy(i.boundingSphere),So.applyMatrix4(r),So.radius+=s,!1===e.ray.intersectsSphere(So))return;wo.copy(r).invert(),_o.copy(e.ray).applyMatrix4(wo);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=this.isLineSegments?2:1,h=i.index,u=i.attributes.position;if(null!==h){let i=Math.max(0,a.start),r=Math.min(h.count,a.start+a.count);for(let s=i,a=r-1;s<a;s+=l){let i=h.getX(s),r=h.getX(s+1),a=K(this,e,_o,o,i,r,s);a&&t.push(a)}if(this.isLineLoop){let s=h.getX(r-1),a=h.getX(i),n=K(this,e,_o,o,s,a,r-1);n&&t.push(n)}}else{let i=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let s=i,a=r-1;s<a;s+=l){let i=K(this,e,_o,o,s,s+1,s);i&&t.push(i)}if(this.isLineLoop){let s=K(this,e,_o,o,r-1,i,r-1);s&&t.push(s)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){let t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}},Ao=new ns,No=new ns,Po=class extends Co{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(null===e.index){let t=e.attributes.position,i=[];for(let e=0,r=t.count;e<r;e+=2)Ao.fromBufferAttribute(t,e),No.fromBufferAttribute(t,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+Ao.distanceTo(No);e.setAttribute("lineDistance",new Ha(i,1))}else f("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Ro=class extends un{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new aa(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Eo=class extends ws{constructor(e,t,i,r,s=qt,a=qt,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let h=this;"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(function t(){h.needsUpdate=!0,h._requestVideoFrameCallbackId=e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e==0&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}},Oo=class extends ws{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=jt,this.minFilter=jt,this.generateMipmaps=!1,this.needsUpdate=!0}},Bo=class extends ws{constructor(e=[],t=Vt,i,r,s,a,n,o,l,h){super(e,t,i,r,s,a,n,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Vo=class extends ws{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Do=class extends ws{constructor(e,t,i=ei,r,s,a,n=jt,o=jt,l,h=di,u=1){if(h!==di&&h!==ci)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:u},r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new vs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}},Io=class extends Do{constructor(e,t=ei,i=Vt,r,s,a=jt,n=jt,o,l=di){let h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,i,r,s,a,n,o,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Lo=class extends an{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};let n=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);let o=[],l=[],h=[],u=[],d=0,c=0;function p(e,t,i,r,s,a,p,m,g,f,y){let v=a/g,b=p/f,x=a/2,w=p/2,_=m/2,S=g+1,M=f+1,T=0,C=0,A=new ns;for(let a=0;a<M;a++){let n=a*b-w;for(let o=0;o<S;o++){let d=o*v-x;A[e]=d*r,A[t]=n*s,A[i]=_,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[i]=m>0?1:-1,h.push(A.x,A.y,A.z),u.push(o/g),u.push(1-a/f),T+=1}}for(let e=0;e<f;e++)for(let t=0;t<g;t++){let i=d+t+S*e,r=d+t+S*(e+1),s=d+(t+1)+S*(e+1),a=d+(t+1)+S*e;o.push(i,r,a),o.push(r,s,a),C+=6}n.addGroup(c,C,y),c+=C,d+=T}p("z","y","x",-1,-1,i,t,e,a,s,0),p("z","y","x",1,-1,i,t,-e,a,s,1),p("x","z","y",1,1,e,i,t,r,a,2),p("x","z","y",1,-1,e,i,-t,r,a,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(o),this.setAttribute("position",new Ha(l,3)),this.setAttribute("normal",new Ha(h,3)),this.setAttribute("uv",new Ha(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lo(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}},zo=class extends an{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,n=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],u=[],d=[],c=[],p=0,m=[],g=i/2,f=0;function y(i){let s=p,a=new rs,m=new ns,y=0,v=!0===i?e:t,b=!0===i?1:-1;for(let e=1;e<=r;e++)u.push(0,g*b,0),d.push(0,b,0),c.push(.5,.5),p++;let x=p;for(let e=0;e<=r;e++){let t=e/r*o+n,i=Math.cos(t),s=Math.sin(t);m.x=v*s,m.y=g*b,m.z=v*i,u.push(m.x,m.y,m.z),d.push(0,b,0),a.x=.5*i+.5,a.y=.5*s*b+.5,c.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=s+e,r=x+e;!0===i?h.push(r,r+1,t):h.push(r+1,r,t),y+=3}l.addGroup(f,y,!0===i?1:2),f+=y}(function(){let a=new ns,y=new ns,v=0,b=(t-e)/i;for(let l=0;l<=s;l++){let h=[],f=l/s,v=f*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,s=t*o+n,l=Math.sin(s),m=Math.cos(s);y.x=v*l,y.y=-f*i+g,y.z=v*m,u.push(y.x,y.y,y.z),a.set(l,b,m).normalize(),d.push(a.x,a.y,a.z),c.push(t,1-f),h.push(p++)}m.push(h)}for(let i=0;i<r;i++)for(let r=0;r<s;r++){let a=m[r][i],n=m[r+1][i],o=m[r+1][i+1],l=m[r][i+1];(e>0||0!==r)&&(h.push(a,n,l),v+=3),(t>0||r!==s-1)&&(h.push(n,o,l),v+=3)}l.addGroup(f,v,0),f+=v})(),!1===a&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Ha(u,3)),this.setAttribute("normal",new Ha(d,3)),this.setAttribute("uv",new Ha(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zo(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ko=class extends zo{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,n=2*Math.PI){super(0,e,t,i,r,s,a,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:n}}static fromJSON(e){return new ko(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Uo=class extends an{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];function n(e,t,i,r){let s=r+1,a=[];for(let r=0;r<=s;r++){a[r]=[];let n=e.clone().lerp(i,r/s),o=t.clone().lerp(i,r/s),l=s-r;for(let e=0;e<=l;e++)a[r][e]=0===e&&r===s?n:n.clone().lerp(o,e/l)}for(let e=0;e<s;e++)for(let t=0;t<2*(s-e)-1;t++){let i=Math.floor(t/2);t%2==0?(o(a[e][i+1]),o(a[e+1][i]),o(a[e][i])):(o(a[e][i+1]),o(a[e+1][i+1]),o(a[e+1][i]))}}function o(e){s.push(e.x,e.y,e.z)}function l(t,i){let r=3*t;i.x=e[r+0],i.y=e[r+1],i.z=e[r+2]}function h(e,t,i,r){r<0&&1===e.x&&(a[t]=e.x-1),0===i.x&&0===i.z&&(a[t]=r/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}function d(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}(function(e){let i=new ns,r=new ns,s=new ns;for(let a=0;a<t.length;a+=3)l(t[a+0],i),l(t[a+1],r),l(t[a+2],s),n(i,r,s,e)})(r),function(e){let t=new ns;for(let i=0;i<s.length;i+=3)t.x=s[i+0],t.y=s[i+1],t.z=s[i+2],t.normalize().multiplyScalar(e),s[i+0]=t.x,s[i+1]=t.y,s[i+2]=t.z}(i),function(){let e=new ns;for(let t=0;t<s.length;t+=3){e.x=s[t+0],e.y=s[t+1],e.z=s[t+2];let i=u(e)/2/Math.PI+.5,r=d(e)/Math.PI+.5;a.push(i,1-r)}(function(){let e=new ns,t=new ns,i=new ns,r=new ns,n=new rs,o=new rs,l=new rs;for(let d=0,c=0;d<s.length;d+=9,c+=6){e.set(s[d+0],s[d+1],s[d+2]),t.set(s[d+3],s[d+4],s[d+5]),i.set(s[d+6],s[d+7],s[d+8]),n.set(a[c+0],a[c+1]),o.set(a[c+2],a[c+3]),l.set(a[c+4],a[c+5]),r.copy(e).add(t).add(i).divideScalar(3);let p=u(r);h(n,c+0,e,p),h(o,c+2,t,p),h(l,c+4,i,p)}})(),function(){for(let e=0;e<a.length;e+=6){let t=a[e+0],i=a[e+2],r=a[e+4],s=Math.max(t,i,r),n=Math.min(t,i,r);s>.9&&n<.1&&(t<.2&&(a[e+0]+=1),i<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Ha(s,3)),this.setAttribute("normal",new Ha(s.slice(),3)),this.setAttribute("uv",new Ha(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Uo(e.vertices,e.indices,e.radius,e.detail)}},Fo=class extends Uo{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Fo(e.radius,e.detail)}},jo=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){f("Curve: .getPoint() not implemented.")}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t,i=[],r=this.getPoint(0),s=0;i.push(0);for(let a=1;a<=e;a++)t=this.getPoint(a/e),s+=t.distanceTo(r),i.push(s),r=t;return this.cacheArcLengths=i,i}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let i,r=this.getLengths(),s=0,a=r.length;i=t||e*r[a-1];let n,o=0,l=a-1;for(;o<=l;)if(s=Math.floor(o+(l-o)/2),n=r[s]-i,n<0)o=s+1;else{if(!(n>0)){l=s;break}l=s-1}if(s=l,r[s]===i)return s/(a-1);let h=r[s];return(s+(i-h)/(r[s+1]-h))/(a-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),a=this.getPoint(r),n=t||(s.isVector2?new rs:new ns);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){let i=new ns,r=[],s=[],a=[],n=new ns,o=new As;for(let t=0;t<=e;t++){let i=t/e;r[t]=this.getTangentAt(i,new ns)}s[0]=new ns,a[0]=new ns;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),d<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let t=1;t<=e;t++){if(s[t]=s[t-1].clone(),a[t]=a[t-1].clone(),n.crossVectors(r[t-1],r[t]),n.length()>Number.EPSILON){n.normalize();let e=Math.acos(x(r[t-1].dot(r[t]),-1,1));s[t].applyMatrix4(o.makeRotationAxis(n,e))}a[t].crossVectors(r[t],s[t])}if(!0===t){let t=Math.acos(x(s[0].dot(s[e]),-1,1));t/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(t=-t);for(let i=1;i<=e;i++)s[i].applyMatrix4(o.makeRotationAxis(r[i],t*i)),a[i].crossVectors(r[i],s[i])}return{tangents:r,normals:s,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Go=class extends jo{constructor(e=0,t=0,i=1,r=1,s=0,a=2*Math.PI,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t=new rs){let i=t,r=2*Math.PI,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(s=a?0:r),!0===this.aClockwise&&!a&&(s===r?s=-r:s-=r);let n=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(0!==this.aRotation){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),i=o-this.aX,r=l-this.aY;o=i*e-r*t+this.aX,l=i*t+r*e+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Wo=class extends Go{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}},qo=new ns,Ho=new ns,$o=new Z,Yo=new Z,Xo=new Z,Ko=class extends jo{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new ns){let i,r,s=t,a=this.points,n=a.length,o=(n-(this.closed?0:1))*e,l=Math.floor(o),h=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/n)+1)*n:0===h&&l===n-1&&(l=n-2,h=1),this.closed||l>0?i=a[(l-1)%n]:(Ho.subVectors(a[0],a[1]).add(a[0]),i=Ho);let u=a[l%n],d=a[(l+1)%n];if(this.closed||l+2<n?r=a[(l+2)%n]:(qo.subVectors(a[n-1],a[n-2]).add(a[n-1]),r=qo),"centripetal"===this.curveType||"chordal"===this.curveType){let e="chordal"===this.curveType?.5:.25,t=Math.pow(i.distanceToSquared(u),e),s=Math.pow(u.distanceToSquared(d),e),a=Math.pow(d.distanceToSquared(r),e);s<1e-4&&(s=1),t<1e-4&&(t=s),a<1e-4&&(a=s),$o.initNonuniformCatmullRom(i.x,u.x,d.x,r.x,t,s,a),Yo.initNonuniformCatmullRom(i.y,u.y,d.y,r.y,t,s,a),Xo.initNonuniformCatmullRom(i.z,u.z,d.z,r.z,t,s,a)}else"catmullrom"===this.curveType&&($o.initCatmullRom(i.x,u.x,d.x,r.x,this.tension),Yo.initCatmullRom(i.y,u.y,d.y,r.y,this.tension),Xo.initCatmullRom(i.z,u.z,d.z,r.z,this.tension));return s.set($o.calc(h),Yo.calc(h),Xo.calc(h)),s}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let i=e.points[t];this.points.push((new ns).fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}},Zo=class extends jo{constructor(e=new rs,t=new rs,i=new rs,r=new rs){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new rs){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(ee(e,r.x,s.x,a.x,n.x),ee(e,r.y,s.y,a.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Jo=class extends jo{constructor(e=new ns,t=new ns,i=new ns,r=new ns){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ns){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(ee(e,r.x,s.x,a.x,n.x),ee(e,r.y,s.y,a.y,n.y),ee(e,r.z,s.z,a.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Qo=class extends jo{constructor(e=new rs,t=new rs){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new rs){let i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new rs){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},el=class extends jo{constructor(e=new ns,t=new ns){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new ns){let i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ns){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},tl=class extends jo{constructor(e=new rs,t=new rs,i=new rs){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new rs){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(Q(e,r.x,s.x,a.x),Q(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},il=class extends jo{constructor(e=new ns,t=new ns,i=new ns){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ns){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(Q(e,r.x,s.x,a.x),Q(e,r.y,s.y,a.y),Q(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},rl=class extends jo{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new rs){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),n=s-a,o=r[0===a?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return i.set(J(n,o.x,l.x,h.x,u.x),J(n,o.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let i=e.points[t];this.points.push((new rs).fromArray(i))}return this}},sl=Object.freeze({__proto__:null,ArcCurve:Wo,CatmullRomCurve3:Ko,CubicBezierCurve:Zo,CubicBezierCurve3:Jo,EllipseCurve:Go,LineCurve:Qo,LineCurve3:el,QuadraticBezierCurve:tl,QuadraticBezierCurve3:il,SplineCurve:rl}),al=class extends jo{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=!0===e.isVector2?"LineCurve":"LineCurve3";this.curves.push(new sl[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let e=r[s]-i,a=this.curves[s],n=a.getLength(),o=0===n?0:1-e/n;return a.getPointAt(o,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t,i=[];for(let r=0,s=this.curves;r<s.length;r++){let a=s[r],n=a.isEllipseCurve?2*e:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(n);for(let e=0;e<o.length;e++){let r=o[e];t&&t.equals(r)||(i.push(r),t=r)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let i=e.curves[t];this.curves.push((new sl[i.type]).fromJSON(i))}return this}},nl=class extends al{constructor(e){super(),this.type="Path",this.currentPoint=new rs,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Qo(this.currentPoint.clone(),new rs(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new tl(this.currentPoint.clone(),new rs(e,t),new rs(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new Zo(this.currentPoint.clone(),new rs(e,t),new rs(i,r),new rs(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new rl(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,a,n,o),this}absellipse(e,t,i,r,s,a,n,o){let l=new Go(e,t,i,r,s,a,n,o);if(this.curves.length>0){let e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},ol=class extends nl{constructor(e){super(e),this.uuid=b(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let i=e.holes[t];this.holes.push((new nl).fromJSON(i))}return this}},ll=class{static triangulate(e,t,i=2){return function(e,t,i=2){let r,s,a,n=t&&t.length,o=n?t[0]*i:e.length,l=te(e,0,o,i,!0),h=[];if(!l||l.next===l.prev)return h;if(n&&(l=function(e,t,i,r){let s=[];for(let i=0,a=t.length;i<a;i++){let n=te(e,t[i]*r,i<a-1?t[i+1]*r:e.length,r,!1);n===n.next&&(n.steiner=!0),s.push(ce(n))}s.sort(le);for(let e=0;e<s.length;e++)i=he(s[e],i);return i}(e,t,l,i)),e.length>80*i){r=e[0],s=e[1];let t=r,n=s;for(let a=i;a<o;a+=i){let i=e[a],o=e[a+1];i<r&&(r=i),o<s&&(s=o),i>t&&(t=i),o>n&&(n=o)}a=Math.max(t-r,n-s),a=0!==a?32767/a:0}return re(l,h,i,r,s,a,0),h}(e,t,i)}},hl=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return.5*i}static isClockWise(e){return hl.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Ce(e),Ae(i,e);let a=e.length;t.forEach(Ce);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Ae(i,t[e]);let n=ll.triangulate(i,r);for(let e=0;e<n.length;e+=3)s.push(n.slice(e,e+3));return s}},ul=class extends Uo{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ul(e.radius,e.detail)}},dl=class extends an{constructor(e=[new rs(0,-.5),new rs(.5,0),new rs(0,.5)],t=12,i=0,r=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=x(r,0,2*Math.PI);let s=[],a=[],n=[],o=[],l=[],h=1/t,u=new ns,d=new rs,c=new ns,p=new ns,m=new ns,g=0,f=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:g=e[t+1].x-e[t].x,f=e[t+1].y-e[t].y,c.x=1*f,c.y=-g,c.z=0*f,m.copy(c),c.normalize(),o.push(c.x,c.y,c.z);break;case e.length-1:o.push(m.x,m.y,m.z);break;default:g=e[t+1].x-e[t].x,f=e[t+1].y-e[t].y,c.x=1*f,c.y=-g,c.z=0*f,p.copy(c),c.x+=m.x,c.y+=m.y,c.z+=m.z,c.normalize(),o.push(c.x,c.y,c.z),m.copy(p)}for(let s=0;s<=t;s++){let c=i+s*h*r,p=Math.sin(c),m=Math.cos(c);for(let i=0;i<=e.length-1;i++){u.x=e[i].x*p,u.y=e[i].y,u.z=e[i].x*m,a.push(u.x,u.y,u.z),d.x=s/t,d.y=i/(e.length-1),n.push(d.x,d.y);let r=o[3*i+0]*p,h=o[3*i+1],c=o[3*i+0]*m;l.push(r,h,c)}}for(let i=0;i<t;i++)for(let t=0;t<e.length-1;t++){let r=t+i*e.length,a=r,n=r+e.length,o=r+e.length+1,l=r+1;s.push(a,n,l),s.push(o,l,n)}this.setIndex(s),this.setAttribute("position",new Ha(a,3)),this.setAttribute("uv",new Ha(n,2)),this.setAttribute("normal",new Ha(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dl(e.points,e.segments,e.phiStart,e.phiLength)}},cl=class extends an{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,a=t/2,n=Math.floor(i),o=Math.floor(r),l=n+1,h=o+1,u=e/n,d=t/o,c=[],p=[],m=[],g=[];for(let e=0;e<h;e++){let t=e*d-a;for(let i=0;i<l;i++){let r=i*u-s;p.push(r,-t,0),m.push(0,0,1),g.push(i/n),g.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<n;t++){let i=t+l*e,r=t+l*(e+1),s=t+1+l*(e+1),a=t+1+l*e;c.push(i,r,a),c.push(r,s,a)}this.setIndex(c),this.setAttribute("position",new Ha(p,3)),this.setAttribute("normal",new Ha(m,3)),this.setAttribute("uv",new Ha(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cl(e.width,e.height,e.widthSegments,e.heightSegments)}},pl=class extends an{constructor(e=1,t=32,i=16,r=0,s=2*Math.PI,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+n,Math.PI),l=0,h=[],u=new ns,d=new ns,c=[],p=[],m=[],g=[];for(let c=0;c<=i;c++){let f=[],y=c/i,v=a+y*n,b=e*Math.cos(v),x=Math.sqrt(e*e-b*b),w=0;0===c&&0===a?w=.5/t:c===i&&o===Math.PI&&(w=-.5/t);for(let e=0;e<=t;e++){let i=e/t,a=r+i*s;u.x=-x*Math.cos(a),u.y=b,u.z=x*Math.sin(a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),g.push(i+w,1-y),f.push(l++)}h.push(f)}for(let e=0;e<i;e++)for(let r=0;r<t;r++){let t=h[e][r+1],s=h[e][r],n=h[e+1][r],l=h[e+1][r+1];(0!==e||a>0)&&c.push(t,s,l),(e!==i-1||o<Math.PI)&&c.push(s,n,l)}this.setIndex(c),this.setAttribute("position",new Ha(p,3)),this.setAttribute("normal",new Ha(m,3)),this.setAttribute("uv",new Ha(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pl(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},ml=class extends an{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],u=new ns,d=new ns,c=new ns,p=new ns,m=new ns,g=new ns,f=new ns;for(let n=0;n<=i;++n){let v=n/i*s*Math.PI*2;y(v,s,a,e,c),y(v+.01,s,a,e,p),g.subVectors(p,c),f.addVectors(p,c),m.crossVectors(g,f),f.crossVectors(m,g),m.normalize(),f.normalize();for(let e=0;e<=r;++e){let s=e/r*Math.PI*2,a=-t*Math.cos(s),p=t*Math.sin(s);u.x=c.x+(a*f.x+p*m.x),u.y=c.y+(a*f.y+p*m.y),u.z=c.z+(a*f.z+p*m.z),o.push(u.x,u.y,u.z),d.subVectors(u,c).normalize(),l.push(d.x,d.y,d.z),h.push(n/i),h.push(e/r)}}for(let e=1;e<=i;e++)for(let t=1;t<=r;t++){let i=(r+1)*(e-1)+(t-1),s=(r+1)*e+(t-1),a=(r+1)*e+t,o=(r+1)*(e-1)+t;n.push(i,s,o),n.push(s,a,o)}function y(e,t,i,r,s){let a=Math.cos(e),n=Math.sin(e),o=i/t*e,l=Math.cos(o);s.x=r*(2+l)*.5*a,s.y=r*(2+l)*n*.5,s.z=r*Math.sin(o)*.5}this.setIndex(n),this.setAttribute("position",new Ha(o,3)),this.setAttribute("normal",new Ha(l,3)),this.setAttribute("uv",new Ha(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ml(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},gl=class extends un{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new aa(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},fl=class extends un{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=function(e){let t={};for(let i in e){t[i]={};for(let r in e[i]){let s=e[i][r];if(Ne(s))s.isRenderTargetTexture?(f("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[i][r]=null):t[i][r]=s.clone();else if(Array.isArray(s))if(Ne(s[0])){let e=[];for(let t=0,i=s.length;t<i;t++)e[t]=s[t].clone();t[i][r]=e}else t[i][r]=s.slice();else t[i][r]=s}}return t}(e.uniforms),this.uniformsGroups=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let r=this.uniforms[i].value;r&&r.isTexture?t.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[i]={type:"m4",value:r.toArray()}:t.uniforms[i]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),void 0!==e.uniforms)for(let i in e.uniforms){let r=e.uniforms[i];switch(this.uniforms[i]={},r.type){case"t":this.uniforms[i].value=t[r.value]||null;break;case"c":this.uniforms[i].value=(new aa).setHex(r.value);break;case"v2":this.uniforms[i].value=(new rs).fromArray(r.value);break;case"v3":this.uniforms[i].value=(new ns).fromArray(r.value);break;case"v4":this.uniforms[i].value=(new Ss).fromArray(r.value);break;case"m3":this.uniforms[i].value=(new us).fromArray(r.value);break;case"m4":this.uniforms[i].value=(new As).fromArray(r.value);break;default:this.uniforms[i].value=r.value}}if(void 0!==e.defines&&(this.defines=e.defines),void 0!==e.vertexShader&&(this.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(this.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(this.glslVersion=e.glslVersion),void 0!==e.extensions)for(let t in e.extensions)this.extensions[t]=e.extensions[t];return void 0!==e.lights&&(this.lights=e.lights),void 0!==e.clipping&&(this.clipping=e.clipping),this}},yl=class extends un{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new aa(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new aa(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nr,this.normalScale=new rs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ls,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},vl=class extends yl{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new rs(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return x(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new aa(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new aa(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new aa(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},bl=class extends un{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new aa(16777215),this.specular=new aa(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new aa(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nr,this.normalScale=new rs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ls,this.combine=St,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},xl=class extends un{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new aa(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new aa(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nr,this.normalScale=new rs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},wl=class extends un{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nr,this.normalScale=new rs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},_l=class extends un{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new aa(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new aa(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nr,this.normalScale=new rs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ls,this.combine=St,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Sl=class extends un{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new aa(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nr,this.normalScale=new rs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}},Ml=class extends vo{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}},Tl=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let a=i+2;;){if(void 0===r){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){let n=t[1];e<n&&(i=2,s=n);for(let a=i-2;;){if(void 0===s)return this._cachedIndex=0,this.copySampleValue_(0);if(i===a)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){let r=i+a>>>1;e<t[r]?a=r:i=r+1}if(r=t[i],s=t[i-1],void 0===s)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===r)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let e=0;e!==r;++e)t[e]=i[s+e];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},Cl=class extends Tl{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:rr,endingEnd:rr}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,n=r[s],o=r[a];if(void 0===n)switch(this.getSettings_().endingStart){case sr:s=e,n=2*t-i;break;case ar:s=r.length-2,n=t+r[s]-r[s+1];break;default:s=e,n=i}if(void 0===o)switch(this.getSettings_().endingEnd){case sr:a=e,o=2*i-t;break;case ar:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}let l=.5*(i-t),h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,c=this._weightNext,p=(i-t)/(r-t),m=p*p,g=m*p,f=-d*g+2*d*m-d*p,y=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-c)*g+(1.5+c)*m+.5*p,b=c*g-c*m;for(let e=0;e!==n;++e)s[e]=f*a[h+e]+y*a[l+e]+v*a[o+e]+b*a[u+e];return s}},Al=class extends Tl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),u=1-h;for(let e=0;e!==n;++e)s[e]=a[l+e]*u+a[o+e]*h;return s}},Nl=class extends Tl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Pl=class extends Tl{interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this.inTangents,u=this.outTangents;if(!h||!u){let e=(i-t)/(r-t),h=1-e;for(let t=0;t!==n;++t)s[t]=a[l+t]*h+a[o+t]*e;return s}let d=2*n,c=e-1;for(let p=0;p!==n;++p){let n,m,g,f,y,v=a[l+p],b=a[o+p],x=c*d+2*p,w=u[x],_=u[x+1],S=e*d+2*p,M=h[S],T=h[S+1],C=(i-t)/(r-t);for(let e=0;e<8;e++){n=C*C,m=n*C,g=1-C,f=g*g,y=f*g;let e=y*t+3*f*C*w+3*g*n*M+m*r-i;if(Math.abs(e)<1e-10)break;let s=3*f*(w-t)+6*g*C*(M-w)+3*n*(r-M);if(Math.abs(s)<1e-10)break;C-=e/s,C=Math.max(0,Math.min(1,C))}s[p]=y*v+3*f*C*_+3*g*n*T+m*b}return s}},(Rl=class{constructor(e,t,i,r){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Pe(t,this.TimeBufferType),this.values=Pe(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t,i=e.constructor;if(i.toJSON!==this.toJSON)t=i.toJSON(e);else{t={name:e.name,times:Pe(e.times,Array),values:Pe(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t}InterpolantFactoryMethodDiscrete(e){return new Nl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Al(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Cl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Pl(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case er:t=this.InterpolantFactoryMethodDiscrete;break;case tr:t=this.InterpolantFactoryMethodLinear;break;case ir:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier}if(void 0===t){let t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return f("KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return er;case this.InterpolantFactoryMethodLinear:return tr;case this.InterpolantFactoryMethodSmooth:return ir;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(1!==e){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;-1!==a&&i[a]>t;)--a;if(++a,0!==s||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let e=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(y("KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;0===s&&(y("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==s;t++){let r=i[t];if("number"==typeof r&&isNaN(r)){y("KeyframeTrack: Time is not a valid number.",this,t,r),e=!1;break}if(null!==a&&a>r){y("KeyframeTrack: Out of order keys.",this,t,r,a),e=!1;break}a=r}if(void 0!==r&&c(r))for(let t=0,i=r.length;t!==i;++t){let i=r[t];if(isNaN(i)){y("KeyframeTrack: Value is not a valid number.",this,t,i),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===ir,s=e.length-1,a=1;for(let n=1;n<s;++n){let s=!1,o=e[n];if(o!==e[n+1]&&(1!==n||o!==e[0]))if(r)s=!0;else{let e=n*i,r=e-i,a=e+i;for(let n=0;n!==i;++n){let i=t[e+n];if(i!==t[r+n]||i!==t[a+n]){s=!0;break}}}if(s){if(n!==a){e[a]=e[n];let r=n*i,s=a*i;for(let e=0;e!==i;++e)t[s+e]=t[r+e]}++a}}if(s>0){e[a]=e[s];for(let e=s*i,r=a*i,n=0;n!==i;++n)t[r+n]=t[e+n];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}).prototype.ValueTypeName="",Rl.prototype.TimeBufferType=Float32Array,Rl.prototype.ValueBufferType=Float32Array,Rl.prototype.DefaultInterpolation=tr,(El=class extends Rl{constructor(e,t,i){super(e,t,i)}}).prototype.ValueTypeName="bool",El.prototype.ValueBufferType=Array,El.prototype.DefaultInterpolation=er,El.prototype.InterpolantFactoryMethodLinear=void 0,El.prototype.InterpolantFactoryMethodSmooth=void 0,(Ol=class extends Rl{constructor(e,t,i,r){super(e,t,i,r)}}).prototype.ValueTypeName="color",(Bl=class extends Rl{constructor(e,t,i,r){super(e,t,i,r)}}).prototype.ValueTypeName="number",Vl=class extends Tl{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let e=l+n;l!==e;l+=4)ss.slerpFlat(s,0,a,l-n,a,l,o);return s}},(Dl=class extends Rl{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new Vl(this.times,this.values,this.getValueSize(),e)}}).prototype.ValueTypeName="quaternion",Dl.prototype.InterpolantFactoryMethodSmooth=void 0,(Il=class extends Rl{constructor(e,t,i){super(e,t,i)}}).prototype.ValueTypeName="string",Il.prototype.ValueBufferType=Array,Il.prototype.DefaultInterpolation=er,Il.prototype.InterpolantFactoryMethodLinear=void 0,Il.prototype.InterpolantFactoryMethodSmooth=void 0,(Ll=class extends Rl{constructor(e,t,i,r){super(e,t,i,r)}}).prototype.ValueTypeName="vector",zl=class{constructor(e="",t=-1,i=[],r=2500){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=b(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let e=0,s=i.length;e!==s;++e)t.push(Oe(i[e]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,r=i.length;e!==r;++e)t.push(Rl.toJSON(i[e]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let e=0;e<s;e++){let n=[],o=[];n.push((e+s-1)%s,e,(e+1)%s),o.push(0,1,0);let l=Re(n);n=Ee(n,1,l),o=Ee(o,1,l),!r&&0===n[0]&&(n.push(s),o.push(o[0])),a.push(new Bl(".morphTargetInfluences["+t[e].name+"]",n,o).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let t=e;i=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<i.length;e++)if(i[e].name===t)return i[e];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let t=0,i=e.length;t<i;t++){let i=e[t],a=i.name.match(s);if(a&&a.length>1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(i)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,i));return a}resetDuration(){let e=0;for(let t=0,i=this.tracks.length;t!==i;++t){let i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}},kl={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(Be(e)||(this.files[e]=t))},get:function(e){if(!1!==this.enabled&&!Be(e))return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},Ul=new class{constructor(e,t,i){let r,s=this,a=!1,n=0,o=0,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(e){o++,!1===a&&void 0!==s.onStart&&s.onStart(e,n,o),a=!0},this.itemEnd=function(e){n++,void 0!==s.onProgress&&s.onProgress(e,n,o),n===o&&(a=!1,void 0!==s.onLoad&&s.onLoad())},this.itemError=function(e){void 0!==s.onError&&s.onError(e)},this.resolveURL=function(e){return e=e.normalize("NFC"),r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){let t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,i=l.length;t<i;t+=2){let i=l[t],r=l[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return r}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},(Fl=class{constructor(e){this.manager=void 0!==e?e:Ul,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}).DEFAULT_MATERIAL_NAME="__DEFAULT",jl={},Gl=class extends Error{constructor(e,t){super(e),this.response=t}},Wl=class extends Fl{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let s=kl.get(`file:${e}`);if(void 0!==s)return this.manager.itemStart(e),void setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0);if(void 0!==jl[e])return void jl[e].push({onLoad:t,onProgress:i,onError:r});jl[e]=[],jl[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),n=this.mimeType,o=this.responseType;fetch(a).then(t=>{if(200===t.status||0===t.status){if(0===t.status&&f("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||void 0===t.body||void 0===t.body.getReader)return t;let i=jl[e],r=t.body.getReader(),s=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),a=s?parseInt(s):0,n=0!==a,o=0,l=new ReadableStream({start(e){!function t(){r.read().then(({done:r,value:s})=>{if(r)e.close();else{o+=s.byteLength;let r=new ProgressEvent("progress",{lengthComputable:n,loaded:o,total:a});for(let e=0,t=i.length;e<t;e++){let t=i[e];t.onProgress&&t.onProgress(r)}e.enqueue(s),t()}},t=>{e.error(t)})}()}});return new Response(l)}throw new Gl(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>(new DOMParser).parseFromString(e,n));case"json":return e.json();default:if(""===n)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(n),i=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(i);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{kl.add(`file:${e}`,t);let i=jl[e];delete jl[e];for(let e=0,r=i.length;e<r;e++){let r=i[e];r.onLoad&&r.onLoad(t)}}).catch(t=>{let i=jl[e];if(void 0===i)throw this.manager.itemError(e),t;delete jl[e];for(let e=0,r=i.length;e<r;e++){let r=i[e];r.onError&&r.onError(t)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},ql=class extends Fl{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new Yn,n=new Wl(this.manager);return n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setPath(this.path),n.setWithCredentials(s.withCredentials),n.load(e,function(e){let i;try{i=s.parse(e)}catch(e){return void(void 0!==r?r(e):y(e))}s._applyTexData(a,i),t&&t(a,i)},i,r),a}createDataTexture(e){let t=new Yn;return this._applyTexData(t,this.parse(e)),t}_applyTexData(e,t){void 0!==t.image?e.image=t.image:void 0!==t.data&&(e.image.width=t.width,e.image.height=t.height,e.image.data=t.data),e.wrapS=void 0!==t.wrapS?t.wrapS:Ut,e.wrapT=void 0!==t.wrapT?t.wrapT:Ut,e.magFilter=void 0!==t.magFilter?t.magFilter:qt,e.minFilter=void 0!==t.minFilter?t.minFilter:qt,e.anisotropy=void 0!==t.anisotropy?t.anisotropy:1,void 0!==t.colorSpace&&(e.colorSpace=t.colorSpace),void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.format&&(e.format=t.format),void 0!==t.type&&(e.type=t.type),void 0!==t.mipmaps&&(e.mipmaps=t.mipmaps,e.minFilter=$t),1===t.mipmapCount&&(e.minFilter=qt),void 0!==t.generateMipmaps&&(e.generateMipmaps=t.generateMipmaps),e.needsUpdate=!0}},Hl=class extends ea{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new aa(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},$l=class extends Hl{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ea.DEFAULT_UP),this.updateMatrix(),this.groundColor=new aa(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Yl=new As,Xl=new ns,Kl=new ns,Zl=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new rs(512,512),this.mapType=Xt,this.map=null,this.mapPass=null,this.matrix=new As,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new go,this._frameExtents=new rs(1,1),this._viewportCount=1,this._viewports=[new Ss(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;Xl.setFromMatrixPosition(e.matrixWorld),t.position.copy(Xl),Kl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Kl),t.updateMatrixWorld(),Yl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Yl,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Gr||t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Yl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return(new this.constructor).copy(this)}toJSON(){let e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),(512!==this.mapSize.x||512!==this.mapSize.y)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Jl=new ns,Ql=new ss,eh=new ns,th=class extends ea{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new As,this.projectionMatrix=new As,this.projectionMatrixInverse=new As,this.coordinateSystem=jr,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Jl,Ql,eh),1===eh.x&&1===eh.y&&1===eh.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Jl,Ql,eh.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(Jl,Ql,eh),1===eh.x&&1===eh.y&&1===eh.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Jl,Ql,eh.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}},ih=new ns,rh=new rs,sh=new rs,ah=class extends th{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*es*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*Qr*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*es*Math.atan(Math.tan(.5*Qr*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){ih.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ih.x,ih.y).multiplyScalar(-e/ih.z),ih.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ih.x,ih.y).multiplyScalar(-e/ih.z)}getViewSize(e,t){return this.getViewBounds(e,rh,sh),t.subVectors(sh,rh)}setViewOffset(e,t,i,r,s,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*Qr*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){let e=a.fullWidth,n=a.fullHeight;s+=a.offsetX*r/e,t-=a.offsetY*i/n,r*=a.width/e,i*=a.height/n}let n=this.filmOffset;0!==n&&(s+=e*n/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},nh=class extends Zl{constructor(){super(new ah(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,i=2*es*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},oh=class extends Hl{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ea.DEFAULT_UP),this.updateMatrix(),this.target=new ea,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new nh}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},lh=class extends Zl{constructor(){super(new ah(90,1,.5,500)),this.isPointLightShadow=!0}},hh=class extends Hl{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new lh}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},uh=class extends th{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,a=i+e,n=r+t,o=r-t;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=e*this.view.offsetX,a=s+e*this.view.width,n-=t*this.view.offsetY,o=n-t*this.view.height}this.projectionMatrix.makeOrthographic(s,a,n,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}},dh=class extends Zl{constructor(){super(new uh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ch=class extends Hl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ea.DEFAULT_UP),this.updateMatrix(),this.target=new ea,this.shadow=new dh}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},ph=class extends Hl{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},mh=class extends Hl{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},gh=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new ns)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],i*r*1.092548),t.addScaledVector(a[5],r*s*1.092548),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],i*s*1.092548),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*r),t.addScaledVector(a[2],1.023328*s),t.addScaledVector(a[3],1.023328*i),t.addScaledVector(a[4],.858086*i*r),t.addScaledVector(a[5],.858086*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],.858086*i*s),t.addScaledVector(a[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+3*r);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+3*r);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},fh=class extends Hl{constructor(e=new gh,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},yh=class{static extractUrlBase(e){let t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},vh=class extends an{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},bh=class extends Fl{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new Wl(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(i){try{t(s.parse(JSON.parse(i)))}catch(t){r?r(t):y(t),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(e,r){if(void 0!==t[r])return t[r];let s=e.interleavedBuffers[r],a=function(e,t){if(void 0!==i[t])return i[t];let r=e.arrayBuffers[t],s=new Uint32Array(r).buffer;return i[t]=s,s}(e,s.buffer),n=d(s.type,a),o=new nn(n,s.stride);return o.uuid=s.uuid,t[r]=o,o}let s=e.isInstancedBufferGeometry?new vh:new an,a=e.data.index;if(void 0!==a){let e=d(a.type,a.array);s.setIndex(new ja(e,1))}let n=e.data.attributes;for(let t in n){let i,a=n[t];if(a.isInterleavedBufferAttribute){let t=r(e.data,a.data);i=new ln(t,a.itemSize,a.offset,a.normalized)}else{let e=d(a.type,a.array);i=new(a.isInstancedBufferAttribute?Jn:ja)(e,a.itemSize,a.normalized)}void 0!==a.name&&(i.name=a.name),void 0!==a.usage&&i.setUsage(a.usage),s.setAttribute(t,i)}let o=e.data.morphAttributes;if(o)for(let t in o){let i=o[t],a=[];for(let t=0,s=i.length;t<s;t++){let s,n=i[t];if(n.isInterleavedBufferAttribute){let t=r(e.data,n.data);s=new ln(t,n.itemSize,n.offset,n.normalized)}else{let e=d(n.type,n.array);s=new ja(e,n.itemSize,n.normalized)}void 0!==n.name&&(s.name=n.name),a.push(s)}s.morphAttributes[t]=a}e.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){let t=l[e];s.addGroup(t.start,t.count,t.materialIndex)}let h=e.data.boundingSphere;return void 0!==h&&(s.boundingSphere=(new Ka).fromJSON(h)),e.name&&(s.name=e.name),e.userData&&(s.userData=e.userData),s}},xh=-90,wh=class extends ea{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new ah(xh,1,e,t);r.layers=this.layers,this.add(r);let s=new ah(xh,1,e,t);s.layers=this.layers,this.add(s);let a=new ah(xh,1,e,t);a.layers=this.layers,this.add(a);let n=new ah(xh,1,e,t);n.layers=this.layers,this.add(n);let o=new ah(xh,1,e,t);o.layers=this.layers,this.add(o);let l=new ah(xh,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,a,n,o]=t;for(let e of t)this.remove(e);if(e===jr)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),n.up.set(0,1,0),n.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==Gr)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),n.up.set(0,-1,0),n.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,a,n,o,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),c=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;g=!0===e.isWebGLRenderer?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(i,0,r),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,r),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,r),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,n),e.setRenderTarget(i,3,r),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,4,r),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=m,e.setRenderTarget(i,5,r),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,c),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}},_h=class{constructor(e,t,i){let r,s,a;switch(this.binding=e,this.valueSize=i,t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(0===a){for(let e=0;e!==r;++e)i[s+e]=i[e];a=t}else{a+=t;let e=t/a;this._mixBufferRegion(i,s,0,e,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let e=t*this._origIndex;this._mixBufferRegion(i,r,e,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let e=t,s=t+t;e!==s;++e)if(i[e]!==i[e+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let e=i,s=r;e!==s;++e)t[e]=t[r+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let r=0;r!==s;++r)e[t+r]=e[i+r]}_slerp(e,t,i,r){ss.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;ss.multiplyQuaternionsFlat(e,a,e,t,e,i),ss.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let s=t+n;e[s]=e[s]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let s=t+a;e[s]=e[s]+e[i+a]*r}}},Sh="\\[\\]\\.:\\/",Mh=new RegExp("["+Sh+"]","g"),Th="[^"+Sh+"]",Ch="[^"+Sh.replace("\\.","")+"]",Ah=/((?:WC+[\/:])*)/.source.replace("WC",Th),Nh=/(WCOD+)?/.source.replace("WCOD",Ch),Ph=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Th),Rh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Th),Eh=new RegExp("^"+Ah+Nh+Ph+Rh+"$"),Oh=["material","materials","bones","map"],Bh=class{constructor(e,t,i){let r=i||Vh.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];void 0!==r&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},(Vh=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Vh.parseTrackName(t),this.node=Vh.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Vh.Composite(e,t,i):new Vh(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Mh,"")}static parseTrackName(e){let t=Eh.exec(e);if(null===t)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){let e=i.nodeName.substring(r+1);-1!==Oh.indexOf(e)&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=e)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){let i=function(e){for(let r=0;r<e.length;r++){let s=e[r];if(s.name===t||s.uuid===t)return s;let a=i(s.children);if(a)return a}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Vh.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void f("PropertyBinding: No target node found for track: "+this.path+".");if(i){let r=t.objectIndex;switch(i){case"materials":if(!e.material)return void y("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void y("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void y("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===r){r=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void y("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void y("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[i])return void y("PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==r){if(void 0===e[r])return void y("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[r]}}let a=e[r];if(void 0===a)return void y("PropertyBinding: Trying to update property for track: "+t.nodeName+"."+r+" but it wasn't found.",e);let n=this.Versioning.None;this.targetObject=e,!0===e.isMaterial?n=this.Versioning.NeedsUpdate:!0===e.isObject3D&&(n=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==s){if("morphTargetInfluences"===r){if(!e.geometry)return void y("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void y("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[s]&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else void 0!==a.fromArray&&void 0!==a.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}).Composite=Bh,Vh.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Vh.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Vh.prototype.GetterByBindingType=[Vh.prototype._getValue_direct,Vh.prototype._getValue_array,Vh.prototype._getValue_arrayElement,Vh.prototype._getValue_toArray],Vh.prototype.SetterByBindingTypeAndVersioning=[[Vh.prototype._setValue_direct,Vh.prototype._setValue_direct_setNeedsUpdate,Vh.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Vh.prototype._setValue_array,Vh.prototype._setValue_array_setNeedsUpdate,Vh.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Vh.prototype._setValue_arrayElement,Vh.prototype._setValue_arrayElement_setNeedsUpdate,Vh.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Vh.prototype._setValue_fromArray,Vh.prototype._setValue_fromArray_setNeedsUpdate,Vh.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]],Dh=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,n=new Array(a),o={endingStart:rr,endingEnd:rr};for(let e=0;e!==a;++e){let t=s[e].createInterpolant(null);n[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=Ji,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),!0===i){let i=this._clip.duration,r=e._clip.duration,s=r/i,a=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,n=this._timeScaleInterpolant;null===n&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled)return void this._updateWeight(e);let s=this._startTime;if(null!==s){let r=(e-s)*i;r<0||0===i?t=0:(this._startTime=null,t=i*r)}t*=this._updateTimeScale(e);let a=this._updateTime(t),n=this._updateWeight(e);if(n>0){let e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let i=0,r=e.length;i!==r;++i)e[i].evaluate(a),t[i].accumulateAdditive(n);else for(let i=0,s=e.length;i!==s;++i)e[i].evaluate(a),t[i].accumulate(r,n)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(null!==i){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;null!==i&&(t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(0===t?this.paused=!0:(null!==this._restoreTimeScale&&(t=this._restoreTimeScale),this.timeScale=t),this.stopWarping()))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===Qi;if(0===e)return-1===s||!a||1&~s?r:t-r;if(i===Zi){-1===s&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else{if(!(r<0)){this.time=r;break e}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===s&&(e>=0?(s=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),r>=t||r<0){let i=Math.floor(r/t);r-=t*i,s+=Math.abs(i);let n=this.repetitions-s;if(n<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===n){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this._loopCount=s,this.time=r;if(a&&!(1&~s))return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=sr,r.endingEnd=sr):(r.endingStart=e?this.zeroSlopeAtStart?sr:rr:ar,r.endingEnd=t?this.zeroSlopeAtEnd?sr:rr:ar)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},Ih=new Float32Array(1),Lh=class extends Kr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];void 0===h&&(h={},l[o]=h);for(let e=0;e!==s;++e){let s=r[e],l=s.name,u=h[l];if(void 0!==u)++u.referenceCount,a[e]=u;else{if(u=a[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,o,l));continue}let r=t&&t._propertyBindings[e].binding.parsedPath;u=new _h(Vh.create(i,l,r),s.ValueTypeName,s.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,o,l),a[e]=u}n[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){let t=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t)}let t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){let i=t[e];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){let i=t[e];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,n=a[s],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null,delete n.actionByRoot[(e._localRoot||this._root).uuid],0===o.length&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){let i=t[e];0===--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];void 0===a&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,n=a[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[s],0===Object.keys(n).length&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return void 0===i&&(i=new Al(new Float32Array(2),new Float32Array(2),1,Ih),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a="string"==typeof e?zl.findByName(r,e):e,n=null!==a?a.uuid:e,o=this._actionsByClip[n],l=null;if(void 0===i&&(i=null!==a?a.blendMode:2500),void 0!==o){let e=o.actionByRoot[s];if(void 0!==e&&e.blendMode===i)return e;l=o.knownActions[0],null===a&&(a=l._clip)}if(null===a)return null;let h=new Dh(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s="string"==typeof e?zl.findByName(i,e):e,a=s?s.uuid:e,n=this._actionsByClip[a];return void 0!==n&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let n=0;n!==i;++n)t[n]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)n[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(void 0!==s){let e=s.knownActions;for(let i=0,r=e.length;i!==r;++i){let r=e[i];this._deactivateAction(r);let s=r._cacheIndex,a=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,a._cacheIndex=s,t[s]=a,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let e in i){let r=i[e].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}let r=this._bindingsByRootAndName[t];if(void 0!==r)for(let e in r){let t=r[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){let i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},zh=class extends nn{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},kh=new As,Uh=class{constructor(e,t,i=0,r=1/0){this.ray=new Bn(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new zs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):y("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return kh.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(kh),this}intersectObject(e,t=!0,i=[]){return De(e,this,i,t),i.sort(Ve),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)De(e[r],this,i,t);return i.sort(Ve),i}},Fh=class{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=x(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(x(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},Gh=jh=class{constructor(e,t,i,r){this.elements=[1,0,0,1],void 0!==e&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){let s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}},jh.prototype.isMatrix2=!0,Wh=new rs,qh=class{constructor(e=new rs(1/0,1/0),t=new rs(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Wh.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Wh).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Hh=new ns,$h=new ns,Yh=new ns,Xh=new ns,Kh=new ns,Zh=new ns,Jh=new ns,Qh=class{constructor(e=new ns,t=new ns){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Hh.subVectors(e,this.start),$h.subVectors(this.end,this.start);let i=$h.dot($h);if(0===i)return 0;let r=$h.dot(Hh)/i;return t&&(r=x(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=Zh,i=Jh){let r,s,a=10000000000000001e-32,n=this.start,o=e.start,l=this.end,h=e.end;Yh.subVectors(l,n),Xh.subVectors(h,o),Kh.subVectors(n,o);let u=Yh.dot(Yh),d=Xh.dot(Xh),c=Xh.dot(Kh);if(u<=a&&d<=a)return t.copy(n),i.copy(o),t.sub(i),t.dot(t);if(u<=a)r=0,s=c/d,s=x(s,0,1);else{let e=Yh.dot(Kh);if(d<=a)s=0,r=x(-e/u,0,1);else{let t=Yh.dot(Xh),i=u*d-t*t;r=0!==i?x((t*c-e*d)/i,0,1):0,s=(t*r+c)/d,s<0?(s=0,r=x(-e/u,0,1)):s>1&&(s=1,r=x((t-e)/u,0,1))}}return t.copy(n).addScaledVector(Yh,r),i.copy(o).addScaledVector(Xh,s),t.distanceToSquared(i)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},eu=new ns,tu=class extends ea{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new an,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,i=32;e<i;e++,t++){let s=e/i*Math.PI*2,a=t/i*Math.PI*2;r.push(Math.cos(s),Math.sin(s),1,Math.cos(a),Math.sin(a),1)}i.setAttribute("position",new Ha(r,3));let s=new vo({fog:!1,toneMapped:!1});this.cone=new Po(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorldNeedsUpdate=!0;let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),eu.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(eu),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},iu=class extends Hn{constructor(e,t,i){super(new pl(t,4,2),new Vn({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},ru=new ns,su=new ns,au=new ns,nu=class extends ea{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===t&&(t=1);let r=new an;r.setAttribute("position",new Ha([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new vo({fog:!1,toneMapped:!1});this.lightPlane=new Co(r,s),this.add(this.lightPlane),r=new an,r.setAttribute("position",new Ha([0,0,0,0,0,1],3)),this.targetLine=new Co(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),ru.setFromMatrixPosition(this.light.matrixWorld),su.setFromMatrixPosition(this.light.target.matrixWorld),au.subVectors(su,ru),this.lightPlane.lookAt(su),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(su),this.targetLine.scale.z=au.length()}},ou=new ns,lu=new th,hu=class extends Po{constructor(e){let t=new an,i=new vo({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};function n(e,t){o(e),o(t)}function o(e){r.push(0,0,0),s.push(0,0,0),void 0===a[e]&&(a[e]=[]),a[e].push(r.length/3-1)}n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4"),t.setAttribute("position",new Ha(r,3)),t.setAttribute("color",new Ha(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let l=new aa(16755200),h=new aa(16711680),u=new aa(43775),d=new aa(16777215),c=new aa(3355443);this.setColors(l,h,u,d,c)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");return a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0,this}update(){let e,t,i=this.geometry,r=this.pointMap;if(lu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)e=1,t=0;else if(this.camera.coordinateSystem===jr)e=-1,t=1;else{if(this.camera.coordinateSystem!==Gr)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);e=0,t=1}Ie("c",r,i,lu,0,0,e),Ie("t",r,i,lu,0,0,t),Ie("n1",r,i,lu,-1,-1,e),Ie("n2",r,i,lu,1,-1,e),Ie("n3",r,i,lu,-1,1,e),Ie("n4",r,i,lu,1,1,e),Ie("f1",r,i,lu,-1,-1,t),Ie("f2",r,i,lu,1,-1,t),Ie("f3",r,i,lu,-1,1,t),Ie("f4",r,i,lu,1,1,t),Ie("u1",r,i,lu,.7,1.1,e),Ie("u2",r,i,lu,-.7,1.1,e),Ie("u3",r,i,lu,0,2,e),Ie("cf1",r,i,lu,-1,0,t),Ie("cf2",r,i,lu,1,0,t),Ie("cf3",r,i,lu,0,-1,t),Ie("cf4",r,i,lu,0,1,t),Ie("cn1",r,i,lu,-1,0,e),Ie("cn2",r,i,lu,1,0,e),Ie("cn3",r,i,lu,0,-1,e),Ie("cn4",r,i,lu,0,1,e),i.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},uu=class extends Po{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new an;r.setIndex(new ja(i,1)),r.setAttribute("position",new Ha([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(r,new vo({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},du=class extends Po{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=new an;i.setAttribute("position",new Ha(t,3)),i.setAttribute("color",new Ha([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new vo({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,i){let r=new aa,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Le}})),typeof window<"u"&&(window.__THREE__?f("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Le)}),Tu=n(()=>{cu=()=>!(typeof window>"u")&&window.navigator.platform.toUpperCase().includes("MAC"),pu=()=>!(typeof window>"u")&&(/iPad|iPhone|iPod/.test(window.navigator.userAgent)||bu&&"ontouchend"in document),mu=()=>!(typeof window>"u")&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,gu=()=>!(typeof window>"u")&&("ontouchstart"in window||navigator.maxTouchPoints>0),fu=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},yu=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},vu=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},!(typeof window>"u")&&window.navigator.userAgent.toLowerCase().includes(" electron/")&&vu(),(()=>{if(!(typeof window>"u"))return window.spline})(),bu=cu(),xu=pu(),wu=mu(),_u=gu(),fu(),Number(yu())}),Cu=n(()=>{Su=!0});function Au(e){return bu?e.metaKey:e.ctrlKey}function Nu(e,t){return Math.abs(e+3*t)<=Pu||Math.abs(e+3*window.devicePixelRatio*t)<=Pu}var Pu,Ru=n(()=>{Tu(),Pu=2}),Eu=n(()=>{});function Ou(e){zu.includes(e)||zu.push(e)}function Bu(e){delete ku[e.pointerId];for(let t=0;t<zu.length;t++)if(zu[t].pointerId===e.pointerId){zu.splice(t,1);break}}function Vu(e){if("touch"!==e.pointerType)return;let t=ku[e.pointerId];void 0===t&&(t={x:0,y:0},ku[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Du(e){let t=e.pointerId===zu[0].pointerId?zu[1]:zu[0];return ku[t.pointerId]}function Iu(e){Uu[e.key]=!0,Fu[e.key]=void 0===Fu[e.key]?1:Fu[e.key]+1}function Lu(e){if(bu&&Uu.Meta)for(let e in Uu)Uu[e]=!1;else Uu[e.key]=!1;Fu={}}var zu,ku,Uu,Fu,ju,Gu=n(()=>{Tu(),zu=[],ku={},Uu={},Fu={}}),Wu=n(()=>{}),qu=n(()=>{ju=typeof window<"u"&&!!window.spline?.isShellTabs}),Hu=n(()=>{});function $u(e,t=0,i={}){let r,s,a,n,o,l=!0===i.leading,h=!1!==i.trailing,u=void 0!==i.maxWait?Math.max(i.maxWait,t):void 0,d=0,c=t=>{let i=s,r=a;return s=a=void 0,d=t,n=e.apply(r,i),n},p=e=>{if(void 0===o)return!0;let i=e-o;return i>=t||i<0||void 0!==u&&e-d>=u},m=e=>(r=void 0,h&&s?c(e):(s=a=void 0,n)),g=()=>{let e=Date.now();p(e)?m(e):r=setTimeout(g,(e=>{let i=t-(e-o);return void 0!==u?Math.min(i,u-(e-d)):i})(e))},f=function(...e){let i=Date.now(),h=p(i);if(s=e,a=this,o=i,h){if(void 0===r)return d=i,r=setTimeout(g,t),l?c(i):n;if(void 0!==u)return r=setTimeout(g,t),c(i)}return void 0===r&&(r=setTimeout(g,t)),n};return f.cancel=()=>{void 0!==r&&clearTimeout(r),d=0,s=o=a=r=void 0},f.flush=()=>void 0===r?n:m(Date.now()),f}function Yu(e){return Xu(e,new Map)}function Xu(e,t){if(null===e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof ArrayBuffer)return e.slice(0);if(ArrayBuffer.isView(e))return new e.constructor(e.buffer.slice(0),e.byteOffset,e instanceof DataView?e.byteLength:e.length);if(e instanceof Map){let i=new Map;return t.set(e,i),e.forEach((e,r)=>i.set(Xu(r,t),Xu(e,t))),i}if(e instanceof Set){let i=new Set;return t.set(e,i),e.forEach(e=>i.add(Xu(e,t))),i}if(Array.isArray(e)){let i=new e.constructor(e.length);t.set(e,i);for(let[r,s]of Object.entries(e))i[r]=Xu(s,t);return i}let i=Object.create(Object.getPrototypeOf(e));t.set(e,i);for(let[r,s]of Object.entries(e))i[r]=Xu(s,t);return i}function Ku(e,t){let i=new Set(t),r={};for(let[t,s]of Object.entries(e))i.has(t)||(r[t]=s);return r}var Zu,Ju,Qu,ed=n(()=>{}),td=n(()=>{}),id=n(()=>{}),rd=o(e=>{var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function r(e,i,r){var s=null;if(void 0!==r&&(s=""+r),void 0!==i.key&&(s=""+i.key),"key"in i)for(var a in r={},i)"key"!==a&&(r[a]=i[a]);else r=i;return i=r.ref,{$$typeof:t,type:e,key:s,ref:void 0!==i?i:null,props:r}}e.Fragment=i,e.jsx=r,e.jsxs=r}),sd=o((e,t)=>{t.exports=rd()}),ad=n(()=>{h(sd(),1)}),nd=n(()=>{Zu="__splineHtmlContent"}),od=n(()=>{nd(),Ju=`(function () {\n\t'use strict';\n\tvar MARKER = ${JSON.stringify(Zu)};\n\tvar callSeq = 1;\n\tvar pending = {};\n\tvar listeners = {};\n\tvar acked = false;\n\tvar readyResolve;\n\tvar readyPromise = new Promise(function (resolve) { readyResolve = resolve; });\n\n\tfunction post(msg) {\n\t\tmsg[MARKER] = true;\n\t\ttry {\n\t\t\twindow.parent.postMessage(msg, '*');\n\t\t} catch (e) { /* parent gone — nothing to do */ }\n\t}\n\n\tfunction call(method, args) {\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tvar id = callSeq++;\n\t\t\tpending[id] = { resolve: resolve, reject: reject };\n\t\t\tpost({ kind: 'call', id: id, method: method, args: args });\n\t\t});\n\t}\n\n\t// ---- the public API ----------------------------------------------------\n\tvar spline = {\n\t\t/** Resolves once the editor has acknowledged the frame. */\n\t\tready: readyPromise,\n\t\tsetVariable: function (name, value) { return call('setVariable', [name, value]); },\n\t\tsetVariables: function (variables) { return call('setVariables', [variables]); },\n\t\tgetVariable: function (name) { return call('getVariable', [name]); },\n\t\tgetVariables: function () { return call('getVariables', []); },\n\t\tgetAllObjects: function () { return call('getAllObjects', []); },\n\t\tfindObjectByName: function (name) { return call('findObjectByName', [name]); },\n\t\tfindObjectById: function (id) { return call('findObjectById', [id]); },\n\t\t/** Read a mesh's live geometry ({vertexCount, triangleCount, indexed, bounds, vertices: Float32Array, indices?, normals?, uvs?}); options {space: 'local'|'world'}. Resolves undefined (with a console warning) when unreadable. */\n\t\tgetGeometry: function (nameOrId, options) { return call('getGeometry', [nameOrId, options || {}]); },\n\t\t/** Runtime-only transform/visibility update ({position,rotation,scale,visible}; rotation in degrees). */\n\t\tupdateObject: function (nameOrId, props) { return call('updateObject', [nameOrId, props]); },\n\t\t/** Runtime-only object creation ('Cube', 'Sphere', …, 'Text', 'Group', lights); resolves to the new object's snapshot. */\n\t\tcreateObject: function (type, options) {\n\t\t\t// A three.js material instance or createCustomMaterial factory can't cross\n\t\t\t// the postMessage boundary (textures/callbacks/functions fail\n\t\t\t// structured clone) — fail loud, not with a cryptic DataCloneError.\n\t\t\tif (options && options.material && (\n\t\t\t\toptions.material.isMaterial === true ||\n\t\t\t\ttypeof options.material === 'function'\n\t\t\t)) {\n\t\t\t\treturn Promise.reject(new Error(\n\t\t\t\t\t'createObject: custom three.js materials need the inline ' +\n\t\t\t\t\t'HTML-content mode (the editor Preview/Play frame and web ' +\n\t\t\t\t\t'exports); this embed runs the sandboxed mode, whose transport ' +\n\t\t\t\t\t'cannot carry them. Use a color/PBR bag or shared material ' +\n\t\t\t\t\t'name here instead.'\n\t\t\t\t));\n\t\t\t}\n\t\t\treturn call('createObject', [type, options || {}]);\n\t\t},\n\t\t/** Custom three.js/TSL materials — inline HTML-content mode only; the\n\t\t * factory function cannot cross this sandboxed transport. */\n\t\tcreateCustomMaterial: function () {\n\t\t\treturn Promise.reject(new Error(\n\t\t\t\t'createCustomMaterial: custom three.js materials need the inline ' +\n\t\t\t\t'HTML-content mode (the editor Preview/Play frame and web ' +\n\t\t\t\t'exports); this embed runs the sandboxed mode, whose transport ' +\n\t\t\t\t'cannot carry the factory function or the material it returns.'\n\t\t\t));\n\t\t},\n\t\t/** Replace a mesh's material with a custom three.js material — inline\n\t\t * HTML-content mode only; neither factories nor instances can cross\n\t\t * this sandboxed transport. */\n\t\tsetMaterial: function () {\n\t\t\treturn Promise.reject(new Error(\n\t\t\t\t'setMaterial: custom three.js materials need the inline ' +\n\t\t\t\t'HTML-content mode (the editor Preview/Play frame and web ' +\n\t\t\t\t'exports); this embed runs the sandboxed mode, whose transport ' +\n\t\t\t\t'cannot carry the factory function or the material it returns.'\n\t\t\t));\n\t\t},\n\t\t/** Runtime-only deep clone of an existing object; resolves to the clone's snapshot. */\n\t\tcloneObject: function (nameOrId, options) { return call('cloneObject', [nameOrId, options || {}]); },\n\t\t/** Removes an object (and its subtree); resolves to false when none matched. */\n\t\tremoveObject: function (nameOrId) { return call('removeObject', [nameOrId]); },\n\t\t/** Spawn a runtime-only copy of a template object; resolves to its snapshot ({id,...}) or undefined. */\n\t\tspawnObject: function (templateNameOrId, options) { return call('spawnObject', [templateNameOrId, options || {}]); },\n\t\t/** Remove a spawned copy by id (or assigned name). Spawned objects only. */\n\t\tdestroyObject: function (idOrName) { return call('destroyObject', [idOrName]); },\n\t\t/** Per-copy transform writes on a cloner ([{position,rotation,scale}|null, ...]; degrees); null clears all. Resolves to the copy count. */\n\t\tsetInstanceTransforms: function (nameOrId, transforms) { return call('setInstanceTransforms', [nameOrId, transforms === undefined ? null : transforms]); },\n\t\t/** Trigger a Spline event on an object (requires Play mode). */\n\t\temitEvent: function (eventName, nameOrUuid) { return call('emitEvent', [eventName, nameOrUuid]); },\n\t\temitEventReverse: function (eventName, nameOrUuid) { return call('emitEventReverse', [eventName, nameOrUuid]); },\n\t\trequestRender: function () { return call('requestRender', []); },\n\t\taddEventListener: function (eventName, cb) {\n\t\t\tif (typeof cb !== 'function') return;\n\t\t\tif (!listeners[eventName]) {\n\t\t\t\tlisteners[eventName] = [];\n\t\t\t\tcall('listenEvent', [eventName]);\n\t\t\t}\n\t\t\tlisteners[eventName].push(cb);\n\t\t},\n\t\tremoveEventListener: function (eventName, cb) {\n\t\t\tvar list = listeners[eventName];\n\t\t\tif (!list) return;\n\t\t\tvar i = list.indexOf(cb);\n\t\t\tif (i !== -1) list.splice(i, 1);\n\t\t\tif (list.length === 0) {\n\t\t\t\tdelete listeners[eventName];\n\t\t\t\tcall('unlistenEvent', [eventName]);\n\t\t\t}\n\t\t},\n\t};\n\twindow.spline = spline;\n\n\t// ---- editor -> frame ---------------------------------------------------\n\twindow.addEventListener('message', function (event) {\n\t\tif (event.source !== window.parent) return;\n\t\tvar data = event.data;\n\t\tif (!data || data[MARKER] !== true) return;\n\t\tif (data.kind === 'ready-ack') {\n\t\t\tacked = true;\n\t\t\treadyResolve();\n\t\t} else if (data.kind === 'result') {\n\t\t\tvar entry = pending[data.id];\n\t\t\tif (!entry) return;\n\t\t\tdelete pending[data.id];\n\t\t\tif (data.ok) entry.resolve(data.value);\n\t\t\telse entry.reject(new Error(data.error || 'spline bridge call failed'));\n\t\t} else if (data.kind === 'event') {\n\t\t\tvar list = listeners[data.eventName];\n\t\t\tif (!list) return;\n\t\t\tfor (var i = 0; i < list.length; i++) {\n\t\t\t\ttry {\n\t\t\t\t\tlist[i](data.payload);\n\t\t\t\t} catch (e) {\n\t\t\t\t\treportError(e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\t// ---- console + error capture --------------------------------------------\n\tfunction stringify(value, depth) {\n\t\ttry {\n\t\t\tif (typeof value === 'string') return value;\n\t\t\tif (value instanceof Error) return value.stack || String(value);\n\t\t\tif (typeof value === 'function') return '[function ' + (value.name || 'anonymous') + ']';\n\t\t\tif (value === undefined) return 'undefined';\n\t\t\tvar seen = [];\n\t\t\tvar json = JSON.stringify(value, function (k, v) {\n\t\t\t\tif (typeof v === 'object' && v !== null) {\n\t\t\t\t\tif (seen.indexOf(v) !== -1) return '[circular]';\n\t\t\t\t\tseen.push(v);\n\t\t\t\t}\n\t\t\t\tif (typeof v === 'function') return '[function]';\n\t\t\t\treturn v;\n\t\t\t});\n\t\t\treturn json === undefined ? String(value) : json;\n\t\t} catch (e) {\n\t\t\ttry { return String(value); } catch (e2) { return '[unserializable]'; }\n\t\t}\n\t}\n\n\tfunction sendConsole(level, args) {\n\t\tvar parts = [];\n\t\tfor (var i = 0; i < args.length; i++) parts.push(stringify(args[i]));\n\t\tvar text = parts.join(' ');\n\t\tif (text.length > 4000) text = text.slice(0, 4000) + '…';\n\t\tpost({ kind: 'console', level: level, text: text });\n\t}\n\n\t['log', 'info', 'warn', 'error'].forEach(function (level) {\n\t\tvar original = console[level];\n\t\tconsole[level] = function () {\n\t\t\tsendConsole(level, arguments);\n\t\t\tif (original) original.apply(console, arguments);\n\t\t};\n\t});\n\n\tfunction reportError(error) {\n\t\tsendConsole('error', [error instanceof Error ? error : String(error)]);\n\t}\n\twindow.addEventListener('error', function (event) {\n\t\tsendConsole('error', [event.message + (event.filename ? ' (' + event.filename + ':' + event.lineno + ')' : '')]);\n\t});\n\twindow.addEventListener('unhandledrejection', function (event) {\n\t\tsendConsole('error', ['Unhandled promise rejection: ' + stringify(event.reason)]);\n\t});\n\n\t// ---- input passthrough ---------------------------------------------------\n\t// A pointer that goes DOWN on the page background belongs to the 3D scene\n\t// until it is released; one that goes down on generated UI never forwards.\n\tvar forwardedPointers = {};\n\n\tfunction isBackground(target) {\n\t\tif (!target || target === document || target === document.documentElement || target === document.body) {\n\t\t\treturn true;\n\t\t}\n\t\tif (target.closest && target.closest('[data-spline-passthrough]')) return true;\n\t\treturn false;\n\t}\n\n\tfunction baseInput(e, type) {\n\t\treturn {\n\t\t\ttype: type,\n\t\t\tx: e.clientX,\n\t\t\ty: e.clientY,\n\t\t\tbutton: e.button,\n\t\t\tbuttons: e.buttons,\n\t\t\tpointerId: e.pointerId,\n\t\t\tpointerType: e.pointerType,\n\t\t\tisPrimary: e.isPrimary,\n\t\t\tmovementX: e.movementX,\n\t\t\tmovementY: e.movementY,\n\t\t\tshiftKey: e.shiftKey,\n\t\t\tctrlKey: e.ctrlKey,\n\t\t\taltKey: e.altKey,\n\t\t\tmetaKey: e.metaKey,\n\t\t};\n\t}\n\n\tdocument.addEventListener('pointerdown', function (e) {\n\t\tif (!isBackground(e.target)) return;\n\t\tforwardedPointers[e.pointerId] = true;\n\t\tpost({ kind: 'input', event: baseInput(e, 'pointerdown') });\n\t}, true);\n\n\tdocument.addEventListener('pointermove', function (e) {\n\t\tif (!forwardedPointers[e.pointerId] && !isBackground(e.target)) return;\n\t\tpost({ kind: 'input', event: baseInput(e, 'pointermove') });\n\t}, true);\n\n\t['pointerup', 'pointercancel'].forEach(function (type) {\n\t\tdocument.addEventListener(type, function (e) {\n\t\t\tvar wasForwarded = forwardedPointers[e.pointerId];\n\t\t\tdelete forwardedPointers[e.pointerId];\n\t\t\tif (!wasForwarded && !isBackground(e.target)) return;\n\t\t\tpost({ kind: 'input', event: baseInput(e, type) });\n\t\t}, true);\n\t});\n\n\t['click', 'dblclick'].forEach(function (type) {\n\t\tdocument.addEventListener(type, function (e) {\n\t\t\tif (!isBackground(e.target)) return;\n\t\t\tpost({ kind: 'input', event: baseInput(e, type) });\n\t\t}, true);\n\t});\n\n\tdocument.addEventListener('wheel', function (e) {\n\t\tif (!isBackground(e.target)) return;\n\t\te.preventDefault();\n\t\tvar msg = baseInput(e, 'wheel');\n\t\tmsg.deltaX = e.deltaX;\n\t\tmsg.deltaY = e.deltaY;\n\t\tmsg.deltaMode = e.deltaMode;\n\t\t// The legacy wheelDelta fields carry the trackpad-vs-mouse signature\n\t\t// the editor's pan/zoom discrimination reads (wheelDeltaY === -3*dY\n\t\t// on trackpads) — a reconstructed WheelEvent loses them, turning\n\t\t// two-finger pans into zooms. Forward them verbatim.\n\t\tif (typeof e.wheelDeltaX === 'number') msg.wheelDeltaX = e.wheelDeltaX;\n\t\tif (typeof e.wheelDeltaY === 'number') msg.wheelDeltaY = e.wheelDeltaY;\n\t\tpost({ kind: 'input', event: msg });\n\t}, { capture: true, passive: false });\n\n\t['keydown', 'keyup'].forEach(function (type) {\n\t\tdocument.addEventListener(type, function (e) {\n\t\t\t// Never steal keys from the page's own form fields.\n\t\t\tvar t = e.target;\n\t\t\tif (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return;\n\t\t\tpost({ kind: 'input', event: {\n\t\t\t\ttype: type,\n\t\t\t\tkey: e.key,\n\t\t\t\tcode: e.code,\n\t\t\t\trepeat: e.repeat,\n\t\t\t\tshiftKey: e.shiftKey,\n\t\t\t\tctrlKey: e.ctrlKey,\n\t\t\t\taltKey: e.altKey,\n\t\t\t\tmetaKey: e.metaKey,\n\t\t\t} });\n\t\t}, true);\n\t});\n\n\t// ---- handshake -----------------------------------------------------------\n\t// Announce readiness and KEEP announcing until the editor acks. A single\n\t// 'ready' can race the editor attaching its listener (or land while the\n\t// editor is busy); code that awaits spline.ready would then hang forever.\n\t// The editor acks every 'ready' (and posts a proactive ack on attach), so\n\t// this settles within one round-trip in the normal case.\n\tpost({ kind: 'ready' });\n\tvar readyRetry = setInterval(function () {\n\t\tif (acked) {\n\t\t\tclearInterval(readyRetry);\n\t\t\treturn;\n\t\t}\n\t\tpost({ kind: 'ready' });\n\t}, 250);\n})();`}),ld=n(()=>{Qu=class{constructor(e,t,i){this.deps=e,this.onConsole=t,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let e of this.eventUnsubs.values())e();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(e,t){let i=this.deps;switch(e){case"setVariable":{let e=i.setVariable(String(t[0]),t[1]);return e.warning&&this.onConsole("warn",e.warning),e.ok}case"setVariables":{let e=t[0]??{},r=!0;for(let[t,s]of Object.entries(e)){let e=i.setVariable(t,s);e.warning&&this.onConsole("warn",e.warning),r=r&&e.ok}return r}case"getVariable":return i.getVariable(String(t[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(t[0]));case"getGeometry":{let e=i.getGeometry(String(t[0]),t[1]??{});return e.warning&&this.onConsole("warn",e.warning),e.data}case"updateObject":return i.updateObject(String(t[0]),t[1]??{});case"createObject":return i.createObject(String(t[0]),t[1]??{});case"createCustomMaterial":if(void 0===i.createCustomMaterial)throw new Error("createCustomMaterial: not available on this surface — custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.createCustomMaterial(t[0]);case"setMaterial":if(void 0===i.setMaterial)throw new Error("setMaterial: not available on this surface — custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.setMaterial(String(t[0]),t[1]);case"cloneObject":return i.cloneObject(String(t[0]),t[1]??{});case"removeObject":return i.removeObject(String(t[0]));case"spawnObject":{let e=i.spawnObject(String(t[0]),t[1]??{});return e.warning&&this.onConsole("warn",e.warning),e.object}case"destroyObject":return i.destroyObject(String(t[0]));case"setInstanceTransforms":{let e=null===t[1]||void 0===t[1]?null:t[1],r=i.setInstanceTransforms(String(t[0]),e);return r<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(t[0])}" has no cloner — make the object a cloner first (its copies are what this drives).`),r}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(t[0]),String(t[1]),"emitEventReverse"===e);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let e=String(t[0]);return"variableChange"===e?this.startVariablePolling():this.eventUnsubs.has(e)||this.eventUnsubs.set(e,i.addSplineEventListener(e,t=>{this.onEvent(e,t)})),!0}case"unlistenEvent":{let e=String(t[0]);return"variableChange"===e?this.stopVariablePolling():(this.eventUnsubs.get(e)?.(),this.eventUnsubs.delete(e)),!0}default:throw new Error(`Unknown spline bridge method: ${e}`)}}startVariablePolling(){null===this.variablePollHandle&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let e=this.deps.getVariables(),t=function(e,t){let i=[];for(let r of Object.keys(t))e[r]!==t[r]&&i.push({name:r,value:t[r]});return i}(this.lastVariables??{},e);this.lastVariables=e;for(let e of t)this.onEvent("variableChange",e)},100))}stopVariablePolling(){null!==this.variablePollHandle&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function hd(e,t,i,r){return[e[0]*t+e[4]*i+e[8]*r+e[12],e[1]*t+e[5]*i+e[9]*r+e[13],e[2]*t+e[6]*i+e[10]*r+e[14]]}var ud=n(()=>{});var dd,cd=n(()=>{}),pd=n(()=>{nd(),ld(),dd=class{constructor(e,t,i){this.iframe=e,this.deps=t,this.onConsole=i,this.disposed=!1,this.handshakeSeen=!1,this.handshakeTimer=null,this.onMessage=e=>{if(this.disposed||e.source!==this.iframe.contentWindow)return;let t=e.data;var i;"object"!=typeof(i=t)||null===i||!0!==i[Zu]||"string"!=typeof i.kind||this.handleMessage(t)},this.host=new Qu(t,i,(e,t)=>{this.sendEvent(e,t)})}attach(){window.addEventListener("message",this.onMessage),this.send({[Zu]:!0,kind:"ready-ack"}),this.handshakeTimer=window.setTimeout(()=>{this.handshakeTimer=null,!this.handshakeSeen&&!this.disposed&&this.onConsole("warn","The HTML content frame has not initialized (no signal from its scripts yet) — if the page looks frozen, check for errors in its code.")},6e3)}dispose(){this.disposed=!0,window.removeEventListener("message",this.onMessage),this.host.dispose(),null!==this.handshakeTimer&&(window.clearTimeout(this.handshakeTimer),this.handshakeTimer=null)}handleMessage(e){switch(e.kind){case"ready":this.handshakeSeen=!0,this.send({[Zu]:!0,kind:"ready-ack"});break;case"console":this.onConsole(e.level,e.text);break;case"call":{let t;try{t=Promise.resolve(this.host.execute(e.method,e.args))}catch(e){t=Promise.reject(e)}t.then(t=>{this.send({[Zu]:!0,kind:"result",id:e.id,ok:!0,value:t,error:void 0})},t=>{let i=t instanceof Error?t.message:String(t);this.send({[Zu]:!0,kind:"result",id:e.id,ok:!1,value:void 0,error:i}),this.onConsole("error",i)});break}case"input":this.dispatchInput(e.event)}}send(e){this.iframe.contentWindow?.postMessage(e,"*")}sendEvent(e,t){this.send({[Zu]:!0,kind:"event",eventName:e,payload:t})}dispatchInput(e){let t=this.deps.getCanvas();if(!t)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey};switch(e.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":t.dispatchEvent(new PointerEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons,pointerId:e.pointerId,pointerType:e.pointerType,isPrimary:e.isPrimary,movementX:e.movementX,movementY:e.movementY}));break;case"click":case"dblclick":t.dispatchEvent(new MouseEvent(e.type,{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,button:e.button,buttons:e.buttons}));break;case"wheel":{let s=new WheelEvent("wheel",{...r,clientX:(e.x??0)+i.left,clientY:(e.y??0)+i.top,deltaX:e.deltaX,deltaY:e.deltaY,deltaMode:e.deltaMode});"number"==typeof e.wheelDeltaX&&Object.defineProperty(s,"wheelDeltaX",{value:e.wheelDeltaX}),"number"==typeof e.wheelDeltaY&&Object.defineProperty(s,"wheelDeltaY",{value:e.wheelDeltaY}),t.dispatchEvent(s);break}case"keydown":case"keyup":t.dispatchEvent(new KeyboardEvent(e.type,{...r,key:e.key,code:e.code,repeat:e.repeat}))}}}}),md=n(()=>{Tu(),Cu(),Ru(),Eu(),Gu(),Wu(),qu(),Hu(),ed(),td(),id(),ad(),nd(),od(),ld(),ud(),cd(),pd()}),gd=n(()=>{});function fd(e){return Array.isArray(e)?e:[e]}function yd(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var vd=n(()=>{});function bd(e,t){return Object.setPrototypeOf(e,t),e}function xd(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function wd(e,t,i){if(void 0===e?void 0===t?(e=0,t=10):e=t-10:void 0===t&&(t=e+10),e>t){let i=e;e=t,t=i}let r=[],s=1/(i+1);for(let a=0;a<i;a++){let i=e+(t-e)*(a+.75+.5*Math.random())*s;r.push(i)}return r}function _d(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}var Sd=n(()=>{});function Md(e){if(void 0!==e.deepFreeze)return void e.deepFreeze(e);let t=Object.getOwnPropertyNames(e);for(let i of t){let t=e[i];t&&"object"==typeof t&&Md(t)}return Object.freeze(e)}function Td(e){for(let t of Object.keys(e))void 0===e[t]&&delete e[t];return e}var Cd,Ad,Nd,Pd,Rd,Ed=n(()=>{}),Od=n(()=>{gd(),vd(),Sd(),Ed()}),Bd=n(()=>{Cd=class{},Ad=class extends Cd{constructor(e){super(),this.id=e}},Nd=class extends Cd{constructor(e){super(),this.data=e}}}),Vd=n(()=>{}),Dd=n(()=>{Pd=class{modifyById(e,t){let i=this;if(void 0===i[e])throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,Pd.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(1===e.type){let i,r=t[e.id];i=void 0===r?{type:2,id:e.id}:{type:1,id:e.id,data:r};let{id:s,data:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,Pd.prototype),{data:n,actual:e,reverse:i}}if(2===e.type){let{id:i}=e,r=t[i];if(void 0===r)return null;{let s={...t};return Object.setPrototypeOf(s,Pd.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}}}),Id=n(()=>{Rd=class extends Error{}});function Ld(e,t){for(let i of e)!0!==t(i.id,i.data)&&Ld(i.children,t)}function zd(e,t){if(!0!==t(e.id,e.data))for(let i of e.children)zd(i,t)}var kd,Ud,Fd,jd,Gd=n(()=>{Od(),Id(),Od(),kd=class extends Array{constructor(...e){super(...e),u(this,"partialObjectCaches"),u(this,"objCaches"),u(this,"parentCaches"),Object.setPrototypeOf(this,kd.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Md(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let t of e.children)this.fillCaches0(t,e.id)}fillCaches(){if(void 0===this.objCaches){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(0!==e.length)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(!t)return e;e=t}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return void 0!==this.childrenOf(e)}partialCache(e){void 0===this.partialObjectCaches&&(this.partialObjectCaches=new Map);let t=this.get(e);void 0!==t&&this.partialObjectCaches.set(e,t)}get(e){if(void 0!==this.partialObjectCaches){let t=this.partialObjectCaches.get(e);if(void 0!==t)return t}return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return null===e?this:this.get(e)?.children}traverseFrom(e,t){if(null===e)this.traverse(t);else{let i=this.get(e);i&&zd(i,t)}}traverse(e){Ld(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return null===e?this:this.get(e).children}modifyById(e,t){if(void 0===this.get(e))throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(t=>t.id===e);if(s<0)throw new Error("not expected");let a=r[s];r=[...r],r[s]={...a,data:t};let n=new Map;return n.set(e,r[s]),this.modifyArrayBy(i,r,n)}}modifyArrayBy(e,t,i=void 0){let r=e,s=t;for(;null!==r;){let e=s,t=r;if(r=this.parent(r),void 0===r)throw new Error;s=this.childrenArray(r);let a=s.findIndex(e=>e.id===t);if(a<0)throw new Error;s=[...s],s[a]={...s[a],children:e},i&&i.set(t,s[a])}Object.setPrototypeOf(s,kd.prototype);let a=s;if(i&&void 0!==this.objCaches&&void 0!==this.parentCaches){a.objCaches=this.objCaches;for(let[e,t]of i)a.objCaches.set(e,t);a.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else a.fillCaches();return a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(void 0!==this.get(e))return!0;for(let e of t)if(this.checkDuplicatedIdRec(e))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:a}=e;if(null!==t&&void 0===this.get(t))return null;if(this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((e,t)=>e.fi-t.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(null===this.get(t))return null;{let i=this.parent(t);if(void 0===i)return null;let r=this.childrenArray(i),s=r.findIndex(e=>e.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(null!==t&&void 0===this.get(t))return this.deleteOp({type:8,id:r});if(null!==t){let e=t;for(;null!==e;){if(void 0===e)throw new Error;if(e===r)throw new Rd("cyclic tree");e=this.parent(e)}}let s=this.parent(r);if(void 0===s)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(e=>e.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((e,t)=>e.fi-t.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:u,id:r}}}previous(e,t){if(null===t){let t=this.childrenArray(e);return 0===t.length?null:t[t.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(void 0!==t){let i=this.childrenArray(t),r=i.findIndex(t=>t.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(void 0!==t){let i=this.childrenArray(t),r=i.findIndex(t=>t.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let e=this.getWithSortKey(i.id);void 0!==e&&t.push({...i,...e})}t.sort((e,t)=>yd(e.sortKey,t.sortKey));for(let e of t)delete e.sortKey;return t}getAllIdSorted(e){let t=[];for(let i of e){let e=this.getWithSortKey(i);void 0!==e&&t.push(e)}t.sort((e,t)=>yd(e.sortKey,t.sortKey));for(let e of t)delete e.sortKey;return t.map(e=>e.id)}getWithSortKey(e){let t=e,i=[],r=this.get(t),s=r;if(void 0!==r){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),null!==t&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(null===t){if(0===r.length)return wd(0,i,i);{let e=r[0].fi;return wd(e-i,e,i)}}{let s=this.get(t);if(void 0===s||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(e=>e.fi>s.fi);if(void 0===a){let e=r[r.length-1].fi;return wd(e,e+i,i)}return wd(s.fi,a.fi,i)}}}}),Wd=n(()=>{var e;Ud=null,(e=Fd||(Fd={})).setPreservePrototype=function(e){Ud=e},e.tryPreservePrototype=function(e,t){return Object.getPrototypeOf(e)===Ud&&Object.setPrototypeOf(t,Ud),t},e.runOp=function(t,i){if(0!==i.type)return null;if(Array.isArray(t)){let e=i.props,r={},s=[...t],a=!1;if(e)for(let t of Object.keys(e)){let i=parseInt(t);if(isNaN(i))throw new Error("wrong index");r[t]=s[i],s[i]=e[t],a=!0}return a?{data:s,actual:i,reverse:{type:0,props:r}}:null}{let r=i.props,s={},a={...t},n=!1;if(r)for(let e of Object.keys(r)){s[e]=a[e];let t=r[e];void 0===t?delete a[e]:a[e]=t,n=!0}return n?{data:e.tryPreservePrototype(t,a),actual:i,reverse:{type:0,props:s}}:null}}}),qd=n(()=>{Od(),Od(),jd=class extends Array{constructor(...e){super(...e),u(this,"objCaches"),Object.setPrototypeOf(this,jd.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Md(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(void 0===this.objCaches){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(0!==e.length)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(void 0===this.get(e))throw new Error("not expected");{let i=this,r=i.findIndex(t=>t.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,jd.prototype);let t=e;return typeof process<"u"||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((e,t)=>e.fi-t.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(e=>e.id===t);if(-1===r)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(e=>e.id===i);if(-1===s)return null;let a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((e,t)=>e.fi-t.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(null===e)return 0===this.length?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(null===e){if(0===i.length)return wd(0,t,t);{let e=i[0].fi;return wd(e-t,e,t)}}{let r=this.get(e);if(void 0===r)throw new Error("illegal args");let s=i.find(e=>e.fi>r.fi);if(void 0===s){let e=i[i.length-1].fi;return wd(e,e+t,t)}return wd(r.fi,s.fi,t)}}}});function Hd(e,t){let i={cur:[],result:[],len:0};return[e=Kd(e,t,i)??e,i.result]}function $d(e,t){return null===e?null:(e.cur[e.len]=t,e.len+=1,e)}function Yd(e){e&&(e.len-=1)}function Xd(e,t,i){let r=!1,s=e.map(e=>{let s=e.id,a=t[s];if(void 0!==a&&"string"==typeof a&&(r=!0,s=a,null!==i))throw new Error("not supported");let n=Kd(e.data,t,$d(i,s));Yd(i),r=r||void 0!==n,void 0===n&&(n=e.data);let o=Xd(e.children,t,i);return void 0!==o?r=!0:o=e.children,{...e,id:s,data:n,children:o}});if(r)return s}function Kd(e,t,i){if(e instanceof kd){let r=Xd(e,t,i);return void 0!==r&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}if(e instanceof jd)return function(e,t,i){let r=!1,s=e.map(e=>{let s=e.id,a=t[s];if(void 0!==a&&"string"==typeof a&&(r=!0,s=a,null!==i))throw new Error("not supported");let n=Kd(e.data,t,$d(i,s));return Yd(i),r=r||void 0!==n,void 0===n&&(n=e.data),{...e,id:s,data:n}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((e,s)=>{let a=Kd(e,t,$d(i,s));return Yd(i),r=r||void 0!==a,void 0===a&&(a=e),a});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}if(e&&"object"==typeof e&&!_d(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if("name"!==a&&"variableId"!==a){let e=t[a];if("string"==typeof e){if(null!==i)throw new Error("not supported");s=!0,a=e}let o=Kd(n,t,$d(i,a));Yd(i),s=s||void 0!==o,void 0===o&&(o=n),r[a]=o}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if("string"==typeof e){let r=t[e];return void 0!==r&&function(e){if(null===e)return null;e.result.push(e.cur.slice(0,e.len))}(i),r}}var Zd=n(()=>{Gd(),qd(),Od()});function Jd(e){return e&&"object"==typeof e&&e instanceof ic}function Qd(e,t){if(void 0===t)return;let i=!1,r=e.map(e=>{let r=e.id,s=ec(e.data,t[r]);if(i=i||void 0!==s,void 0===s&&(s=e.data),e.children){let a=Qd(e.children,t);return void 0!==a?i=!0:a=e.children,{...e,id:r,data:s,children:a}}return{...e,id:r,data:s}});return i?r:void 0}function ec(e,t){if(!Jd(t))return t;if(e instanceof kd){let i=Qd(e,t);return void 0!==i&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}if(e instanceof jd)return function(e,t){if(void 0===t)return;let i=!1,r=e.map(e=>{let r=e.id,s=ec(e.data,t[r]);return i=i||void 0!==s,void 0===s&&(s=e.data),{...e,id:r,data:s}});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}(e,t);if(Array.isArray(e)){let i=!1,r=e.map((e,r)=>{let s=ec(e,t[r]);return i=i||void 0!==s,void 0===s&&(s=e),s});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}if(e instanceof ic)return tc(e,t);if(e&&"object"==typeof e){let i={},r=!1;for(let[s,a]of Object.entries(e)){let e=ec(a,t[s]);r=r||void 0!==e,void 0===e&&(e=a),i[s]=e}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}function tc(e,t){if(void 0===e)return t;if(void 0===t)return e;if(!Jd(t))return t;if(!Jd(e))return rc.apply(e,t);let i=new Set;for(let t of Object.keys(e))i.add(t);for(let e of Object.keys(t))i.add(e);let r=new ic;for(let s of i){let i=tc(void 0===e?void 0:e[s],void 0===t?void 0:t[s]);r[s]=i}return r}var ic,rc,sc,ac,nc,oc=n(()=>{var e;Gd(),qd(),Nc(),Od(),ic=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=void 0===i?void 0:i[e.path[r]],void 0!==i&&!Jd(i))return null;r+=1}i=i?xd(i):new ic;for(let[t,r]of Object.entries(e.props)){let e=i[t];s[t]=e,void 0===r?delete i[t]:i[t]=r}for(;r>0;){if(0===Object.keys(i).length){let s=t[r-1];s&&(i=xd(s),delete i[e.path[r-1]])}else{let s=t[r-1];if(s){let t=xd(s);t[e.path[r-1]]=i,i=t}else{let t=new ic;t[e.path[r-1]]=i,i=t}}r-=1}return{data:Object.setPrototypeOf(i,ic.prototype),actual:e,reverse:{...e,props:s}}}},(e=rc||(rc={})).apply=function(e,t){return ec(e,t)??e},e.merge=function(e,t){return tc(e,t)},e.filterOp=function(e,t){let i=0,r=t.path,s=e;for(;i<r.length&&void 0!==s;){if(s=Cc.zoomOnce(s,r[i]),void 0===s)return t;if(!Jd(s))return;i+=1}if(void 0===s)return t;if(Jd(s)){if(0===t.type){let e={...t.props};for(let t of Object.keys(s))delete e[t];return{...t,props:e}}if(1===t.type||4===t.type||7===t.type){let e=Qd([t],s);return e?e[0]:t}return t}}}),lc=n(()=>{Nc(),Dd(),Gd(),Id(),Wd(),qd(),Zd(),oc(),(sc||(sc={})).replaceProps=function(e,t){let i=Cc.zoom(t,e.path);if("object"==typeof i){let t={};for(let r of Object.keys(e.props))t[r]=i[r];return{...e,props:t}}return{...e,props:{}}},(e=>{function t(e,t){let i=t.path,r=[];for(;;){let s;if(e instanceof ic&&0===t.type&&(s=e.runOp({...t,path:i.slice(r.length)}),null===s&&(s=void 0)),void 0===s&&r.length===i.length&&(s=e instanceof kd||e instanceof jd||e instanceof Pd?e.runOp(t):Fd.runOp(e,t)),void 0!==s){if(null!==s){let e=s.data;for(let t=r.length-1;t>=0;t--){let s=i[t],a=r[t];if(a instanceof kd){if("number"==typeof s)throw new Error("illegal arg");e=a.modifyById(s,e)}else if(a instanceof jd){if("number"==typeof s)throw new Error("illegal arg");e=a.modifyById(s,e)}else if(a instanceof Pd){if("number"==typeof s)throw new Error("illegal arg");e=a.modifyById(s,e)}else if(a instanceof ic){let t={...a,[s]:e};e=Object.setPrototypeOf(t,ic.prototype)}else{if("object"!=typeof a)return null;if(Array.isArray(a)){if("string"==typeof s&&(s=parseInt(s),isNaN(s)))throw new Error("Invalid path");let t=e;e=[...a],e[s]=t}else e=Fd.tryPreservePrototype(a,{...a,[s]:e})}}return{data:e,actual:{...s.actual,path:i},reverse:{...s.reverse,path:i}}}return null}let a,n=i[r.length];if(e instanceof kd){if("number"==typeof n)throw new Error("");a=e.get(n)?.data}else if(e instanceof jd){if("number"==typeof n)throw new Error("");a=e.get(n)?.data}else null!==e&&(a=e[n]);if(void 0===a)return null;r.push(e),e=a}}function i(e,t){for(let i=0;i<e.length&&i<t.length;i++)if(e[i]!==t[i])return!0;return!1}function r(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}e.drop=function(e,t){return{...e,path:e.path.slice(t)}},e.applySimple=function(e,i){return t(e,i)?.data??e},e.apply=t,e.pathDisjoint=i,e.pathEq=r,e.commutative=function(e,t){return i(e.path,t.path)},e.subsumed=function(e,t){return!(0!==e.type||0!==t.type||!r(e.path,t.path))&&Object.keys(e.props).every(e=>void 0!==t.props[e])}})(ac||(ac={})),(e=>{function t(e,t){let i=e,r=[],s=[];for(let e of t)try{if(3===e.type||5===e.type&&"variables"===e.path[e.path.length-1]){let t,a,n;if(3===e.type?(t=Cc.zoom(i,[...e.path,e.id]),n=ac.apply(i,{...e,type:2})):(t=Cc.zoom(i,[...e.path,e.id,"value"]),n=ac.apply(i,e)),null!==n){i=n.data;let[o,l]=Hd(i,{[e.id]:t});i=o;for(let n=0;n<l.length;n++){let o=l[n],h=o.pop();if("number"==typeof h){let r=[h];for(let e=n+1;e<l.length;e++){let t=l[e],i=t[t.length-1];if("number"!=typeof i||!Cc.equal(o,t.slice(0,t.length-1)))break;r.push(i),l.splice(e,1)}let s=Cc.zoom(i,o);a=s.map((t,i)=>r.includes(i)?e.id:t),t=s,h=o.pop()}else{if("alphaOverride"===h||"alpha"===h){t/=100;let e=t,r=Cc.zoom(i,o.slice(0,o.length-2)),s=r.layers.map(t=>t.id===o[o.length-1]?{...t,data:{...t.data,[h]:e}}:t);Object.setPrototypeOf(s,Object.getPrototypeOf(r.layers)),r.layers=s}a=e.id}r.push({type:0,path:o,props:{[h]:t}}),s.push({type:0,path:o,props:{[h]:a}})}s.push(n.reverse),r.push(n.actual)}}else{let t=ac.apply(i,e);null!==t&&(r.push(t.actual),i=t.data,s.push(t.reverse))}}catch(e){if(e instanceof Rd)return null;throw e}return{data:i,actual:r,reverse:s.reverse()}}e.empty=function(){return[]},e.removePrefix=function(e,t){let i=[];for(let r of e){let[e,...s]=r.path;e===t&&i.push({...r,path:s})}return i},e.addPrefix=function(e,t){return e.map(e=>({...e,path:[t,...e.path]}))},e.concat=function(e,t){return[...e,...t]},e.compress=function(e,t){return[...e.filter(e=>!t.some(t=>ac.subsumed(e,t))),...t]},e.commutative=function(e,t){return e.every(e=>t.every(t=>ac.commutative(e,t)))},e.applyAll=function(e,i){for(let r of i){let i=t(e,r);null!==i&&(e=i.data)}return e},e.apply=t})(nc||(nc={}))});function hc(e,t,i){if(e.length>0){let r=e[e.length-1];if(0===r.type&&0===t.type&&Cc.equal(r.path,i))return void Object.assign(r.props,t.props)}e.push({...t,path:i})}function uc(e,t,i){return i instanceof kd?new Sc(e,t,i):i instanceof jd?new Mc(e,t,i):i instanceof Pd?new Proxy(new bc(e,t,i),_c):null!==i&&"object"==typeof i?_d(i)?i:new Proxy(new vc(e,t,i),wc):i}function dc(e){let t=new Tc(e);return[uc(t,"",e),t]}function cc(e,t){let[i,r]=dc(e);return t(i),r.result()}function pc(e){return e instanceof Sc||e instanceof Mc?e._current:null!==e&&"object"==typeof e?e[mc]:e}var mc,gc,fc,yc,vc,bc,xc,wc,_c,Sc,Mc,Tc,Cc,Ac=n(()=>{Dd(),Gd(),Wd(),qd(),Od(),Nc(),mc=Symbol(),gc=Symbol(),fc=Symbol(),yc=class{reportOp(e,t,i=[]){let r=this;if(null===t)return;r._current=t.data;let s=i;for(;!(r instanceof Tc);){let e=r._path,t=r._current;if(""!==e&&s.splice(0,0,e),r=r._parent,null===r)return;r.update(e,t)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[fc];i&&i(),delete this._children[e]}}}},vc=class extends yc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if("string"==typeof e&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=Fd.tryPreservePrototype(this._current,{...this._current,[e]:t})}runOp(e){this.reportOp(e,Fd.runOp(this._current,e),e.path)}},bc=class extends yc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Pd.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},xc={get(e,t){if(t===fc)return()=>{e._parent=null};if(t===mc)return e._current;if(t===gc)return e;let{_current:i,_children:r}=e;if("push"===t&&Array.isArray(i))throw new Error("not supported to expand array");let s=void 0===r?void 0:r[t];if(void 0!==s)return s;let a=i[t],n=uc(e,t,a);return n!==a?(void 0===r&&(r={},e._children=r),r[t]=n,n):a},has:(e,t)=>t in e._current,ownKeys:e=>Reflect.ownKeys(e._current),defineProperty(){throw Error("not supported")},getPrototypeOf:e=>Object.getPrototypeOf(e._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},wc={...xc,set(e,t,i){let r={type:0,props:{[t]:pc(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},_c={...xc,set(e,t,i){return void 0===i?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty:(e,t)=>(e.runOp({type:2,id:t}),!0)},Sc=class extends yc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[fc]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=void 0===i?void 0:i[e];if(void 0!==r)return r;let s=t.get(e)?.data,a=uc(this,e,s);return a!==s?(void 0===i&&(i={},this._children=i),i[e]=a,a):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let t=0;t<i.length;t++){let s=i[t];this.add(e,r[t],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let t=0;t<i.length;t++){let s=i[t];this.add(e,r[t],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let t=0;t<i.length;t++){let s=i[t];this.move(e,r[t],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let t=0;t<i.length;t++){let s=i[t];this.move(e,r[t],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Mc=class extends yc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[fc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let t=this._current[i].id,r=this._current[i].fi;e(this.data(this._current[i].id),t,r,i)}}find(e){let t=this.length;for(let i=0;i<t;i++){let t=this._current[i].id;if(e(this.data(t),t))return this.get(t)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}at(e){let{id:t,fi:i}=this._current.at(e);return{id:t,fi:i,data:this.data(t)}}data(e){let{_current:t,_children:i}=this,r=void 0===i?void 0:i[e];if(void 0!==r)return r;let s=t.get(e)?.data,a=uc(this,e,s);return a!==s?(void 0===i&&(i={},this._children=i),i[e]=a,a):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let e=0;e<t.length;e++){let r=t[e];this.add(i[e],r.id,r.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let e=0;e<t.length;e++){let r=t[e];this.add(i[e],r.id,r.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let e=0;e<t.length;e++){let r=t[e];this.move(i[e],r)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let e=0;e<t.length;e++){let r=t[e];this.move(i[e],r)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}},Tc=class extends yc{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(""!==e)throw new Error("");this._current=t}push(e,t,i,r){hc(this.ts,t,e),hc(this.actual,i,e),hc(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),Nc=n(()=>{Bd(),Ac(),qd(),Gd(),Od(),(e=>{function t(e,t){return(e instanceof kd||e instanceof Sc)&&"string"==typeof t||(e instanceof jd||e instanceof Mc)&&"string"==typeof t?e.data(t):"number"==typeof t&&Array.isArray(e)||"string"==typeof t&&"object"==typeof e&&null!==e?e[t]:void 0}function i(e,i,r=0){for(;r<i.length&&void 0!==e;)e=t(e,i[r]),r+=1;return e}e.equal=function(e,t){if(t.length!==e.length)return!1;{let i=0;for(;i<e.length;){if(e[i]!==t[i])return!1;i+=1}}return!0},e.removeOverridden=function(e,t,r){let s=i(r,e);if(void 0!==s&&"object"==typeof s&&null!==s){let e={...t};return Object.keys(s).forEach(t=>{delete e[t]}),e}return t},e.zoomOnce=t,e.zoom=i,e.findPathes=function(e,t){let i=[];return function e(r,s){if(r instanceof Ad&&r.id===t.id)i.push(s);else if(r instanceof jd)for(let t=0;t<r.length;t++)e(r[t].data,[...s,r[t].id]);else if(r instanceof kd)r.traverse((t,i)=>{e(t,[...s,i])});else if(Array.isArray(r))for(let t=0;t<r.length;t++)e(r[t],[...s,t]);else{if(_d(r))return;if("object"==typeof r&&null!==r)for(let t in r)e(r[t],[...s,t])}}(e,[]),i}})(Cc||(Cc={}))}),Pc=n(()=>{});function Rc(e,t){let i=[];if(!(t.length<=e.length))return null;{let r=0;for(;r<t.length;){if("*"===t[r])i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}}return i}var Ec=n(()=>{});function Oc(e){try{if(!rp.trusted&&!mp){let e=sp.sharedLength||0;e<sp.length&&(sp.length=e)}let t;if(rp.randomAccessStructure&&Zc[Qc]<64&&Zc[Qc]>=32&&fp?(t=fp(Zc,Qc,Jc,rp),Zc=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),Qc=Jc):t=Vc(),lp&&(Qc=lp.postBundlePosition,lp=null),mp&&(sp.restoreStructures=null),Qc==Jc)sp&&sp.restoreStructures&&Bc(),sp=null,Zc=null,hp&&(hp=null);else{if(Qc>Jc)throw new Error("Unexpected end of MessagePack data");if(!mp){let e;try{e=JSON.stringify(t,(e,t)=>"bigint"==typeof t?`${t}n`:t).slice(0,100)}catch(t){e="(JSON view not available "+t+")"}throw new Error("Data read, but end of buffer not reached "+e)}}return t}catch(e){throw sp&&sp.restoreStructures&&Bc(),Yc(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||Qc>Jc)&&(e.incomplete=!0),e}}function Bc(){for(let e in sp.restoreStructures)sp[e]=sp.restoreStructures[e];sp.restoreStructures=null}function Vc(){let e=Zc[Qc++];if(e<160){if(e<128){if(e<64)return e;{let t=sp[63&e]||rp.getStructures&&Ic()[63&e];return t?(t.read||(t.read=Dc(t,63&e)),t.read()):e}}if(e<144){if(e-=128,rp.mapsAsObjects){let t={};for(let i=0;i<e;i++){let e=qc();"__proto__"===e&&(e="__proto_"),t[e]=Vc()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Vc(),Vc());return t}}{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Vc();return rp.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(op>=Qc)return ap.slice(Qc-np,(Qc+=t)-np);if(0==op&&Jc<140){let e=t<16?Fc(t):Uc(t);if(null!=e)return e}return wp(t)}{let t;switch(e){case 192:return null;case 193:return lp?(t=Vc(),t>0?lp[1].slice(lp.position1,lp.position1+=t):lp[0].slice(lp.position0,lp.position0-=t)):pp;case 194:return!1;case 195:return!0;case 196:if(t=Zc[Qc++],void 0===t)throw new Error("Unexpected end of buffer");return Gc(t);case 197:return t=dp.getUint16(Qc),Qc+=2,Gc(t);case 198:return t=dp.getUint32(Qc),Qc+=4,Gc(t);case 199:return Wc(Zc[Qc++]);case 200:return t=dp.getUint16(Qc),Qc+=2,Wc(t);case 201:return t=dp.getUint32(Qc),Qc+=4,Wc(t);case 202:if(t=dp.getFloat32(Qc),rp.useFloat32>2){let e=Op[(127&Zc[Qc])<<1|Zc[Qc+1]>>7];return Qc+=4,(e*t+(t>0?.5:-.5)|0)/e}return Qc+=4,t;case 203:return t=dp.getFloat64(Qc),Qc+=8,t;case 204:return Zc[Qc++];case 205:return t=dp.getUint16(Qc),Qc+=2,t;case 206:return t=dp.getUint32(Qc),Qc+=4,t;case 207:return"number"===rp.int64AsType?(t=4294967296*dp.getUint32(Qc),t+=dp.getUint32(Qc+4)):"string"===rp.int64AsType?t=dp.getBigUint64(Qc).toString():"auto"===rp.int64AsType?(t=dp.getBigUint64(Qc),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=dp.getBigUint64(Qc),Qc+=8,t;case 208:return dp.getInt8(Qc++);case 209:return t=dp.getInt16(Qc),Qc+=2,t;case 210:return t=dp.getInt32(Qc),Qc+=4,t;case 211:return"number"===rp.int64AsType?(t=4294967296*dp.getInt32(Qc),t+=dp.getUint32(Qc+4)):"string"===rp.int64AsType?t=dp.getBigInt64(Qc).toString():"auto"===rp.int64AsType?(t=dp.getBigInt64(Qc),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=dp.getBigInt64(Qc),Qc+=8,t;case 212:if(t=Zc[Qc++],114==t)return Ap(63&Zc[Qc++]);{let e=up[t];if(e)return e.read?(Qc++,e.read(Vc())):e.noBuffer?(Qc++,e()):e(Zc.subarray(Qc,++Qc));throw new Error("Unknown extension "+t)}case 213:return t=Zc[Qc],114==t?(Qc++,Ap(63&Zc[Qc++],Zc[Qc++])):Wc(2);case 214:return Wc(4);case 215:return Wc(8);case 216:return Wc(16);case 217:return t=Zc[Qc++],op>=Qc?ap.slice(Qc-np,(Qc+=t)-np):_p(t);case 218:return t=dp.getUint16(Qc),op>=(Qc+=2)?ap.slice(Qc-np,(Qc+=t)-np):Sp(t);case 219:return t=dp.getUint32(Qc),op>=(Qc+=4)?ap.slice(Qc-np,(Qc+=t)-np):Mp(t);case 220:return t=dp.getUint16(Qc),Qc+=2,zc(t);case 221:return t=dp.getUint32(Qc),Qc+=4,zc(t);case 222:return t=dp.getUint16(Qc),Qc+=2,kc(t);case 223:return t=dp.getUint32(Qc),Qc+=4,kc(t);default:if(e>=224)return e-256;if(void 0===e){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+e)}}}function Dc(e,t){function i(){if(i.count++>gp){let r;try{r=e.read=new Function("r","return function(){return "+(rp.freezeData?"Object.freeze":"")+"({"+e.map(e=>"__proto__"===e?"__proto_:r()":bp.test(e)?e+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"})}")(Vc)}catch{return gp=1/0,i()}return e.read0=r,0===e.highByte&&(e.read=xp(t,e.read)),r()}let r={};for(let t=0,i=e.length;t<i;t++){let i=e[t];"__proto__"===i&&(i="__proto_"),r[i]=Vc()}return rp.freezeData?Object.freeze(r):r}return i.count=0,e.read0=i,0===e.highByte?xp(t,i):i}function Ic(){let e=$c(()=>(Zc=null,rp.getStructures()));return sp=rp._mergeStructures(e,sp)}function Lc(e){let t;if(e<16&&(t=Fc(e)))return t;if(e>64&&Kc)return Kc.decode(Zc.subarray(Qc,Qc+=e));let i=Qc+e,r=[];for(t="";Qc<i;){let e=Zc[Qc++];if(128&e)if(192==(224&e)){let t=(31&e)<<6|63&Zc[Qc++];t<128?r.push(65533):r.push(t)}else if(224==(240&e)){let t=(31&e)<<12|(63&Zc[Qc++])<<6|63&Zc[Qc++];t<2048||t>=55296&&t<=57343?r.push(65533):r.push(t)}else if(240==(248&e)){let t=(7&e)<<18|(63&Zc[Qc++])<<12|(63&Zc[Qc++])<<6|63&Zc[Qc++];t<65536||t>1114111?r.push(65533):(t>65535&&(t-=65536,r.push(t>>>10&1023|55296),t=56320|1023&t),r.push(t))}else r.push(65533);else r.push(e);r.length>=4096&&(t+=Tp.apply(String,r),r.length=0)}return r.length>0&&(t+=Tp.apply(String,r)),t}function zc(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Vc();return rp.freezeData?Object.freeze(t):t}function kc(e){if(rp.mapsAsObjects){let t={};for(let i=0;i<e;i++){let e=qc();"__proto__"===e&&(e="__proto_"),t[e]=Vc()}return t}{let t=new Map;for(let i=0;i<e;i++)t.set(Vc(),Vc());return t}}function Uc(e){let t=Qc,i=new Array(e);for(let r=0;r<e;r++){let e=Zc[Qc++];if((128&e)>0)return void(Qc=t);i[r]=e}return Tp.apply(String,i)}function Fc(e){if(e<4){if(e<2){if(0===e)return"";{let e=Zc[Qc++];return(128&e)>1?void(Qc-=1):Tp(e)}}{let t=Zc[Qc++],i=Zc[Qc++];if((128&t)>0||(128&i)>0)return void(Qc-=2);if(e<3)return Tp(t,i);let r=Zc[Qc++];return(128&r)>0?void(Qc-=3):Tp(t,i,r)}}{let t=Zc[Qc++],i=Zc[Qc++],r=Zc[Qc++],s=Zc[Qc++];if((128&t)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(Qc-=4);if(e<6){if(4===e)return Tp(t,i,r,s);{let e=Zc[Qc++];return(128&e)>0?void(Qc-=5):Tp(t,i,r,s,e)}}if(e<8){let a=Zc[Qc++],n=Zc[Qc++];if((128&a)>0||(128&n)>0)return void(Qc-=6);if(e<7)return Tp(t,i,r,s,a,n);let o=Zc[Qc++];return(128&o)>0?void(Qc-=7):Tp(t,i,r,s,a,n,o)}{let a=Zc[Qc++],n=Zc[Qc++],o=Zc[Qc++],l=Zc[Qc++];if((128&a)>0||(128&n)>0||(128&o)>0||(128&l)>0)return void(Qc-=8);if(e<10){if(8===e)return Tp(t,i,r,s,a,n,o,l);{let e=Zc[Qc++];return(128&e)>0?void(Qc-=9):Tp(t,i,r,s,a,n,o,l,e)}}if(e<12){let h=Zc[Qc++],u=Zc[Qc++];if((128&h)>0||(128&u)>0)return void(Qc-=10);if(e<11)return Tp(t,i,r,s,a,n,o,l,h,u);let d=Zc[Qc++];return(128&d)>0?void(Qc-=11):Tp(t,i,r,s,a,n,o,l,h,u,d)}{let h=Zc[Qc++],u=Zc[Qc++],d=Zc[Qc++],c=Zc[Qc++];if((128&h)>0||(128&u)>0||(128&d)>0||(128&c)>0)return void(Qc-=12);if(e<14){if(12===e)return Tp(t,i,r,s,a,n,o,l,h,u,d,c);{let e=Zc[Qc++];return(128&e)>0?void(Qc-=13):Tp(t,i,r,s,a,n,o,l,h,u,d,c,e)}}{let p=Zc[Qc++],m=Zc[Qc++];if((128&p)>0||(128&m)>0)return void(Qc-=14);if(e<15)return Tp(t,i,r,s,a,n,o,l,h,u,d,c,p,m);let g=Zc[Qc++];return(128&g)>0?void(Qc-=15):Tp(t,i,r,s,a,n,o,l,h,u,d,c,p,m,g)}}}}}function jc(){let e,t=Zc[Qc++];if(t<192)e=t-160;else switch(t){case 217:e=Zc[Qc++];break;case 218:e=dp.getUint16(Qc),Qc+=2;break;case 219:e=dp.getUint32(Qc),Qc+=4;break;default:throw new Error("Expected string")}return Lc(e)}function Gc(e){return rp.copyBuffers?Uint8Array.prototype.slice.call(Zc,Qc,Qc+=e):Zc.subarray(Qc,Qc+=e)}function Wc(e){let t=Zc[Qc++];if(up[t]){let i;return up[t](Zc.subarray(Qc,i=Qc+=e),e=>{Qc=e;try{return Vc()}finally{Qc=i}})}throw new Error("Unknown extension type "+t)}function qc(){let e=Zc[Qc++];if(!(e>=160&&e<192))return Qc--,Hc(Vc());if(e-=160,op>=Qc)return ap.slice(Qc-np,(Qc+=e)-np);if(!(0==op&&Jc<180))return wp(e);let t,i=4095&(e<<5^(e>1?dp.getUint16(Qc):e>0?Zc[Qc]:0)),r=Cp[i],s=Qc,a=Qc+e-3,n=0;if(r&&r.bytes==e){for(;s<a;){if(t=dp.getUint32(s),t!=r[n++]){s=1879048192;break}s+=4}for(a+=3;s<a;)if(t=Zc[s++],t!=r[n++]){s=1879048192;break}if(s===a)return Qc=s,r.string;a-=3,s=Qc}for(r=[],Cp[i]=r,r.bytes=e;s<a;)t=dp.getUint32(s),r.push(t),s+=4;for(a+=3;s<a;)t=Zc[s++],r.push(t);let o=e<16?Fc(e):Uc(e);return r.string=null!=o?o:wp(e)}function Hc(e){if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return e.toString();if(null==e)return e+"";if(rp.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return e.flat().toString();throw new Error("Invalid property type for record: "+typeof e)}function $c(e){yp&&yp();let t=Jc,i=Qc,r=ip,s=np,a=op,n=ap,o=tp,l=hp,h=lp,u=new Uint8Array(Zc.slice(0,Jc)),d=sp,c=sp.slice(0,sp.length),p=rp,m=mp,g=e();return Jc=t,Qc=i,ip=r,np=s,op=a,ap=n,tp=o,hp=l,lp=h,Zc=u,mp=m,(sp=d).splice(0,sp.length,...c),rp=p,dp=new DataView(Zc.buffer,Zc.byteOffset,Zc.byteLength),g}function Yc(){Zc=null,hp=null,sp=null}function Xc(e){e.unpack?up[e.type]=e.unpack:up[e.type]=e}var Kc,Zc,Jc,Qc,ep,tp,ip,rp,sp,ap,np,op,lp,hp,up,dp,cp,pp,mp,gp,fp,yp,vp,bp,xp,wp,_p,Sp,Mp,Tp,Cp,Ap,Np,Pp,Rp,Ep,Op,Bp,Vp,Dp,Ip,Lp,zp,kp,Up,Fp,jp,Gp,Wp,qp,Hp,$p,Yp,Xp,Kp,Zp,Jp,Qp,em,tm,im,rm,sm,am,nm,om=n(()=>{try{Kc=new TextDecoder}catch{}Qc=0,tp=ep=[],ip=0,rp={},np=0,op=0,up=[],cp={useRecords:!1,mapsAsObjects:!0},(pp=new class{}).name="MessagePack 0xC1",mp=!1,gp=2,vp=class{constructor(e){e&&(!1===e.useRecords&&void 0===e.mapsAsObjects&&(e.mapsAsObjects=!0),e.sequential&&!1!==e.trusted&&(e.trusted=!0,!e.structures&&0!=e.useRecords&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(Zc)return $c(()=>(Yc(),this?this.unpack(e,t):vp.prototype.unpack.call(cp,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),"object"==typeof t?(Jc=t.end||e.length,Qc=t.start||0):(Qc=0,Jc=t>-1?t:e.length),ip=0,op=0,ap=null,tp=ep,lp=null,Zc=e;try{dp=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(t){throw Zc=null,e instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&"object"==typeof e?e.constructor.name:typeof e))}if(this instanceof vp){if(rp=this,this.structures)return sp=this.structures,Oc(t);(!sp||sp.length>0)&&(sp=[])}else rp=cp,(!sp||sp.length>0)&&(sp=[]);return Oc(t)}unpackMultiple(e,t){let i,r=0;try{mp=!0;let s=e.length,a=this?this.unpack(e,s):Bp.unpack(e,s);if(!t){for(i=[a];Qc<s;)r=Qc,i.push(Oc());return i}if(!1===t(a,r,Qc))return;for(;Qc<s;)if(r=Qc,!1===t(Oc(),r,Qc))return}catch(e){throw e.lastPosition=r,e.values=i,e}finally{mp=!1,Yc()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,i=e.length;t<i;t++){let i=e[t];i&&(i.isShared=!0,t>=32&&(i.highByte=t-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}},bp=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,xp=(e,t)=>function(){let i=Zc[Qc++];if(0===i)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=sp[r]||Ic()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=Dc(s,e)),s.read()},wp=Lc,_p=Lc,Sp=Lc,Mp=Lc,Tp=String.fromCharCode,Cp=new Array(4096),Ap=(e,t)=>{let i=Vc().map(Hc),r=e;void 0!==t&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=sp[e];return s&&(s.isShared||mp)&&((sp.restoreStructures||(sp.restoreStructures=[]))[e]=s),sp[e]=i,i.read=Dc(i,r),(i.read0||i.read)()},up[0]=()=>{},up[0].noBuffer=!0,up[66]=e=>{let t=e.byteLength%8||8,i=BigInt(128&e[0]?e[0]-256:e[0]);for(let r=1;r<t;r++)i<<=BigInt(8),i+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),s=(e,t)=>{let i=t-e;if(i<=40){let i=r.getBigUint64(e);for(let s=e+8;s<t;s+=8)i<<=BigInt(64),i|=r.getBigUint64(s);return i}let a=e+(i>>4<<3),n=s(e,a),o=s(a,t);return n<<BigInt(8*(t-a))|o};i=i<<BigInt(8*(r.byteLength-t))|s(t,r.byteLength)}return i},Np={Error:Error,EvalError:EvalError,RangeError:RangeError,ReferenceError:ReferenceError,SyntaxError:SyntaxError,TypeError:TypeError,URIError:URIError,AggregateError:"function"==typeof AggregateError?AggregateError:null},up[101]=()=>{let e=Vc();if(!Np[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return Np[e[0]](e[1],{cause:e[2]})},up[105]=e=>{if(!1===rp.structuredClone)throw new Error("Structured clone extension is disabled");let t=dp.getUint32(Qc-4);hp||(hp=new Map);let i,r=Zc[Qc];i=r>=144&&r<160||220==r||221==r?[]:r>=128&&r<144||222==r||223==r?new Map:(r>=199&&r<=201||r>=212&&r<=216)&&115===Zc[Qc+1]?new Set:{};let s={target:i};hp.set(t,s);let a=Vc();if(!s.used)return s.target=a;if(Object.assign(i,a),i instanceof Map)for(let[e,t]of a.entries())i.set(e,t);if(i instanceof Set)for(let e of Array.from(a))i.add(e);return i},up[112]=e=>{if(!1===rp.structuredClone)throw new Error("Structured clone extension is disabled");let t=dp.getUint32(Qc-4),i=hp.get(t);return i.used=!0,i.target},up[115]=()=>new Set(Vc()),Pp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),Rp="object"==typeof globalThis?globalThis:window,up[116]=e=>{let t=e[0],i=Uint8Array.prototype.slice.call(e,1).buffer,r=Pp[t];if(!r){if(16===t)return i;if(17===t)return new DataView(i);throw new Error("Could not find typed array for code "+t)}return new Rp[r](i)},up[120]=()=>{let e=Vc();return new RegExp(e[0],e[1])},Ep=[],up[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=Qc;return Qc+=t-e.length,lp=Ep,(lp=[jc(),jc()]).position0=0,lp.position1=0,lp.postBundlePosition=Qc,Qc=i,Vc()},up[255]=e=>4==e.length?new Date(1e3*(16777216*e[0]+(e[1]<<16)+(e[2]<<8)+e[3])):8==e.length?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+1e3*(4294967296*(3&e[3])+16777216*e[4]+(e[5]<<16)+(e[6]<<8)+e[7])):12==e.length?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+1e3*((128&e[4]?-281474976710656:0)+1099511627776*e[6]+4294967296*e[7]+16777216*e[8]+(e[9]<<16)+(e[10]<<8)+e[11])):new Date("invalid"),Op=new Array(147);for(let e=0;e<256;e++)Op[e]=+("1e"+Math.floor(45.15-.30103*e));(Bp=new vp({useRecords:!1})).unpack,Bp.unpackMultiple,Bp.unpack,Vp=new Float32Array(1),new Uint8Array(Vp.buffer,0,4)}),lm=n(()=>{om(),Bd(),oc(),qd(),Dd(),Gd(),Dp=[{Class:Pd.prototype.constructor,type:1,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,Pd.prototype),e)},{Class:jd.prototype.constructor,type:2,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,jd.prototype),e)},{Class:kd.prototype.constructor,type:3,write:e=>[...e],read:e=>(Object.setPrototypeOf(e,kd.prototype),e)},{Class:Ad.prototype.constructor,type:4,write:e=>e.id,read:e=>new Ad(e)},{Class:Nd.prototype.constructor,type:5,write:e=>e.data,read:e=>new Nd(e)},{Class:ic.prototype.constructor,type:6,write:e=>({...e}),read:e=>(Object.setPrototypeOf(e,ic.prototype),e)}];for(let e of Dp)Xc(e);Ip=new vp({structuredClone:!0}),(Lp||(Lp={})).deserialize=function(e){return Ip.unpack(e)}}),hm=n(()=>{lm(),zp=e=>()=>{throw new Error(e+" is not available in the runtime build (decode-only CollabSerialize)")},kp={deserialize:Lp.deserialize,serialize:zp("CollabSerialize.serialize"),checksum:zp("CollabSerialize.checksum")}}),um=n(()=>{Nc(),Vd(),Id(),Gd(),Dd(),Wd(),qd(),lc(),Pc(),Ac(),Ec(),Bd(),hm(),Zd(),oc()}),dm=n(()=>{var e,t,i;um(),Mu(),(e=Up||(Up={})).toEventUIType=function(e){return"Conditional"===e.type?"Distance"===e.condition.type?"Distance":"StateChange":e.type},e.fromEventUIType=function(e){return"Distance"===e||"StateChange"===e?"Conditional":e},Fp={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},(e=>{e.is=function(e){return"MouseDown"===e.type||"MouseUp"===e.type||"MousePress"===e.type||"KeyDown"===e.type||"KeyUp"===e.type||"KeyPress"===e.type},e.defaultData=function(e){return"MouseDown"===e||"MouseUp"===e||"MousePress"===e?{type:e,mode:"Object",disabled:!1,name:"",actions:new jd}:{type:e,disabled:!1,name:"",key:void 0,actions:new jd}}})(jp||(jp={})),(e=>{e.propertyDefaultData=function(e){return{type:"Property",value:[e??null,"position","x"]}},e.valueDefaultData={type:"Literal",value:0}})(Gp||(Gp={})),(t=Wp||(Wp={})).comparisonDefaultData=function(e){return{type:"Comparison",operator:"==",lOperand:Gp.propertyDefaultData(e),rOperand:{...Gp.valueDefaultData}}},t.distanceDefaultData=function(e){return{type:"Distance",toObject:e??null,fromObject:e??null,distance:200}},t.stateDefaultData=function(e,t){return{type:"State",object:e??null,state:t??null}},(qp||(qp={})).isConditionalSubActions=function(e){return void 0!==e.find(e=>"ifActions"===e||"elseActions"===e)},(e=>{e.is=function(e){return"Conditional"===e.type},e.defaultData=function(e){return{type:"Conditional",disabled:!1,name:"",inActions:new jd,outActions:new jd,condition:Wp.distanceDefaultData(e)}}})(Hp||(Hp={})),($p||($p={})).defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new jd,drop:new jd}},(Yp||(Yp={})).defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new jd},(Xp||(Xp={})).defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5},(e=>{e.is=function(e){return"MouseHover"===e.type},e.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new jd}}})(Kp||(Kp={})),(e=>{e.is=function(e){return"Scroll"===e.type},e.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new jd}}})(Zp||(Zp={})),(e=>{e.is=function(e){return"Start"===e.type},e.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new jd}}})(Jp||(Jp={})),(e=>{e.is=function(e){return"Collision"===e.type},e.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new jd}}})(Qp||(Qp={})),(e=>{e.is=function(e){return"Trigger"===e.type},e.defaultData=function(e,t){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new jd,triggerZone:"box",position:t.toArray(),rotation:[0,0,0],size:e.toArray(),radius:e.length()/2,helperVisible:!0}}})(em||(em={})),(i=tm||(tm={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(e){return"Resize"===e.type},i.sizeToDevice=function(e){return"string"==typeof e?e:"custom"},i.deviceToSize=function(e){return"string"==typeof e?[...i.defaultSizes[e]]:[...e]},i.defaultData=function(){let e={size:"mobile",operator:"<",actions:new jd},t={size:"tablet",operator:"<",actions:new jd},r={size:[...i.defaultSizes.custom],operator:"<>",actions:new jd},s=new jd;return s.push({id:ts.generateUUID(),fi:0,data:e},{id:ts.generateUUID(),fi:1,data:t},{id:ts.generateUUID(),fi:2,data:r}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:s}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new jd}},(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]},e.is=function(e){return"VariableChange"===e.type},e.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new jd,variableId:"",objectId:null,property:"Position X"}}})(im||(im={})),(e=>{e.is=function(e){return"API"===e.type},e.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new jd,errorActions:new jd,userAPIId:""}}})(rm||(rm={})),(e=>{e.is=function(e){return"WEBHOOK"===e.type},e.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new jd,userWebhookId:""}}})(sm||(sm={})),(e=>{e.is=function(e){return"AIAssistantListener"===e.type},e.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new jd,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(am||(am={})),(e=>{e.is=function(e){return"AIAssistantTrigger"===e.type},e.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new jd}}})(nm||(nm={}))});function cm(e){let t=typeof e;return null!==e&&("object"===t||"function"===t)}function pm(e){return"string"==typeof e&&36===e.length&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}var mm,gm,fm,ym,vm,bm,xm,wm,_m,Sm,Mm,Tm,Cm,Am,Nm,Pm,Rm,Em,Om,Bm,Vm,Dm,Im,Lm,zm,km,Um,Fm,jm,Gm,Wm,qm,Hm,$m,Ym,Xm,Km,Zm,Jm,Qm,eg,tg,ig,rg,sg,ag,ng,og,lg,hg,ug,dg,cg,pg,mg,gg,fg,yg,vg,bg,xg,wg,_g,Sg,Mg,Tg,Cg,Ag,Ng,Pg,Rg,Eg,Og,Bg,Vg,Dg,Ig,Lg,zg,kg,Ug,Fg,jg,Gg,Wg,qg,Hg,$g,Yg,Xg,Kg,Zg,Jg=n(()=>{var e,t,i,r,s,a,n,o;mm="personal camera",gm="a218fcc3-276b-49b9-b485-49037fd14f5f",fm=2500134,ym=5526619,(e=vm||{}).x="x",e.y="y",e.z="z",vm=e,(e=>{function t(e,t){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)}function i(e,i){return Math.sqrt(t(e,i))}function r(t,i,r){let s=e.sub(i,t),a=e.sub(r,t),n=e.dot(s,a)/e.dot(s,s),o=e.scalarMultiply(s,n);return e.add(t,o)}e.isEqual=function(e,t){return e[0]===t[0]&&e[1]===t[1]},e.lerp=function(e,t,i){return[e[0]+(t[0]-e[0])*i,e[1]+(t[1]-e[1])*i]},e.add=function(e,t){return[e[0]+t[0],e[1]+t[1]]},e.sub=function(e,t){return[e[0]-t[0],e[1]-t[1]]},e.multiply=function(e,t){return[e[0]*t[0],e[1]*t[1]]},e.divide=function(e,t){return[e[0]/t[0],e[1]/t[1]]},e.distanceSquared=t,e.distance=i,e.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},e.scalarMultiply=function(e,t){return[e[0]*t,e[1]*t]},e.projectionOnto=r,e.projectionOntoDistance=function(e,t,s){return i(e,r(e,t,s))},e.center=function(e,t){return[.5*(e[0]+t[0]),.5*(e[1]+t[1])]}})(bm||(bm={})),(t=xm||(xm={})).isEqual=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},t.add=function(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]},t.sub=function(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]},t.div=function(e,t){return[e[0]/t[0],e[1]/t[1],e[2]/t[2]]},t.mul=function(e,t){return[e[0]*t[0],e[1]*t[1],e[2]*t[2]]},t.dist=function(e,t){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},t.lerp=function(e,t,i){return[e[0]+(t[0]-e[0])*i,e[1]+(t[1]-e[1])*i,e[2]+(t[2]-e[2])*i]},(i=wm||(wm={})).isEqual=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},i.lerp=function(e,t,i){return[e[0]+(t[0]-e[0])*i,e[1]+(t[1]-e[1])*i,e[2]+(t[2]-e[2])*i,e[3]+(t[3]-e[3])*i]},(e=>{let t=180/Math.PI,i=Math.PI/180;function r(e){return"number"==typeof e?e*t:e}function s(e){return"number"==typeof e?e*i:e}e.radToDeg=function(e){return[r(e[0]),r(e[1]),r(e[2])]},e.degToRad=function(e){return[s(e[0]),s(e[1]),s(e[2])]}})(_m||(_m={})),(r=Sm||(Sm={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(e,t){for(let i=0;i<16;i++)if(e[i]!==t[i])return!1;return!0},r.simplify=function(e){return e??r.identity},r.applyMatrix4=function(e,t){let i=t.slice(0);for(let r=0,s=t.length;r<s;r+=3){let s=e[3]*t[r]+e[7]*t[r+1]+e[11]*t[r+2]+e[15];i[r]=(e[0]*t[r]+e[4]*t[r+1]+e[8]*t[r+2]+e[12])/s,i[r+1]=(e[1]*t[r]+e[5]*t[r+1]+e[9]*t[r+2]+e[13])/s,i[r+2]=(e[2]*t[r]+e[6]*t[r+1]+e[10]*t[r+2]+e[14])/s}return i},(s=Mm||(Mm={})).isRGB=function(e){return"object"==typeof e&&"number"==typeof e.r&&"number"==typeof e.g&&"number"==typeof e.b},s.white={r:1,g:1,b:1},s.red={r:1,g:0,b:0},s.black={r:0,g:0,b:0},s.toRgb255a1=function(e){return{r:Math.round(255*e.r),g:Math.round(255*e.g),b:Math.round(255*e.b),a:1}},s.clone=function(e){return{r:e.r,g:e.g,b:e.b}},s.fromHex=function(e){return{r:((e=Math.floor(e))>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}},s.toHex=function(e){return 65536*Math.round(255*e.r)+256*Math.round(255*e.g)+Math.round(255*e.b)},s.equals=function(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b},s.equalsFixed=function(e,t){return e.r.toFixed(2)===t.r.toFixed(2)&&e.g.toFixed(2)===t.g.toFixed(2)&&e.b.toFixed(2)===t.b.toFixed(2)},s.lerp=function(e,t,i){return{r:e.r+(t.r-e.r)*i,g:e.g+(t.g-e.g)*i,b:e.b+(t.b-e.b)*i}},s.is=function(e){return!!cm(e)&&"r"in e&&"g"in e&&"b"in e&&!("a"in e)},(a=Tm||(Tm={})).white={...Mm.white,a:1},a.is=function(e){return!!cm(e)&&"r"in e&&"g"in e&&"b"in e&&"a"in e},a.transparent={...Mm.white,a:0},a.from0to1=function(e){return{r:e[0],g:e[1],b:e[2],a:e[3]}},a.fromHexAndA=function(e,t){return{...Mm.fromHex(e),a:t}},a.toRgb255a1=function(e){return{r:Math.round(255*e.r),g:Math.round(255*e.g),b:Math.round(255*e.b),a:e.a}},a.equals=function(e,t){return Mm.equals(e,t)&&e.a===t.a},a.equalsFixed=function(e,t){return Mm.equalsFixed(e,t)&&e.a.toFixed(2)===t.a.toFixed(2)},a.lerp=function(e,t,i){return{r:e.r+(t.r-e.r)*i,g:e.g+(t.g-e.g)*i,b:e.b+(t.b-e.b)*i,a:e.a+(t.a-e.a)*i}},a.toStyle=function({r:e,g:t,b:i,a:r}=a.white){return`rgba(${255*e}, ${255*t}, ${255*i}, ${r})`},(Cm||(Cm={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(n=Am||{})[n.LINEAR=0]="LINEAR",n[n.EASE=1]="EASE",n[n.EASE_IN=2]="EASE_IN",n[n.EASE_OUT=3]="EASE_OUT",n[n.EASE_IN_OUT=4]="EASE_IN_OUT",n[n.CUBIC=5]="CUBIC",n[n.SPRING=6]="SPRING",n[n.ARC=7]="ARC",n[n.NONE=8]="NONE",Am=n,(Nm||(Nm={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(Pm||(Pm={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=Rm||(Rm={})).linear=[0,0,1,1],o.ease=[.25,.1,.25,1],o.easeIn=[.42,0,1,1],o.easeOut=[0,0,.58,1],o.easeInOut=[.42,0,.58,1]}),Qg=n(()=>{var e,t;um(),dm(),(Em||(Em={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(Om||(Om={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(Bm||(Bm={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(Vm||(Vm={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(Dm||(Dm={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(Im||(Im={})).defaultData={type:"Create",name:"",object:"",delay:0,creationSpeed:10,coordinateSystem:"world",dynamic:!0,destroy:"No",destroyAfterQuantity:5,lifetime:2,position:[0,0,0],rotation:[0,0,0],velocity:[1e3,0,0],hideBase:"No"},(Lm||(Lm={})).defaultData={type:"Reset",name:"",delay:0},(zm||(zm={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(e=km||(km={})).pauseDefaultData={interaction:"pause",delay:0},e.stopDefaultData={interaction:"stop",delay:0},(t=Um||(Um={})).defaultData={type:"Audio",name:"",...zm.defaultData},t.hasAudioByActions=e=>e.some(({data:e})=>"Audio"===e.type&&"play"===e.interaction&&e.audio),t.hasAudioByEvents=e=>{for(let{data:i}of e)if(jp.is(i)||"Start"===i.type||"Collision"===i.type){if(t.hasAudioByActions(i.actions))return!0}else if("Conditional"===i.type){if(t.hasAudioByActions(i.inActions)||t.hasAudioByActions(i.outActions))return!0}else if("GameControl"===i.type&&Object.values(i.gameActions).find(e=>t.hasAudioByActions(e)))return!0},t.getAudiosByActions=e=>{let i=[];return e.forEach(e=>{let r=e.data;"Audio"===r.type&&"play"===r.interaction&&r.audio&&i.push(e),"Conditional"===r.type&&(i.push(...t.getAudiosByActions(r.ifActions)),i.push(...t.getAudiosByActions(r.elseActions)))}),i},t.getAudiosByEvents=e=>{let i=[];return e.forEach(({data:e})=>{jp.is(e)||"Collision"===e.type||"Start"===e.type||"Trigger"===e.type?i.push(...t.getAudiosByActions(e.actions)):"Conditional"===e.type?(i.push(...t.getAudiosByActions(e.inActions)),i.push(...t.getAudiosByActions(e.outActions))):"GameControl"===e.type?Object.values(e.gameActions).forEach(e=>{i.push(...t.getAudiosByActions(e))}):"DragDrop"===e.type&&(i.push(...t.getAudiosByActions(e.dragDropActions.drag)),i.push(...t.getAudiosByActions(e.dragDropActions.drop)))}),i},(Fm||(Fm={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(e=>{e.pauseDefaultData={interaction:"pause",delay:0},e.stopDefaultData={interaction:"stop",delay:0}})(jm||(jm={})),(e=>{e.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...Fm.defaultData},e.hasVideoByActions=e=>e.some(({data:e})=>"Video"===e.type&&"play"===e.interaction&&e.layerId),e.hasVideoByObject=t=>{if(t.events)for(let{data:i}of t.events)if((jp.is(i)||"Start"===i.type)&&e.hasVideoByActions(i.actions))return!0},e.getVideosByActions=e=>{let t=[];return e.forEach(e=>{let i=e.data;"Video"===i.type&&"play"===i.interaction&&i.layerId&&t.push(e)}),t},e.getVideosByEvents=t=>{let i=[];return t.forEach(({data:t})=>{(jp.is(t)||"Start"===t.type)&&i.push(...e.getVideosByActions(t.actions))}),i}})(Gm||(Gm={})),(Wm||(Wm={})).defaultData=function(e){return{state:e,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(qm||(qm={})).defaultData=function(){return{tweens:new jd,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(Hm||(Hm={})).defaultData=function(e){return{type:"Transition",name:"",runMode:"Once",object:e??null,...qm.defaultData()}},($m||($m={})).defaultData=function(e){return{interaction:"play",timeline:e,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Once"}},(e=>{e.pauseDefaultData={interaction:"pause",delay:0},e.stopDefaultData={interaction:"stop",delay:0}})(Ym||(Ym={})),(Xm||(Xm={})).defaultData=function(e){return{type:"TimelineAnimation",name:"",...$m.defaultData(e)}},(Km||(Km={})).defaultData=function(e,t,i){return{type:"Animation",name:"",object:e,clipId:t,crop:i,crop2:i,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(Zm||(Zm={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(Jm||(Jm={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new jd,elseActions:new jd,condition:[]}),(Qm||(Qm={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(eg||(eg={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(tg||(tg={})).defaultData={name:"",type:"UserAPI"}}),ef=n(()=>{var e;(e=ig||(ig={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},e.maxSize=2e6}),tf=n(()=>{var e;(e=rg||(rg={})).all=["PerspectiveCamera","OrthographicCamera"],e.is=function(t){return e.all.includes(t)},(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.MinTargetOffset=.001,e.sanitizeTargetOffset=function(t){return void 0===t||!Number.isFinite(t)||t<e.MinTargetOffset?e.DefaultTargetOffset:t},e.DefaultAzimuth=-24,e.DefaultElevation=15;let t=e.DefaultAzimuth*Math.PI/180,i=e.DefaultElevation*Math.PI/180,r=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(t)*Math.cos(i),e.DefaultTargetOffset*Math.sin(i),e.DefaultTargetOffset*Math.cos(t)*Math.cos(i)],e.DefaultRotation=[Math.atan2(-Math.sin(i),Math.cos(t)*Math.cos(i))*r,Math.asin(Math.sin(t)*Math.cos(i))*r,Math.atan2(Math.sin(t)*Math.sin(i),Math.cos(t))*r],e.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset},e.getZoom=function(e){return"PerspectiveCamera"===e.type?e.perspective?.zoom??1:e.orthographic?.zoom??1}})(sg||(sg={}))}),rf=n(()=>{var e;(e=ag||(ag={})).defaultData=function(e,t=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max("number"==typeof e[0]?e[0]:1,"number"==typeof e[1]?e[1]:1),start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[("number"==typeof e[0]?e[0]+e[0]:1)*t,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:e.map(e=>("number"==typeof e?e:1)*(1+t)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}},e.merge=function(e,t){let i={...e};if(og.forEach(r=>{Object.assign(i,{[r]:t[r]??e[r]})}),i.radial={...e.radial},t.radial){let r=e.radial,s=t.radial;lg.forEach(e=>{Object.assign(i.radial,{[e]:s[e]??r[e]})})}if(i.linear={...e.linear},t.linear){let r=e.linear,s=t.linear;hg.forEach(e=>{Object.assign(i.linear,{[e]:s[e]??r[e]})})}if(i.grid={...e.grid},t.grid){let r=e.grid,s=t.grid;ug.forEach(e=>{Object.assign(i.grid,{[e]:s[e]??r[e]})})}if(i.toObject={...e.toObject},t.toObject){let r=e.toObject,s=t.toObject;dg.forEach(e=>{Object.assign(i.toObject,{[e]:s[e]??r[e]})})}if(i.randomnessObject={...e.randomnessObject},t.randomnessObject){let r=e.randomnessObject,s=t.randomnessObject;cg.forEach(e=>{Object.assign(i.randomnessObject,{[e]:s[e]??r[e]})})}return i},e.isPartial=function(e){return!(!e.randomnessObject&&!e.toObject)},(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];e.toOps=function(e,i){let r=[];void 0!==e.count&&r.push({type:0,path:i,props:{count:e.count}});for(let s of t){let t=e[s];t&&Object.keys(t).length>0&&r.push({type:0,path:[...i,s],props:t})}return r}})(ng||(ng={})),og=["count"],lg=["radius","start","end","position","scale","rotation"],hg=["position","scale","rotation"],ug=["count","size"],dg=["count","position","scale","rotation"],cg=["strength","scale","rotation","position","movement","seed","freqScale"]}),sf=n(()=>{var e;Jg(),(e=pg||(pg={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],e.is=function(t){return e.all.includes(t)},(mg||(mg={})).defaultData=function(e){return function(e){if("PointLight"===e)return{type:e,color:Tm.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if("SpotLight"===e)return{type:e,color:Tm.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if("DirectionalLight"===e)return{type:e,color:Tm.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),af=n(()=>{var e;(e=gg||(gg={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}}),nf=n(()=>{var e;(e=fg||(fg={})).defaultData={gravity:5,damping:.03,localStiffness:.67,globalStiffness:.5,globalRange:.15,stiffnessFalloff:.1,windStrength:3,vspCoefficient:.01,elasticity:.15,hairLength:.75,tipSeparation:.8,kink:0,kinkFrequency:0,clumpStrength:0,clumpSize:32,clumpTipScale:1.5,spreadRadius:.03,guideStrands:8192,headShape:"sphere",baseObjectId:null,hairColorSource:"custom",hairShadeRoot:.6,hairShadeTip:1.15,hairRootColor:{r:.29,g:.102,b:.039,a:1},hairMidColor:{r:.8,g:.267,b:.133,a:1},hairTipColor:{r:.545,g:.18,b:.18,a:1},headColor:{r:.325,g:.137,b:.114,a:1},noiseEnabled:!1,noiseColorA:{r:.545,g:.184,b:.788,a:1},noiseColorB:{r:.914,g:.188,b:.914,a:1},noiseColorC:{r:.2,g:.4,b:1,a:1},noiseColorD:{r:.2,g:1,b:.6,a:1},noiseScale:1.8,noiseMixHair:.75,noiseMixHead:.8,castShadow:!0,receiveShadow:!0,hairWidth:1.75,specularPower:40,specularIntensity:.4,diffuseIntensity:.6,ambientIntensity:.25,opacity:1,tipFade:.4,autoPlay:!0},e.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),of=n(()=>{(yg||(yg={})).defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]}}),lf=n(()=>{var e,t;(e=vg||{})[e.Front=0]="Front",e[e.Back=1]="Back",e[e.Double=2]="Double",vg=e,(t=bg||(bg={})).defaultData={castShadow:!0,receiveShadow:!0},t.equals=function(e,t){return e.castShadow===t.castShadow&&e.receiveShadow===t.receiveShadow},(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0},e.equals=function(e,t){return e.flatShading===t.flatShading&&e.side===t.side&&e.wireframe===t.wireframe&&(e.shadowCatcher??!1)===(t.shadowCatcher??!1)}})(xg||(xg={})),(wg||(wg={})).defaultData={...xg.defaultData,...bg.defaultData},(_g||(_g={})).getMaterialData=function(e,t){let i=[];if("material"in e){let r="string"==typeof e.material?t.materials[e.material]??t.lib.materials[e.material]?.asset:e.material;r&&i.push(r)}else if("materials"in e)for(let r of e.materials){let e="string"==typeof r?t.materials[r]??t.lib.materials[r]?.asset:r;e&&i.push(e)}return i}}),hf=n(()=>{var e;(e=Sg||(Sg={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7}),uf=n(()=>{var e,t,i,r;um(),Jg(),hf(),Jg(),(Mg||(Mg={})).is=function(e){return"texture"===e||"video"===e||"color"===e||"depth"===e||"normal"===e||"gradient"===e||"noise"===e||"fresnel"===e||"cavity"===e||"dust"===e||"rainbow"===e||"toon"===e||"outline"===e||"particle"===e||"transmission"===e||"reflection"===e||"matcap"===e||"displace"===e||"pattern"===e||"vertexColor"===e||"light"===e},(Tg||(Tg={})).is=function(e){return"luminance"===e||"r"===e||"g"===e||"b"===e||"a"===e},(Cg||(Cg={})).is=function(e){return"object"==typeof e&&null!==e&&null!=e.image},(Ag||(Ag={})).is=function(e){return"phong"===e||"toon"===e||"lambert"===e||"physical"===e},(r=Ng||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",Ng=r,Pg=(e=>(e[e.RepeatWrapping=1e3]="RepeatWrapping",e[e.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",e[e.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",e))(Pg||{}),Rg=(e=>(e[e.NearestFilter=1003]="NearestFilter",e[e.LinearFilter=1006]="LinearFilter",e[e.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",e))(Rg||{}),(i=Eg||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",Eg=i,(t=Og||{})[t.Simplex=0]="Simplex",t[t.SimplexFractal=1]="SimplexFractal",t[t.Ashima=2]="Ashima",t[t.Fbm=3]="Fbm",t[t.Perlin=4]="Perlin",t[t.Voronoi=5]="Voronoi",Og=t,(e=Bg||{})[e.F1=0]="F1",e[e.F2=1]="F2",e[e.F2MinusF1=2]="F2MinusF1",e[e.SmoothBlend=3]="SmoothBlend",e[e.Edge=4]="Edge",e[e.Power=5]="Power",e[e.Lines=6]="Lines",e[e.Cells=7]="Cells",Bg=e,Vg=(e=>(e[e.Lights=0]="Lights",e[e.Static=1]="Static",e[e.Camera=2]="Camera",e))(Vg||{}),Dg=(e=>(e[e.Circle=0]="Circle",e[e.Ring=1]="Ring",e[e.Polygon=2]="Polygon",e[e.Cross=3]="Cross",e[e.Diamond=4]="Diamond",e[e.Checkerboard=5]="Checkerboard",e[e.Line=6]="Line",e[e.Wave=7]="Wave",e))(Dg||{}),(e=>{e.patch=function(e,t){let{texture:i,...r}=t;if(Object.assign(e,r),i){let t=e.texture;t&&Object.assign(t,i)}},e.defaultColorLayer=function(t){return{...e.defaultData("color"),color:t}},e.defaultData=function(e,t){return"light"===e&&t?function(e){let t={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(e){case"phong":return{...t,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...t,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...t,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...t,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(t):function(e){let t={alpha:1,mode:0,isMask:!1,visible:!0};switch(e){case"texture":return{...t,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...t,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Sg.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...t,type:"color",color:Mm.fromHex(ym)};case"vertexColor":return{...t,type:"vertexColor"};case"depth":return{...t,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...t,type:"normal",cnormal:[1,1,1]};case"gradient":return{...t,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...t,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Mm.fromHex(6710886),a:1},colorB:{...Mm.fromHex(6710886),a:1},colorC:{...Mm.fromHex(16777215),a:1},colorD:{...Mm.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"cavity":return{...t,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...t,type:"fresnel",color:Tm.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...t,type:"dust",color:Tm.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...t,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...t,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Tm.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...t,type:"outline",outlineColor:Tm.fromHexAndA(0,1),contourColor:Tm.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...t,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...t,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...t,type:"reflection",blur:0,thickness:.001,steps:60,stepSize:.005,tracingMode:1,mirror:0};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...t,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Mm.fromHex(0),a:1},colorB:{...Mm.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(e)}})(Ig||(Ig={})),(e=>{function t(e,t="layer1",i="layer2",r=Mm.fromHex(16777215)){let s=new jd;return s.push({fi:0,data:Ig.defaultData("light",e),id:t}),s.push({fi:1,data:Ig.defaultData("color"),id:i}),{layers:s}}e.isMergable=function(e){return!e.layers.some(e=>"texture"===e.data.type&&0!==e.data.projection||"depth"===e.data.type&&!e.data.isWorldSpace||"noise"===e.data.type||"dust"===e.data.type&&0!==e.data.noiseStrength||"displace"===e.data.type)},e.getHash=function(e){let t="";return e.layers.forEach(e=>{Object.entries(e.data).forEach(([e,i])=>{t+=`${e}${i}`,Array.isArray(i)?i.forEach(e=>t+=`${e}`):"object"==typeof i?Object.values(i).forEach(e=>{t+="number"==typeof e?`${e.toFixed(4)}`:`${e}`}):t+=`${i}`})}),t},e.defaultEmptyData=function(){return{layers:new jd}},e.defaultData=function(e="layer1",i="layer2"){return t("physical",e,i)},e.withName=function(e,t){return{...e,name:t}},e.defaultTwoLayerData=t,e.defaultColorMaterial=function(e,t,i="layer1",r="layer2"){let s=new jd;return s.push({fi:0,data:Ig.defaultData("light",t),id:i}),s.push({fi:1,data:Ig.defaultColorLayer(e),id:r}),{layers:s}},e.defaultUIObjectMaterial=function(e){let t=Ig.defaultData("texture");e&&Object.assign(t.texture,{image:e});let i=new jd;return i.push({fi:0,data:t,id:"layer1"}),i.push({fi:1,data:{...Ig.defaultData("transmission"),alpha:1},id:"layer2"}),i.push({fi:2,data:{...Ig.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:i}},e.defaultTwoLayerTextureData=function(e,t="physical",i="layer1",r="layer2"){let s=Ig.defaultData("texture");Object.assign(s.texture,{image:e});let a=new jd;return a.push({fi:0,data:s,id:i}),a.push({fi:1,data:Ig.defaultData("light",t),id:r}),{layers:a}},e.defaultTwoLayerVideoTextureData=function(e,t="physical",i="layer1",r="layer2"){let s=Ig.defaultData("video");Object.assign(s.texture,{video:e});let a=new jd;return a.push({fi:0,data:s,id:i}),a.push({fi:1,data:Ig.defaultData("light",t),id:r}),{layers:a}}})(Lg||(Lg={}))}),df=n(()=>{zg="Roboto_regular",kg="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),cf=n(()=>{um(),(Ug||(Ug={})).defaultData=function(){return{points:new jd,roundness:0,shapeHoles:[],isClosed:!1}}}),pf=n(()=>{um(),(Fg||(Fg={})).defaultData=function(){return{points:new jd,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},jg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(Gg||(Gg={})).merge=function(e,t){let i={...e};return qg.forEach(r=>{Object.assign(i,{[r]:t[r]??e[r]})}),i},Wg={shape:jg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},qg=["depth","offset","angle","twist","startScale","endScale"]}),mf=n(()=>{var e,t;cf(),pf(),(e=Hg||(Hg={})).is2DParametricMesh=function(e){return"PolygonGeometry"===e||"RectangleGeometry"===e||"StarGeometry"===e||"TriangleGeometry"===e||"EllipseGeometry"===e||"UIGeometry"===e},e.isParametricMesh=function(e){return"PolygonGeometry"===e||"RectangleGeometry"===e||"StarGeometry"===e||"TriangleGeometry"===e||"EllipseGeometry"===e||"PathGeometry"===e||"VectorGeometry"===e||"ConeGeometry"===e||"CubeGeometry"===e||"CylinderGeometry"===e||"DodecahedronGeometry"===e||"HelixGeometry"===e||"IcosahedronGeometry"===e||"LatheGeometry"===e||"PyramidGeometry"===e||"SphereGeometry"===e||"PlaneGeometry"===e||"BackdropGeometry"===e||"TorusGeometry"===e||"TorusKnotGeometry"===e||"BooleanGeometry"===e||"TextGeometry"===e||"InputGeometry"===e||"DecalGeometry"===e},e.isSwappableGeometry=function(e){return"PolygonGeometry"===e||"RectangleGeometry"===e||"StarGeometry"===e||"TriangleGeometry"===e||"EllipseGeometry"===e||"PathGeometry"===e||"VectorGeometry"===e||"ConeGeometry"===e||"CubeGeometry"===e||"CylinderGeometry"===e||"DodecahedronGeometry"===e||"HelixGeometry"===e||"IcosahedronGeometry"===e||"LatheGeometry"===e||"PyramidGeometry"===e||"SphereGeometry"===e||"PlaneGeometry"===e||"BackdropGeometry"===e||"TorusGeometry"===e||"TorusKnotGeometry"===e||"TextGeometry"===e||"SubdivGeometry"===e||"NonParametricGeometry"===e},($g||($g={})).merge=function(e,t){let i={...e};return Object.assign(i,t),"PathGeometry"===i.type&&"extrusion"in t&&t.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,Gg.merge(i.extrusion,t.extrusion))),i},(t=Yg||(Yg={})).defaultData=function(e){if("RectangleGeometry"===e)return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if("UIGeometry"===e)return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if("PathGeometry"===e)return{type:e,width:1,height:1,depth:1,path:Fg.defaultData(),extrusion:Wg};if("VectorGeometry"===e)return{width:1,height:1,type:e,subdivisions:12,shape:Ug.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if("BooleanGeometry"===e)return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if("ShapeBlendGeometry"===e)return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if("DecalGeometry"===e)return{type:e,width:200,height:200,depth:200,offset:1};if("TextGeometry"===e)return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if("InputGeometry"===e)return{...t.defaultData("TextGeometry"),type:e,editable:!0};if("SphereGeometry"===e)return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}}),gf=n(()=>{Jg(),(e=>{function t(e){return e.mode??"linear"}e.defaultData={enabled:!1,useBackgroundColor:!1,color:Mm.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},e.getMode=t,e.getModeIndex=function(e){let i=t(e);return"height"===i?1:"both"===i?2:0},e.getDensity=function(t){return t.density??e.defaultData.density},e.getHeightFalloff=function(t){return t.heightFalloff??e.defaultData.heightFalloff},e.getHeightBase=function(t){return t.heightBase??e.defaultData.heightBase}})(Xg||(Xg={}))}),ff=n(()=>{(Kg||(Kg={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Zg||(Zg={})).defaultData={enabled:!1,mode:"hdri",hdri:Kg.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function yf(e){let t="string"==typeof e?Number.parseInt(e,10):e;return"number"==typeof t&&Number.isFinite(t)?Math.min(5,Math.max(0,Math.round(t))):3}var vf,bf,xf,wf,_f,Sf,Mf,Tf,Cf,Af,Nf,Pf,Rf,Ef,Of,Bf,Vf,Df,If,Lf,zf,kf,Uf,Ff,jf,Gf,Wf,qf,Hf,$f,Yf,Xf,Kf,Zf,Jf,Qf,ey,ty,iy,ry,sy,ay,ny,oy=n(()=>{(()=>{let e={opacity:1,blendFunction:13,enabled:!1};(vf||(vf={})).defaultData={enabled:!1,pixelation:{...e,blendFunction:16,granularity:15},bloom:{...e,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...e,offset:[2,2]},vignette:{...e,darkness:1,offset:0},hueSaturation:{...e,hue:3,saturation:0},brightnessContrast:{...e,brightness:.25,contrast:0},depthOfField:{...e,focusDistance:100,focalLength:20,bokehScale:5},noise:{...e,blendFunction:16}}})()}),ly=n(()=>{var e;gf(),ff(),oy(),Jg(),(e=bf||(bf={})).defaultData={type:"normal",softShadowQuality:"low"},e.isSoft=function(e){return null!=e&&(void 0===e.type||"soft"===e.type)},(xf||(xf={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(wf||(wf={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},e.isUntouched=function(e){return void 0===e||"classic"===e.pipeline&&("none"===e.toneMapping||"aces"===e.toneMapping)&&1===e.exposure}})(_f||(_f={})),(Sf||(Sf={})).defaultData={usePhysics:!1,gravity:-10},(Mf||(Mf={})).defaultData={playCamera:mm,gameControlObject:null},(Tf||(Tf={})).defaultData={backgroundColor:Tm.fromHexAndA(fm,1),postprocessing:vf.defaultData,fog:Xg.defaultData,sky:Zg.defaultData,globalPhysics:Sf.defaultData,ambient:xf.defaultData,ao:wf.defaultData,shadow:bf.defaultData,publish:Mf.defaultData,grading:_f.defaultData}}),hy=n(()=>{(Cf||(Cf={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),uy=n(()=>{var e,t,i;um(),tf(),sf(),af(),nf(),of(),lf(),Jg(),uf(),mf(),rf(),Od(),ly(),hy(),(e=Af||(Af={})).isComponentRelated=function(e){return"Component"===e||"Instance"===e},e.isEmptyOrComponent=function(e){return"Empty"===e||"Instance"===e},(t=Nf||(Nf={})).identity={...Cm.identity,hiddenMatrix:Sm.identity},t.fromObject=function(e){return{position:e.position,rotation:e.rotation,scale:e.scale,pivot:e.pivot,pivotRotation:e.pivotRotation,hiddenMatrix:e.hiddenMatrix}},t.merge=function(e,t){return{position:t?.position||e.position,rotation:t?.rotation||e.rotation,pivot:t?.pivot||e.pivot,pivotRotation:t?.pivotRotation||e.pivotRotation,scale:t?.scale||e.scale,hiddenMatrix:t?.hiddenMatrix||e.hiddenMatrix}},t.diff=function(e,t){return Td({position:xm.isEqual(e.position,t.position)?void 0:t.position,rotation:xm.isEqual(e.rotation,t.rotation)?void 0:t.rotation,scale:xm.isEqual(e.scale,t.scale)?null:t.scale,hiddenMatrix:Sm.isEqual(e.hiddenMatrix,t.hiddenMatrix)?void 0:t.hiddenMatrix})},(Pf||(Pf={})).defaultData={states:new jd,events:new jd,timelineAnimations:new Pd,visible:!0,raycastLock:!1,physics:yg.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Nf.identity,cloner:null},(Rf||(Rf={})).defaultData={type:"Empty",...Pf.defaultData},(Ef||(Ef={})).defaultData={type:"ParticleCollider",...Cf.defaultData,...Pf.defaultData},(Of||(Of={})).defaultData={type:"Component",...Pf.defaultData},(Bf||(Bf={})).defaultData={type:"Particle",...Pf.defaultData,...gg.defaultData},(Vf||(Vf={})).defaultData={type:"Hair",...Pf.defaultData,...fg.defaultData},(Df||(Df={})).defaultData={type:"Mesh",...Pf.defaultData,...wg.defaultData},(If||(If={})).defaultData={...Pf.defaultData,...Nf.identity,position:sg.DefaultPosition,rotation:sg.DefaultRotation,...sg.defaultData},(e=>{e.defaultData=function(e){return{...Pf.defaultData,...mg.defaultData(e)}},e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Lf||(Lf={})),(e=>{function t(e,t,i=0){for(;i<t.length;){let r=e?e[t[i]]:void 0;if(t.length===i+1)return r;if(!r)return;e=r.descendants,i+=1}}e.resolveWithDes=t,e.resolve=function(e,i,r=0){let s=t(e,i,r);if(s){let e=Object.keys(s);if(1===e.length&&"descendants"===e[0])return}return s}})(zf||(zf={})),(e=>{function t(e,t){return{...Pf.defaultData,...t,component:e,overrides:new ic,physics:void 0,events:void 0,type:"Instance"}}e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"],e.ofComponent=t,e.fromComponentData=function(e){let i=Nf.fromObject(e.data);return t(e.id,i)}})(kf||(kf={})),(e=>{e.defaultData={type:"Page",...Pf.defaultData,physics:{...yg.defaultData,fusedBody:!1},...Tf.defaultData,camera:If.defaultData},e.isUIPage=function(e){return void 0!==e.uiScene}})(Uf||(Uf={})),(i=Ff||(Ff={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:Sm.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:yg.defaultData,states:new jd,events:new jd,timelineAnimations:new Pd,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...sg.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...Pf.defaultData,...Df.defaultData,geometry:Yg.defaultData("RectangleGeometry"),material:Lg.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Pf.defaultData,...Df.defaultData,geometry:Yg.defaultData("BooleanGeometry"),material:Lg.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...Pf.defaultData,...Df.defaultData,geometry:Yg.defaultData("ShapeBlendGeometry"),material:Lg.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...Pf.defaultData,...Df.defaultData,geometry:Yg.defaultData("TextGeometry"),material:Lg.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...Pf.defaultData,...Df.defaultData,geometry:Yg.defaultData("InputGeometry"),material:Lg.defaultTwoLayerData("physical","layer1","layer2")},(e=>{e.newEmpty=function(e,t){let i={name:t};return"Mesh"===e.type?(i.geometry={},"material"in e&&(i.material={layers:new ic}),"materials"in e&&(i.materials=e.materials.map(e=>({layers:new ic})))):rg.is(e.type)&&(i.perspective={},i.orthographic={}),i},e.toOps=function(e,t){let i,r=[],s={orthographic:0,perspective:0,geometry:0};function a(e,t){for(let[i,s]of Object.entries(t.layers)){let{texture:t,...a}=s;if(void 0!==t&&Object.keys(t).length>0){let s={path:[...e,"layers",i,"texture"],props:t,type:0};r.push(s)}if(Object.keys(a).length>0){let t={path:[...e,"layers",i],props:a,type:0};r.push(t)}}}for(let[e,n]of Object.entries(t)){let t=n;if("name"!==e)if("cloner"===e)r.push(...ng.toOps(t,["cloner"]));else if("pathSnapping"===e)r.push({path:[e],props:{slide:t.slide,offset:t.offset},type:0});else if("material"===e)a(["material"],t);else if("materials"===e)for(let[e,i]of Object.entries(t))a(["materials",e],i);else if(0===s[e]){if("geometry"===e&&void 0!==t.extrusion){let i={path:[e,"extrusion"],props:t.extrusion,type:0};r.push(i),t={...t},delete t.extrusion}if(Object.keys(t).length>0){let i={path:[e],props:t,type:0};r.push(i)}}else void 0===i&&(i={path:[],props:{},type:0},r.push(i)),i.props[e]=t}return r},e.patch=function(e,t){if(void 0===t)return e;let i={...e};if(Object.assign(i,Nf.merge(i,t)),Object.assign(i,{pathSnapping:Object.assign({},i.pathSnapping,{slide:t.pathSnapping?.slide??i.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??i.pathSnapping?.offset??0})}),rg.is(e.type)){i.orthographic={...i.orthographic},i.perspective={...i.perspective};let e=t;void 0!==e.orthographic?.zoom&&(i.orthographic.zoom=e.orthographic.zoom),void 0!==e.perspective?.zoom&&(i.perspective.zoom=e.perspective.zoom),void 0!==e.isUpVectorFlipped&&(i.isUpVectorFlipped=e.isUpVectorFlipped),void 0!==e.targetOffset&&(i.targetOffset=e.targetOffset)}else if("Mesh"===e.type)"geometry"in t&&Object.assign(i,{geometry:$g.merge(i.geometry,t.geometry)}),(t.material||t.materials)&&(i=function(e,t){if(void 0===t)return e;let i={...e};return"material"in i&&"material"in t&&t.material&&(i.material=cc(i.material,e=>{if("string"!=typeof e)for(let[i,r]of Object.entries(t.material.layers)){let t=e.layers.data(i);t&&Ig.patch(t,r)}}).data),i.materials&&t.materials&&(i.materials=cc(i.materials,e=>{for(let r=0;r<i.materials.length;r++){let i=t.materials[r];if("string"!=typeof i)for(let[t,s]of Object.entries(i.layers)){let i=e[r]?.layers?.data(t);i&&Ig.patch(i,s)}}}).data),i}(i,t)),i.cloner&&"cloner"in t&&Object.assign(i,{cloner:ag.merge(i.cloner,t.cloner)});else if("Empty"===e.type)i.cloner&&"cloner"in t&&Object.assign(i,{cloner:ag.merge(i.cloner,t.cloner)});else if(pg.is(e.type)){let e=t;void 0!==e.intensity&&(i.intensity=e.intensity),void 0!==e.color&&("string"==typeof e.color?i.color=e.color:i.color=Mm.clone(e.color))}return i}})(jf||(jf={}))}),dy=n(()=>{(Gf||(Gf={})).defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0}}),cy=n(()=>{dy(),Jg(),(Wf||(Wf={})).defaultData={orbitControls:Gf.defaultData,playPage:gm,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let i=0,r=0;return t<5?r=-30:t<10&&(r=30),0===t||10===t||5===t?i=30:(4===t||11===t||9===t)&&(i=-30),[120,[i,r],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1,renderer:"webgpu"}}),py=n(()=>{var e;(qf||(qf={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(Hf||(Hf={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(e=$f||($f={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...qf.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Hf.defaultData}),e.generateSeed=()=>Math.round(1e5*Math.random())}),my=n(()=>{uy(),um(),cy(),Jg(),Od(),py(),(e=>{function t(e,t){let i=e.scene.objects.get(t);if(i&&"Component"===i.data.type)return i;{let i=e.shared.lib.components[t];if(i)return{...i.asset,id:t}}}e.physicsEnabled=function(e){return void 0!==e.find(e=>"Page"===e.data.type&&e.data.globalPhysics.usePhysics)},e.getComponentData=t,e.traverseModuleInstances=function(e,i,r){e.scene.objects.traverseFrom(i,(i,s)=>{if("Instance"===s.type){let a=t(e,s.component)?.data;a&&r(i,s,a.events)}else r(i,s,s.events)})}})(Yf||(Yf={})),(e=>{function t(t=!0,i=[]){let r=[];t&&r.push({...e.defaultLight}),r.push(...i);let s=new kd;return s.push({fi:1,id:gm,data:{...Uf.defaultData,name:"Scene 1"},children:r}),s}function i(t){return{...e.defaultData,objects:bd(t,kd.prototype)}}e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:Lf.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:Wf.defaultData,styles:$f.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new kd,publish:Wf.defaultData,styles:$f.defaultData()}},e.emptyDataWithPage=function(e=!0){return{objects:t(e),publish:Wf.defaultData,styles:$f.defaultData()}},e.emptyData=function(){return{objects:new kd,publish:{...Wf.defaultData},styles:$f.defaultData()}},e.withObjs=i,e.withObj=function(e,t){return i([{id:e,data:t,children:[],fi:0}])}})(Xf||(Xf={}))}),gy=n(()=>{(Kf||(Kf={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),fy=n(()=>{var e,t;um(),Od(),(e=Zf||(Zf={})).defaultData=e=>({url:e,name:"New Webhook",parametersSchemas:new jd}),e.defaultParameterValueByType=e=>"number"===e?0:"boolean"!==e&&"",(Jf||(Jf={})).defaultData=(e,t="GET")=>({url:e,method:t,name:"New API",headers:new jd,queries:new jd,autoStart:!0}),(e=>{function t(e){return void 0!==e.textValue}function i(e){return"boolean"==typeof e}e.isTextValue=t,e.isNumber=function(e){return"number"==typeof e},e.isBoolean=i,e.typeOfVariable=function(e){return t(e)?"string":i(e)?"boolean":"number"},e.getDisplayedValue=function(t){return e.isTextValue(t)?Array.isArray(t.textValue)?t.textValue.map(e=>e.toString().padStart(t.padding??2,"0")).join(t.deliminator??":")+(void 0!==t.suffix?" "+t.suffix:""):t.textValue.toString():e.isBoolean(t)?t?"True":"False":e.isNumber(t)?parseFloat(t.toFixed(3)).toString():t.toString()}})(Qf||(Qf={})),(ey||(ey={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(ty||(ty={})).all=[...ey.all,"components"],(iy||(iy={})).defaultData=function(){return{images:new Pd,videos:new Pd,colors:new Pd,audios:new Pd,particles:new Pd,fonts:new Pd,materials:new Pd,components:new Pd,variables:new Pd,userAPIs:new Pd,userWebhooks:new Pd,timelineAnimations:new Pd}},(ry||(ry={})).defaultData=function(){return{images:new Pd,videos:new Pd,colors:new Pd,audios:new Pd,particles:new Pd,fonts:new Pd,materials:new Pd,components:new Pd,variables:new Pd,userAPIs:new Pd,userWebhooks:new Pd,timelineAnimations:new Pd}},(t=sy||(sy={})).defaultColors=function(){return bd({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},Pd.prototype)},t.defaultImages=function(){return bd({},Pd.prototype)},t.emptyData=function(){return{catelogs:new Pd,materials:new Pd,images:new Pd,videos:new Pd,colors:new Pd,timelineAnimations:new Pd,audios:new Pd,particles:new Pd,fonts:new Pd,variables:new jd,userAPIs:new Pd,userWebhooks:new Pd,lib:ry.defaultData()}},t.defaultVariables=function(e){switch(e){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":{let e=[0,0,0];return{name:"Time",value:{textValue:e,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:e,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1}}case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",e)}},t.getFormattedTimerTime=function(e,t){if("HH:mm:ss"===t.format){let t=Math.floor(e/3600),i=Math.floor((e-3600*t)/60);return{textValue:[t,i,Math.round(e-3600*t-60*i)]}}if("mm:ss"===t.format){let t=Math.floor(e/60);return{textValue:[t,Math.round(e-60*t)]}}return"number"===t.format?Math.round(e):Math.round(1e3*e)/1e3}}),yy=n(()=>{}),vy=n(()=>{var e;um(),my(),gy(),fy(),(e=ay||(ay={})).defaultData={schema:130,scene:Xf.defaultData,frames:(new Pd).add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Kf.defaultData),shared:{...sy.emptyData(),colors:sy.defaultColors()}},e.createDefaultData=function(){return kp.deserialize(kp.serialize(e.defaultData))},e.emptyDataForImports=function(){return{schema:130,scene:Xf.emptyDataWithPage(),frames:(new Pd).add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Kf.defaultData),shared:{...sy.emptyData(),colors:sy.defaultColors(),images:sy.defaultImages()}}},e.emptyData=function(){return{schema:130,scene:Xf.emptyDataWithPage(),frames:(new Pd).add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Kf.defaultData),shared:sy.emptyData()}},e.clipboard2dData=function(){return{schema:130,scene:Xf.emptyData(),frames:new Pd,shared:sy.emptyData()}},e.withoutLib=function(e){return{...e,shared:{...e.shared,lib:ry.defaultData()}}},e.getComponentData=function(e,t){return Yf.getComponentData(e,t)},e.hasSensitiveData=function(e){let t=Object.values(e.shared.userAPIs);for(let e of t){let t=e.headers;for(let e of t)if("authorization"===e.data.key.toLowerCase()&&""!==e.data.value)return!0}return!1}}),by=n(()=>{(ny||(ny={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}}),xy={};function wy(){}l(xy,{updateDocumentSchema:()=>wy});var _y,Sy,My,Ty,Cy,Ay,Ny,Py,Ry,Ey,Oy,By,Vy,Dy,Iy,Ly,zy,ky,Uy,Fy,jy=n(()=>{}),Gy=n(()=>{var e;Jg(),um(),(_y||(_y={})).list=["idle","move","jump","run"],(e=Sy||(Sy={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","▲"],["rotPosY","◀"],["rotNegX","▼"],["rotNegY","▶"],["jump","Space"],["run","⇧"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new jd,move:new jd,jump:new jd,run:new jd},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Tm.fromHexAndA(3728051,1)}}}),Wy=n(()=>{var e,t,i;Jg(),um(),Od(),(My||(My={})).is=function(e){return!0},(e=Ty||(Ty={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},e.merge=function(e,t){return{position:t?.position??e.position,rotation:t?.rotation??e.rotation,scale:t?.scale??e.scale,shear:t?.shear??e.shear}},e.diff=function(e,t){return Td({position:bm.isEqual(e.position,t.position)?void 0:t.position,rotation:e.rotation===t.rotation?void 0:t.rotation,scale:bm.isEqual(e.scale,t.scale)?void 0:t.scale,shear:e.shear&&t.shear&&bm.isEqual(e.shear,t.shear)?void 0:t.shear})},(Cy||(Cy={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(Ay||(Ay={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(Ny||(Ny={})).defaultData={opacity:1,fill:{color:Tm.fromHexAndA(ym,1),enabled:!0},stroke:{color:Tm.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Tm.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Tm.from0to1([0,0,0,1]),enabled:!1,spread:0}},(t=Py||(Py={})).newEmpty=function(e,t){return{name:t}},t.patch=function(e,t){if(void 0===t)return e;let i={...e};return Object.assign(i,Ty.merge(i,t)),i=function(e,t){if(void 0===t)return e;let i={...e},r=["width","height","cornerRadius"];for(let e of r)e in i&&e in t&&void 0!==t[e]&&Object.assign(i,{[e]:t[e]});return i}(i,t),i=function(e,t){if(void 0===t)return e;let i={...e};return"fill"in i&&"fill"in t&&void 0!==t.fill&&Object.assign(i,{fill:{...i.fill,...t.fill}}),"stroke"in i&&"stroke"in t&&void 0!==t.stroke&&Object.assign(i,{stroke:{...i.stroke,...t.stroke}}),"layerBlur"in i&&"layerBlur"in t&&void 0!==t.layerBlur&&Object.assign(i,{layerBlur:{...i.layerBlur,...t.layerBlur}}),"backgroundBlur"in i&&"backgroundBlur"in t&&void 0!==t.backgroundBlur&&Object.assign(i,{backgroundBlur:{...i.backgroundBlur,...t.backgroundBlur}}),"dropShadow"in i&&"dropShadow"in t&&void 0!==t.dropShadow&&Object.assign(i,{dropShadow:{...i.dropShadow,...t.dropShadow}}),"innerShadow"in i&&"innerShadow"in t&&void 0!==t.innerShadow&&Object.assign(i,{innerShadow:{...i.innerShadow,...t.innerShadow}}),i}(i,t),i},t.toOps=function(e,t){let i,r=[];for(let[e,s]of Object.entries(t))"name"!==e&&(void 0===i&&(i={path:[],props:{},type:0},r.push(i)),i.props[e]=s);return r},(Ry||(Ry={})).defaultData={...Ty.defaultData,...Cy.defaultData,states:new jd,events:new jd,visible:!0,raycastLock:!1},(Ey||(Ey={})).defaultData={...Ry.defaultData,...Ny.defaultData},(Oy||(Oy={})).defaultData={cornerRadius:[0,0,0,0]},(By||(By={})).defaultData={...Ey.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(Vy||(Vy={})).defaultData={...Ey.defaultData,...Oy.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(Dy||(Dy={})).defaultData={...Ey.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"},(Iy||(Iy={})).defaultData={...Ey.defaultData,type:"path2d",path:"",name:"Path"},(Ly||(Ly={})).is=function(e){return"ellipse2d"===e.type||"rectangle2d"===e.type||"text2d"===e.type||"vector2d"===e.type||"path2d"===e.type},(zy||(zy={})).defaultData={...Ry.defaultData,name:"Group",type:"group2d"},(ky||(ky={})).defaultData=()=>({...Ry.defaultData,...Oy.defaultData,...Ny.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Tm.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Tm.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(e=>{e.defaultData=function(e){switch(e){case"rectangle2d":case"vector2d":return{...Vy.defaultData};case"ellipse2d":return{...By.defaultData};case"text2d":return{...Dy.defaultData};case"path2d":return{...Iy.defaultData};case"frame2d":return{...ky.defaultData()};case"group2d":return{...zy.defaultData}}},e.getPivot=function(e){return"width"in e&&"height"in e?["number"==typeof e.width?.5*e.width:0,"number"==typeof e.height?.5*e.height:0]:[0,0]},e.isResizeable=function(e){return"rectangle2d"===e.type||"ellipse2d"===e.type||"text2d"===e.type||"frame2d"===e.type},e.isAutoLayoutable=function(e){return"frame2d"===e.type&&void 0!==e.autoLayout},e.hasCorners=function(e){return"rectangle2d"===e.type||"frame2d"===e.type}})(Uy||(Uy={})),(i=Fy||(Fy={})).defaultData={name:"UI",type:"scene2d",objects:new kd},i.emptyData=function(){return{type:"scene2d",objects:new kd}}}),qy=n(()=>{Qg(),ef(),tf(),rf(),vy(),dm(),by(),hf(),gf(),ff(),jy(),gy(),mf(),of(),sf(),uf(),lf(),oy(),Jg(),cy(),uy(),dy(),pf(),fy(),my(),df(),cf(),Gy(),ly(),af(),nf(),Wy()});function Hy(e,t=!1){let i=null!==e[0].index,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),a={},n={},o=e[0].morphTargetsRelative,l=new an,h=0;for(let u=0;u<e.length;++u){let d=e[u],c=0;if(i!==(null!==d.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let e in d.attributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===a[e]&&(a[e]=[]),a[e].push(d.attributes[e]),c++}if(c!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let e in d.morphAttributes){if(!s.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;void 0===n[e]&&(n[e]=[]),n[e].push(d.morphAttributes[e])}if(t){let e;if(i)e=d.index.count;else{if(void 0===d.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;e=d.attributes.position.count}l.addGroup(h,e,u),h+=e}}if(i){let t=0,i=[];for(let r=0;r<e.length;++r){let s=e[r].index;for(let e=0;e<s.count;++e)i.push(s.getX(e)+t);t+=e[r].attributes.position.count}l.setIndex(i)}for(let e in a){let t=$y(a[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;l.setAttribute(e,t)}for(let e in n){let t=n[e][0].length;if(0!==t){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let i=0;i<t;++i){let t=[];for(let r=0;r<n[e].length;++r)t.push(n[e][r][i]);let r=$y(t);if(!r)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;l.morphAttributes[e].push(r)}}}return l}function $y(e){let t,i,r,s=-1,a=0;for(let n=0;n<e.length;++n){let o=e[n];if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===r&&(r=o.normalized),r!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===s&&(s=o.gpuType),s!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=o.count*i}let n=new t(a),o=new ja(n,i,r),l=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=l/i;for(let t=0,s=r.count;t<s;t++)for(let s=0;s<i;s++){let i=r.getComponent(t,s);o.setComponent(t+e,s,i)}}else n.set(r.array,l);l+=r.count*i}return void 0!==s&&(o.gpuType=s),o}var Yy=n(()=>{Mu()});function Xy(e){let t=e.points.length/7,i=new jd;for(let r=0;r<t;r++){let t=7*r,s=e.points[t+0],a=e.points[t+1],n=e.points[t+2],o=e.points[t+3],l=e.points[t+4],h=e.points[t+5],u=e.points[t+6];i.push({fi:r,id:ts.generateUUID(),data:{roundness:u,position:[s,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[n,o]},controlNext:{position:[l,h]}}})}return{points:i,isClosed:e.isClosed,roundness:e.roundness,shapeHoles:e.shapeHoles?.map(e=>Xy(e))??[]}}function Ky(e){let{userData:t,uuid:i,...r}=e;if(void 0===t||"NonParametricGeometry"===t.type)return function(e){let t,{userData:i,data:r}=e,s=r?.groups,a=r?.attributes??{},n=r?.morphAttributes??{},o=r?.interleavedBuffers,l=r?.arrayBuffers,h=r?.index;void 0!==a.position&&Array.isArray(a.position.array)&&(t=function(e){let t=1/0,i=1/0,r=1/0,s=-1/0,a=-1/0,n=-1/0;for(let o=0;o<e.length;o+=3){let l=e[o],h=e[o+1],u=e[o+2];t=Math.min(t,l),i=Math.min(i,h),r=Math.min(r,u),s=Math.max(s,l),a=Math.max(a,h),n=Math.max(n,u)}return{width:s-t,height:a-i,depth:n-r}}(a.position.array));let u={type:"NonParametricGeometry",...void 0===i?{}:i.parameters,data:{attributes:a,morphAttributes:n,interleavedBuffers:o,arrayBuffers:l},...void 0===t?{}:t};return void 0!==h&&Object.assign(u.data,{index:h}),void 0!==s&&Object.assign(u.data,{groups:s.map(e=>({...e,materialIndex:e.materialIndex??0}))}),u}(e);if("SubdivGeometry"===t.type){let e="SubdivGeometry",i=r.data?.attributes;if(void 0===i?.positionWASM){let e=new an;if(void 0===i?.position||void 0===i?.faceMap)return null;let t=i.position.array,s=i.faceMap.array,a=r.data.index.array;e.setAttribute("position",new Ha(t,3)),e.setIndex(new Wa(a,1));let n=function(e,t=1e-4){t=Math.max(t,Number.EPSILON);let i={},r=e.getIndex(),s=e.getAttribute("position"),a=r?r.count:s.count,n=0,o=Object.keys(e.attributes),l={},h={},u=[],d=["getX","getY","getZ","getW"],c=["setX","setY","setZ","setW"];for(let t=0,i=o.length;t<i;t++){let i=o[t],r=e.attributes[i];l[i]=new r.constructor(new r.array.constructor(r.count*r.itemSize),r.itemSize,r.normalized);let s=e.morphAttributes[i];s&&(h[i]||(h[i]=[]),s.forEach((e,t)=>{let r=new e.array.constructor(e.count*e.itemSize);h[i][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=.5*t,m=Math.log10(1/t),g=Math.pow(10,m),f=p*g;for(let t=0;t<a;t++){let s=r?r.getX(t):t,a="";for(let t=0,i=o.length;t<i;t++){let i=o[t],r=e.getAttribute(i),n=r.itemSize;for(let e=0;e<n;e++)a+=~~(r[d[e]](s)*g+f)+","}if(a in i)u.push(i[a]);else{for(let t=0,i=o.length;t<i;t++){let i=o[t],r=e.getAttribute(i),a=e.morphAttributes[i],u=r.itemSize,p=l[i],m=h[i];for(let e=0;e<u;e++){let t=d[e],i=c[e];if(p[i](n,r[t](s)),a)for(let e=0,r=a.length;e<r;e++)m[e][i](n,a[e][t](s))}}i[a]=n,u.push(n),n++}}let y=e.clone();for(let t in e.attributes){let e=l[t];if(y.setAttribute(t,new e.constructor(e.array.slice(0,n*e.itemSize),e.itemSize,e.normalized)),t in h)for(let e=0;e<h[t].length;e++){let i=h[t][e];y.morphAttributes[t][e]=new i.constructor(i.array.slice(0,n*i.itemSize),i.itemSize,i.normalized)}}return y.setIndex(u),y}(e),o=[],l=new Array(s[s.length-1]+1).fill(3),h=n.getIndex().array;for(let e=0,t=s.length;e<t;)s[e]===s[e+1]?(l[s[e]]++,o.push(...new Set(h.slice(3*e,3*e+6))),e+=2):(o.push(...h.slice(3*e,3*e+3)),e++);i.indexWASM={array:o},i.positionWASM=n.attributes.position,i.verticesPerFaceWASM={array:l}}if(void 0===i?.positionWASM||0===i?.positionWASM.length||void 0===i?.indexWASM||0===i?.indexWASM.length||void 0===i?.verticesPerFaceWASM||0===i?.verticesPerFaceWASM.length)return null;let s={type:e,...Zy(i.positionWASM.array)};s.subdivisions=t.parameters.subdivisions;for(let e in i)"positionWASM"===e?s[e]=new Float32Array(i[e].array):"indexWASM"===e?s[e]=new Int32Array(i[e].array):"verticesPerFaceWASM"===e&&(s[e]=new Int8Array(i[e].array));return s.scaleBaked=[1,1,1],s}let s=t.type,a=t.parameters;return"VectorGeometry"===s?(a.extrudeDepth&&(a.depth=a.extrudeDepth),{...a,width:100,height:100,shape:Xy(t.shape),type:s}):"LatheGeometry"===s?{...t.parameters,type:s,points:(t?.parameters.points??[]).map(e=>[e.x,e.y])}:(a.extrudeDepth&&(a.depth=a.extrudeDepth),{...a,type:s})}function Zy(e){return Jy.setFromArray(e),Jy.getSize(Qy),{width:Qy.x,height:Qy.y,depth:Qy.z}}var Jy,Qy,ev=n(()=>{um(),Mu(),Yy(),new As,new ss,new Ls,new ns,new ns,Jy=new Sa,Qy=new ns}),tv=n(()=>{}),iv=n(()=>{um(),jy()});function rv(e,t=[0,0]){return[e&&!isNaN(e[0])?e[0]:t[0],e&&!isNaN(e[1])?e[1]:t[1]]}function sv(e,t,i){switch(e){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:{let{control1:e,control2:i}=t??{...Pm.defaultData};return`cubicBezier( ${e[0]}, ${e[1]}, ${i[0]}, ${i[1]} )`}case 6:{let{mass:e,stiffness:t,damping:r,velocity:s}=i??{...Nm.defaultData},a=new lv(e,t,r,s),n=a.solve(1);return()=>e=>a.solve(e)/n}case 8:return()=>e=>Math.floor(e)}}function av(e,t,i){return{id:t,fi:i,data:{id:t,path:e,keyframes:new jd}}}var nv,ov,lv,hv,uv,dv,cv,pv,mv,gv,fv,yv,vv,bv,xv,wv,_v,Sv,Mv,Tv,Cv,Av,Nv,Pv,Rv,Ev,Ov=n(()=>{var e;um(),Jg(),(nv||(nv={})).is=function(e){return e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z},(e=ov||(ov={})).getControlsWithDefault=function(e,t){let i=[0,0],r=[1,1];if(e?.cubicControls)i=rv(e.cubicControls.control1,i);else switch(e?.type){case 2:case 4:i=[.42,0];break;case 3:case 0:i=[0,0];break;case 1:i=[.25,.1];break;case 7:i=[.25,1]}if(t?.cubicControls)r=rv(t.cubicControls.control2,r);else switch(t?.type){case 2:case 0:r=[1,1];break;case 3:case 4:r=[.58,1];break;case 1:r=[.25,1];break;case 7:r=[.5,1]}return{control1:i,control2:r}},e.defaultData=function(e,t){return{id:e,name:t,to:5,properties:new jd}},e.createMaterialGroup=function(e){let t=new jd;return e.forEach(({data:e,id:i,fi:r})=>{if("light"===e.type){let s=av(["material",`${e.category} lighting`],i,r);t.push(s)}else{let s=av(["material",e.type],i,r);t.push(s)}}),t},e.createName=function(e){return Object.entries(e).reduce((e,[t,i])=>("string"!=typeof i&&e.push({name:i.name}),e),[])},e.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:sv(3),duration:1e3},opacity:{value:[0,1],easing:sv(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:sv(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:sv(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:sv(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}],lv=class{constructor(e=1,t=100,i=10,r=0){this.mass=e,this.stiffness=t,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(t/e),this.m_zeta=i/(2*Math.sqrt(t*e)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+this.m_w0)}solve(e){return 1-(this.m_zeta<1?Math.exp(-e*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*e)+this.m_B*Math.sin(this.m_wd*e)):(this.m_A+this.m_B*e)*Math.exp(-e*this.m_w0))}getDuration(){let e=.16666666666666666,t=0,i=0;for(;;)if(t+=e,1===this.solve(t)){if(i++,i>=16)break}else i=0;return t*e*1e3}}}),Bv=n(()=>{qy(),tv(),yy(),jy(),iv(),Ov(),Gy(),um()}),Vv=n(()=>{hv=[3,4,8,9],uv=5,dv=3,cv=32}),Dv=n(()=>{Mu(),pv=e=>{var t;return(t=class extends e{}).geometryHelper=new Lo(30,30,30),t}}),Iv=n(()=>{Mu(),mv=new Bn,gv=new Ka,fv=new As,yv=(e,t,i,r,s=!1,a=e)=>{let n=t,o=a.matrixWorld;if(null===n.boundingSphere&&n.computeBoundingSphere(),gv.copy(n.boundingSphere),gv.applyMatrix4(o),!1===i.ray.intersectsSphere(gv)||(fv.copy(o).invert(),mv.copy(i.ray).applyMatrix4(fv),null!==n.boundingBox&&!1===mv.intersectsBox(n.boundingBox)))return;let l,h,u,d,c,p,m=n.index,g=n.attributes.position,f=n.drawRange;if(!1===s){for(c=Math.max(0,f.start),p=Math.min(m.count,f.start+f.count);c<p;c+=3)if(h=m.getX(c),u=m.getX(c+1),d=m.getX(c+2),l=y(e,i,mv,g,h,u,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let t=n.attributes.position,s=new ns,o=new ns,l=new ns,h=new ns,u=2,d=1/((a.scale.x+a.scale.y+a.scale.z)/3),c=d*d;for(let n=Math.max(0,f.start),d=Math.min(t.count,f.start+f.count)-1;n<d;n+=u){if(s.fromBufferAttribute(t,n),o.fromBufferAttribute(t,n+1),mv.distanceSqToSegment(s,o,h,l)>c)continue;h.applyMatrix4(a.matrixWorld);let u=i.ray.origin.distanceTo(h);u<i.near||u>i.far||r.push({distance:u,point:l.clone().applyMatrix4(a.matrixWorld),object:e})}}function y(e,t,i,r,s,a,n){let o=new ns,l=new ns,h=new ns,u=new ns,d=new ns;if(o.fromBufferAttribute(r,s),l.fromBufferAttribute(r,a),h.fromBufferAttribute(r,n),null===i.intersectTriangle(o,l,h,!1,u))return null;d.copy(u),d.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(d);return c<t.near||c>t.far?null:{faceIndex:1,distance:c,point:d.clone(),object:e}}}}),Lv=n(()=>{Mu(),Dv(),Iv(),vv=new ns(1,1,1),bv=new ns,xv=new ns,wv=new ss,_v=class extends(pv(du)){constructor(e,t=15){super(t),this.object=e,this.dummy=new ta,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){yv(this.object,_v.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(bv,wv,xv),this.matrix.compose(bv,wv,vv),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}}}),zv=n(()=>{Mu(),Sv=new ns,Mv=new ns,Tv=new As,Cv=[new ns(-1,1,1),new ns(-1,-1,1),new ns(1,-1,1),new ns(1,1,1),new ns(-1,1,-1),new ns(-1,-1,-1),new ns(1,-1,-1),new ns(1,1,-1)],Av=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Nv=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Pv=(e,t,i)=>{e.updateEntityBoxSize(Sv,Mv),Tv.copy(t).multiply(e.matrixWorld),0===Mv.x&&0===Mv.y&&0===Mv.z?i.push(new ns(Sv.x,Sv.y,Sv.z).applyMatrix4(Tv)):Cv.forEach(e=>{i.push(e.clone().multiply(Mv).add(Sv).applyMatrix4(Tv))})},Rv=class extends Sa{constructor(){super(...arguments),this.matrix=new As,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(e=>e.clone()),this.faces=e.faces.map(e=>e.clone()),this.edges=e.edges.map(e=>e.clone()),this.centerEdges=e.centerEdges.map(e=>e.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=(new As).copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];if(!0===i){let i=[];e.traverseEntity(e=>{if(e.visible||e.cloner&&e.data.visible){if(!("geometry"in e))return Tv.copy(t).multiply(e.matrixWorld),void i.push((new ns).applyMatrix4(Tv));Pv(e,t,r)}}),0===r.length&&r.push(...i)}else Pv(e,t,r);return this.setFromPoints(r)}getCenter(e){return(e=super.getCenter(e)).applyMatrix4(this.matrix),e}getPositionToCenter(e){return(e=super.getCenter(e)).applyMatrix4(Tv.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Mv).multiplyScalar(.5),this.getCenter(Sv),Tv.copy(this.matrix).setPosition(Sv),this.vertices=Cv.map(e=>e.clone().multiply(Mv).applyMatrix4(Tv))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Av.map(([e,t])=>new Qh(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new ns))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Nv.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}}}),kv=n(()=>{Ev={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function Uv(e){return!0===e?.isParticleSystem}function Fv(e){return!0===e?.isHairSystem}function jv(e){return!0===e?.isShapeBlendEntity}function Gv(e){return!0===e?.isObject2D}function Wv(e){return!0===e?.isUIObject}function qv(e){return!0===e?.isCloner}function Hv(e){return!0===e?.isClone}function $v(e){return!0===e?.isComponentObject}var Yv=n(()=>{});function Xv(e){rb.add(e)}function Kv(e,t){let i=`${e}:${t}`;sb.has(i)||sb.add(i)}function Zv(e){return ab.get(e)}function Jv(e,t){nb.set(e,t)}function Qv(e){return nb.get(e)}function eb(e,t){ob.set(e,t)}function tb(e){return ob.get(e)}function ib(){return lb}var rb,sb,ab,nb,ob,lb,hb=n(()=>{rb=new Set,sb=new Set,ab=new Map,nb=new Map,ob=new Map,lb=null});function ub(e,t,i){return function(e){let t=e.elements;db.set(t[0],t[1],t[2]),cb.set(t[4],t[5],t[6]),pb.set(t[8],t[9],t[10])}(e),function(){let e=Math.max(db.lengthSq(),cb.lengthSq(),pb.lengthSq());db.lengthSq()>yb*e?mb.copy(db).normalize():mb.set(1,0,0),gb.crossVectors(pb,mb),gb.lengthSq()<=yb*e&&(gb.copy(cb).addScaledVector(mb,-cb.dot(mb)),gb.lengthSq()<=yb*e&&function(e,t){e.set(1,0,0).cross(t),e.lengthSq()<=yb&&e.set(0,1,0).cross(t),e.normalize()}(gb,mb)),gb.normalize(),fb.crossVectors(mb,gb)}(),t.makeBasis(mb,gb,fb),i.set(mb.dot(db),mb.dot(cb),mb.dot(pb),0,gb.dot(db),gb.dot(cb),gb.dot(pb),0,fb.dot(db),fb.dot(cb),fb.dot(pb),0,0,0,0,1),function(){let e=db.length(),t=cb.length(),i=pb.length(),r=Math.max(e,t,i);if(r-e>vb||r-t>vb||r-i>vb)return!0;let s=vb*r*r;return Math.abs(db.dot(cb))>s||Math.abs(db.dot(pb))>s||Math.abs(cb.dot(pb))>s}()}var db,cb,pb,mb,gb,fb,yb,vb,bb,xb,wb,_b=n(()=>{Mu(),db=new ns,cb=new ns,pb=new ns,mb=new ns,gb=new ns,fb=new ns,new As,yb=1e-12,vb=.01}),Sb=n(()=>{Mu(),_b(),bb=new As,(xb||(xb={})).is=function(e){return e&&e.__isSPEObject},wb=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new As,this.copyPreviousMatrix=!0,this.hiddenMatrix=new As,this.pivotMatrix=new As,this.matrixWorldRigid=new As,this.shearScale=new As,this.shearScaleInv=new As}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(bb.copy(this.parent.matrixWorld).invert()),e.premultiply(bb.copy(this.hiddenMatrix).invert()),e.multiply(bb.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof ea&&(e=e.uuid);let t=this;for(;t.parent;){if(t.parent.uuid===e)return!0;t=t.parent}return!1}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let t of this.children)t.updateMatrixWorld(e)}updateWorldMatrix(e,t){let i=this.parent;if(e&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),t)for(let e of this.children)e.updateWorldMatrix(!1,!0)}traverseChildren(e,t=0){for(let i of this.children)xb.is(i)&&i.traverseObject(e,t+1)}traverseObject(e,t=0){if(!0!==e(this,t))for(let i of this.children)xb.is(i)&&i.traverseObject(e,t+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=ub(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(e,t){this.updateWorldMatrix(!0,!1);let i=(new As).copy(this.matrixWorld).invert();return null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),i.multiply(e.parent.matrixWorld)),"hiddenMatrix"in e&&e.hiddenMatrix instanceof As?e.hiddenMatrix.premultiply(i):e.applyMatrix4(i),e.updateWorldMatrix(!1,!1),this.add(e),void 0!==t&&(this.children.pop(),this.children.splice(t,0,e)),this}copy(e,t=!1){return super.copy(e,t),this.hasNonUniformScale=e.hasNonUniformScale,this}onAfterRender(e,t,i,r,s,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function Mb(e,t,i){return Ab.subVectors(t,e),Nb.subVectors(t,i),Ab.cross(Nb).length()<=Cb}var Tb,Cb,Ab,Nb,Pb,Rb,Eb,Ob,Bb,Vb,Db,Ib,Lb,zb,kb,Ub,Fb,jb,Gb,Wb,qb,Hb,$b,Yb,Xb,Kb,Zb,Jb=n(()=>{Mu(),Tb=class extends al{constructor(){super()}getPoints(e=12){let t,i=[],r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a<n.length;a++){let o=n[a],l=0===a?r[a]:r[a]-r[a-1],h=Math.ceil(e*l/s),u=o.getPoints(h);for(let e=0;e<u.length;e++){let r=u[e];t&&t.equals(r)||(i.push(r),t=r)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},Cb=.001,Ab=new ns,Nb=new ns,Pb=new ns,Rb=new ns,Eb=new ns,Ob=new ns,Bb=new ns,Vb=new ns,Db=new ns,Ib=new WeakMap}),Qb=n(()=>{Mu(),Bv(),zv(),um(),md(),kv(),Yv(),hb(),Sb(),Jb(),md(),(Lb||(Lb={})).is=function(e){return e&&e.__isEntity},zb=e=>Lb.is(e),kb={type:"completeState",isfromEntity:!0},Ub=["x","y","z"],Fb=new ns,jb=new ns(1,1,1),Gb=new ss,Wb=new Ls,qb=(new ns).set(0,1,0),Hb=new As,$b=new As,Yb=e=>class extends(wb(e)){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new Rv,this._recursiveBBox=new Rv,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(e){let t=this.children[e];if(Lb.is(t))return t}entityChildrenCount(){let e=this.children.length;for(;e--;)if(Lb.is(this.children[e]))return e+1;return 0}get isConcreteEntity(){return"string"==typeof this.identity}get isVirtualEntity(){return"string"!=typeof this.identity}get isInstanceRoot(){return this.isConcreteEntity&&"Instance"===this.data.type}nearestInstanceSelfOrParent(){let e=this;for(;"Instance"!==e.data.type;){let t=e.parent;if(!Lb.is(t))return;e=t}return e}forInstancesRec(e){this.instances.forEach(t=>{t.disposed||e(t),t.forInstancesRec(e)})}super_Entity(e,t){"string"==typeof e&&(this.uuid=e),this.identity=e,this.data=t,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(e,t,i=!1){if(0!==this.data.states.length||i){for(let e of this.data.states)jf.toOps(this.data,e.data).forEach(e=>{let i=sc.replaceProps(e,this.data);this.dataPatched=this.data,this.updateByPatchedOp(i,this.data,t)});if(null!==e){let i=this.data.states.data(e);i&&(this.dataPatched=jf.patch(this.data,i),jf.toOps(this.data,i).forEach(e=>{this.updateByPatchedOp(e,this.dataPatched,t)}))}i&&this.updateTransformState(this.dataPatched,t),this.stateSelection=e,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(e,t){e.setScalar(0),t.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{zb(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let t;return this.traverseEntity(i=>{i.uuid===e&&(t=i)}),t}traverseSortNextHelper(){let e=this.parent;if(e){let t=e.children,i=t.indexOf(this)+1;if(Lb.is(t[i]))return t[i];if(Lb.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&Lb.is(this.children[0])?e[0]:this.traverseSortNextHelper()}goUp(e){let t=this;for(;e>0&&null!==t;)t=t.parent,e-=1;return t}hasAnccestorOrSelf(e){return this===e||this.hasAnccestor(e)}hasAnccestor(e){let t=this.parent;for(;t;){if(e===t)return!0;t=t.parent}return!1}countToAccestor(e){let t=0,i=this;for(;i!==e;){if(null===i)return-1;i=i.parent,t+=1}return t}forEachEntity(e){for(let t of this.children)zb(t)&&e(t)}traverseEntityAncestors(e){this.traverseAncestors(t=>{Lb.is(t)&&e(t)})}traverseConcreteEntity(e,t=0){if(!0!==e(this,t))for(let i of this.children)zb(i)&&i.isConcreteEntity&&i.traverseEntity(e,t+1)}traverseEntity(e,t=0){if(!0!==e(this,t))for(let i of this.children)zb(i)&&i.traverseEntity(e,t+1)}traverseVisibleEntity(e){e(this);for(let t of this.children)zb(t)&&t.visible&&t.traverseVisibleEntity(e)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(e){super.updateMatrixWorld(e),this.dispatchEvent({type:"updateMatrixWorld"})}copy(e,t=!1){return super.copy(e,t),this.dataPatched=e.dataPatched,this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this.hiddenMatrix.copy(e.hiddenMatrix),this}hasEntityChild(){return this.children.some(e=>zb(e))}isAncestorOf(e){if(this.uuid===e)return!1;let t=!1;return this.traverseEntity(i=>{i.uuid===e&&(t=!0)}),t}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),Ku({position:this.position.toArray(),rotation:[this.rotation.x*ts.RAD2DEG,this.rotation.y*ts.RAD2DEG,this.rotation.z*ts.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,t,i){return t[e].map((t,r)=>i?.shared.getVariable(t,[this.uuid,e,Ub[r]])??t)}updateTransformState(e,t){let i=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,t)),i=!0),e.rotation&&(Fb.fromArray(this.getTransformValues("rotation",e,t)).multiplyScalar(ts.DEG2RAD),this.rotation.setFromVector3(Fb),i=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,t)),i=!0),void 0!==e.hiddenMatrix&&(i=!0,this.hiddenMatrix.fromArray(e.hiddenMatrix??Sm.identity)),void 0!==e.pivot||void 0!==e.pivotRotation)if(i=!0,void 0!==e.pivot&&void 0!==e.pivotRotation)this.pivotMatrix.compose(Fb.fromArray(e.pivot).negate(),Gb.setFromEuler(Wb.fromArray(e.pivotRotation.map(e=>e*ts.DEG2RAD))).invert(),jb);else if(void 0!==e.pivot)this.pivotMatrix.setPosition(-e.pivot[0],-e.pivot[1],-e.pivot[2]);else if(void 0!==e.pivotRotation){let t=Fb.setFromMatrixPosition(this.pivotMatrix);Gb.setFromEuler(Wb.fromArray(e.pivotRotation.map(e=>e*ts.DEG2RAD))).invert(),this.pivotMatrix.compose(t,Gb,jb)}return i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(e=>{e.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&void 0!==e.hiddenMatrix&&this.updateWorldMatrix(!1,!0),i}onVariableUpdate(e=!1){e?this.resetBBoxNeedsUpdate():(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(e=>{e.invalidateClonerTransform(this)}),this.requestRender())}dispose(){this.disposed=!0,this.cloner&&(this.cloner.dispose(),this.cloner=void 0)}disposeChildrenRecursively(){for(let e of this.children)Lb.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{Lb.is(e)&&e.disposeRecursively()})}toState(e=[]){return Ku({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(e)},e)}updateByObjUpdateOp(e,t){void 0!==e&&this.updateByOp({type:0,props:e,path:[]},{...this.data,...e},t,!1)}updateByOp(e,t,i,r){let s=this.data;this.data=t;let a=e,n=Rc(e.path,["states","*"]);if(null!==n){if(0===e.type){let[t]=n;if(this?.stateSelection===t){let t={...e.props};if(delete t.name,Object.values(e.props).some(e=>void 0===e)){let i=this.data;if(void 0!==i){let r=Cc.zoom(i,e.path.slice(2));if(r)for(let i in e.props)void 0===e.props[i]&&i in r&&(t[i]=r[i])}}a={...e,props:t,path:e.path.slice(2)}}}}else if(0===e.type){let t=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(void 0!==t){if(void 0!==e.props.name&&t.name){let{name:e,...i}=t;t=i}if(void 0!==e.props.material&&"material"in t){let{material:e,...i}=t;t=i}let i=Cc.removeOverridden(e.path,e.props,t);a={...e,props:i}}}if(this.updateByPatchedOpBase(a,jf.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Rc(e.path,["overrides"])){let r=[],s=[...e.path];for(r.push(s[1]),s.splice(0,2);s.length>0&&"descendants"===s[0];)r.push(s[1]),s.splice(0,2);if(void 0===r[r.length-1]){if(0===e.type)for(let t of Object.keys(e.props)){r[r.length-1]=t;let s=i.scene.findInstance([this.uuid,...r]);s&&(s.overrideData=e.props[t],s.updateState(rc.apply(s.component.data,s.overrideData),i))}}else{let a=i.scene.findInstance([this.uuid,...r]);if(a){let n=Cc.zoom(a.component.data,s);if(0===(e={...e,path:s}).type){let t=e.props;if(n)for(let[i,r]of Object.entries(e.props))void 0===r&&(t===e.props&&(t={...e.props}),t[i]=n[i]);e={...e,props:t}}a.overrideData=zf.resolve(t.overrides,r),a.updateByOp(e,ac.applySimple(a.data,e),i,!1)}}}else if(this.instances.length>0){let r;if(0===e.path.length&&0===e.type){let t;for(let i of kf.rootOverrideProps)i in e.props&&(void 0===t&&(t={}),t[i]=e.props[i]);t&&(r={...e,props:t})}else for(let t of kf.rootOverrideProps)if(Rc(e.path,[t])){r=e;break}void 0!==r&&this.instances.forEach(e=>{if(e.isInstanceRoot){let t=rc.filterOp(e.overrideData,r);t&&e.updateByOp(t,ac.applySimple(e.data,t),i,!0)}}),this.instances.forEach(r=>{if(!r.isInstanceRoot){let a=rc.filterOp(r.overrideData,e);if(a){let n;n=s===r.data&&e===a?t:ac.applySimple(r.data,a),r.updateByOp(a,n,i,!0)}}})}}updateByPatchedOpBase(e,t,i){if(this.dataPatched=t,0===e.path.length&&0===e.type)void 0!==e.props.type&&!rg.is(e.props.type)&&Ev.changeEntityProptotype(this,t,i);else if(1===e.path.length&&"geometry"===e.path[0]&&0===e.type&&"type"in e.props){Ev.changeEntityProptotype(this,t,i);for(let e of this.children)Lb.is(e)&&e.updateVisible(i.scene)}this.updateByPatchedOp(e,t,i)}updateByPatchedOp(e,t,i){if(0===e.path.length&&0===e.type?this.updateState(e.props,i):0===e.type&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(t,i),"morphTargetInfluences"===e.path[0]&&0===e.type){let r=t.morphTargetInfluences.get(e.path[1])?.data.name;r&&this.updateMorphInfluences(r,i.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",r]))}if(null!==Rc(e.path,["pathSnapping"])&&this.updatePathSnapping(t.pathSnapping),null!==Rc(e.path,["cloner"])){let r=ac.drop(e,1);0===r.path.length&&0===r.type&&!0===r.props.disabled?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(t.cloner,i):(this.setFromClonerState(t.cloner,i),this.expandCloner(i)),this.updateVisible(i.scene)}}updatePathSnapping(e=this.dataPatched.pathSnapping){this._updatedPathSnapping=e,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(e){if(!1===this._needApplyPathSnapping)return;let t=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,r=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(null===t)return;let a=e.find(t);if(!a)return;this._needApplyPathSnapping=!1;let n=a.data;if(n.geometry.path.points.length<=1)return;let o=function(e){let t=Ib.get(e.points);if(void 0!==t&&t.isClosed===e.isClosed)return t.curve;let i=function(e){let t=e.points,i=[t[0]],r=[new ns(...t[0].data.position)];Pb.copy(r[0]);for(let e=0;e<t.length-1;e++)Ab.fromArray(t[e].data.position),Nb.fromArray(t[e+1].data.position),Eb.subVectors(Ab,Pb),Bb.subVectors(Ab,Nb),Eb.cross(Bb).length()>Cb&&(i.push(t[e]),r.push((new ns).copy(Ab)),Pb.copy(Ab));let s=t[t.length-1];i.push(s),r.push(new ns(...s.data.position));let a=e.isClosed,n=i.length-(a?0:1),o=i.length,l=[],h=[];for(let e=0;e<o;e++){let t=i[e].data;l.push(new ns(...t.controlPrevious.position)),h.push(new ns(...t.controlNext.position))}let u=[];for(let e=0;e<n;e++){let t=e===o-1?0:e+1;u.push(Mb(r[e],h[e],r[t])&&Mb(r[e],l[t],r[t]))}let d=[];for(let e=0;e<o;e++){let t=i[e].data,s=r[e],n={position:s,prevDir:void 0,nextDir:void 0,controlPrevious:l[e],controlNext:h[e],tan:void 0,baseRoundness:t.roundness,removedLength:0};if(d.push(n),0===t.roundness||!a&&(0===e||e===o-1))continue;let c=a&&0==e?o-1:e-1,p=a&&e==o-1?0:e+1,m=(new ns).subVectors(r[c],s).normalize(),g=(new ns).subVectors(r[p],s).normalize();n.prevDir=m,n.nextDir=g;let f=u[a&&0===e?o-1:e-1],y=u[e];if(f&&y){Rb.addVectors(m,g).normalize();let e=Pb.crossVectors(Rb,m).length()/m.dot(Rb);n.tan=e,n.removedLength=t.roundness/e}}for(let e=0;e<n;e++){let t=a&&e===o-1?0:e+1,i=d[e],r=d[t];if(0!==i.removedLength||0!==r.removedLength){let e=i.position.distanceTo(r.position);i.removedLength=Math.min(i.removedLength,e/2),r.removedLength=Math.min(r.removedLength,e/2)}}let c=new Array(2*o).fill(null);for(let e=0;e<n;e++){let t=a&&e===o-1?0:e+1,i=d[e],r=d[t],s=null;if(u[e]){let e=i.position.clone(),t=r.position.clone();(0!==i.removedLength||0!==r.removedLength)&&(i.nextDir&&e.add(Pb.copy(i.nextDir).setLength(i.removedLength)),r.prevDir&&t.add(Pb.copy(r.prevDir).setLength(r.removedLength))),e.distanceTo(t)>Cb&&(s=new Jo(e,e.clone().lerp(t,.3),t.clone().lerp(e,.3),t))}else i.position.distanceTo(r.position)>Cb&&(s=new Jo(i.position,i.controlNext,r.controlPrevious,r.position));c[2*e+1]=s}for(let e=0;e<o;e++){let t=d[e];if(0===t.removedLength)continue;let i=t.position,r=t.prevDir.clone().multiplyScalar(t.removedLength).add(i),s=t.nextDir.clone().multiplyScalar(t.removedLength).add(i),a=t.tan*t.removedLength;Rb.addVectors(t.prevDir,t.nextDir).normalize(),Eb.copy(r).lerp(s,.5);let n=r.distanceTo(s)/2;Db.copy(Rb).multiplyScalar(Math.sqrt(Math.pow(a,2)-Math.pow(n,2))).add(Eb),Ob.copy(Rb).multiplyScalar(-a).add(Db);let o=i.distanceTo(Ob)/i.distanceTo(Eb);Bb.copy(t.prevDir).multiplyScalar(o*i.distanceTo(r)).add(i),Vb.copy(Bb).lerp(Ob,2);let l=r.clone().lerp(Bb,4/3),h=s.clone().lerp(Vb,4/3);c[2*e]=new Jo(r,l,h,s)}let p=new Tb;for(let e=0;e<c.length;e++){let t=c[e];t&&p.add(t)}return p}(e);return Ib.set(e.points,{isClosed:e.isClosed,curve:i}),i}(n.geometry.path),l=(i+r)%1;i+r===1&&0===l&&(l=1);let h=null;try{h=o.curves.length?o.getPointAt(l):null}catch(e){Su&&(console.warn(`The aligned path on ${this.name} is invalid. (${a.name})`),console.error(e))}if(null===h)return;a.updateMatrixWorld();let u=this.parent?Hb.copy(this.parent.matrixWorld).invert():Hb.identity();u.multiply(a.matrixWorld),h.applyMatrix4(u);let d={position:h.toArray(),rotation:n.rotation};if("tangential"===s){let e=$b.extractRotation(a.matrixWorld),t=o.getTangentAt(l).applyMatrix4(e).add(h),i=$b.lookAt(h,t,qb),r=Fb.setFromEuler(Wb.setFromRotationMatrix(i)).multiplyScalar(ts.RAD2DEG);d={...d,rotation:r.toArray()}}this.updateTransformState(d),this.traverseEntity(e=>{e._cameraType&&e.dispatchEvent(kb)})}updateVisible(e){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||!0!==this.dataPatched.cloner?.hideBase),!e)return;let t=!1;this.traverseEntity(e=>{if("Splat"===e.data.type)return t=!0,!0}),t&&e.reloadSplats()}updateState_Entity(e,t){void 0!==e.name&&(this.name=e.name),void 0!==e.raycastLock&&(this.raycastLock=e.raycastLock),void 0!==e.visible&&(this.updateVisible(t?.scene),this.resetBBoxNeedsUpdate()),t&&"cloner"in e&&void 0!==e.cloner&&(this.setFromClonerState(e.cloner,t),this.updateVisible(t.scene)),this.updateTransformState(e,t)}get attachedSurfaceCloners(){return this.children.filter(e=>qv(e)&&"toObject"===e.parameters.type)}setFromClonerState(e,t){if(!this.disposed)if(null===e||e.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(void 0===this.cloner){if(null===Ev.Cloner)return void Kv("cloners","a cloner");this.cloner=new Ev.Cloner(this,e),t.scene.addPendingExpandCloner(this)}else this.cloner.updateState(e,t)}expandCloner(e){!this.disposed&&this.cloner&&this.cloner.expandClones(e)}invalidateClonerTransform(e){this.cloner&&this.cloner.invalidateTransform(e)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),ex=n(()=>{Mu(),Qb(),(Xb||(Xb={})).is=e=>"objectHelper"in e,Kb=(e,t)=>class extends(Yb(e)){constructor(){super(...arguments),this.objectHelper=new t(this),this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(e,t){this.objectHelper.raycast(e,t)}showGizmos(){for(let e in this.gizmos){let t=this.gizmos[e];t instanceof uu&&(t.visible=!0)}}updateEntityBoxSize(e,t){this.objectHelper.visible&&this.geometryHelper instanceof Lo?(e.setScalar(0),t.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(e,t)}hideGizmos(){for(let e in this.gizmos){let t=this.gizmos[e];t instanceof uu&&(t.visible=!1)}}}}),tx=n(()=>{Mu(),Lv(),ex(),Zb=class extends(Kb(ta,_v)){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),"Empty"===this.data.type&&(this.objectHelper.visible=!1)}updateState(e,t){this.updateState_Entity(e,t),"buffer"in e&&1===Object.keys(e).length&&t.scene.reloadSplats()}}});function ix(e,t,i,r,s,a,n){rx.set(s,a,n).unproject(r);let o=t[e];if(void 0!==o){let e=i.getAttribute("position");for(let t=0,i=o.length;t<i;t++)e.setXYZ(o[t],rx.x,rx.y,rx.z)}}var rx,sx,ax,nx,ox=n(()=>{Mu(),Dv(),Iv(),rx=new ns,sx=new th,ax=class extends Po{constructor(e){let t=new an,i=new vo({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={},n=new aa(15711266),o=new aa(15711266),l=new aa(2857471);function h(e,t,i){u(e,i),u(t,i)}function u(e,t){r.push(0,0,0),s.push(t.r,t.g,t.b),void 0===a[e]&&(a[e]=[]),a[e].push(r.length/3-1)}h("n1","n2",n),h("n2","n4",n),h("n4","n3",n),h("n3","n1",n),h("f1","f2",n),h("f2","f4",n),h("f4","f3",n),h("f3","f1",n),h("n1","f1",n),h("n2","f2",n),h("n3","f3",n),h("n4","f4",n),h("p","n1",o),h("p","n2",o),h("p","n3",o),h("p","n4",o),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),t.setAttribute("position",new Ha(r,3)),t.setAttribute("color",new Ha(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,t=this.pointMap;sx.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;ix("n1",t,e,sx,-1,-1,i),ix("n2",t,e,sx,1,-1,i),ix("n3",t,e,sx,-1,1,i),ix("n4",t,e,sx,1,1,i);let r=i;ix("f1",t,e,sx,-1,-1,r),ix("f2",t,e,sx,1,-1,r),ix("f3",t,e,sx,-1,1,r),ix("f4",t,e,sx,1,1,r);let s=r;ix("u1",t,e,sx,.35,1.1,s),ix("u2",t,e,sx,-.35,1.1,s),ix("u3",t,e,sx,0,1.55,s),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},nx=class extends(pv(ax)){constructor(e){super(e),this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){yv(this.object,this.geometry,e,t,!0)}}});function lx(e){return 1-Math.pow(1-e,3)}var hx,ux,dx,cx,px,mx,gx,fx,yx=n(()=>{Mu(),ox(),Bv(),ex(),md(),hx=new ns,ux=new ns,dx=new ss,cx=new ns,px=new ns,mx=new ns,gx=class extends(Kb(th,nx)){constructor(e="",t={...If.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=sg.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(void 0===e)return;if(this.disposed)return void this._endProjectionTransition();e.raf=requestAnimationFrame(this._tickProjectionTransition);let t=gx.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),t?.()},this.super_Entity(e,t),this.previousProjectionMatrix=new As,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new uh(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new ah(45,i/r,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(e){let t=gx.projectionTransitionsEnabled;gx.projectionTransitionsEnabled=!1;try{return e()}finally{gx.projectionTransitionsEnabled=t}}get isPerspectiveCamera(){return"PerspectiveCamera"===this.cameraType}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){"PerspectiveCamera"===e?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&("PerspectiveCamera"===e?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){"PerspectiveCamera"===e?this.toPerspective():"OrthographicCamera"===e&&this.toOrthographic()}get near(){return"PerspectiveCamera"===this._cameraType?this.perspCamera.near:this.orthoCamera.near}set near(e){"PerspectiveCamera"===this._cameraType?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return"PerspectiveCamera"===this._cameraType?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&("PerspectiveCamera"===this._cameraType?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,i){"number"==typeof e&&(e=new ns(e,t,i)),super.lookAt(e),this.getWorldPosition(hx),this.targetOffset=hx.distanceTo(e)}getTarget(e=new ns){return this.getWorldDirection(ux),this.getWorldPosition(hx),ux.multiplyScalar(this.targetOffset),e.copy(hx).add(ux),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(hx),hx.distanceTo(e)}updateUp(){this.getWorldQuaternion(dx),cx.set(0,0,1).applyQuaternion(dx),px.copy(ea.DEFAULT_UP),this.isUpVectorFlipped&&px.negate(),px.applyQuaternion(dx),mx.copy(ea.DEFAULT_UP).projectOnPlane(cx),this.angleOffsetFromUp=mx.angleTo(px),this.angleOffsetFromUp*=mx.cross(px).dot(cx)>=0?1:-1}updateTransformState(e,t){let i=super.updateTransformState(e,t);return void 0!==e.isUpVectorFlipped&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let t=e.getWorldPosition(new ns),i=e.getWorldDirection(new ns).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let t=this.getWorldDirection(new ns).multiplyScalar(this.targetOffset);return{position:e.clone().sub(t),target:e}}getViewToObject(e){let t=new ns;return e.getWorldPosition(t),this.getViewToTarget(t)}setViewplaneSize(e,t,i=!1){if(this.aspect=e/t,i){let i=e>t?this.aspect:1,r=e>t?1:this.aspect;this.left=-395*i,this.right=395*i,this.top=1/r*395,this.bottom=1/r*-395}else this.left=.5*-e,this.right=.5*e,this.top=.5*t,this.bottom=.5*-t;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return void 0!==this._projectionTransition}get projectionTransitionProgress(){let e=this._projectionTransition;if(void 0===e)return 1;let t=(performance.now()-e.start)/e.duration;return t>=1?1:t<=0?0:lx(t)}get _activeSubCamera(){return"PerspectiveCamera"===this._cameraType?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return gx.projectionTransitionsEnabled&&"function"==typeof requestAnimationFrame&&typeof performance<"u"&&performance.now()-this._createdAt>=gx.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let t=this._projectionTransition;void 0===t&&(t={from:new As,blend:new As,blendInverse:new As,start:0,duration:gx.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=t),t.from.copy(this.projectionMatrix),t.start=performance.now(),t.duration=gx.projectionTransitionDuration,t.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(t.requestRender=e),0!==t.raf&&cancelAnimationFrame(t.raf),t.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(void 0===e)return;let t=(performance.now()-e.start)/e.duration;if(t>=1)return void this._endProjectionTransition();let i=lx(t),r=e.from.elements,s=this._activeSubCamera.projectionMatrix.elements,a=e.blend.elements,n=e.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*n),l=i*o/(i*o+(1-i)*Math.max(1e-6,s[15]-s[11]*n));for(let e=0;e<16;e++)a[e]=r[e]+(s[e]-r[e])*l;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(void 0===e)return;0!==e.raf&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let t=this._activeSubCamera;this.projectionMatrix=t.projectionMatrix,this.projectionMatrixInverse=t.projectionMatrixInverse}_syncProjectionTransition(e){let t=e._projectionTransition;if(void 0===t)return void(void 0!==this._projectionTransition&&this._endProjectionTransition());let i=this._projectionTransition;void 0===i?(i={from:new As,blend:new As,blendInverse:new As,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):0!==i.raf&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(t.from),i.start=t.start,i.duration=t.duration,i.referenceDepth=t.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,i,r,s,a){"PerspectiveCamera"===this._cameraType?this.perspCamera.setViewOffset(e,t,i,r,s,a):this.orthoCamera.setViewOffset(e,t,i,r,s,a),this._applyProjectionTransition()}clearViewOffset(){"PerspectiveCamera"===this._cameraType?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){"PerspectiveCamera"===this._cameraType?this.toPerspective():"OrthographicCamera"===this._cameraType&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=null===e.view?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=sg.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){return Ku({type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped},e)}updateCameraSubtype(e,t){let i="perspective"===e?"PerspectiveCamera":"OrthographicCamera";void 0!==t.zoom&&this.setZoom(i,t.zoom),void 0!==t.near&&this.setNear(i,t.near),void 0!==t.fov&&"PerspectiveCamera"===i&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),void 0!==e.far&&(this.far=e.far),void 0!==e.orthographic&&this.updateCameraSubtype("orthographic",e.orthographic),void 0!==e.perspective&&this.updateCameraSubtype("perspective",e.perspective),void 0!==e.type&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(t?.shared.requestRender),this.cameraType=e.type),void 0!==e.up&&this.up.fromArray(e.up.map(e=>"number"==typeof e?e:0)),void 0!==e.targetOffset&&(this.targetOffset=sg.sanitizeTargetOffset(e.targetOffset)),void 0!==e.isUpVectorFlipped&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),1===e.path.length&&0===e.type&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},(fx=gx).projectionTransitionsEnabled=!1,fx.projectionTransitionDuration=350,fx.projectionTransitionMinAgeMs=1e3});function vx(e){return"TorusGeometry"===e.type&&360===e.arc}var bx,xx,wx,_x=n(()=>{Mu(),bx=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),a=Math.abs(i.depth??r),n=Math.abs(Math.min(r,a))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:a,radius:n,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:a,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:d}=e.parameters,c=new wx(!1,t,i,r,s,a,n,o,l,h,u,d);return Object.assign(c,{userData:{...e,type:"HelixGeometry"}})}},xx=new Wa([0,0,0],1),wx=class extends an{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,u=1,d=1){if(super(),0===a)return;let c=e&&1===a;c&&(d=0),u>100&&(u=100),0===u&&(d=0);let p,m,g,f,y,v,b,x,w=()=>new ns,_=new ns,S=w(),M=w(),T=w(),C=w(),A=w(),N=w(),P=w(),R=w(),E=w(),O=w(),B=w(),V=i-2*o+.001,D=V/a,I=Math.ceil(n*a),L=I+1,z=V/I,k=-V/2,U=h+1,F=2*Math.PI/h,j=Math.PI/2/d,G=Math.min((1-u/100)*o,o-.01),W=o-G,q=0,H=2*d+2,$=U*H/2,Y=$+U*L,X=Math.max(0,U*(L+H)),[K,Z,J]=[3,3,2].map(e=>Array(X*e).fill(0)),Q=[],ee=s-o;function te(t,i){let r=Math.PI/2;v=i*z,x=2*Math.PI*(v%D)/D+r,v+=k,b=Math.sin(x)*ee,y=Math.cos(x)*ee,e?t.set(y,b,v):t.set(y,v,b)}te(_,-1e-10),te(S,0),C.copy(_),te(_,1);let ie=_.distanceTo(S),re=c?0:W+G,se=ie*I+2*re,ae=G,ne=se-re;for(let t=0;t<=I;t++){te(M,t),B.subVectors(M,C).normalize(),C.copy(M),E.copy(M).setComponent(+e+1,0).normalize(),O.crossVectors(B,E).normalize();let i=0===t,r=t===I,s=i?3*Math.PI/2:j,a=i?ae:ne,n=i?U:Y,l=i?0:X-U,u=B.clone().multiplyScalar(i?-W:W).add(M),p=B.clone().multiplyScalar(i?-1:1).normalize();for(let e=0;e<U;e++){let m=e*F;if(A.addVectors(_.copy(E).multiplyScalar(o*Math.cos(m)),S.copy(O).multiplyScalar(o*Math.sin(m))),N.copy(A).normalize(),i||r){c||(q=l+e,[0,1,2].forEach(e=>{K[3*q+e]=u.getComponent(e),Z[3*q+e]=p.getComponent(e)}),J[2*q]=+r,J[2*q+1]=e/h),S.copy(N).multiplyScalar(G),T.addVectors(M,S);for(let t=0;t<d;t++){let r=t*j+s;P.addVectors(_.copy(B).multiplyScalar(W*Math.sin(r)),S.copy(N).multiplyScalar(W*Math.cos(r))),R.copy(P).normalize(),S.addVectors(T,P),P.normalize(),q=n+t*U+e,[0,1,2].forEach(e=>{K[3*q+e]=S.getComponent(e),Z[3*q+e]=R.getComponent(e)});let o=+i+Math.sin(r);J[2*q]=(a+W*o)/se,J[2*q+1]=e/h}}S.addVectors(M,A),q=$+t*U+e,[0,1,2].forEach(e=>{K[3*q+e]=S.getComponent(e),Z[3*q+e]=N.getComponent(e)}),J[2*q]=(re+t*ie)/se,J[2*q+1]=e/h}}let oe=L+2*d+2,[le,he]=[+c,oe-1];for(let e=le;e<=he-1;e++){let t=c&&e===he-1;for(let i=0;i<U-1;i++)p=e*U+i,m=p+1,g=(t?i:p)+U,f=(t?i+1:m)+U,0===e?Q.push(m,f,g):e===oe-2?Q.push(p,m,g):Q.push(p,m,g,m,f,g)}this.setIndex(Q),this.setAttribute("position",new Ha(K,3)),this.setAttribute("normal",new Ha(Z,3)),this.setAttribute("uv",new Ha(J,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e,t,i,r,s=this.userData.parameters,a=Math.ceil(s.tubularSegments),n=s.radialSegments,o=n+1,l=[];for(let s=1;s<a;s++)for(let a=0;a<n;a++)e=s*o+a,t=e+1,i=e+o,r=t+o,l.push(e,t,i,t,r,i);for(let s=0;s<n;s++)e=a*o+s,t=e+1,i=s+o,r=s+1+o,l.push(e,t,i,t,r,i);return xx.array=new Uint32Array(l),xx.count=l.length,xx}}});function Sx(e){return Bx||(Bx=async function(){let t=e??(Su?".":"https://cdn.spline.design/@splinetool/runtime@2.0.2/build"),i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(e=>e.arrayBuffer())]);await r.default({module_or_path:s}),Rx=r}())}function Mx(){if(void 0===Rx)throw new Error("boolean-wasm is not loaded");return Rx}function Tx(e){let t=Ex.get(e);if(void 0===t)throw new Error("Unknown csg mesh set handle "+e);return t}function Cx(e){return Ex.set(++Ox,e),Ox}function Ax(e,t,i){if(void 0===Rx)return-1;let{positions:r,indices:s,normals:a}=function(e,t){if(t&&void 0!==e.userData.positions){let t=e.userData,i=[];for(let e=0,r=0;e<t.verticesPerFace.length;e++){let s=t.verticesPerFace[e];for(let e=1;e<s-1;e++)i.push(t.indices[r],t.indices[r+e],t.indices[r+e+1]);r+=s}return{positions:t.positions instanceof Float32Array?t.positions:new Float32Array(t.positions),indices:new Uint32Array(i)}}let i;i=vx(e.userData.parameters)?e.getClosedTorusIndicesForBooleanOrSubdiv():e.getIndex();let r,s=e.getAttribute("position");if(null===i){r=new Uint32Array(s.count);for(let e=0;e<r.length;e++)r[e]=e}else r=i.array instanceof Uint32Array?i.array:new Uint32Array(i.array);let a=e.getAttribute("normal"),n=void 0!==a&&3===a.itemSize&&a.count===s.count&&a.array instanceof Float32Array&&!0!==a.isInterleavedBufferAttribute?a.array:void 0;return{positions:s.array,indices:r,normals:n}}(e,t);return Cx(new Rx.CsgMesh(r,s,a))}function Nx(e,t){let i=Mx(),r=Vx[t];if(void 0===r)throw new Error("Unknown boolean operation "+t);let s=e.map(Tx);if(1===s.length)return i.clone_mesh(s[0]);let a,n=[];if(2===t&&s.length>2){let e=s[0];for(let t=1;t<s.length-1;t++)e=i.boolean_mesh(e,s[t],0),n.push(e);a=i.boolean_mesh(s[s.length-1],e,2)}else if(2===t)a=i.boolean_mesh(s[1],s[0],2);else{let e=s[s.length-1];for(let t=0;t<s.length-1&&(e=i.boolean_mesh(e,s[t],r),n.push(e),0!==e.tri_count());t++);a=e,n.pop()}for(let e of n)e.free();return a}function Px(e,t){Tx(e).transform(new Float32Array(t.elements))}var Rx,Ex,Ox,Bx,Vx,Dx=n(()=>{Mu(),md(),_x(),Ex=new Map,Ox=0,Vx={0:0,1:1,2:2}});function Ix(e){return null!==e&&"booleanOp"in e}var Lx,zx,kx=n(()=>{Mu(),Qb(),Dx(),Lx=class extends(Yb(Hn)){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new As}updateVisible(e){super.updateVisible(e),this.visible=!Ix(this.parent)&&this.visible,Ix(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){-1!==this.booleanMeshSetAddress&&(function(e){let t=Ex.get(e);void 0!==t&&(t.free(),Ex.delete(e))}(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ix(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Lx&&(e.freeBooleanPointer(),Ix(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Ix(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ix(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),Ux=n(()=>{zx=null});function Fx(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let r=t;r<i;r++){let t=e.getX(r),i=e.getY(r),s=e.getZ(r);t<a&&(a=t),i<n&&(n=i),s<o&&(o=s),t>l&&(l=t),i>h&&(h=i),s>u&&(u=s)}jx.min.set(a,n,o),jx.max.set(l,h,u),jx.getCenter(r),jx.getSize(s).multiplyScalar(.5)}var jx,Gx,Wx,qx,Hx=n(()=>{Mu(),kx(),Ux(),jx=new Sa,Gx=new an,Wx=new Vn,qx=class extends Lx{constructor(e,t){super(Gx,Wx),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}raycast(e,t){let i=zx;null===i?super.raycast(e,t):i(this,e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");void 0!==i?Fx(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}}});function $x(e){return!0===e?.isClassicNodeMaterial}var Yx,Xx,Kx,Zx,Jx,Qx,ew,tw,iw=n(()=>{}),rw=n(()=>{Mu(),Yx=class extends aa{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if("transparent"===e)return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a="rgba"===s?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a="hsla"===s?parseFloat(r[4]):1,super.setStyle(e,t)}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}}}),sw=n(()=>{rw(),Xx=class extends Yx{}}),aw=n(()=>{Kx=class{constructor(e=1e4){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev,t.next=null,t.prev=null,t.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;){this.dispose(t.src,t.data),this.cache.delete(t.src);let e=t;t=t.next,t.prev=this.head,this.head.next=t,e.next=null,e.prev=null,e.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return void 0===i?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){null!==this.cleanupTimer&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((e,t)=>{this.dispose(t,e.data),e.next=null,e.prev=null,e.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),nw=n(()=>{aw(),Zx=class extends Kx{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}}}),ow=n(()=>{md(),Qx=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){if(0===this.refCount&&Su)throw new Error("ref count -1?");this.refCount-=1,0===this.refCount&&(this.cache.remove(this),this.dispose())}dispose(){if(0!==this.refCount&&Su)throw new Error("ref count is not 0")}},ew=class{constructor(){this.cache=new Map}remove(e){if(!1===this.cache.delete(e.data)&&Su)throw new Error("ref count remove non-exists")}load(e){let t=this.cache.get(e);return void 0===t&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}}}),lw=n(()=>{Mu(),tw=class extends ql{constructor(e){super(e),this.type=ii}parse(e){let t=function(e,t){switch(e){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(t||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(t||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(t||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(t||""))}},i=function(e,t,i){t=t||1024;let r=e.pos,s=-1,a=0,n="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));for(;0>(s=o.indexOf("\n"))&&a<t&&r<e.byteLength;)n+=o,a+=o.length,r+=128,o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<s&&(!1!==i&&(e.pos+=a+s+1),n+o.slice(0,s))},r=function(e,t,i,r){let s=e[t+3],a=Math.pow(2,s-128)/255;i[r+0]=e[t+0]*a,i[r+1]=e[t+1]*a,i[r+2]=e[t+2]*a,i[r+3]=1},s=function(e,t,i,r){let s=e[t+3],a=Math.pow(2,s-128)/255;i[r+0]=za.toHalfFloat(Math.min(e[t+0]*a,65504)),i[r+1]=za.toHalfFloat(Math.min(e[t+1]*a,65504)),i[r+2]=za.toHalfFloat(Math.min(e[t+2]*a,65504)),i[r+3]=za.toHalfFloat(1)},a=new Uint8Array(e);a.pos=0;let n,o,l,h=function(e){let r,s,a=/^#\?(\S+)/,n=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,l=/^\s*FORMAT=(\S+)\s*$/,h=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,u={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};for((e.pos>=e.byteLength||!(r=i(e)))&&t(1,"no header found"),(s=r.match(a))||t(3,"bad initial token"),u.valid|=1,u.programtype=s[1],u.string+=r+"\n";r=i(e),!1!==r;)if(u.string+=r+"\n","#"!==r.charAt(0)){if((s=r.match(n))&&(u.gamma=parseFloat(s[1])),(s=r.match(o))&&(u.exposure=parseFloat(s[1])),(s=r.match(l))&&(u.valid|=2,u.format=s[1]),(s=r.match(h))&&(u.valid|=4,u.height=parseInt(s[1],10),u.width=parseInt(s[2],10)),2&u.valid&&4&u.valid)break}else u.comments+=r+"\n";return 2&u.valid||t(3,"missing format specifier"),4&u.valid||t(3,"missing image size specifier"),u}(a),u=h.width,d=h.height,c=function(e,i,r){let s=i;if(s<8||s>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);s!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");let a=new Uint8Array(4*i*r);a.length||t(4,"unable to allocate buffer space");let n=0,o=0,l=4*s,h=new Uint8Array(4),u=new Uint8Array(l),d=r;for(;d>0&&o<e.byteLength;){o+4>e.byteLength&&t(1),h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],(2!=h[0]||2!=h[1]||(h[2]<<8|h[3])!=s)&&t(3,"bad rgbe scanline format");let i,r=0;for(;r<l&&o<e.byteLength;){i=e[o++];let s=i>128;if(s&&(i-=128),(0===i||r+i>l)&&t(3,"bad scanline data"),s){let t=e[o++];for(let e=0;e<i;e++)u[r++]=t}else u.set(e.subarray(o,o+i),r),r+=i,o+=i}let c=s;for(let e=0;e<c;e++){let t=0;a[n]=u[e+t],t+=s,a[n+1]=u[e+t],t+=s,a[n+2]=u[e+t],t+=s,a[n+3]=u[e+t],n+=4}d--}return a}(a.subarray(a.pos),u,d);switch(this.type){case ti:l=c.length/4;let e=new Float32Array(4*l);for(let t=0;t<l;t++)r(c,4*t,e,4*t);n=e,o=ti;break;case ii:l=c.length/4;let t=new Uint16Array(4*l);for(let e=0;e<l;e++)s(c,4*e,t,4*e);n=t,o=ii;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:u,height:d,data:n,header:h.string,gamma:h.gamma,exposure:h.exposure,type:o,colorSpace:ur,minFilter:qt,magFilter:qt,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}}});function hw(e){return e.length>2&&35===e[0]&&63===e[1]}var uw,dw,cw,pw=n(()=>{Mu(),lw()}),mw=n(()=>{Mu(),nw(),ow(),pw(),uw=0,dw=class extends Qx{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.instanceId=++uw,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo="video"===e.type,this.isBuffer=!0===e.isWebGLRenderTarget,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let t=()=>{this.loaded=!0;for(let e of Object.values(this._cache))for(let t of Object.values(e))for(let e of Object.values(t))e&&(e.image=this.img,e.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,"string"!=typeof e){let t,i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"})),await new Promise(e=>{i.onloadend=i=>{t=i.target?.result,e(null)}}),this.img.src=t}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else if(e instanceof Uint8Array?hw(e):"string"==typeof e&&/\.hdr($|[?#])/i.test(e)){let i=e instanceof Uint8Array?e:null;if(null===i)try{i=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{i=null}let r=null!==i&&hw(i)?function(e){try{let t=(new tw).parse(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(!t||!t.width||!t.height)return null;let{width:i,height:r}=t,s=t.data,a=new Uint16Array(s.length),n=4*i,o=e=>za.toHalfFloat(Math.pow(Math.max(za.fromHalfFloat(e),0),1/2.2)),l=new Map,h=e=>{let t=l.get(e);return void 0===t&&(t=o(e),l.set(e,t)),t};for(let e=0;e<r;e++){let t=e*n,i=(r-1-e)*n;for(let e=0;e<n;e+=4)a[i+e]=h(s[t+e]),a[i+e+1]=h(s[t+e+1]),a[i+e+2]=h(s[t+e+2]),a[i+e+3]=s[t+e+3]}return{isSplineHdr:!0,data:a,width:i,height:r}}catch{return null}}(i):null;null!==r&&(this.isHdr=!0,this.img=r,t())}else this.img=new Image,this.img.src="string"==typeof(i=e)?i:(Jx||(Jx=new Zx),Jx.load(i)),this.img.onload=t,await new Promise(e=>{this.img.onload=()=>{t(),e(null)}});var i}getTexture(e,t=1008,i=1006){let r=this._cache[e]?.[t]?.[i];if(r)return r;{let r;return this.isBuffer?r=this.img.texture:this.isVideo?r=new Eo(this.img,void 0,e,e):this.isHdr?(r=function(e){let t=new Yn(e.data,e.width,e.height,ui,ii);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}(this.img),r.wrapS=e,r.wrapT=e,r.magFilter=i,r.minFilter=t):r=new ws(this.img,void 0,e,e,i,t),this.isBuffer||(r.anisotropy=8,r.generateMipmaps=1008===t),this.loaded&&(r.needsUpdate=!0),void 0===this._cache[e]&&(this._cache[e]={}),void 0===this._cache[e][t]&&(this._cache[e][t]={}),this._cache[e][t][i]=r,r}}setNeedsUpdate(e){if(!this.isBuffer)for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let t of Object.values(i))t&&(t.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[t,s]of Object.entries(r))s?.dispose(),void 0!==this._cache[e]&&void 0!==this._cache[e][i]&&(this._cache[e][i][t]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),gw=n(()=>{mw(),cw=class extends dw{}});function fw(e){if("string"==typeof e)return e;let t=yw.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},yw.set(e,t)),t.url}var yw,vw=n(()=>{yw=new Map});function bw(){if(!_w)return Sw||(Sw=async function(){await import("./howler.js"),xw(void 0!==window?window:global),_w=!0}())}var xw,ww,_w,Sw,Mw=n(()=>{ww=new Promise(e=>{xw=e}),_w=!1});function Tw(e,t){e.forEach(e=>{"dragDropActions"in e.data?(t.push(...e.data.dragDropActions.drag),t.push(...e.data.dragDropActions.drop)):"inActions"in e.data?(t.push(...e.data.inActions),t.push(...e.data.outActions)):"gameActions"in e.data?(t.push(...e.data.gameActions.idle),t.push(...e.data.gameActions.move),t.push(...e.data.gameActions.jump),t.push(...e.data.gameActions.run)):"breakpoints"in e.data?e.data.breakpoints.forEach(e=>{t.push(...e.data.actions)}):"actions"in e.data&&(t.push(...e.data.actions),e.data.actions.forEach(e=>{"Conditional"===e.data.type&&e.data.ifActions&&(t.push(...e.data.ifActions),t.push(...e.data.elseActions))}))})}function Cw(e){let t=!1,i=[];return e.scene.objects.traverse((e,r)=>{if("Page"===r.type&&void 0!==r.uiScene&&r.uiScene.objects.traverse((e,r)=>{if(void 0===r.events||!1===Array.isArray(r.events))return!0;Tw(r.events,i),t=t||i.some(e=>"Audio"===e.data.type)}),void 0===r.events||!1===Array.isArray(r.events))return!0;Tw(r.events,i),t=t||i.some(e=>"Audio"===e.data.type)}),t}var Aw,Nw,Pw=n(()=>{vw(),Mw(),ww.then(e=>Aw=e),Nw=class{constructor({src:e,volume:t,delay:i,loop:r}){let s;this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)},s="string"==typeof e?{src:e}:{src:fw(e),format:"wav"},this.sound=new Aw.Howl(s),this.sound.on("end",this.onEnd),this.src=e,void 0!==t&&(this.volume=t),void 0!==i&&(this.delay=i),void 0!==r&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){"playing"===this._status||this.sound.playing()||("paused"===this._status?(0===this.sound.seek()?this.replay():this.sound.play(),this._status="playing"):"stopped"===this._status&&(this.replay(),this._status="playing"))}pause(){"playing"===this._status&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function Rw(e){let t=!1;return e.scene.objects.traverse((e,i)=>{"Mesh"===i.type&&("TextGeometry"===i.geometry.type||"InputGeometry"===i.geometry.type)&&(t=!0)}),t}var Ew,Ow=n(()=>{Ew=null});function Bw(e){return new rs(e.y,-e.x)}var Vw,Dw,Iw,Lw,zw,kw,Uw,Fw,jw,Gw=n(()=>{Mu(),Vw=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,s=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);s.thetaLength=ts.clamp(s.thetaLength,0,360),s.hollow=ts.clamp(s.hollow??0,0,1);let a=s.width/2,n=s.radiusTop??a,o=s.radiusBottom??a;if(n===o?(n=a,o=a):n>o?(n=a,o=o*a/n):(n=n*a/o,o=a),s.shapeBlendNode){n=i??a,o=r??a;let e=2*Math.max(n,o);s.width=e,s.depth=e}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:n,radiusBottom:o})}}static build(e){let t,{width:i,depth:r,height:s,radialSegments:a,heightSegments:n,openEnded:o,thetaStart:l,thetaLength:h,radiusTop:u,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=e.parameters;0===h?(t=new an,t.setAttribute("position",new Ha([],3))):t=c||m?new Dw(u,d,s,a,n,o,l,h*Math.PI/180,c,c,p,m):new zo(u,d,s,a,n,o,l,h*Math.PI/180);let g=r/i;return 1!==g&&t.scale(1,1,g),Object.assign(t,{userData:{...e,type:"CylinderGeometry"}})}},Dw=class extends an{constructor(e,t,i,r,s,a,n,o,l,h,u,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",e=void 0!==e?e:1,t=void 0!==t?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,a=void 0!==a&&a,n=void 0!==n?n:0,o=void 0!==o?o:2*Math.PI,a&&(l=0,h=0);let p=i/2;c&&0==e&&(e=l),c&&0==t&&(t=h);let m=new rs(e,p),g=new rs(t,-p),f=null,y=null,v=null,b=null,x=m.clone().sub(g),w=0,_=0,S=0;d>0&&(w=Math.min(e,t)*(1-d),_=e-w,S=t-w);let M=m.clone();M.x-=w;let T=Math.PI-x.angle(),C=x.angle(),A=Math.tan(C/2),N=Math.tan(T/2),P=A+N,R=d?P:N,E=d?P:A;if(l=Math.min(l,(e-_)/R,x.length()/P),h=Math.min(h,(t-S)/E,x.length()/P),l>0){let e=l/A;f=m.clone().sub(new rs(e,l)),d&&(v=f.clone(),v.x-=w-P*l),m.sub(x.clone().setLength(e))}if(h>0){let e=h/N;y=g.clone().sub(new rs(e,-h)),g.add(x.clone().setLength(e)),d&&(b=y.clone(),b.x-=w-P*h,M.sub(x.clone().setLength(e)))}x=m.clone().sub(g);let O=x.length()<.5,B=[],V=[],D=[],I=[],L=[],z=[],k=(e,t,r,s,a)=>{for(let n=0;n<u+1;n++){let o=n/u,l=s<0?o:1-o;a&&(l-=1),l*=e;let h=Math.sin(l),d=Math.cos(l)*s,c=d*t+r.y;B.push(h*t+r.x),V.push(c),D.push(h),I.push(d),L.push(.5+c/i),z.push(!1)}},U=(e,t,i)=>{let r=[e,t];i<0&&r.reverse();for(let e of r)B.push(e),V.push(p*i),D.push(0),I.push(i),L.push(.5),z.push(!0)};if(b&&y?(k(T,h,b,-1,!0),k(C,h,y,-1,!1)):y?(U(y.x,0,-1),k(C,h,y,-1,!1)):a||U(t,S,-1),!O){let e=Bw(x).normalize();for(let t=0;t<=s;t++){let r=t/s,a=x.y*r+g.y;B.push(x.x*r+g.x),V.push(a),D.push(e.x),I.push(e.y),L.push(.5+a/i),z.push(!1)}}if(v&&f?(k(T,l,f,1,!1),k(C,l,v,1,!0)):f?(k(T,l,f,1,!1),U(f.x,0,1)):a||U(e,_,1),d&&!O){let e=Bw(x).multiplyScalar(-1).normalize();for(let t=0;t<=s;t++){let r=t/s,a=x.y*-r+M.y;B.push(x.x*-r+M.x),V.push(a),D.push(e.x),I.push(e.y),L.push(.5+a/i),z.push(!1)}}let F=B.length,j=F+(d&&!a?1:0),G=(e,t)=>e*F+(t===F?0:t),W=o<2*Math.PI,q=(r+1)*F+(W?2*(1+j):0),H=new Float32Array(3*q),$=new Float32Array(3*q),Y=new Float32Array(2*q),X=q-1>65535?new Uint32Array(r*Math.max(0,j-1)*6+(W?2*(j+1)*3:0)):new Uint16Array(r*Math.max(0,j-1)*6+(W?2*(j+1)*3:0)),K=0,Z=0;for(let e=0;e<=r;e++){let t=e/r,i=t*o+n,s=Math.sin(i),a=Math.cos(i);for(let e=0;e<F;e++){let i=3*Z,r=2*Z,n=B[e],o=D[e];H[i]=n*s,H[i+1]=V[e],H[i+2]=n*a,$[i]=o*s,$[i+1]=I[e],$[i+2]=o*a,z[e]?(Y[r]=.5,Y[r+1]=.5):(Y[r]=t,Y[r+1]=L[e]),Z++}}for(let e=0;e<r;e++)for(let t=0;t<j-1;t++){if(a&&d&&t==s)continue;let i=G(e,t),r=G(e+1,t),n=G(e+1,t+1),o=G(e,t+1),l=H[3*n+0],h=H[3*n+2];X[K++]=i,X[K++]=r,X[K++]=o,(0!=l||0!=h)&&(X[K++]=r,X[K++]=n,X[K++]=o)}function J(i,r,s){let a=Math.sin(s),n=Math.cos(s),o=-n,l=a,h=i<0?(e,t,i)=>{X[K++]=e,X[K++]=t,X[K++]=i}:(e,t,i)=>{X[K++]=e,X[K++]=i,X[K++]=t},u=(e+t+_+S)/4,d=3*Z,c=2*Z;H[d]=u*a,H[d+1]=0,H[d+2]=u*n,$[d]=o,$[d+1]=0,$[d+2]=l,Y[c]=.5,Y[c+1]=.5;let p=Z++;for(let e=0;e<j;e++){let t=3*(r+(e===F?0:e));d=3*Z,c=2*Z,H[d]=H[t],H[d+1]=H[t+1],H[d+2]=H[t+2],$[d]=o,$[d+1]=0,$[d+2]=l;let i=t/3*2|0;Y[c]=Y[i],Y[c+1]=Y[i+1],Z++}for(let e=p+1;e<Z-1;e++)h(p,e,e+1);h(p,Z-1,p+1)}W&&(J(-1,0,n),J(1,r*F,n+o)),this.setIndex(new ja(X.slice(0,K),1)),this.setAttribute("position",new ja(H,3)),this.setAttribute("normal",new ja($,3)),this.setAttribute("uv",new ja(Y,2))}}}),Ww=n(()=>{Mu(),Gw(),Iw=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=ts.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let t,{width:i,depth:r,height:s,radialSegments:a,heightSegments:n,openEnded:o,thetaStart:l,thetaLength:h,cornerRadiusTop:u,cornerRadiusBottom:d,cornerSegments:c}=e.parameters;0===h?(t=new an,t.setAttribute("position",new Ha([],3))):t=u>0||d>0||h<360?new Dw(0,i/2,s,a,n,o,l,h*Math.PI/180,u,d,c,0,!0):new ko(i/2,s,a,n,o);let p=r/i;return 1!==p&&t.scale(1,1,p),Object.assign(t,{userData:{...e,type:"ConeGeometry"}})}}}),qw=n(()=>{Mu(),Lw=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let t,{width:i,height:r,depth:s,widthSegments:a,heightSegments:n,depthSegments:o,cornerRadius:l,cornerSegments:h}=e.parameters;return t=0===l?new Lo(i,r,s,a,n,o):new kw(i,r,s,a,n,o,l,h),Object.assign(t,{userData:{...e,type:"CubeGeometry"}})}},zw=Math.PI/2,kw=class extends an{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o);let l=(n=Math.min(n,e/2,t/2,i/2))>0,h=o+1,u=2*((a+1)*(s+1)+(r+1)*(a+1)+(r+1)*(s+1))+(l?4*h*(a+1+(r+1)+(s+1))+h*(h+1)/2*8:0),d=2*(a*s+r*a+r*s)+(l?4*o*(a+r+s):0),c=l?8*o*o:0,p=new Float32Array(3*u),m=new Float32Array(3*u),g=new Float32Array(2*u),f=u-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(h),x=new Float64Array(h),w=new Float64Array(h),_=new Float64Array(h);for(let e=0;e<h;e++){let t=e/o*zw;b[e]=Math.sin(t)*n,x[e]=(1-Math.cos(t))*n,w[e]=Math.sin(t),_[e]=Math.cos(t)}let S=h*(h+1)/2,M=new Float64Array(3*S),T=new Float64Array(3*S);{let r=new ns(e/2,t/2,i/2);r.subScalar(n);let s=0;for(let e=0;e<=o;e++){let t=zw*(1-e/o),i=Math.cos(t),a=Math.sin(t),l=0;for(let t=0;t<=e;t++){let t=i*Math.cos(l),o=a,h=i*Math.sin(l);M[3*s]=t,M[3*s+1]=o,M[3*s+2]=h,T[3*s]=r.x+t*n,T[3*s+1]=r.y+o*n,T[3*s+2]=r.z+h*n,s++,l+=zw/e}}}function C(e,t,i,r,s,a,o,l,h,u){let d=(a-2*n)/h,c=(o-2*n)/u,b=a/2-n,x=o/2-n,w=l/2,_=h+1,S=u+1,M=0,T=new ns;for(let a=0;a<S;a++){let n=a*c-x;for(let o=0;o<_;o++){let c=o*d-b,f=3*(y+M),v=2*(y+M);T[e]=c*r,T[t]=n*s,T[i]=w,p[f]=T.x,p[f+1]=T.y,p[f+2]=T.z,T[e]=0,T[t]=0,T[i]=l>0?1:-1,m[f]=T.x,m[f+1]=T.y,m[f+2]=T.z,g[v]=o/h,g[v+1]=1-a/u,M+=1}}for(let e=0;e<u;e++)for(let t=0;t<h;t++){let i=y+t+_*e,r=y+t+_*(e+1),s=y+(t+1)+_*(e+1),a=y+(t+1)+_*e;f[v++]=i,f[v++]=r,f[v++]=a,f[v++]=r,f[v++]=s,f[v++]=a}y+=M}function A(e,t,i,r,s,a,l,h,u,d){let c=(l-2*n)/d,S=l/2-n,M=h/2-n,T=u/2,C=d+1,A=0,N=new ns,P=new ns;for(let n=0;n<o+1;n++){N[t]=(M+b[n])*s,N[i]=(T-x[n])*a,P[e]=0,P[t]=w[n]*Math.sign(N[t]),P[i]=_[n]*Math.sign(N[i]);for(let t=0;t<C;t++){let i=t*c-S;N[e]=i*r;let s=3*(y+A),a=2*(y+A);p[s]=N.x,p[s+1]=N.y,p[s+2]=N.z,m[s]=P.x,m[s+1]=P.y,m[s+2]=P.z,g[a]=t/d,g[a+1]=0,A+=1}}for(let e=0;e<o;e++)for(let t=0;t<d;t++){let i=y+t+C*e,r=y+t+C*(e+1),s=y+(t+1)+C*(e+1),a=y+(t+1)+C*e;f[v++]=i,f[v++]=r,f[v++]=a,f[v++]=r,f[v++]=s,f[v++]=a}y+=A}function N(e,t,i){let r=e*t*i>0?(e,t,i)=>{f[v++]=e,f[v++]=t,f[v++]=i}:(e,t,i)=>{f[v++]=e,f[v++]=i,f[v++]=t},s=y;for(let r=0;r<S;r++){let s=3*r,a=3*y,n=2*y;p[a]=e*T[s],p[a+1]=t*T[s+1],p[a+2]=i*T[s+2],m[a]=e*M[s],m[a+1]=t*M[s+1],m[a+2]=i*M[s+2],g[n]=0,g[n+1]=0,y++}for(let e=0;e<o;e++){let t=s+e*(e+1)/2,i=s+(e+1)*(e+2)/2;r(t,i+1,i);for(let s=1;s<=e;s++)r(t+s-1,t+s,i+s),r(t+s,i+s+1,i+s)}}C("z","y","x",-1,-1,i,t,e,a,s),C("z","y","x",1,-1,i,t,-e,a,s),C("x","z","y",1,1,e,i,t,r,a),C("x","z","y",1,-1,e,i,-t,r,a),C("x","y","z",1,-1,e,t,i,r,s),C("x","y","z",-1,-1,e,t,-i,r,s),n>0&&(A("z","y","x",-1,-1,1,i,t,e,a),A("z","y","x",1,-1,-1,i,t,e,a),A("z","y","x",-1,1,-1,i,t,e,a),A("z","y","x",1,1,1,i,t,e,a),A("x","y","z",-1,-1,-1,e,t,i,r),A("x","y","z",1,-1,1,e,t,i,r),A("x","y","z",-1,1,1,e,t,i,r),A("x","y","z",1,1,-1,e,t,i,r),A("y","x","z",-1,-1,1,t,e,i,s),A("y","x","z",1,-1,-1,t,e,i,s),A("y","x","z",1,1,1,t,e,i,s),A("y","x","z",-1,1,-1,t,e,i,s),N(1,1,1),N(-1,1,1),N(1,-1,1),N(-1,-1,1),N(1,1,-1),N(-1,1,-1),N(1,-1,-1),N(-1,-1,-1)),this.setIndex(new ja(f,1)),this.setAttribute("position",new ja(p,3)),this.setAttribute("normal",new ja(m,3)),this.setAttribute("uv",new ja(g,2))}}}),Hw=n(()=>{Mu(),Uw=class extends an{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n,o,l,h=0;return function(){0==(s=Math.min(.99999,s))&&(a=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new ns,c=d.clone(),p=new _a,m=s*r,g=r-m,f=a+1,y=new ns,v=(e,t)=>y.subVectors(e,t).normalize(),b=(e,t)=>Array(e).fill(void 0).map(t),x=b(e.length/3,(t,i)=>(new ns).fromArray(e,3*i).setLength(r)),w=[],_=1e6;for(let e=0;e<x.length;e++){let i,r,s,a=x[e],n=[],o=1e10,l=-1;for(;-1!=(l=t.indexOf(e,l+1));){let e=l-l%3;i=t[e+(l+1)%3],r=t[e+(l+2)%3],s=a.distanceToSquared(x[i]),o=Math.min(o,s),n.push([i,r,s])}o+=1e-6;let h=[],u=0,d=n.length;for(let t=0;t<d;t++){[i,r,s]=n[u];let t=1==w[i]?.includes(e);s<=o&&h.push(i+ +t*_),u=n.findIndex(e=>e[0]==r)}w.push(h)}let S=[];{let e,t,i=0,r=0,s=3==u;for(let n=0;n<=a;n++){e=n*(n+1)/2,t=(n+1)*(n+2)/2;for(let o=0;o<a-n;o++)[i,r]=[e+o+n+2,t+o+n+3],S.push(e,t,...s?[r,e]:[i,t],r,i),[e,t]=[i,r];S.push(e,t,e+a+2)}}let M=0;for(let e=0;e<w.length;e++)for(let t=0;t<u;t++)w[e][t]<_&&M++;let T=x.length*u*S.length*3+M*f*6*3+2*M*3*3;n=new Float64Array(T),o=new Float64Array(T),l=new Float64Array(T/3*2);let C=(e,t,i)=>{let r=h/3*2;l[r]=Math.atan2(i,-e)/2/Math.PI+.5,l[r+1]=1-(Math.atan2(-t,Math.sqrt(e*e+i*i))/Math.PI+.5)},A=e=>{n[h]=e.x,n[h+1]=e.y,n[h+2]=e.z,o[h]=y.x,o[h+1]=y.y,o[h+2]=y.z,C(e.x,e.y,e.z),h+=3},N=e=>{n[h]=e[0].x,n[h+1]=e[0].y,n[h+2]=e[0].z,o[h]=e[1].x,o[h+1]=e[1].y,o[h+2]=e[1].z,C(e[0].x,e[0].y,e[0].z),h+=3},P=(a+2)*(a+3)/2,R=new Float64Array(3*P),E=new Float64Array(3*P),O=new Float64Array(2*P),B=b(2*u*f,()=>new ns),V=b(a*Math.max(0,a-1)/2,()=>new ns),D=d.clone(),I=d.clone(),L=d.clone(),z=d.clone(),k=d.clone(),U=[],F=b(x.length,()=>b(u,()=>d.clone()));for(let e=0;e<x.length;e++){d.copy(x[e]).normalize(),D.copy(d).multiplyScalar(g);let t=w[e];for(let i=0;i<t.length;i++){let r=t[i],s=t[(i+1)%u];p.setFromPointsAndIndices(x,e,r%_,s%_),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(D,F[e][i])}let i=0,r=[],s=[],b=new ns;0==a&&[...F[e]].reduce((e,t)=>e.add(t),b).multiplyScalar(1/u);for(let t=0;t<u;t++){let n=[],o=(t-1+u)%u,l=F[e][o],h=F[e][t];d.copy(l).sub(D),c.copy(h).sub(D);let p=D.angleTo(d),x=d.angleTo(c),w=Math.cos(p)*m;0==a?I.copy(b):I.copy(D).setLength(g+w),r.push(w);let _=[I,l,h];for(let e=0;e<2;e++){let t=_[e],r=_[e+1];z.subVectors(t,D),k.subVectors(r,D),L.crossVectors(z,k).normalize();for(let r=0;r<f;r++){let s=[p,x][e]*r/f;d.copy(z).applyAxisAngle(L,s).add(D),B[i++].copy(d),e&&(v(d,D),n.push([0==r?t:d.clone(),y.clone()]))}e&&(v(r,D),n.push([r,y.clone()]))}s.push(n)}U.push(s);let M=2*f,T=2;for(let e=0;e<u;e++){let t=M*e,i=M*((e+1)%u),s=0,a=[B[t]];for(let n=1;n<f;n++){let o=B[t+n],l=B[i+n];a.push(o);for(let t=1,i=n-T+1;t<=i;t++)d.lerpVectors(o,l,t/(i+1)),d.sub(D).setLength(r[e]).add(D),a.push(V[s++].copy(d));a.push(l)}for(let e=0;e<f;e++)a.push(B[e+f+t]);a.push(B[i+f]);for(let e=0,t=a.length;e<t;e++){let t=a[e],i=3*e,r=2*e;R[i]=t.x,R[i+1]=t.y,R[i+2]=t.z,v(t,D),E[i]=y.x,E[i+1]=y.y,E[i+2]=y.z,O[r]=Math.atan2(t.z,-t.x)/2/Math.PI+.5,O[r+1]=1-(Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5)}for(let e=0,t=S.length;e<t;e++){let t=3*S[e],i=2*S[e],r=h/3*2;n[h]=R[t],n[h+1]=R[t+1],n[h+2]=R[t+2],o[h]=E[t],o[h+1]=E[t+1],o[h+2]=E[t+2],l[r]=O[i],l[r+1]=O[i+1],h+=3}}}let j=[];for(let e=0;e<w.length;e++)for(let t=0;t<u;t++){let i=w[e][t];if(i<_){let r=w[i].findIndex(t=>t%_==e),s=U[e][t],a=U[i][r];for(let e=0;e<f;e++){let t=s[e],i=a[f-e],r=s[e+1],n=a[f-(e+1)];N(t),N(i),N(r),N(r),N(i),N(n)}j.push(s[0][0],a[f][0],s[f][0],a[0][0])}}for(;j.length;){let e,t,i,[r,s]=j.splice(0,2);e=s;let a=[r];for(;r!=e;)a.push(e),t=j.indexOf(e),i=t%2,e=j.splice(t-i,2)[1-i];y.subVectors(a[0],a[1]).cross(d.subVectors(a[0],a[2])).normalize();let n=y.dot(a[0])<0;n&&y.negate();for(let e=1;e<=a.length-2;e++)A(a[e+ +n]),A(a[e+1-+n]),A(a[0])}}(),function(){let e=new ns,t=new ns,i=new ns,r=new ns,s=new rs,a=new rs,o=new rs,u=(e,t,i,r)=>{r<0&&1===e.x&&(l[t]=e.x-1),0===i.x&&0===i.z&&(l[t]=r/2/Math.PI+.5)};for(let d=0,p=0;d<h;d+=9,p+=6){e.set(n[d+0],n[d+1],n[d+2]),t.set(n[d+3],n[d+4],n[d+5]),i.set(n[d+6],n[d+7],n[d+8]),s.set(l[p+0],l[p+1]),a.set(l[p+2],l[p+3]),o.set(l[p+4],l[p+5]),r.copy(e).add(t).add(i).divideScalar(3);let h=c(r);u(s,p+0,e,h),u(a,p+2,t,h),u(o,p+4,i,h)}let d=h/3*2;for(let e=0;e<d;e+=6){let t=l[e+0],i=l[e+2],r=l[e+4],s=Math.max(t,i,r),a=Math.min(t,i,r);s>.9&&a<.1&&(t<.2&&(l[e+0]+=1),i<.2&&(l[e+2]+=1),r<.2&&(l[e+4]+=1))}function c(e){return Math.atan2(e.z,-e.x)}}(),this.setAttribute("position",new ja(new Float32Array(n.subarray(0,h)),3)),this.setAttribute("normal",new ja(new Float32Array(o.subarray(0,h)),3)),void this.setAttribute("uv",new ja(new Float32Array(l.subarray(0,h/3*2)),2))}static fromJSON(e){return new Uw(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}}}),$w=n(()=>{Hw(),Mu(),Fw=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:a,cornerSides:n}=e.parameters,o=0===s&&0!==a?new jw(.5*t,a,n):new Fo(.5*t,s),l=i/t,h=r/t;return(1!==l||1!==h)&&o.scale(1,l,h),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},jw=class extends Uw{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a="DodecahedronGeometry";super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,e,t,i),this.type=a}static fromJSON(e){return new jw(e.radius,e.corner,e.cornerSides)}}});function Yw(e,t=new rs){let i=e.length();return t.set(-e.y/i,e.x/i)}function Xw(e){let t=new rs;t.addVectors(e.v0,m_.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new rs;return i.addVectors(e.v2,g_.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Zo(e.v0,t,i,e.v2)}function Kw(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function Zw(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function Jw(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function Qw(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-a*a)/(2*s*r))}function e_(e,t,i){return n_(e,t)&&n_(t,i)&&t_(e.position,t.position,i.position)}function t_(e,t,i){return 0===m_.copy(t).sub(e).cross(g_.copy(i).sub(e))}function i_(e,t,i,r,s){let a=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(e.y-t.y)/a,h=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(t.x-e.x)/a;return r.set(o+l,n+h),s.set(o-l,n-h),[r,s]}function r_(e,t,i){return e.distanceTo(i)<t.distanceTo(i)?t:e}function s_(e,t,i,r,s,a){let n,o=t.x-e.x,l=t.y-e.y,h=i.x-e.x,u=i.y-e.y,d=Math.sqrt((o+h)*(o+h)+(l+u)*(l+u));return Qw(t,e,i)>Math.PI&&(d*=-1),n=Kw(u,l)?(l+u)*(r/d-.5)*8/3/(o-h):(o+h)*(r/d-.5)*8/3/(u-l),s.set(t.x-n*l,t.y+n*o),a.set(i.x+n*u,i.y-n*h),[s,a]}function a_(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function n_(e,t){return t_(e.position,e.controls[1].position,t.position)&&t_(e.position,t.controls[0].position,t.position)}function o_(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s<a;s++){let a=e[s],n=0;if(i&&void 0!==a.roundedCurveCorner){let e=.5*l_(a.roundedCurveCorner,t);s>0&&(r[s-1]+=e),n+=e}void 0!==a.curveAfter&&(n+=l_(a.curveAfter,t)),r.push(n)}return e.length>0&&i&&void 0!==e[0].roundedCurveCorner&&(r[e.length-1]+=.5*l_(e[0].roundedCurveCorner,t)),r}function l_(e,t=12){return e&&e instanceof Go?2*t:e&&(e instanceof Qo||e instanceof el)?1:e&&e instanceof rl?t*e.points.length:t}var h_,u_,d_,c_,p_,m_,g_,f_,y_,v_,b_,x_,w_,__,S_,M_,T_,C_,A_,N_,P_=n(()=>{Mu(),h_=1e-12,u_=class{constructor(e){this.position=new rs,this.startPosition=new rs,this.uuid=ts.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new u_(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},d_=class extends u_{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new d_(this.parent).copy(this)}},c_=class extends u_{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new d_(this),new d_(this))}static create(e,t){let i=new c_(e,new rs(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return 0===t?this.controls[1]:1===t?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let r=this.controls[i];this.position.distanceTo(r.position)<=t?r.position.copy(this.position):r.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new c_(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new rs,t=new rs){let[i,r]=this.computeTangents();return i&&r&&(Yw(i,e),Yw(r,t)),[e,t]}computeTangent(e=new rs){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new rs){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}},p_=e=>e,m_=new rs,g_=new rs,f_=new rs,y_=new rs,v_=new rs,b_=new rs,x_=new ns,w_=new ns}),R_=n(()=>{Mu(),P_(),__=new rs,S_=new rs,M_=new rs,T_=new rs,C_=new rs,A_=new rs,N_=class extends ol{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new uo(new ns(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=ts.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new N_;return r.isClosed=e.isClosed,r.points=e.points.map(e=>c_.create(e.id,e.data)),"number"==typeof e.roundness&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(e=>N_.createFromState(e)),void 0!==t&&void 0!==i&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(e=>this.getPointIndexById(e)).filter(e=>e>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(t=>t.uuid===e);if(i<0){let i=t;for(let t=0,r=this.shapeHoles.length;t<r;t++){let r=this.shapeHoles[t],s=r.points.length,a=r.getPointIndexById(e);if(!(a<0))return a+i;i+=s}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let r=this.shapeHoles[i],s=e-t;if(s<=r.points.length-1)return r.points[s];t+=r.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let r=this.shapeHoles[i],s=r.points.indexOf(e);if(s>=0)return t+s;t+=r.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(e=>e.points));return[...this.points,...e]}applySize(e,t){0===e&&(e=.001),0===t&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=__.set(e,t);for(let e=0,t=this.points.length;e<t;e++){let t=this.points[e];t.position.multiply(i),t.controls[0].position.multiply(i),t.controls[1].position.multiply(i)}for(let i=0,r=this.shapeHoles.length;i<r;i++)this.shapeHoles[i].applyScale(e,t);this._update()}createPoint(e,t=0,i=ts.generateUUID()){let r;r=e instanceof rs?e:new rs(e,t);let s=new c_(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let i=this.points[t];if(i.uuid===e)return i}for(let t=0,i=this.shapeHoles.length;t<i;t++){let i=this.shapeHoles[t].getPointByUuid(e);if(i)return i}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(t=>t.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,void 0===this.curveDivisions&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(e,t,i=12,r=!0){let s,a=w_.set(0,0,0),n=0,o=[];for(let r=0;r<t.length;r++){let l=p_(t[r]),h=m_,u=l_(l,i);o.push(u);for(let t=0;t<=u;t++)if(l instanceof Zo||l instanceof tl||l instanceof Qo){if(l.getPoint(t/u,h),a.set(h.x,h.y,0),void 0!==s&&Jw(s,a))continue;void 0===s&&(s=x_),s.copy(a),e.setXYZ(n,a.x,a.y,a.z),n++}}r&&n>1&&(e.getX(n-1)!==e.getX(0)||e.getY(n-1)!==e.getY(0)||e.getZ(n-1)!==e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++)}(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((e,t)=>e+t,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=o_(this.points,e,!1),this.roundedCurveDivisions=o_(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return 2*function(e,t,i,r=12,s=!0){let a=w_.set(0,0,0),n=0,o=[];for(let s=0;s<t.length;s++){if(!1===i[s])continue;let l,h=p_(t[s]),u=m_,d=l_(h,r);o.push(d);for(let t=0;t<=d;t++)if(h instanceof Zo||h instanceof tl||h instanceof Qo){if(h.getPoint(t/d,u),a.set(u.x,u.y,0),l?.equals(a))continue;void 0===l?l=x_:(e.setXYZ(n,l.x,l.y,l.z),n++,e.setXYZ(n,a.x,a.y,a.z),n++),l.copy(a)}}return s&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}(e,this.curves,t,i,this.autoClose).reduce((e,t)=>e+t,0)}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,void 0===this.curveDivisions&&this.computeCurveDivisions(t),function(e,t,i=12,r=!0){let s,a=0;for(let r=0;r<t.length;r++){let n=p_(t[r]),o=l_(n,i),l=m_;for(let t=0;t<=o;t++)if(n instanceof Zo||n instanceof tl||n instanceof Qo){if(n.getPoint(t/o,l),void 0!==s&&Zw(s,l,h_))continue;void 0===s&&(s=g_),s.copy(l),e.push(l.x,l.y),a++}}return Kw(e[0],e[e.length-2],h_)&&Kw(e[1],e[e.length-1],h_)&&(e.pop(),e.pop()),r&&a>1&&!(Kw(e[a-1],e[1],h_)&&Kw(e[a-2],e[0],h_))&&(e.push(e[0],e[1]),a++),e}(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;void 0===this.curveDivisions&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&void 0!==this.points[0].roundedCurveCorner&&(s=.5*l_(this.points[0].roundedCurveCorner,this.subdivision));let a=e-s;a<0&&(a+=r.reduce((e,t)=>e+t,0));for(let e=0,t=r.length;e<t;e++){let t=r[e];if(a<i+t)return[e,(a-i+1)/t];i+=t}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,n=a[e];if(a_(r,s)){let e=r.position.distanceTo(s.position);return r.position.distanceTo(__.set(i.x,i.y))/e}let o=0;for(let t=0;t<e;t++)o+=a[t];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){a_(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let e=0,t=this.points.length;e<t;e++){let t=this.points[e];if(0===e)this.moveTo(t.position.x,t.position.y);else{let i=this.points[e-1];this._applyCurveForPoint(t,i)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let e=this.points[0],t=this.points[this.points.length-1];this._applyCurveForPoint(e,t)}if(this.points.length>2){let e=0;for(let t=0,i=this.points.length;t<i;t++){let i=this.points[t],r=this.points[t-1]??this.points[this.points.length-1],s=this.points[t+1]??this.points[0],a=i.roundness,n=r&&s&&e_(r,i,s);if(!i.controlsMoved()&&a>0&&!n){let r=i.curveBefore,s=i.curveAfter;if(void 0===r||void 0===s)continue;let n,o=i.roundedCurveBefore,l=i.roundedCurveAfter,h=r instanceof Qo?r.v1.distanceTo(r.v2):r.getLength(),u=s instanceof Qo?s.v1.distanceTo(s.v2):s.getLength(),d=Math.min(a,.499*h),c=Math.min(a,.499*u),p=Math.min(d,c),m=1-p/h,g=p/u,f=r.getPointAt(m,__),y=s.getPointAt(g,S_);if(this._subSplitCurve(r,o,m,f,void 0),this._subSplitCurve(s,l,g,void 0,y),this.useCubicForRoundedCorners){let e=Qw(f,i.position,y)/2,t=Math.tan(e)*f.distanceTo(i.position),[r,s]=i_(f,y,t,M_,T_),a=r_(r,s,i.position),[o,l]=s_(a,f,y,t,C_,A_);n=new Zo(f.clone(),o.clone(),l.clone(),y.clone())}else n=new tl(f.clone(),i.position.clone(),y.clone());i.roundedCurveCorner=n,this.roundedCurves.splice(t+e,0,n),e++}}}}_subSplitCurve(e,t,i,r,s){if(!(e instanceof Qo)){let a=e,n=t,o=a.getUtoTmapping(i,0),l=function(e,t,i,r,s=.5){let a=m_.subVectors(t,e).multiplyScalar(s).add(e),n=g_.subVectors(i,t).multiplyScalar(s).add(t),o=f_.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=y_.subVectors(n,a).multiplyScalar(s).add(a),u=v_.subVectors(o,n).multiplyScalar(s).add(n),d=o,c=b_.subVectors(u,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,c.x,c.y,u.x,u.y,d.x,d.y,r.x,r.y]}(a.v0,a.v1,a.v2,a.v3,o);return void 0!==r&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),void 0!==s&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return void 0!==r&&t.v2.copy(r),void 0!==s&&t.v1.copy(s),t}clone(){let e=new N_(this._width,this._height);return e.points=this.points.map(e=>e.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(e=>e.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let t=7*i,r=e.points[t+0],s=e.points[t+1],a=e.points[t+2],n=e.points[t+3],o=e.points[t+4],l=e.points[t+5],h=e.points[t+6],u=new c_(ts.generateUUID(),new rs(r,s));u.controls[0].position.set(a,n),u.controls[1].position.set(o,l),u.roundness=h,this.points.push(u)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(e=>{let t=new N_;return t.fromJSON(e),t}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(e,t)=>{t instanceof Zo&&t.v3.equals(e.position)&&e.controls[0].position.copy(t.v2)};return this.points=(e=>{let t,r,s=[];for(t=0,r=e.length;t<r;t++)e[t]instanceof tl&&(e[t]=Xw(e[t]));for(t=0,r=e.length;t<r;t++){let r,a=e[t],n=t>0?e[t-1]:null;a instanceof Zo?(r=this.createPoint(a.v0),r.controls[1].position.copy(a.v1)):a instanceof Qo&&(r=this.createPoint(a.v1)),void 0!==r&&(null!==n&&i(r,n),s.push(r))}let a=e[e.length-1],n=!1;return a instanceof Zo?a.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(a.v2),n=!0):a instanceof Qo&&a.v2.equals(s[0].position)&&(n=!0),this.isClosed=n,s})(e.curves),e instanceof ol&&(this.shapeHoles=e.holes.map(e=>{let t=new N_;return t.fromShape(e),t})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(void 0!==t.position&&i.position.fromArray(t.position),void 0!==t.roundness&&(i.roundness=t.roundness),void 0!==t.areControlsDirectionsMirrored&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}}});function E_({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function O_(e,t){let i=1.5707963267948966===t?.551915024494:-1.5707963267948966===t?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function B_(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}var V_,D_=n(()=>{V_=2*Math.PI});function I_(e,t){if(!e)throw t||"Assertion Failed!"}function L_(e){var t=e.windingRule,i=void 0===t?z_.ODD:t,r=e.elementType,s=void 0===r?k_.POLYGONS:r,a=e.polySize,n=void 0===a?3:a,o=e.vertexSize,l=void 0===o?2:o,h=e.normal,u=void 0===h?[0,0,1]:h,d=e.contours,c=void 0===d?[]:d,p=e.strict,m=void 0===p||p,g=e.debug,f=void 0!==g&&g;if(!c&&m)throw new Error("Contours can't be empty");if(c){var y=new J_;e.edgeCreateCallback&&(y.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(y.vertexIdCallback=e.vertexIdCallback);for(var v=0;v<c.length;v++)y.addContour(l||2,c[v]);return y.tesselate(i,s,n,l,u,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:f?y.mesh:void 0}}}var z_,k_,U_,F_,j_,G_,W_,q_,H_,$_,Y_,X_,K_,Z_,J_,Q_,eS,tS,iS=n(()=>{var e;(e=z_||(z_={}))[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(k_||(k_={})),U_=function(){function e(){}return e.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},e.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},e.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},e.edgeEval=function(t,i,r){I_(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?s<a?i.t-t.t+(t.t-r.t)*(s/(s+a)):i.t-r.t+(r.t-t.t)*(a/(s+a)):0},e.edgeSign=function(t,i,r){I_(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){I_(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s<a?i.s-t.s+(t.s-r.s)*(s/(s+a)):i.s-r.s+(r.s-t.s)*(a/(s+a)):0},e.transSign=function(t,i,r){I_(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?(i.s-r.s)*s+(i.s-t.s)*a:0},e.vertCCW=function(e,t,i){return e.s*(t.t-i.t)+t.s*(i.t-e.t)+i.s*(e.t-t.t)>=0},e.interpolate=function(e,t,i,r){return(e=e<0?0:e)<=(i=i<0?0:i)?0===i?(t+r)/2:t+e/(e+i)*(r-t):r+i/(e+i)*(t-r)},e.intersect=function(t,i,r,s,a){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?((n=e.edgeEval(t,r,i))+(o=e.edgeEval(r,i,s))<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):((n=e.edgeSign(t,r,i))+(o=-e.edgeSign(t,s,i))<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?((n=e.transEval(t,r,i))+(o=e.transEval(r,i,s))<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):((n=e.transSign(t,r,i))+(o=-e.transSign(t,s,i))<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),F_=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},j_=function(){function e(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),e}(),G_=function(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0},W_=function(){function e(){var e=new G_,t=new F_,i=new j_(0),r=new j_(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,i.next=i,i.Sym=r,r.next=r,r.Sym=i,this.vHead=e,this.fHead=t,this.eHead=i,this.eHeadSym=r}return e.prototype.makeEdge_=function(e){var t=new j_(0),i=new j_(1);e.Sym.side<e.side&&(e=e.Sym);var r=e.Sym.next;return i.next=r,r.Sym.next=t,t.next=e,e.Sym.next=i,t.Sym=i,t.Onext=t,t.Lnext=i,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,i.Sym=t,i.Onext=i,i.Lnext=t,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,t},e.prototype.splice_=function(e,t){var i=e.Onext,r=t.Onext;i.Sym.Lnext=t,r.Sym.Lnext=e,e.Onext=r,t.Onext=i},e.prototype.makeVertex_=function(e,t,i){var r=e;I_(r,"Vertex can't be null!");var s=i.prev;r.prev=s,s.next=r,r.next=i,i.prev=r,r.anEdge=t;var a=t;do{a.Org=r,a=a.Onext}while(a!==t)},e.prototype.makeFace_=function(e,t,i){var r=e;I_(r,"Face can't be null");var s=i.prev;r.prev=s,s.next=r,r.next=i,i.prev=r,r.anEdge=t,r.trail=null,r.marked=!1,r.inside=i.inside;var a=t;do{a.Lface=r,a=a.Lnext}while(a!==t)},e.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,i=e.Sym.next;t.Sym.next=i,i.Sym.next=t},e.prototype.killVertex_=function(e,t){var i=e.anEdge,r=i;do{r.Org=t,r=r.Onext}while(r!==i);var s=e.prev,a=e.next;a.prev=s,s.next=a},e.prototype.killFace_=function(e,t){var i=e.anEdge,r=i;do{r.Lface=t,r=r.Lnext}while(r!==i);var s=e.prev,a=e.next;a.prev=s,s.next=a},e.prototype.makeEdge=function(){var e=new G_,t=new G_,i=new F_,r=this.makeEdge_(this.eHead);return this.makeVertex_(e,r,this.vHead),this.makeVertex_(t,r.Sym,this.vHead),this.makeFace_(i,r,this.fHead),r},e.prototype.splice=function(e,t){var i=!1,r=!1;if(e!==t){if(t.Org!==e.Org&&(r=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(i=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!r){var s=new G_;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!i){var a=new F_;this.makeFace_(a,t,e.Lface),e.Lface.anEdge=e}}},e.prototype.delete=function(e){var t=e.Sym,i=!1;if(e.Lface!==e.Rface&&(i=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!i){var r=new F_;this.makeFace_(r,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},e.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),i=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var r=new G_;return this.makeVertex_(r,i,t.Org),t.Lface=i.Lface=e.Lface,t},e.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e).Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,t),e.Dst=t.Org,t.Dst.anEdge=t.Sym,t.Rface=e.Rface,t.winding=e.winding,t.Sym.winding=e.Sym.winding,t.idx=e.idx,t.Sym.idx=e.Sym.idx,t},e.prototype.connect=function(e,t){var i=!1,r=this.makeEdge_(e),s=r.Sym;if(t.Lface!==e.Lface&&(i=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(r,e.Lnext),this.splice_(s,t),r.Org=e.Dst,s.Org=t.Org,r.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!i){var a=new F_;this.makeFace_(a,r,e.Lface)}return r},e.prototype.zapFace=function(e){var t,i,r,s,a,n=e.anEdge;i=n.Lnext;do{i=(t=i).Lnext,t.Lface=null,null===t.Rface&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),(r=t.Sym).Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),this.killEdge_(t))}while(t!=n);s=e.prev,(a=e.next).prev=s,s.next=a},e.prototype.countFaceVerts_=function(e){var t=e.anEdge,i=0;do{i++,t=t.Lnext}while(t!==e.anEdge);return i},e.prototype.mergeConvexFaces=function(e){var t,i,r,s,a;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(t.inside)for(a=(i=t.anEdge).Org;r=i.Lnext,(s=i.Sym)&&s.Lface&&s.Lface.inside&&this.countFaceVerts_(t)+this.countFaceVerts_(s.Lface)-2<=e&&U_.vertCCW(i.Lprev.Org,i.Org,s.Lnext.Lnext.Org)&&U_.vertCCW(s.Lprev.Org,s.Org,i.Lnext.Lnext.Org)&&(r=s.Lnext,this.delete(s),i=null,s=null),!i||i.Lnext.Org!==a;)i=r;return!0},e.prototype.check=function(){var e,t,i,r,s,a,n=this.fHead,o=this.vHead,l=this.eHead;for(t=n,t=n;(e=t.next)!==n;t=e){I_(e.prev===t),s=e.anEdge;do{I_(s.Sym!==s),I_(s.Sym.Sym===s),I_(s.Lnext.Onext.Sym===s),I_(s.Onext.Sym.Lnext===s),I_(s.Lface===e),s=s.Lnext}while(s!==e.anEdge)}for(I_(e.prev===t&&null===e.anEdge),r=o,r=o;(i=r.next)!==o;r=i){I_(i.prev===r),s=i.anEdge;do{I_(s.Sym!==s),I_(s.Sym.Sym===s),I_(s.Lnext.Onext.Sym===s),I_(s.Onext.Sym.Lnext===s),I_(s.Org===i),s=s.Onext}while(s!==i.anEdge)}for(I_(i.prev===r&&null===i.anEdge),a=l,a=l;(s=a.next)!==l;a=s)I_(s.Sym.next===a.Sym),I_(s.Sym!==s),I_(s.Sym.Sym===s),I_(null!==s.Org),I_(null!==s.Dst),I_(s.Lnext.Onext.Sym===s),I_(s.Onext.Sym.Lnext===s);I_(s.Sym.next===a.Sym&&s.Sym===this.eHeadSym&&s.Sym.Sym===s&&null===s.Org&&null===s.Dst&&null===s.Lface&&null===s.Rface)},e}(),q_=function(){this.handle=null},H_=function(){this.key=null,this.node=0},$_=function(){function e(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var i=0;i<e+1;i++)this.nodes[i]=new q_,this.handles[i]=new H_;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(e){var t,i,r,s=this.nodes,a=this.handles;for(t=s[e].handle;;){if((r=e<<1)<this.size&&this.leq(a[s[r+1].handle].key,a[s[r].handle].key)&&++r,I_(r<=this.max),i=s[r].handle,r>this.size||this.leq(a[t].key,a[i].key)){s[e].handle=t,a[t].node=e;break}s[e].handle=i,a[i].node=e,e=r}},e.prototype.floatUp_=function(e){var t,i,r,s=this.nodes,a=this.handles;for(t=s[e].handle;;){if(i=s[r=e>>1].handle,0===r||this.leq(a[i].key,a[t].key)){s[e].handle=t,a[t].node=e;break}s[e].handle=i,a[i].node=e,e=r}},e.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(e){var t,i;if(2*(t=++this.size)>this.max){var r,s;for(this.max*=2,s=this.nodes.length,this.nodes.length=this.max+1,r=s;r<this.nodes.length;r++)this.nodes[r]=new q_;for(s=this.handles.length,this.handles.length=this.max+1,r=s;r<this.handles.length;r++)this.handles[r]=new H_}return 0===this.freeList?i=t:(i=this.freeList,this.freeList=this.handles[i].node),this.nodes[t].handle=i,this.handles[i].node=t,this.handles[i].key=e,this.initialized&&this.floatUp_(t),i},e.prototype.extractMin=function(){var e=this.nodes,t=this.handles,i=e[1].handle,r=t[i].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[i].key=null,t[i].node=this.freeList,this.freeList=i,--this.size,this.size>0&&this.floatDown_(1)),r},e.prototype.delete=function(e){var t,i=this.nodes,r=this.handles;I_(e>=1&&e<=this.max&&null!==r[e].key),i[t=r[e].node].handle=i[this.size].handle,r[i[t].handle].node=t,--this.size,t<=this.size&&(t<=1||this.leq(r[i[t>>1].handle].key,r[i[t].handle].key)?this.floatDown_(t):this.floatUp_(t)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},e}(),Y_=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},X_=function(){this.key=null,this.next=null,this.prev=null},K_=function(){function e(e,t){this.frame=e,this.leq=t,this.head=new X_,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(e){return this.insertBefore(this.head,e)},e.prototype.search=function(e){var t=this.head;do{t=t.next}while(null!==t.key&&!this.leq(this.frame,e,t.key));return t},e.prototype.insertBefore=function(e,t){do{e=e.prev}while(null!==e.key&&!this.leq(this.frame,e.key,t));var i=new X_;return i.key=t,i.next=e.next,e.next.prev=i,i.prev=e,e.next=i,i},e.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},e}(),Z_=function(){function e(){}return e.regionBelow=function(e){return e.nodeUp.prev.key},e.regionAbove=function(e){return e.nodeUp.next.key},e.debugEvent=function(e){},e.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},e.edgeLeq=function(e,t,i){var r=e.event,s=t.eUp,a=i.eUp;return s.Dst===r?a.Dst===r?U_.vertLeq(s.Org,a.Org)?U_.edgeSign(a.Dst,s.Org,a.Org)<=0:U_.edgeSign(s.Dst,a.Org,s.Org)>=0:U_.edgeSign(a.Dst,r,a.Org)<=0:a.Dst===r?U_.edgeSign(s.Dst,r,s.Org)>=0:U_.edgeEval(s.Dst,r,s.Org)>=U_.edgeEval(a.Dst,r,a.Org)},e.deleteRegion=function(e,t){t.fixUpperEdge&&I_(0===t.eUp.winding),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},e.fixUpperEdge=function(e,t,i){I_(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=i,i.activeRegion=t},e.topLeftRegion=function(t,i){var r,s=i.eUp.Org;do{i=e.regionAbove(i)}while(i.eUp.Org===s);if(i.fixUpperEdge){if(null===(r=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext)))return null;e.fixUpperEdge(t,i,r),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do{t=e.regionAbove(t)}while(t.eUp.Dst===i);return t},e.addRegionBelow=function(e,t,i){var r=new Y_;return r.eUp=i,r.nodeUp=e.dict.insertBefore(t.nodeUp,r),r.fixUpperEdge=!1,r.sentinel=!1,r.dirty=!1,i.activeRegion=r,r},e.isWindingInside=function(e,t){switch(e.windingRule){case z_.ODD:return!!(1&t);case z_.NONZERO:return 0!==t;case z_.POSITIVE:return t>0;case z_.NEGATIVE:return t<0;case z_.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,(s=(a=e.regionBelow(n)).eUp).Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,u,d=!0;h=r;do{I_(U_.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext}while(h!==s);for(null===a&&(a=e.regionBelow(i).eUp.Rprev),l=i,u=a;(h=(o=e.regionBelow(l)).eUp.Sym).Org===u.Org;)h.Onext!==u&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(u.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!d&&e.checkForRightSplice(t,l)&&(e.addWinding(h,u),e.deleteRegion(t,l),t.mesh.delete(u)),d=!1,l=o,u=h;l.dirty=!0,I_(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(e,t,i){e.mesh.splice(t,i)},e.vertexWeights=function(e,t,i){var r=U_.vertL1dist(t,e),s=U_.vertL1dist(i,e),a=.5*s/(r+s),n=.5*r/(r+s);e.coords[0]+=a*t.coords[0]+n*i.coords[0],e.coords[1]+=a*t.coords[1]+n*i.coords[1],e.coords[2]+=a*t.coords[2]+n*i.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(U_.vertLeq(s.Org,a.Org)){if(U_.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;U_.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(U_.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r,s=e.regionBelow(i),a=i.eUp,n=s.eUp;if(I_(!U_.vertEq(a.Dst,n.Dst)),U_.vertLeq(a.Dst,n.Dst)){if(U_.edgeSign(a.Dst,n.Dst,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,r=t.mesh.splitEdge(a),t.mesh.splice(n.Sym,r),r.Lface.inside=i.inside}else{if(U_.edgeSign(n.Dst,a.Dst,n.Org)>0)return!1;i.dirty=s.dirty=!0,r=t.mesh.splitEdge(n),t.mesh.splice(a.Lnext,n.Sym),r.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r,s,a=e.regionBelow(i),n=i.eUp,o=a.eUp,l=n.Org,h=o.Org,u=n.Dst,d=o.Dst,c=new G_;if(I_(!U_.vertEq(d,u)),I_(U_.edgeSign(u,t.event,l)<=0),I_(U_.edgeSign(d,t.event,h)>=0),I_(l!==t.event&&h!==t.event),I_(!i.fixUpperEdge&&!a.fixUpperEdge),l===h||Math.min(l.t,u.t)>Math.max(h.t,d.t))return!1;if(U_.vertLeq(l,h)){if(U_.edgeSign(d,l,h)>0)return!1}else if(U_.edgeSign(u,h,l)<0)return!1;return e.debugEvent(t),U_.intersect(u,l,d,h,c),I_(Math.min(l.t,u.t)<=c.t),I_(c.t<=Math.max(h.t,d.t)),I_(Math.min(d.s,u.s)<=c.s),I_(c.s<=Math.max(h.s,l.s)),U_.vertLeq(c,t.event)&&(c.s=t.event.s,c.t=t.event.t),r=U_.vertLeq(l,h)?l:h,U_.vertLeq(r,c)&&(c.s=r.s,c.t=r.t),U_.vertEq(c,l)||U_.vertEq(c,h)?(e.checkForRightSplice(t,i),!1):!U_.vertEq(u,t.event)&&U_.edgeSign(u,t.event,c)>=0||!U_.vertEq(d,t.event)&&U_.edgeSign(d,t.event,c)<=0?d===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Sym,n),i=e.topLeftRegion(t,i),n=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),a),e.addRightEdges(t,i,n.Oprev,n,n,!0),!0):u===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Lnext,o.Oprev),a=i,i=e.topRightRegion(i),s=e.regionBelow(i).eUp.Rprev,a.eUp=o.Oprev,o=e.finishLeftRegions(t,a,null),e.addRightEdges(t,i,o.Onext,n.Rprev,s,!0),!0):(U_.edgeSign(u,t.event,c)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),U_.edgeSign(d,t.event,c)<=0&&(i.dirty=a.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,n),n.Org.s=c.s,n.Org.t=c.t,n.Org.pqHandle=t.pq.insert(n.Org),e.getIntersectData(t,n.Org,l,u,h,d),e.regionAbove(i).dirty=i.dirty=a.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r,s,a=e.regionBelow(i);;){for(;a.dirty;)i=a,a=e.regionBelow(a);if(!i.dirty&&(a=i,null===(i=e.regionAbove(i))||!i.dirty))return;if(i.dirty=!1,r=i.eUp,s=a.eUp,r.Dst!==s.Dst&&e.checkForLeftSplice(t,i)&&(a.fixUpperEdge?(e.deleteRegion(t,a),t.mesh.delete(s),s=(a=e.regionBelow(i)).eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(r),r=(i=e.regionAbove(a)).eUp)),r.Org!==s.Org)if(r.Dst===s.Dst||i.fixUpperEdge||a.fixUpperEdge||r.Dst!==t.event&&s.Dst!==t.event)e.checkForRightSplice(t,i);else if(e.checkForIntersect(t,i))return;r.Org===s.Org&&r.Dst===s.Dst&&(e.addWinding(s,r),e.deleteRegion(t,i),t.mesh.delete(r),i=e.regionAbove(a))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;o.Dst!==l.Dst&&e.checkForIntersect(t,i),U_.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),U_.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h?e.addRightEdges(t,i,r.Onext,a,a,!0):(s=U_.vertLeq(l.Org,o.Org)?l.Oprev:o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i))},e.connectLeftDegenerate=function(t,i,r){var s,a,n,o,l;return s=i.eUp,U_.vertEq(s.Org,r)?(I_(!1),void e.spliceMergeVertices(t,s,r.anEdge)):U_.vertEq(s.Dst,r)?(I_(!1),i=e.topRightRegion(i),a=o=(n=(l=e.regionBelow(i)).eUp.Sym).Onext,l.fixUpperEdge&&(I_(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),U_.edgeGoesLeft(a)||(a=null),void e.addRightEdges(t,i,n.Onext,o,a,!0)):(t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),void e.sweepEvent(t,r))},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new Y_;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r)){if(n=r.eUp,o=s.eUp,0===U_.edgeSign(n.Dst,i,n.Org))return void e.connectLeftDegenerate(t,r,i);a=U_.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge?(l=a===r?t.mesh.connect(i.anEdge.Sym,n.Lnext):t.mesh.connect(o.Dnext,i.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(t,a,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)):e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;null===r.activeRegion;)if((r=r.Onext)===i.anEdge)return void e.connectLeftVertex(t,i);var s=e.topLeftRegion(t,r.activeRegion);I_(null!==s);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(e,t,i,r){var s=new Y_,a=e.mesh.makeEdge();a.Org.s=i,a.Org.t=r,a.Dst.s=t,a.Dst.t=r,e.event=a.Dst,s.eUp=a,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},e.initEdgeDict=function(t){t.dict=new K_(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;null!==(i=t.dict.min().key);)i.sentinel||(I_(i.fixUpperEdge),I_(1===++r)),I_(0===i.windingNumber),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,U_.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),s=(i=s).Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(e){var t,i,r,s=0;for(i=(r=e.mesh.vHead).next;i!==r;i=i.next)s++;for(s+=8,t=e.pq=new $_(s,U_.vertLeq),i=(r=e.mesh.vHead).next;i!==r;i=i.next)i.pqHandle=t.insert(i);return i===r&&(t.init(),!0)},e.donePriorityQ=function(e){e.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,I_((a=r.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));return!0},e.computeInterior=function(t,i){var r,s;if(void 0===i&&(i=!0),e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);null!==(r=t.pq.extractMin());){for(;null!==(s=t.pq.min())&&U_.vertEq(s,r);)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),!!e.removeDegenerateFaces(t,t.mesh)&&(i&&t.mesh.check(),!0)},e}(),J_=function(){function e(){this.mesh=new W_,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=z_.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},e.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},e.prototype.computeNormal_=function(e){var t,i,r,s,a,n,o=[0,0,0],l=[0,0,0],h=[0,0,0],u=[0,0,0],d=[0,0,0],c=[null,null,null],p=[null,null,null],m=this.mesh.vHead;t=m.next;for(var g=0;g<3;++g)s=t.coords[g],l[g]=s,p[g]=t,o[g]=s,c[g]=t;for(t=m.next;t!==m;t=t.next)for(var f=0;f<3;++f)(s=t.coords[f])<l[f]&&(l[f]=s,p[f]=t),s>o[f]&&(o[f]=s,c[f]=t);var y=0;if(o[1]-l[1]>o[0]-l[0]&&(y=1),o[2]-l[2]>o[y]-l[y]&&(y=2),l[y]>=o[y])return e[0]=0,e[1]=0,void(e[2]=1);for(n=0,i=p[y],r=c[y],h[0]=i.coords[0]-r.coords[0],h[1]=i.coords[1]-r.coords[1],h[2]=i.coords[2]-r.coords[2],t=m.next;t!==m;t=t.next)u[0]=t.coords[0]-r.coords[0],u[1]=t.coords[1]-r.coords[1],u[2]=t.coords[2]-r.coords[2],d[0]=h[1]*u[2]-h[2]*u[1],d[1]=h[2]*u[0]-h[0]*u[2],d[2]=h[0]*u[1]-h[1]*u[0],(a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2])>n&&(n=a,e[0]=d[0],e[1]=d[1],e[2]=d[2]);n<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(h)]=1)},e.prototype.checkOrientation_=function(){for(var e,t,i=this.mesh.fHead,r=this.mesh.vHead,s=0,a=i.next;a!==i;a=a.next)if(!((t=a.anEdge).winding<=0))do{s+=(t.Org.s-t.Dst.s)*(t.Org.t+t.Dst.t),t=t.Lnext}while(t!==a.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var e,t,i=this.mesh.vHead,r=[0,0,0],s=!1;r[0]=this.normal[0],r[1]=this.normal[1],r[2]=this.normal[2],!r[0]&&!r[1]&&!r[2]&&(this.computeNormal_(r),s=!0),e=this.sUnit,t=this.tUnit;var a=this.longAxis_(r);e[a]=0,e[(a+1)%3]=1,e[(a+2)%3]=0,t[a]=0,t[(a+1)%3]=0,t[(a+2)%3]=r[a]>0?1:-1;for(var n=i.next;n!==i;n=n.next)n.s=this.dot_(n.coords,e),n.t=this.dot_(n.coords,t);s&&this.checkOrientation_();for(var o=!0,l=i.next;l!==i;l=l.next)o?(this.bmin[0]=this.bmax[0]=l.s,this.bmin[1]=this.bmax[1]=l.t,o=!1):(l.s<this.bmin[0]&&(this.bmin[0]=l.s),l.s>this.bmax[0]&&(this.bmax[0]=l.s),l.t<this.bmin[1]&&(this.bmin[1]=l.t),l.t>this.bmax[1]&&(this.bmax[1]=l.t))},e.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},e.prototype.tessellateMonoRegion_=function(e,t){var i,r;if((i=t.anEdge).Lnext===i||i.Lnext.Lnext===i)throw"Mono region invalid";for(;U_.vertLeq(i.Dst,i.Org);i=i.Lprev);for(;U_.vertLeq(i.Org,i.Dst);i=i.Lnext);for(r=i.Lprev;i.Lnext!==r;)if(U_.vertLeq(i.Dst,r.Org)){for(;r.Lnext!==i&&(U_.edgeGoesLeft(r.Lnext)||U_.edgeSign(r.Org,r.Dst,r.Lnext.Dst)<=0);)r=e.connect(r.Lnext,r).Sym;r=r.Lprev}else{for(;r.Lnext!==i&&(U_.edgeGoesRight(i.Lprev)||U_.edgeSign(i.Dst,i.Org,i.Lprev.Org)>=0);)i=e.connect(i,i.Lprev).Sym;i=i.Lnext}if(r.Lnext===i)throw"Mono region invalid";for(;r.Lnext.Lnext!==i;)r=e.connect(r.Lnext,r).Sym;return!0},e.prototype.tessellateInterior_=function(e){for(var t,i=e.fHead.next;i!==e.fHead;i=t)if(t=i.next,i.inside&&!this.tessellateMonoRegion_(e,i))return!1;return!0},e.prototype.discardExterior_=function(e){for(var t,i=e.fHead.next;i!==e.fHead;i=t)t=i.next,i.inside||e.zapFace(i)},e.prototype.setWindingNumber_=function(e,t,i){for(var r,s=e.eHead.next;s!==e.eHead;s=r)r=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:i?e.delete(s):s.winding=0},e.prototype.getNeighbourFace_=function(e){return e.Rface&&e.Rface.inside?e.Rface.n:-1},e.prototype.outputPolymesh_=function(e,t,i,r){var s,a,n=0,o=0;i>3&&e.mergeConvexFaces(i);for(var l=e.vHead.next;l!==e.vHead;l=l.next)l.n=-1;for(var h=e.fHead.next;h!==e.fHead;h=h.next)if(h.n=-1,h.inside){s=h.anEdge,a=0;do{-1===(l=s.Org).n&&(l.n=o,o++),a++,s=s.Lnext}while(s!==h.anEdge);if(a>i)throw"Face vertex greater that support polygon";h.n=n,++n}for(this.elementCount=n,t===k_.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*i,this.vertexCount=o,this.vertices=[],this.vertices.length=o*r,this.vertexIndices=[],this.vertexIndices.length=o,l=e.vHead.next;l!==e.vHead;l=l.next)if(-1!==l.n){var u=l.n*r;this.vertices[u+0]=l.coords[0],this.vertices[u+1]=l.coords[1],r>2&&(this.vertices[u+2]=l.coords[2]),this.vertexIndices[l.n]=l.idx}var d=0;for(h=e.fHead.next;h!==e.fHead;h=h.next)if(h.inside){s=h.anEdge,a=0;do{l=s.Org,this.elements[d++]=l.n,a++,s=s.Lnext}while(s!==h.anEdge);for(var c=a;c<i;++c)this.elements[d++]=-1;if(t===k_.CONNECTED_POLYGONS){s=h.anEdge;do{this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext}while(s!==h.anEdge);for(var p=a;p<i;++p)this.elements[d++]=-1}}},e.prototype.outputContours_=function(e,t){var i,r,s=0,a=0;this.vertexCount=0,this.elementCount=0;for(var n=e.fHead.next;n!==e.fHead;n=n.next)if(n.inside){r=i=n.anEdge;do{this.vertexCount++,i=i.Lnext}while(i!==r);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var o=0,l=0,h=0;for(s=0,n=e.fHead.next;n!==e.fHead;n=n.next)if(n.inside){a=0,r=i=n.anEdge;do{this.vertices[o++]=i.Org.coords[0],this.vertices[o++]=i.Org.coords[1],t>2&&(this.vertices[o++]=i.Org.coords[2]),this.vertexIndices[l++]=this.vertexIdCallback?this.vertexIdCallback(i):i.Org.idx,a++,i=i.Lnext}while(i!==r);this.elements[h++]=s,this.elements[h++]=a,s+=a}},e.prototype.addContour=function(e,t){null===this.mesh&&(this.mesh=new W_),e<2&&(e=2),e>3&&(e=3);for(var i=null,r=0;r<t.length;r+=e)null===i?(i=this.mesh.makeEdge(),this.mesh.splice(i,i.Sym)):(this.mesh.splitEdge(i),i=i.Lnext),i.Org.coords[0]=t[r+0],i.Org.coords[1]=t[r+1],i.Org.coords[2]=e>2?t[r+2]:0,i.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(i),i.winding=1,i.Sym.winding=-1},e.prototype.tesselate=function(e,t,i,r,s,a){if(void 0===e&&(e=z_.ODD),void 0===t&&(t=k_.POLYGONS),void 0===a&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,r<2&&(r=2),r>3&&(r=3),!this.mesh)return!1;this.projectPolygon_(),Z_.computeInterior(this,a);var n=this.mesh;return t===k_.BOUNDARY_CONTOURS?this.setWindingNumber_(n,1,!0):this.tessellateInterior_(n),a&&n.check(),t===k_.BOUNDARY_CONTOURS?this.outputContours_(n,r):this.outputPolymesh_(n,t,i,r),!0},e}(),z_.ODD,z_.NONZERO,z_.POSITIVE,z_.NEGATIVE,z_.ABS_GEQ_TWO,k_.POLYGONS,k_.CONNECTED_POLYGONS,k_.BOUNDARY_CONTOURS}),rS=n(()=>{(eS=Q_=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*Q_.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} → ${e}`);let i=e*Q_.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,a=0,n=new Float32Array(r,a*s,3*e);a+=3*e;let o=new Float32Array(r,a*s,3*e);a+=3*e;let l=new Float32Array(r,a*s,2*e);t?(n.set(this.positions.subarray(0,3*this.size)),o.set(this.normals.subarray(0,3*this.size)),l.set(this.uvs.subarray(0,2*this.size))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let e=this.capacity;for(;t>e;)e*=2;this.realloc(e)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} → ${this.size}`),this.realloc(this.size,!0)}}).eSize=8*Float32Array.BYTES_PER_ELEMENT}),sS=n(()=>{tS=class{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let s=e-1>>1,a=t[s];if(i(r,a)>=0)break;t[e]=a,e=s}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,s=t[e];for(;e<r;){let r=1+(e<<1),a=r+1;if(a<this.length&&i(t[a],t[r])<0&&(r=a),i(t[r],s)>=0)break;t[e]=t[r],e=r}t[e]=s}}});function aS(e,t,i,r){this.x=e,this.y=t,this.h=i,this.d=function(e,t,i){let r=!1,s=1/0;for(let a of i)for(let i=0,n=a.length,o=n-1;i<n;o=i++){let n=a[i],l=a[o];n[1]>t!=l[1]>t&&e<(l[0]-n[0])*(t-n[1])/(l[1]-n[1])+n[0]&&(r=!r),s=Math.min(s,nS(e,t,n,l))}return 0===s?0:(r?1:-1)*Math.sqrt(s)}(e,t,r),this.max=this.d+this.h*Math.SQRT2}function nS(e,t,i,r){let s=i[0],a=i[1],n=r[0]-s,o=r[1]-a;if(0!==n||0!==o){let i=((e-s)*n+(t-a)*o)/(n*n+o*o);i>1?(s=r[0],a=r[1]):i>0&&(s+=n*i,a+=o*i)}return n=e-s,o=t-a,n*n+o*o}var oS,lS,hS,uS,dS,cS,pS,mS,gS=n(()=>{sS()}),fS=n(()=>{Mu(),iS(),rS(),md(),gS(),oS={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},lS={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},hS={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},uS=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),dS=class extends an{constructor(e,t,i=0,r=12,s=3,a=z_.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o,l,h,u=this._shape.extractShapePointsToFlatArray([],r),d=this._shape.shapeHoles.map(e=>{let t=e.extractShapePointsToFlatArray([],r),i=[];for(let e=t.length-1;e>=1;e-=2){let r=t[e-1],s=t[e-0];i.push(r,s)}return i}),c=[],p=[];for(let e=0;e<u.length;e+=2)p.push([u[e],u[e+1]]);c.push(p);for(let e=0;e<d.length;e++){let t=d[e],i=[];for(let e=0;e<t.length;e+=2)i.push([t[e],t[e+1]]);c.push(i)}o=e.isText?.1*(new qh).setFromPoints(e.points.map(e=>e.position)).getSize(new rs).length():0===c[0].length?i:i>0?function(e,t,i=1,r=!1){let s=1/0,a=1/0,n=-1/0,o=-1/0;for(let[t,i]of e[0])t<s&&(s=t),i<a&&(a=i),t>n&&(n=t),i>o&&(o=i);let l=n-s,h=o-a,u=Math.max(i,Math.min(l,h));if(u===i){let e=[s,a];return e.distance=0,e.distance}let d=new tS([],(e,t)=>t.max-e.max),c=function(e){let t=0,i=0,r=0,s=e[0];for(let e=0,a=s.length,n=a-1;e<a;n=e++){let a=s[e],o=s[n],l=a[0]*o[1]-o[0]*a[1];i+=(a[0]+o[0])*l,r+=(a[1]+o[1])*l,t+=3*l}let a=new aS(i/t,r/t,0,e);return 0===t||a.d<0?new aS(s[0][0],s[0][1],0,e):a}(e),p=new aS(s+l/2,a+h/2,0,e);p.d>c.d&&(c=p);let m=2;function g(s,a,n){let o=new aS(s,a,n,e);if(m++,o.max>c.d+i&&d.push(o),o.d>c.d&&(c=o,r&&console.log(`found best ${Math.round(1e4*o.d)/1e4} after ${m} probes`),c.d>t))return t}let f=u/2;for(let e=s;e<n;e+=u)for(let t=a;t<o;t+=u)g(e+f,t+f,f);for(;d.length;){let{max:e,x:t,y:r,h:s}=d.pop();if(e-c.d<=i)break;f=s/2,g(t-f,r-f,f),g(t+f,r-f,f),g(t-f,r+f,f),g(t+f,r+f,f)}r&&console.log(`num probes: ${m}\nbest distance: ${c.d}`);let y=[c.x,c.y];return y.distance=c.d,y.distance}(c,i):1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,o,t/2),this._bevelSegments=Math.floor(s));try{l=L_({windingRule:a,elementType:k_.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{l=oS}try{h=L_({windingRule:z_.ODD,elementType:k_.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...d]})}catch{h=lS}if(!l)throw new Error("error generating geometry");let m=l.elementCount;if(h){l.elementCount+=h.elementCount;for(let e=0;e<h.elements.length;e++){let t=h.elements[e],i=e%2==0?l.vertexCount:0;l.elements.push(t+i)}for(let e=0;e<h.vertexIndices.length;e++){let t=h.vertexIndices[e],i=l.vertexCount;l.vertexIndices.push(t+i)}for(let e=0;e<h.vertices.length;e++){let t=h.vertices[e];l.vertices.push(t)}}let g=1/0,f=-1/0,y=1/0,v=-1/0;for(let e=0,t=l.vertexCount;e<t;e++){let t=2*e,i=l.vertices[t+0],r=l.vertices[t+1];i<g&&(g=i),i>f&&(f=i),r<y&&(y=r),r>v&&(v=r)}this._minX=g,this._minY=y,this._width=f-g,this._height=v-y,this._buffer=new eS(this._computeBufferEstimatedSize(l));let b=[],x=[];for(let e=l.elementCount-1;e>=0;e--){let t=e>=m,i=2*e,s=l.elements[i+0],a=l.elements[i+1],h=s+a,u={start:s,count:a,normals:[],continuous:[],concave:[]},c=s,p=h-1,g=s+1,f=this._shape.roundedCurves.length;do{let e=c-s,i=l.vertices[2*p+0],r=l.vertices[2*p+1],n=l.vertices[2*c+0],o=l.vertices[2*c+1],d=l.vertices[2*g+0],m=l.vertices[2*g+1],y=n-i,v=o-r,b=Math.sqrt(y*y+v*v);y/=b,v/=b;let x=n-d,w=o-m,_=Math.sqrt(x*x+w*w);x/=_,w/=_,u.normals[2*e+0]=-w,u.normals[2*e+1]=x,u.concave[e]=y*w-v*x>0;let S=l.vertexIndices[c];if(Array.isArray(S))u.continuous[e]=!1;else{let[t,i]=this._shape.getCurveIndexFromVertexId(S-1,!0);if(i>0&&i<1)u.continuous[e]=!0;else{let r=1===i?t+1:t-1;r=(r+f)%f;let s=1===i?0:1,a=this._shape.roundedCurves[t].getTangent(i),n=this._shape.roundedCurves[r].getTangent(s);u.continuous[e]=a.dot(n)>.95}}t&&(u.normals[2*e+0]*=-1,u.normals[2*e+1]*=-1),[p,c,g]=[c,g,g+1],g>=h&&(g-=a)}while(g!==s+1);let y=[];y.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(2*s,2*h),vertexCount:a,vertexIndices:new Array(a).fill(!0).map((e,t)=>[t,t]),elements:[0,a],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(2*s,2*h)});let v=0;for(let e=1;e<=this._bevelSegments;e++){let i=e/this._bevelSegments*Math.PI/2,s=(1-Math.cos(i))*this._bevel,n=[],o=[],h=[],d=[],c=0;for(let e=0;e<a;e++){let i=2*e,p=(e-1+a)%a*2,m=l.vertices[2*u.start+i+0],g=l.vertices[2*u.start+i+1],f=-u.normals[p+0]*s,y=-u.normals[p+1]*s,v=-u.normals[i+0]*s,b=-u.normals[i+1]*s;if(u.concave[e]||!u.concave[e]&&t){let i=Math.atan2(y,f),a=Math.atan2(b,v);a>i&&(a-=2*Math.PI);let o=a-i;if(u.continuous[e]||t){let r=i+o/2,a=Math.cos(r)*s,l=Math.sin(r)*s;n[2*c+0]=m+a*(t?-1:1),n[2*c+1]=g+l*(t?-1:1),d[c]=e,c++}else{let t=Math.max(1,Math.floor(r/4*Math.abs(o)/Math.PI));for(let r=0;r<=t;r++){let a=i+o*(r/t),l=Math.cos(a)*s,h=Math.sin(a)*s;n[2*c+0]=m+l,n[2*c+1]=g+h,d[c]=e,c++}}}else n[2*c+0]=m+f,n[2*c+1]=g+y,d[c]=e,o[e]=c,c++,n[2*c+0]=m,n[2*c+1]=g,d[c]=e,c++,n[2*c+0]=m+v,n[2*c+1]=g+b,d[c]=e,h[e]=c,c++}let p=L_({windingRule:z_.POSITIVE,elementType:k_.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n],edgeCreateCallback:e=>{let t=e.Org.idx,i=d[t],r=d[(t+1)%d.length];e.idx=[i,r],e.Sym.idx=[r,i]},vertexIdCallback:e=>{let t=e.Lprev.idx;return[t?t[1]:0,e.idx?e.idx[0]:0]}});if(!p)throw console.log("Error"),new Error(`error generating bevel geometry for ${e}'th loop`);if(!p.vertexCount){let t=(e-1)/this._bevelSegments*Math.PI/2;v=(1-Math.sin(t))*this._bevel;break}for(let e=0;e<p.vertexIndices.length;e++){let[t,i]=p.vertexIndices[e];if(t===i)continue;let r=i;i<t&&(r+=a);for(let s=t;s<r;s++){let r=s%a,n=(s+1)%a;if(!u.continuous[r]||!u.continuous[n]){p.vertexIndices[e]=[t,r],p.vertexIndices.splice(e+1,0,[n,i]),p.vertices.splice(2*(e+1),0,p.vertices[2*e],p.vertices[2*e+1]);break}}}y.push({bevelI:e,angle:i,size:s,boundary:p,reverseMap:d,insetPoints:n})}let w=(e,t,i)=>{let r=0,s=e.boundary.vertexIndices.length;for(;r<s&&i(e.boundary.vertexIndices[t]);)t=(t+1)%s,r++;return r},_=b.length;for(let e=1;e<y.length;e++){let t=y[e-1],i=y[e],r=t.boundary.vertexIndices.length,s=i.boundary.vertexIndices.length;if(!r||!s)break;let o=u.concave.length,l=0,h=uS(l,a);for(;!t.boundary.vertexIndices.filter(h).length||!i.boundary.vertexIndices.filter(h).length;)l++,h=uS(l,a);let d=t.boundary.vertexIndices.findIndex(h),c=i.boundary.vertexIndices.findIndex(h);do{d=(d+1)%r}while(h(t.boundary.vertexIndices[d]));do{c=(c+1)%s}while(h(i.boundary.vertexIndices[c]));l=(l+1)%a;let p,m,g=l,f=0,v=this._buildBevelVert(u,t,(d-1+r)%r,void 0,f),x=this._buildBevelVert(u,i,(c-1+s)%s,void 0,f),_=!1;do{f=(l||o)/o,h=uS(l,a);let e=w(t,d,h),g=w(i,c,h),y=_;if(_=!1,e&&!g){for(let i=0;i<e;i++)p=this._buildBevelVert(u,t,(d+i)%r,i/(e-1),f),b.push(v.topN,p.topP,x.topN),!1===n&&b.push(p.bottomP,v.bottomN,x.bottomN),v=p;_=!0}else if(!e&&g)for(let e=0;e<g;e++)m=this._buildBevelVert(u,i,(c+e)%s,e/(g-1),f),b.push(x.topN,v.topP,m.topP),!1===n&&b.push(v.bottomP,x.bottomN,m.bottomP),x=m;else if(e&&g)if(p=this._buildBevelVert(u,t,d,0,f),m=this._buildBevelVert(u,i,c,0,f),y?(b.push(v.topN,m.topP,x.topN),b.push(v.topN,p.topP,m.topP),!1===n&&(b.push(m.bottomP,v.bottomN,x.bottomN),b.push(m.bottomP,p.bottomP,v.bottomN))):(b.push(x.topN,v.topN,p.topP),b.push(x.topN,p.topP,m.topP),!1===n&&(b.push(p.bottomP,v.bottomN,x.bottomN),b.push(p.bottomP,x.bottomN,m.bottomP))),v=p,x=m,e===g)for(let a=1;a<e;a++)p=this._buildBevelVert(u,t,(d+a)%r,a/(e-1),f),m=this._buildBevelVert(u,i,(c+a)%s,a/(g-1),f),b.push(v.topN,p.topP,x.topN),b.push(x.topN,p.topP,m.topP),!1===n&&(b.push(p.bottomP,v.bottomN,x.bottomN),b.push(p.bottomP,x.bottomN,m.bottomP)),v=p,x=m;else if(e>g){let a=e/g,o=0;for(let l=1;l<e;l++)p=this._buildBevelVert(u,t,(d+l)%r,l/(e-1),f),b.push(v.topN,p.topP,x.topN),!1===n&&b.push(p.bottomP,v.bottomN,x.bottomN),v=p,l>(o+1)*a&&(o++,m=this._buildBevelVert(u,i,(c+o)%s,o/(g-1),f),b.push(x.topN,p.topP,m.topP),!1===n&&b.push(p.bottomP,x.bottomN,m.bottomP),x=m)}else{let a=g/e,o=0;for(let l=1;l<g;l++)m=this._buildBevelVert(u,i,(c+l)%s,l/(g-1),f),b.push(x.topN,p.topP,m.topP),!1===n&&b.push(p.bottomP,x.bottomN,m.bottomP),x=m,l>(o+1)*a&&(o++,p=this._buildBevelVert(u,t,(d+o)%r,o/(e-1),f),b.push(v.topN,p.topP,x.topN),!1===n&&b.push(p.bottomP,v.bottomN,x.bottomN),v=p)}d=(d+e)%r,c=(c+g)%s,l=(l+1)%o}while(l!==g)}if(!1===n&&this._depth>2*this._bevel&&this._buildWall(y,u,b),t){let e=[];for(let t=b.length-1;t>=_+2;t-=3){let i=b[t-2],r=b[t-1],s=b[t-0];e.push(s,r,i)}b.splice(_,b.length-_,...e)}if(t){let e=[];for(let t=y[y.length-1].boundary.vertices.length-1;t>=1;t-=2){let i=y[y.length-1].boundary.vertices[t-1],r=y[y.length-1].boundary.vertices[t-0];e.push(i,r)}x.push(e)}if(!t){let e,t=y[y.length-1];try{e=L_({windingRule:y.length>1?z_.POSITIVE:z_.ODD,elementType:k_.POLYGONS,vertexSize:2,strict:!0,contours:[t.insetPoints,...x]})}catch{e=hS}if(!e)throw new Error("Error generating geometry for surface");0===d.length&&this._bevel<o&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let t=0;t<3*e.elementCount;t+=3){let i=this._buildSurfaceVert(e,e.elements[t+0],v),r=this._buildSurfaceVert(e,e.elements[t+1],v),s=this._buildSurfaceVert(e,e.elements[t+2],v);b.push(i.top,r.top,s.top),!1===n&&b.push(s.bottom,r.bottom,i.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new ja(Uint32Array.from(b),1),_=new ja(this._buffer.positions,3),S=new ja(this._buffer.normals,3),M=new ja(this._buffer.uvs,2);_.needsUpdate=!0,S.needsUpdate=!0,M.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",_),this.setAttribute("normal",S),this.setAttribute("uv",M),this.setIndex(w)}_computeBufferEstimatedSize(e){return 2*e.vertexCount*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let e=0,s=r.boundary.vertexCount;e<s;e++){let a=this._buildBevelVert(t,r,e),n=this._buildBevelVert(t,r,(e+1)%s);i.push(n.topP,a.topN,a.bottomN),i.push(n.topP,a.bottomN,n.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[2*t+0],a=e.vertices[2*t+1],n=(s-this._minX)/this._width,o=(a-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=3*l,u=2*l,d={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=n,this._buffer.uvs[u+1]=o,!1===this.forPathBevel&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=n,this._buffer.uvs[u+3]=o),this.vertexCache[r]=d,d}_buildBevelVert(e,t,i,r=1,s){let a=`${t.bevelI}:${i}`;if(a in this.vertexCache&&0!==s&&1!==s&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let n,o,l,h,[u,d]=t.boundary.vertexIndices[i];u!==d?(o=u,n=d,h=!1,l=e.continuous[o]&&e.continuous[n]):(n=u,o=(n-1+e.count)%e.count,h=e.concave[n]&&t.bevelI>0,l=e.continuous[n]||h);let c=Math.cos(t.angle),p=Math.sin(t.angle),m=2*i,g=2*n,f=2*o,y=t.boundary.vertices[m+0],v=t.boundary.vertices[m+1],b=(1-p)*this._bevel,x=(y-this._minX)/this._width,w=(v-this._minY)/this._height;this.forPathBevel&&(void 0!==s&&(x=s),w=1);let _=e.normals[g+0],S=e.normals[g+1],M=e.normals[f+0],T=e.normals[f+1];if(h){_+=(M-_)*(1-r),S+=(T-S)*(1-r);let e=Math.sqrt(_*_+S*S);_/=e,S/=e}let C=this.forPathBevel?this._buffer.get(l?1:2):this._buffer.get(l?2:4),A=3*C,N=2*C,P={i:i,fi:n,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[A+0]=y,this._buffer.positions[A+1]=v,this._buffer.positions[A+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[A+0]=_*c,this._buffer.normals[A+1]=S*c,this._buffer.normals[A+2]=p,this._buffer.uvs[N+0]=x,this._buffer.uvs[N+1]=w,!1===this.forPathBevel&&(this._buffer.positions[A+3]=y,this._buffer.positions[A+4]=v,this._buffer.positions[A+5]=b,this._buffer.normals[A+3]=_*c,this._buffer.normals[A+4]=S*c,this._buffer.normals[A+5]=-p,this._buffer.uvs[N+2]=w,this._buffer.uvs[N+3]=x),l||(this.forPathBevel?(C+=1,A+=3,N+=2):(C+=2,A+=6,N+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[A+0]=y,this._buffer.positions[A+1]=v,this._buffer.positions[A+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[A+0]=M*c,this._buffer.normals[A+1]=T*c,this._buffer.normals[A+2]=p,this._buffer.uvs[N+0]=x,this._buffer.uvs[N+1]=w,!1===this.forPathBevel&&(this._buffer.positions[A+3]=y,this._buffer.positions[A+4]=v,this._buffer.positions[A+5]=b,this._buffer.normals[A+3]=M*c,this._buffer.normals[A+4]=T*c,this._buffer.normals[A+5]=-p,this._buffer.uvs[N+2]=w,this._buffer.uvs[N+3]=x)),this.vertexCache[a]=P,P}clone(){let e=new dS(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Yu(this.userData),e}}}),yS=n(()=>{Mu(),iS(),md(),fS(),cS=class extends an{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=z_.ODD,this.elementType=k_.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:z_.ODD,elementType:k_.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,s,a,n=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(e=>e.extractShapePointsToFlatArray([],this._curveSegments)),l=!0,h=!0;for(let e=0,t=n.length/2;e<t;e++){let t=2*e,i=n[t+0],r=n[t+1];if(void 0!==s&&i!==s&&(l=!1),void 0!==a&&r!==a&&(h=!1),s=i,a=r,!l&&!h)break}if(!l&&!h)try{r=L_({contours:[n,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{r=oS}let u=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new ja(new Float32Array(3*u),3),this._normalAttribute=new ja(new Float32Array(3*u),3),this._uvAttribute=new ja(new Float32Array(2*u),2),this._indexAttribute=new ja(new Uint32Array(3*d),1),r){let e=1/0,t=-1/0,i=1/0,s=-1/0;for(let a=0,n=u;a<n;a++){let n=2*a,o=r.vertices[n+0],l=r.vertices[n+1];o<e&&(e=o),o>t&&(t=o),l<i&&(i=l),l>s&&(s=l)}let a=t-e,n=s-i;for(let t=0,s=u;t<s;t++){let s=2*t,o=r.vertices[s+0],l=r.vertices[s+1],h=(o-e)/a,u=(l-i)/n;this._positionAttribute.setXYZ(t,o,l,0),this._normalAttribute.setXYZ(t,0,0,1),this._uvAttribute.setXY(t,h,u)}for(let e=0,t=d;e<t;e++){let t=3*e,i=r.elements[t+0],s=r.elements[t+1],a=r.elements[t+2];this._indexAttribute.setX(t+0,i),this._indexAttribute.setX(t+1,s),this._indexAttribute.setX(t+2,a)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let e=new cS(this._shape,this._curveSegments);return e.userData=Yu(this.userData),e}}}),vS=n(()=>{iS(),md(),fS(),pS=class extends dS{constructor(e,t,i=0,r=12,s=3,a=z_.ODD){super(e,t,i,r,s,a),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return 2*e.vertexCount*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let e=0,s=r.boundary.vertexCount;e<s;e++){let a=this._buildBevelVert(t,r,e),n=this._buildBevelVert(t,r,(e+1)%s);i.push(n.topP,a.topN,a.bottomN),i.push(n.topP,a.bottomN,n.bottomP)}}clone(){let e=new pS(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Yu(this.userData),e}}}),bS=n(()=>{R_(),yS(),vS(),iS(),mS=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:z_.ODD},e.parameters),s=Math.abs(r.width),a=Math.abs(r.height??r.width),n=Math.abs(r.depth??0),o=e.shape??t?.shape,l=o?.roundness??r.roundness;void 0!==o&&(o instanceof N_?(i=o,(i.width!==s||i.height!==a)&&i.applySize(s,a)):i=new N_(s,a).fromJSON(o),void 0!==e.parameters?.roundness&&e.parameters?.roundness>0&&i.update());let h=i??new N_(s,a);return{parameters:Object.assign(r,{width:s,height:a,depth:n,roundness:l}),shape:h}}static build(e){let t,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:a,roundness:n,windingRule:o}=e.parameters;return e.shape.roundness=n,t=i<=0?new cS(e.shape,a,{windingRule:o}):new pS(e.shape,i,r,a,s,o),Object.assign(t,{userData:{...e,type:"VectorGeometry"}})}}});function xS(e,t,i,r,s,a){if(r>=AS)return s>30||s%4==0?(function(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(SS(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(SS(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(SS(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(SS(s,a-i,s+o,a-i,s-o,a-i)),r>0&&TS(e,t,i,r)}(e,t,i,a),Math.round(s/4)):wS(e,r,s,t,i,a);let n={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=function({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(0===s||0===a)return[];let h=(e-i)/2,u=(t-r)/2;if(0===h&&0===u)return[];s=Math.abs(s),a=Math.abs(a);let d=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(a,2);d>1&&(s*=Math.sqrt(d),a*=Math.sqrt(d));let c=function(e,t,i,r,s,a,n,o,l,h){let u=Math.pow(s,2),d=Math.pow(a,2),c=Math.pow(n,2),p=Math.pow(o,2),m=u*d-u*p-d*c;m<0&&(m=0),m/=u*p+d*c,m=Math.sqrt(m)*(l===h?-1:1);let g=m*s/a*o,f=m*-a/s*n,y=g+(e+i)/2,v=f+(t+r)/2,b=(n-g)/s,x=(o-f)/a,w=(-n-g)/s,_=(-o-f)/a,S=B_(1,0,b,x),M=B_(b,x,w,_);return!h&&M>0&&(M-=V_),h&&M<0&&(M+=V_),{centerx:y,centery:v,ang1:S,ang2:M}}(e,t,i,r,s,a,h,u,n,o),{ang1:p,ang2:m}=c,{centerx:g,centery:f}=c,y=Math.abs(m)/(V_/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);m/=v;for(let e=0;e<v;e++)l.push(O_(p,m)),p+=m;return l.map(e=>{let{x:t,y:i}=E_(e[0],s,a,g,f),{x:r,y:n}=E_(e[1],s,a,g,f),{x:o,y:l}=E_(e[2],s,a,g,f);return{x1:t,y1:i,x2:r,y2:n,x:o,y:l}})}({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?function(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(_S(t,i));for(let t=0,i=r.length;t<i;t++){let i=r[t],s=e.points[t],a=_S(i.x,i.y);s.controls[1].position.set(i.x1,i.y1),a.controls[0].position.set(i.x2,i.y2),e.addPoint(a)}return o>0?MS(e,a,n,o):e.addPoint(_S(0,0)),l}(e,n.x,n.y,h,s,t,i,a):wS(e,r,s,t,i,a)}function wS(e,t,i,r,s,a){let n=-t/i;for(let t=0;t<=i;t++){let i=n*t,a=Math.sin(i)*r,o=Math.cos(i)*s;e.addPoint(_S(a,o))}return t<AS?a>0?MS(e,r,s,a):e.addPoint(_S(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&TS(e,r,s,a)),1}function _S(e,t){return new c_(ts.generateUUID(),new rs(e,t))}function SS(e,t,i,r,s,a){let n=_S(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function MS(e,t,i,r){CS(e,t,i,r).forEach(t=>e.addPoint(t))}function TS(e,t,i,r){let s=CS(e,t,i,r),a=new N_;s.forEach(e=>a.addPoint(e)),a.isClosed=!0,e.shapeHoles.push(a)}function CS(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new rs(s/t,a/i),o=e.points.map(e=>{let t=e.clone();return t.uuid=ts.generateUUID(),t}).reverse();return o.forEach(e=>{e.position.multiply(n);let t=e.controls[0].position.clone().multiply(n),i=e.controls[1].position.clone().multiply(n);e.controls[0].position.copy(i),e.controls[1].position.copy(t)}),o}var AS,NS,PS,RS,ES,OS=n(()=>{R_(),P_(),D_(),bS(),Mu(),AS=2*Math.PI,NS=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=ts.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof N_?e.shape:new N_,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let t,{width:i,height:r,spikes:s,angle:a,innerRadius:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,u=e.shape,d=xS(u,.5*i,.5*r,a*Math.PI/180,s,n);return u.isClosed=!0,u.update(),0===a?(t=new an,t.setAttribute("position",new Ha([],3))):t=mS.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}}),Object.assign(t,{userData:{...e,type:"EllipseGeometry"}})}}}),BS=n(()=>{Mu(),Hw(),PS=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:a,cornerSides:n}=e.parameters,o=0===s&&0!==a?new RS(.5*t,a,n):new ul(.5*t,s),l=i/t,h=r/t;return(1!==l||1!==h)&&o.scale(1,l,h),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},RS=class extends Uw{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s="IcosahedronGeometry";super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s,e,t,i),this.type=s}static fromJSON(e){return new RS(e.radius,e.corner,e.cornerSides)}}}),VS=n(()=>{Mu(),ES=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(e=>{Array.isArray(e)&&(e.x=e[0],e.y=e[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new ol;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let a=new dl(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}}});function DS(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function IS(e){let{positions:t,faces:i,materialIndices:r,uvs:s}=e,a=t.length/3,n=i.length/3,o=null!==s&&n>0,l=3*n,h=new Uint32Array(l),u=new Uint32Array(l),d=new Uint32Array(l),c=new Uint32Array(l),p=new Uint32Array(l),m=0,g=8;for(;g<2*l;)g*=2;let f=g-1,y=new Int32Array(g).fill(-1),v=(e,t)=>{let i=(Math.imul(e,2654435761)^t)&f;for(;;){let r=y[i];if(-1===r)return y[i]=m,h[m]=e,u[m]=t,m++;if(h[r]===e&&u[r]===t)return r;i=i+1&f}},b=(e,t)=>{let i=e<t?e:t,r=e<t?t:e,s=(Math.imul(i,2654435761)^r)&f;for(;;){let e=y[s];if(h[e]===i&&u[e]===r)return e;s=s+1&f}},x=new Uint32Array(a),w=new Float64Array(3*a),_=(e,i,r)=>{let s=e<i?v(e,i):v(i,e),a=++d[s];1===a?c[s]=r:2===a&&(p[s]=r),x[e]++,x[i]++,w[3*e]+=t[3*i],w[3*e+1]+=t[3*i+1],w[3*e+2]+=t[3*i+2],w[3*i]+=t[3*e],w[3*i+1]+=t[3*e+1],w[3*i+2]+=t[3*e+2]};for(let e=0;e<n;e++){let t=i[3*e],r=i[3*e+1],s=i[3*e+2];_(t,r,s),_(r,s,t),_(s,t,r)}let S=new Float64Array(3*m);for(let e=0;e<m;e++){let i=3*h[e],r=3*u[e];if(2===d[e]){let s=3*c[e],a=3*p[e];S[3*e]=.375*(t[i]+t[r])+.125*(t[s]+t[a]),S[3*e+1]=.375*(t[i+1]+t[r+1])+.125*(t[s+1]+t[a+1]),S[3*e+2]=.375*(t[i+2]+t[r+2])+.125*(t[s+2]+t[a+2])}else S[3*e]=.5*(t[i]+t[r]),S[3*e+1]=.5*(t[i+1]+t[r+1]),S[3*e+2]=.5*(t[i+2]+t[r+2])}let M,T=new Float64Array(3*a);for(let e=0;e<a;e++){let i=x[e];3===i?M=3/16:i>3&&(M=3/(8*i));let r=1-i*Number(M),s=Number(M);2===i&&(r=3/4,s=1/8),T[3*e]=t[3*e]*r+w[3*e]*s,T[3*e+1]=t[3*e+1]*r+w[3*e+1]*s,T[3*e+2]=t[3*e+2]*r+w[3*e+2]*s}let C=new Float64Array(3*(a+m));C.set(T),C.set(S,3*a);let A=new Uint32Array(12*n),N=new Array(4*n),P=o?new Float64Array(24*n):null;for(let e=0;e<n;e++){let t=i[3*e],n=i[3*e+1],o=i[3*e+2],l=b(t,n)+a,h=b(n,o)+a,u=b(o,t)+a,d=12*e;A[d++]=l,A[d++]=h,A[d++]=u,A[d++]=t,A[d++]=l,A[d++]=u,A[d++]=n,A[d++]=h,A[d++]=l,A[d++]=o,A[d++]=u,A[d++]=h;let c=r[e];if(N[4*e]=c,N[4*e+1]=c,N[4*e+2]=c,N[4*e+3]=c,null!==P){let t=6*e,i=s[t],r=s[t+1],a=s[t+2],n=s[t+3],o=s[t+4],l=s[t+5],h=DS(i,a),u=DS(r,n),d=DS(a,o),c=DS(n,l),p=DS(i,o),m=DS(r,l),g=24*e;P[g++]=h,P[g++]=u,P[g++]=d,P[g++]=c,P[g++]=p,P[g++]=m,P[g++]=i,P[g++]=r,P[g++]=h,P[g++]=u,P[g++]=p,P[g++]=m,P[g++]=a,P[g++]=n,P[g++]=d,P[g++]=c,P[g++]=h,P[g++]=u,P[g++]=o,P[g++]=l,P[g++]=p,P[g++]=m,P[g++]=d,P[g++]=c}}return{positions:C,faces:A,materialIndices:N,uvs:P}}var LS,zS,kS,US,FS,jS=n(()=>{Mu(),LS=1e4,zS=class{constructor(e=1){this.subdivisions=e}modify(e){let t=function(e){let t=e.getAttribute("position");if(void 0===t)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let i=e.getAttribute("uv"),r=e.getIndex(),s=t.count,a=new Map,n=new Uint32Array(s),o=[],l=0;for(let e=0;e<s;e++){let i=t.getX(e),r=t.getY(e),s=t.getZ(e),h=Math.round(i*LS),u=Math.round(r*LS),d=Math.round(s*LS),c=a.get(h);void 0===c&&(c=new Map,a.set(h,c));let p=c.get(u);void 0===p&&(p=new Map,c.set(u,p));let m=p.get(d);void 0===m&&(m=l++,p.set(d,m),o.push(i,r,s)),n[e]=m}let h=[],u=[],d=void 0===i?null:[],c=null!==r?r.count:s,p=(e,t)=>{let a=null!==r?r.getX(e):e,o=null!==r?r.getX(e+1):e+1,l=null!==r?r.getX(e+2):e+2;if(!(a<s&&o<s&&l<s))return;let c=n[a],p=n[o],m=n[l];c===p||p===m||m===c||(h.push(c,p,m),u.push(t),null!==d&&d.push(i.getX(a),i.getY(a),i.getX(o),i.getY(o),i.getX(l),i.getY(l)))},m=e.groups;if(m.length>0)for(let e=0;e<m.length;e++){let t=m[e],i=void 0===t.materialIndex?0:t.materialIndex,r=Math.max(t.start,0),s=Math.min(t.start+t.count,c);for(let e=r;e<s&&e+2<c;e+=3)p(e,i)}else for(let e=0;e+2<c;e+=3)p(e,0);return{positions:Float64Array.from(o),faces:Uint32Array.from(h),materialIndices:u,uvs:null===d?null:Float64Array.from(d)}}(e),i=this.subdivisions;for(;i-- >0;)t=IS(t);return function(e,t){let{positions:i,faces:r,materialIndices:s,uvs:a}=e,n=i.length/3,o=r.length/3,l=new Float64Array(3*n);for(let e=0;e<o;e++){let t=3*r[3*e],s=3*r[3*e+1],a=3*r[3*e+2],n=i[a]-i[s],o=i[a+1]-i[s+1],h=i[a+2]-i[s+2],u=i[t]-i[s],d=i[t+1]-i[s+1],c=i[t+2]-i[s+2],p=o*c-h*d,m=h*u-n*c,g=n*d-o*u;l[t]+=p,l[t+1]+=m,l[t+2]+=g,l[s]+=p,l[s+1]+=m,l[s+2]+=g,l[a]+=p,l[a+1]+=m,l[a+2]+=g}for(let e=0;e<n;e++){let t=l[3*e],i=l[3*e+1],r=l[3*e+2],s=Math.sqrt(t*t+i*i+r*r)||1;l[3*e]=t/s,l[3*e+1]=i/s,l[3*e+2]=r/s}let h=3*o,u=new Float32Array(3*h),d=new Float32Array(3*h),c=null!==a&&a.length>0?new Float32Array(2*h):null;for(let e=0;e<h;e++){let t=3*r[e];u[3*e]=i[t],u[3*e+1]=i[t+1],u[3*e+2]=i[t+2],d[3*e]=l[t],d[3*e+1]=l[t+1],d[3*e+2]=l[t+2]}null!==c&&c.set(a.subarray(0,2*h));let p=new an;p.setAttribute("position",new ja(u,3)),h>0&&(p.setAttribute("normal",new ja(d,3)),p.setAttribute("color",new ja(new Float32Array(3*h).fill(1),3))),null!==c&&p.setAttribute("uv",new ja(c,2));for(let e=0;e<o;){let t=s[e],i=e;do{e++}while(e<o&&s[e]===t);p.addGroup(3*i,3*(e-i),t)}return null!==t.boundingBox&&(p.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(p.boundingSphere=t.boundingSphere.clone()),p}(t,e)}}}),GS=n(()=>{Mu(),jS(),kS=new ns,US=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i,r=e.geometry??t?.geometry??(new an).copy(new Lo(100,100,100));void 0===t?(r.computeBoundingBox(),r.boundingBox.getSize(kS),i={width:kS.x,height:kS.y,depth:kS.z,subdivisions:0}):i=t.parameters;let s={...i,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:r}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,a=e.geometry??(new an).copy(new Lo(100,100,100)),n=a.userData.parameters;void 0===n?(a.boundingBox=function(e){let t=new Sa,i=e.attributes.position;return i?(t.setFromBufferAttribute(i),t):(t.makeEmpty(),t)}(a),a.boundingBox.getSize(kS)):kS.set(n.width,n.height,n.depth),(t!==kS.x||i!==kS.y||r!==kS.z)&&a.scale(0===kS.x?1:t/kS.x,0===kS.y?1:i/kS.y,0===kS.z?1:r/kS.z);let o=a.originalGeometry;try{s>0?(void 0===o||n?.subdivisions!==s)&&(void 0===o&&(o=a),a=new zS(s).modify(o)):(void 0!==o&&(a=o),o=void 0,void 0===a.getAttribute("normal")&&a.computeVertexNormals())}catch{void 0!==o&&(a=o),o=void 0,void 0===a.getAttribute("normal")&&a.computeVertexNormals()}return void 0!==o&&Object.assign(a,{originalGeometry:o}),delete e.geometry,Object.assign(a,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new bh(i).load(e,e=>{let i=this.normalizeInputs({geometry:e});e.boundingBox.getSize(kS);let r=100/kS.x;Object.assign(i.parameters,{width:100,height:kS.y*r,depth:kS.z*r}),t(this.build(i))})}}}),WS=n(()=>{R_(),bS(),FS=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof N_?e.shape:new N_,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=.5*t,u=.5*i,d=2*Math.PI/r;for(let e=0;e<r;e++){let t=d*e,i=0+Math.sin(t)*h,r=0+Math.cos(t)*u;l.addPoint(l.createPoint(i,r))}l.isClosed=!0;for(let e=0,t=l.points.length;e<t;e++)l.points[e].roundness=s;l.roundness=s,l.update();let c=mS.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(c,{userData:{...e,type:"PolygonGeometry"}})}}});function qS(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function HS(e,t,i,r,s,a){let n=XS.copy(t).sub(e),o=KS.copy(i).sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===s){let t=n.add(o).normalize();a.copy(e).addScaledVector(t,r/Math.sin(l/2))}else{let t=n.angleTo(o);a.copy(e),a.addScaledVector(n,s/Math.sin(t)),a.addScaledVector(o,r/Math.sin(t))}}function $S(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var YS,XS,KS,ZS,JS,QS,eM,tM,iM,rM,sM,aM,nM,oM,lM=n(()=>{Mu(),YS=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:a,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new ZS(.5*t,i,s,a,n,o,l),u=r/t;return 1!==u&&h.scale(1,1,u),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}},XS=new ns,KS=new ns,ZS=class extends an{constructor(e=.5,t=1,i=4,r=1,s=!1,a=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o,l=[],h=[],u=[],d=[],c=0,p=t/2,m=Math.PI/i,g=e*Math.cos(Math.PI/i),f=2*Math.PI/i,y=(i-2)*Math.PI/i,v=Math.PI-y,b=new ns(0,-p,0),x=new ns(0,p,0),w=new rs(e,-p),_=new rs(g,-p),S=new rs(0,x.y).sub(_),M=new rs(0,x.y).sub(w),T=new rs(S.y,-S.x).normalize(),C=new rs(M.y,-M.x).normalize(),A=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;a=Math.min(a,A);{let e=new ns(T.x,T.y,0),t=new ns(Math.cos(f)*e.x,e.y,Math.sin(f)*e.x);o=e.angleTo(t)}let N=a/Math.tan((Math.PI-S.angle())/2),P=a/Math.tan((Math.PI-o)/2),R=new ns;if(!s){h.push(b.x,b.y,b.z),u.push(0,-1,0),d.push(0,0);let e=c++,t=[],r=w.clone(),s=N/Math.cos(Math.PI/i);r.x-=s;for(let e=0;e<i;e++){let s=e/i*Math.PI*2+m;qS(r,new rs(Math.sin(s),Math.cos(s)),R),h.push(R.x,R.y,R.z),u.push(0,-1,0),d.push(0,0),t.push(c++)}for(let i=0;i<t.length;i++)l.push(t[i],e,t[(i+1)%t.length])}let E=[];{let e=new ns,t=new ns,r=new ns,s=new ns,p=new ns,g=new ns;for(let f=0;f<i;f++){let y=f/i*Math.PI*2+m,v=(f+.5)/i*Math.PI*2+m,_=(f+1)/i*Math.PI*2+m,M=new rs(Math.sin(y),Math.cos(y)),A=new rs(Math.sin(v),Math.cos(v)),R=new rs(Math.sin(_),Math.cos(_));qS(w,M,t),qS(w,R,r),qS(T,A,e),HS(x,t,r,P,P,s),h.push(s.x,s.y,s.z),HS(t,x,r,P,N,p),h.push(p.x,p.y,p.z),HS(r,t,x,N,P,g),h.push(g.x,g.y,g.z),u.push(e.x,e.y,e.z),u.push(e.x,e.y,e.z),u.push(e.x,e.y,e.z),d.push(0,0),d.push(0,0),d.push(0,0);let V=c++,D=c++,I=c++;if(l.push(V,D,I),a>0){{let e=t.clone().add(r).multiplyScalar(.5),i=x.clone().sub(e).normalize(),s=b.clone().sub(e).normalize().add(i).normalize().multiplyScalar(-1);O(e,g.clone().sub(p),s,S.angle())}let m,f;{let e=new ns;qS(C,R,e);let t=g.clone().add(s).multiplyScalar(.5);t=$S(t,r,x);let i=g.clone().sub(s);[m,f]=O(t,i,e,o,s.y)}{let e=m,t=e.clone().setY(0).normalize(),i=new ns(0,-1,0),r=t.clone().cross(i);B(e,t,i,r)}E.concat(f);{let t=S.angle(),r=Math.PI-t,s=x.clone();s.y-=a/Math.sin(t-Math.PI/2);let o=new ns,p=[];for(let t=0;t<n;t++){let l=[],m=Math.PI/2-r*t/n,g=Math.cos(m),f=Math.sin(m),y=v;for(let r=0;r<=t;r++){let r=Math.cos(y),n=Math.sin(y);e.x=g*n,e.y=f,e.z=g*r,o.copy(s).addScaledVector(e,a),h.push(o.x,o.y,o.z),u.push(e.x,e.y,e.z),d.push(0,0),l.push(c++),y+=2*Math.PI/t/i}p.push(l)}f.reverse(),p.push(f);let m=p.length-1;for(let e=0;e<m;e++){let t=p[e],i=p[e+1],r=t.length-1;l.push(i[1],t[0],i[0]);for(let e=1;e<=r;e++)l.push(t[e],t[e-1],i[e]),l.push(i[e+1],t[e],i[e])}}}}}function O(e,t,i,r,s){let o=-r/2,p=(Math.PI-r)/2,m=t.clone().normalize().cross(i);e.addScaledVector(i,-a/Math.sin(p));let g=new ns,f=new ns,y=c,v=[];for(let l=0;l<=n;l++){let p=o+l/n*r;f.set(0,0,0),f.addScaledVector(m,Math.sin(p)),f.addScaledVector(i,Math.cos(p));for(let i=0;i<=1;i++){let r=i/1-.5;if(g.copy(e),g.addScaledVector(t,r),g.addScaledVector(f,a),null!=s){let e=Math.max(0,g.y-s);g.addScaledVector(t,-e/t.y)}h.push(g.x,g.y,g.z),u.push(f.x,f.y,f.z),d.push(0,0),0===i&&v.push(c),c++}}for(let e=0;e<n;e++)for(let t=0;t<1;t++){let i=y+t+2*e,r=i+2,s=r+1,a=i+1;l.push(i,r,a),l.push(r,s,a)}return[e.clone().addScaledVector(t,.5),v]}function B(e,t,i,r){let s=Math.PI/2,o=M.angle()-s,p=[],m=new ns,g=new ns;for(let l=0;l<=n;l++){let f=[],y=l/n;for(let n=0;n<=l;n++){let p=((l?n/l:0)-.5)*v,b=Math.cos(p),x=Math.sin(p),w=(s+Math.atan(Math.tan(o)*b))*y,_=Math.cos(w),S=Math.sin(w);m.set(0,0,0),m.addScaledVector(t,S*b),m.addScaledVector(i,_),m.addScaledVector(r,S*x),g.copy(e).addScaledVector(m,a),h.push(g.x,g.y,g.z),u.push(m.x,m.y,m.z),d.push(0,0),f.push(c++)}p.push(f)}let f=p.length-1;for(let e=0;e<f;e++){let t=p[e],i=p[e+1],r=t.length-1;l.push(t[0],i[1],i[0]);for(let e=1;e<=r;e++)l.push(t[e-1],t[e],i[e]),l.push(t[e],i[e+1],i[e])}}this.setIndex(l),this.setAttribute("position",new Ha(h,3)),this.setAttribute("normal",new Ha(u,3)),this.setAttribute("uv",new Ha(d,2))}}}),hM=n(()=>{R_(),bS(),JS=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof N_?e.shape:new N_,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:.5*i,y:.5*r},u={x:-h.x,y:-h.y},d={x:h.x,y:h.y};function c(e,t,s){return t>i&&s>r?Math.min(e*i/t,e*r/s):t>i?e*i/t:s>r?e*r/s:e}let p=[];p[0]=0===s[0]?0:c(s[0],s[0]+s[3],s[0]+s[1]),p[1]=0===s[1]?0:c(s[1],s[1]+s[2],s[1]+s[0]),p[2]=0===s[2]?0:c(s[2],s[2]+s[1],s[2]+s[3]),p[3]=0===s[3]?0:c(s[3],s[3]+s[0],s[3]+s[2]);let m=u.x,g=d.x,f=d.y,y=u.y;t.addPoint(t.createPoint(m,f)),t.addPoint(t.createPoint(g,f)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let v=!0;for(let e=0,i=t.points.length;e<i;e++)t.points[e].roundness=p[e],e>0&&p[e]!==p[e-1]&&(v=!1);v&&(t.roundness=p[0]),t.useCubicForRoundedCorners=1!==a,t.update();let b=mS.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}}}),uM=n(()=>{Mu(),QS=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=ts.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let t,{width:i=100,height:r=i,depth:s=i,widthSegments:a=64,heightSegments:n=64,phiStart:o,phiLength:l,thetaStart:h,thetaLength:u}=e.parameters;return 0===u?(t=new an,t.setAttribute("position",new Ha([],3))):t=new pl(.5*i,a,n,o,l,h,u*ts.DEG2RAD),t.scale(1,r/i,s/i),Object.assign(t,{userData:{...e,type:"SphereGeometry"}})}}}),dM=n(()=>{Mu(),eM=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,a=new cl(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}}}),cM=n(()=>{Mu(),tM=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:a,cornerSegments:n}=e.parameters,o=new iM(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},iM=class extends an{constructor(e=1,t=1,i=1,r=90,s=10,a=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;0==s&&(a=1),a=Math.max(1,Math.floor(a)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],d=Math.PI/2,c=(e=0,t=0,i=0)=>new ns(e,t,i),p=c(),m=c(),[g,f,y]=[t/2,e/2,i/2],v=-f,b=+f,[x,w,_]=[c(v,-g,+y),c(v,-g,-y),c(v,+g,-y)],S=(e,t=!1)=>Math.sin(e-Math.PI/(+t+1)),M=(e,t=!1)=>Math.cos(e-Math.PI/(+t+1));_.y=Math.sin(r)*t-g;let T=Math.cos(r)*t-y,C=x.z-h;r<=d?(_.z=Math.min(T,C),_.z==C&&(_.y-=(T-C)/Math.tan(d-r))):w.z=Math.min(w.z-T-y,x.z-h),p.subVectors(x,w),m.subVectors(_,w);let A=Math.min(p.length(),m.length())*s/100,N=A*Math.tan(r/2),P=A/Math.cos(r/2),R=p.clone().normalize().add(m.normalize()).setLength(P).add(w);p.set(0,S(r,!0),M(r,!0)),u.push([_,p.clone()]);let E=(Math.PI-r)/a;for(let e=0;e<=a;e++){let t=d+r+e*E;p.set(0,Math.sin(t)*N,Math.cos(t)*N),p.add(R),m.set(0,S(t),M(t)),u.push([p.clone(),m.clone()])}u.push([x,c(0,1,0)]);let O=Math.sin(E/2)*N*2,B=u.length-1,V=u[0][0].distanceTo(u[1][0]),D=V+O*a+u[B-1][0].distanceTo(u[B][0]);u[0].push(1);for(let e=0;e<=a;e++)u[e+1].push(1-(V+e*O)/D);u[B].push(0);let I,L,z,[k,U,F]=u[0];for(let e=1;e<u.length;e++)[I,L,z]=u[e],n.push(v,k.y,k.z,v,I.y,I.z,b,k.y,k.z,b,k.y,k.z,v,I.y,I.z,b,I.y,I.z),o.push(0,U.y,U.z,0,L.y,L.z,0,U.y,U.z,0,U.y,U.z,0,L.y,L.z,0,L.y,L.z),l.push(0,F,0,z,1,F,1,F,0,z,1,z),[k,U,F]=[I,L,z];this.setAttribute("position",new Ha(n,3)),this.setAttribute("normal",new Ha(o,3)),this.setAttribute("uv",new Ha(l,2))}}}),pM=n(()=>{R_(),bS(),rM=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof N_?e.shape:new N_,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:a,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,u=e.shape,d=.5*t,c=.5*i,p=n*Math.PI/360/s,m=Math.PI/2*3*-1,g=d*r/100,f=c*r/100;if(3===s&&50===r){p=2*Math.PI/s;for(let e=0;e<s;e++){let t=p*e,i=0+Math.sin(t)*d,r=0+Math.cos(t)*c;u.addPoint(u.createPoint(i,r))}}else for(let e=0;e<s;e++){let e=0+Math.cos(m)*d,t=0+Math.sin(m)*c;u.addPoint(u.createPoint(e,t)),m+=p,e=0+Math.cos(m)*g,t=0+Math.sin(m)*f,u.addPoint(u.createPoint(e,t)),m+=p}u.isClosed=!0;for(let e=0,t=u.points.length;e<t;e++)u.points[e].roundness=a;u.roundness=a,u.update();let y=mS.create({shape:u,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(y,{userData:{...e,type:"StarGeometry"}})}}}),mM=n(()=>{Mu(),sM=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new cl(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}}}),gM=n(()=>{Mu(),_x(),aM=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let a=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:s,depth:a})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:a,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=function(e,t,i,r,s,a,n,o,l,h,u){[t,i]=[i,t],n=t/2;let d=ts.clamp(s/360,0,1);if(0===d){let e=new an;return e.setAttribute("position",new Ha([],3)),e}return 1===d&&(h=0),new wx(!0,e,t,i,r,d,a,n,0,l,h,u)}(t,i,r,.5*t,n,a,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}}}),fM=n(()=>{Mu(),nM=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??.125*i.width})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:a,q:n}=e.parameters,o=.5*t;o!==i&&(o-=i);let l=new ml(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}}}),yM=n(()=>{R_(),bS(),oM=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof N_?e.shape:new N_,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n,isRect:o}=e.parameters,l=e.shape,h=.5*t,u=.5*i;o?(l.addPoint(l.createPoint(-h,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))),l.isClosed=!0;for(let e=0,t=l.points.length;e<t;e++)l.points[e].roundness=r;l.roundness=r,l.update();let d=mS.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(d,{userData:{...e,type:"TriangleGeometry"}})}}}),vM=n(()=>{Mu()}),bM=n(()=>{Mu(),new Ka,new As,new Bn,new ns,new ns,new ns,new ns});function xM(){let e=new an;return e.setAttribute("position",new ja(new Float32Array([]),3)),e.setIndex(new ja(new Uint16Array([]),1)),e}var wM,_M,SM=n(()=>{Od(),Bv(),iS(),Mu(),Yy(),R_(),bS(),wM=xM().attributes,_M=class extends an{constructor(e,t){super(),this.isTextGeometry=!0,this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,wM),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o,text:l,textTransform:h}=e,u=Qf.getDisplayedValue(l),d=function(e,t,i,r){let s="string"==typeof e.width?Number(r.getVariable(e.width)):e.width,a=[""],n="";for(let r of i)n+=r," "===r||"\n"===r?(a[a.length-1]+=n,n="","\n"===r&&a.push("")):t.getTextWidth(a[a.length-1]+n,e)>s&&(a[a.length-1].length&&a.push(""),t.getTextWidth(a[a.length-1]+n,e)>s&&(1===n.length?(a[a.length-1]+=n,n=""):(a[a.length-1]+=n.slice(0,-1),n=n[n.length-1],a.push(""))));return a[a.length-1]+=n,a}(e,i,2===h?u.toUpperCase():3===h?u.toLowerCase():u,t),{shapes:c,charWidths:p,charCoords:m}=i.generateShapes(d,e,t),g=.5*("number"==typeof r?r:Number(t.getVariable(r))),f=.5*("number"==typeof s?s:Number(t.getVariable(s))),y=c.map(e=>(new N_).fromShape(e,!0));this.vectorShapes=y;let v=y.map(e=>mS.create({shape:e,parameters:{depth:a,extrudeBevelSegments:o,extrudeBevelSize:n,windingRule:a<=0?z_.NONZERO:z_.ODD,subdivisions:this.isLowResolution&&a>0?1:12}})),b=v.length?Hy(v):xM();b.translate(-g,f,0),this.dispose(),this.wrappedText=d,this.charCoords=m,this.charWidths=p,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([e,t])=>{this.setAttribute(e,t)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=bd(new an,_M.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([e,t])=>{this.setAttribute(e,t)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}}});function MM(e){if(!AM)return NM||(NM=async function(){let t=e??(Su?".":"https://cdn.spline.design/@splinetool/runtime@2.0.2/build"),i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(e=>e.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});TM(n),AM=!0}())}var TM,CM,AM,NM,PM=n(()=>{md(),CM=new Promise(e=>{TM=e}),AM=!1});function RM(e,t){if(Object.keys(e.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let i=Object.keys(e.attributes),r=Object.keys(t.attributes);if(i.length!==r.length)return!1;for(let i of r){let r=e.attributes[i],s=t.attributes[i];if(void 0===r||!0===r.isInterleavedBufferAttribute||!0===s.isInterleavedBufferAttribute||r.itemSize!==s.itemSize||r.normalized!==s.normalized||r.array.constructor!==s.array.constructor||r.array.length!==s.array.length)return!1}let s=e.index,a=t.index;if(null===s!=(null===a))return!1;let n=!1;if(null!==s&&null!==a){if(s.array.length!==a.array.length)return!1;let e=s.array.constructor,t=a.array.constructor;if(e!==t){if(e!==Uint32Array||t!==Uint16Array)return!1;n=!0}}if(e.groups.length!==t.groups.length)return!1;for(let i=0;i<t.groups.length;i++){let r=e.groups[i],s=t.groups[i];if(r.start!==s.start||r.count!==s.count||r.materialIndex!==s.materialIndex)return!1}for(let i of r){let r=e.attributes[i],s=t.attributes[i];r.array.set(s.array),r.needsUpdate=!0}if(null!==s&&null!==a){if(n){let e=s.array,t=a.array;for(let i=0,r=t.length;i<r;i++){let r=t[i];e[i]=65535===r?4294967295:r}}else s.array.set(a.array);s.needsUpdate=!0}return e.drawRange.start=t.drawRange.start,e.drawRange.count=t.drawRange.count,e.userData=t.userData,e.boundingBox=null,e.boundingSphere=null,!0}function EM(e,t,i,r){let s,a,n,o=e.position.array,l=e.normal.array,h=OM.makeScale(t,i,r).invert().elements;for(let e=0,u=o.length;e<u;e+=3)o[e]*=t,o[e+1]*=i,o[e+2]*=r,s=l[e],a=l[e+1],n=l[e+2],l[e]=h[0]*s+h[4]*a+h[8]*n,l[e+1]=h[1]*s+h[5]*a+h[9]*n,l[e+2]=h[2]*s+h[6]*a+h[10]*n;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var OM,BM=n(()=>{Mu(),OM=new As});function VM(e){let t=Object.keys(e);return 1===t.length&&"subdivisions"===t[0]}function DM(e,t){let i=t?t.count:e.count,r=0,s=1e4,a=new Map,n=new Uint32Array(i),o=[];for(let l=0;l<i;l++){let i=t?t.getX(l):l,h=e.getX(i),u=e.getY(i),d=e.getZ(i),c=Math.round(h*s),p=Math.round(u*s),m=Math.round(d*s),g=a.get(c);void 0===g&&(g=new Map,a.set(c,g));let f=g.get(p);void 0===f&&(f=new Map,g.set(p,f));let y=f.get(m);void 0===y&&(y=r++,f.set(m,y),o.push(h,u,d)),n[l]=y}let l=[],h=[];for(let e=0;e<n.length;e+=3)n[e]===n[e+1]||n[e]===n[e+2]||n[e+1]===n[e+2]||(l.push(n[e],n[e+1],n[e+2]),h.push(t?t.getX(e):e,t?t.getX(e+1):e+1,t?t.getX(e+2):e+2));return{positions:o,triIndices:l,triOriginals:h}}var IM,LM,zM,kM,UM,FM,jM,GM,WM,qM,HM,$M,YM,XM=n(()=>{Mu(),PM(),Bv(),tT(),BM(),_x(),IM=new Sa,LM=new ns,CM.then(e=>{zM=e}),kM=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),UM=new Uint32Array([0,1,2,3]),FM=new Uint8Array([4]),jM=class extends an{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked.map(e=>"number"==typeof e?e:1),r=xm.div(t.map(e=>"number"==typeof e?e:0),i);if(r.every(e=>1===e))return;this.subdividedGeometry&&EM(this.subdividedGeometry.attributes,...r),this.originalGeometry&&EM(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(LM.fromArray(r));let a=LM.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return 0===this.subdivPointer&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let t=e.phongAngle??35;this.flatShading&&(t=-1);let i=null;if(e.subdivisions>0){let r=0;try{r=jM.allocate(e),i=jM.buildRefined(r,e.subdivisions,t)}catch(t){console.error(t,e)}finally{r&&jM.freeSubdivPointer(r)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let r=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=r}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=jM.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Lo(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(jM.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;null===e.boundingSphere&&(e.boundingSphere=new Ka,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;IM.setFromBufferAttribute(t),IM.getCenter(i),e.boundingSphere.radius=i.distanceTo(IM.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),IM.getSize(LM);let r={width:LM.x,height:LM.y,depth:LM.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n=e?.phongAngle??35;!1===i&&(n=-1),t&&(zM.free_bvh(t),zM.free_subdivision_surface(t));try{s=jM.allocate(e,r)}catch(t){console.error(t,e),s=jM.allocate({positionWASM:kM,indexWASM:UM,verticesPerFaceWASM:FM},r)}zM.set_destination_refinement_level(s,0);let o=jM.buildLevel(s,!0,n);return a=e.subdivisions>0?jM.buildRefined(s,e.subdivisions,n):null,{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static buildRefined(e,t,i){try{return zM.set_destination_refinement_level(e,t),jM.buildLevel(e,!1,i)??null}catch{try{return zM.set_destination_refinement_level(e,t-1),jM.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),"DodecahedronGeometry"===e.type&&(e.detail=0);let r,s=void 0!==e.shape||void 0!==e.path?t.geometry:ZM(e,i,!1,t);r=vx(e)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let a,{positions:n,triIndices:o,triOriginals:l}=DM(s.getAttribute("position"),r);if("CylinderGeometry"===e.type&&0===e.cornerRadius&&0===e.hollow&&!1===e.openEnded){let t=e.radialSegments*e.heightSegments*3*2;a=[t,t+3*e.radialSegments]}let{indices:h,verticesPerFace:u,uvs:d}=function(e,t,i,r,s){let a=[],n=[],o=s?i.getAttribute("uv"):void 0,l=o&&2===o.itemSize?[]:void 0,h=e=>{if(l){let t=s[e];l.push(o.getX(t),o.getY(t))}};if(void 0!==i.userData.shape&&0===i.userData.parameters.depth&&0===i.userData.shape.shapeHoles.length){let t=i.userData.shape.extractShapePointsToFlatArray([]),r=i.userData.parameters.spikes;if("EllipseGeometry"===i.userData.type&&r<=24&&r%4==0&&i.userData.parameters.angle>=360){let e=t.length/2/r;t=t.filter((t,i)=>Math.floor(i/2)%e===0)}let s=0;for(let e=0;e<t.length;e+=2)s+=(t[e]-t[(0===e?t.length:e)-2])*(t[e+1]+t[(0===e?t.length:e)-1]);e.length=0;let o=0;if(s<0)for(let i=0;i<t.length;i+=2)e.push(t[i],t[i+1],0),a.push(o++);else for(let i=t.length-2;i>=0;i-=2)e.push(t[i],t[i+1],0),a.push(o++);return n.push(o),{indices:a,verticesPerFace:n}}let u=new Float32Array([i.userData.parameters.depth])[0],d=0;for(;d<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let i=0;if((e[3*t[d]+2]===u||0===e[3*t[d]+2])&&i++,(e[3*t[d+1]+2]===u||0===e[3*t[d+1]+2])&&i++,(e[3*t[d+2]+2]===u||0===e[3*t[d+2]+2])&&i++,3===i)break}if(t[d+1]===t[d+3]&&t[d+2]===t[d+5]||t[d+0]===t[d+3]&&t[d+2]===t[d+4]){GM.set(e[3*t[d]],e[3*t[d]+1],e[3*t[d]+2]),WM.set(e[3*t[d+1]],e[3*t[d+1]+1],e[3*t[d+1]+2]),qM.set(e[3*t[d+4]],e[3*t[d+4]+1],e[3*t[d+4]+2]),HM.set(e[3*t[d+5]],e[3*t[d+5]+1],e[3*t[d+5]+2]),WM.sub(GM).normalize(),qM.sub(GM).normalize(),HM.sub(GM).normalize();let i=WM.cross(qM).dot(HM),s=d;Math.abs(i)>.005||r&&r.some((e,t)=>t%2!=1&&s>=r[t]&&s<r[t+1])?(a.push(t[d],t[d+1],t[d+2]),h(d),h(d+1),h(d+2),n.push(3),d+=3):(a.push(t[d],t[d+1],t[d+4],t[d+5]),h(d),h(d+1),h(d+4),h(d+5),n.push(4),d+=6)}else a.push(t[d],t[d+1],t[d+2]),h(d),h(d+1),h(d+2),n.push(3),d+=3}if(i.useNgonForTopBottomFaceDuringBake){let t=[],r=[],s=0;for(let i=0,a=0;i<e.length;i+=3,a++)0===e[i+2]&&(t.push(a),s++),e[i+2]===u&&r.push(a);if(0===i.userData.parameters.extrudeBevelSize){let e=r[0];r[0]=r[1],r[1]=e}t.reverse(),a.push(...t,...r),n.push(s,s),l=void 0}return{indices:a,verticesPerFace:n,uvs:l}}(n,o,s,a,l);return{positions:n,indices:h,verticesPerFace:u,uvs:d}}static allocate(e,t){let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM,zM.alloc_subdivision_surface_uvs&&e.uvWASM&&e.uvWASM.length===2*r.length&&(n=e.uvWASM)):(i=kM,r=UM,s=FM);let o,l=i.length,h=r.length,u=s.length,d=i.length+a.length+n.length,c=r.length+s.length,p=d*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=zM._malloc(p),f=new Float32Array(zM.HEAPF32.buffer,g,d),y=new Uint32Array(zM.HEAPU32.buffer,g+m,c);f.set(i,0),f.set(a,i.length),f.set(n,i.length+a.length),y.set(r,0),y.set(s,r.length),e?.scaleBaked?.some(e=>1!==e)&&(o=(new As).makeScale(...e.scaleBaked.map(e=>"number"==typeof e?e:1))),t&&(o?o.premultiply(t):o=t);let v=g+(i.length+a.length)*Float32Array.BYTES_PER_ELEMENT,b=n.length?o?zM.alloc_subdivision_surface_uvs2(g,l,g+m,h,g+m+r.length*Uint32Array.BYTES_PER_ELEMENT,u,v,n.length,o.elements):zM.alloc_subdivision_surface_uvs(g,l,g+m,h,g+m+r.length*Uint32Array.BYTES_PER_ELEMENT,u,v,n.length):o?zM.alloc_subdivision_surface2(g,l,g+m,h,g+m+r.length*Uint32Array.BYTES_PER_ELEMENT,u,o.elements):zM.alloc_subdivision_surface(g,l,g+m,h,g+m+r.length*Uint32Array.BYTES_PER_ELEMENT,u);return zM._free(g),b}static buildLevel(e,t,i,r,s,a=!1){let n=s?zM.get_mesh_data2(e,t?zM.Level.CONTROL:zM.Level.REFINED,i,s.elements):zM.get_mesh_data(e,t?zM.Level.CONTROL:zM.Level.REFINED,i),o=zM.HEAPU32.subarray(n>>2,10+(n>>2)),l=o.subarray(4,8),h=0,u=zM.HEAPU32[o[h]>>2],d=zM.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let c=zM.HEAPU32[o[h]>>2],p=zM.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let m=zM.HEAPU32[o[h]>>2],g=zM.HEAPU32.subarray(m>>2,(m>>2)+l[h]);h++;let f,y=zM.HEAPU32[o[h]>>2],v=zM.HEAPU32.subarray(y>>2,(y>>2)+l[h]);if(h++,zM.alloc_subdivision_surface_uvs){let e=o[9];if(e>0){let t=zM.HEAPU32[o[8]>>2];f=zM.HEAPF32.subarray(t>>2,(t>>2)+e)}}if(void 0===r){let e=new an;if(e.setIndex(new Wa(v,1)),e.setAttribute("position",new Ha(d,3)),e.setAttribute("normal",new Ha(p,3)),f&&e.setAttribute("uv",new Ha(f,2)),t){e.setAttribute("faceMap",new Wa(g,1));let t=new Float32Array(p.length/3*4).fill(0);e.setAttribute("color",new ja(t,4))}return zM.free_mesh_data(n),e.userData.type="SubdivGeometry",e}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,a){let e=r.getIndex();null!==e&&e.array.length===v.length&&(e.copyArray(v),e.needsUpdate=!0)}let b=r.getAttribute("uv");f&&b&&b.array.length===f.length&&(b.copyArray(f),b.needsUpdate=!0),zM.free_mesh_data(n)}static freeSubdivPointer(e){zM.free_bvh(e),zM.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=zM.get_wireframe_data_for_base_level(e),s=zM.HEAPU32.subarray(r>>2,4+(r>>2)),a=s.subarray(2,4),n=0,o=zM.HEAPU32[s[n]>>2],l=zM.HEAPF32.subarray(o>>2,(o>>2)+a[n]);n++;let h=zM.HEAPU32[s[n]>>2],u=zM.HEAPU32.subarray(h>>2,(h>>2)+a[n]);if(void 0===t){let e=new an;e.setAttribute("position",new Ha(l,3));let t=new Float32Array(l.length);for(let e=0,r=l.length;e<r;)t[e++]=i.r,t[e++]=i.g,t[e++]=i.b;return e.setAttribute("color",new ja(t,3)),e.setIndex(new Wa(u,1)),zM.free_wireframe_data_for_base_level(r),e}t.getAttribute("position").copyArray(l),t.attributes.position.needsUpdate=!0,zM.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=0===t;r||zM.set_destination_refinement_level(e,t);let s=i?zM.get_topological_data2(e,r?zM.Level.CONTROL:zM.Level.REFINED,i.elements):zM.get_topological_data(e,r?zM.Level.CONTROL:zM.Level.REFINED),a=zM.HEAPU32.subarray(s>>2,8+(s>>2)),n=a.subarray(3,6),o=0,l=zM.HEAPU32[a[o]>>2],h=new Float32Array(zM.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let u=zM.HEAPU32[a[o]>>2],d=new Uint32Array(zM.HEAPU32.subarray(u>>2,(u>>2)+n[o]));o++;let c,p=zM.HEAPU32[a[o]>>2],m=new Uint8Array(zM.HEAPU32.subarray(p>>2,(p>>2)+n[o]));if(zM.alloc_subdivision_surface_uvs){let e=a[7];if(e>0){let t=zM.HEAPU32[a[6]>>2];c=new Float32Array(zM.HEAPF32.subarray(t>>2,(t>>2)+e))}}return zM.free_topological_data(s),{positions:h,indices:d,verticesPerFace:m,uvs:c}}},GM=new ns,WM=new ns,qM=new ns,HM=new ns}),KM=n(()=>{Ww(),qw(),Gw(),$w(),OS(),_x(),BS(),VS(),GS(),WS(),lM(),hM(),uM(),dM(),cM(),pM(),mM(),gM(),fM(),yM(),bS(),hb(),Ww(),qw(),Gw(),$w(),OS(),vM(),_x(),BS(),VS(),GS(),WS(),lM(),hM(),uM(),dM(),cM(),pM(),mM(),gM(),fM(),yM(),bS(),bM(),yS(),SM(),XM(),PM(),Dx(),$M={ConeGeometry:Iw,CubeGeometry:Lw,CylinderGeometry:Vw,DodecahedronGeometry:Fw,EllipseGeometry:NS,HelixGeometry:bx,IcosahedronGeometry:PS,LatheGeometry:ES,NonParametricGeometry:US,PolygonGeometry:FS,PyramidGeometry:YS,RectangleGeometry:JS,SphereGeometry:QS,PlaneGeometry:eM,BackdropGeometry:tM,StarGeometry:rM,TextFrameGeometry:sM,TorusGeometry:aM,TorusKnotGeometry:nM,TriangleGeometry:oM,VectorGeometry:mS},YM=e=>{let t=$M[e.type]??tb(e.type);if(void 0===t)throw new Error(`No geometry factory registered for "${e.type}" — was its feature compiled out of this runtime build?`);return t.create(e)}});function ZM(e,t,i,r){let s,a,n;"PathGeometry"===e.type?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let e of n){let i=a;for(let t of e)i=i[t];for(s in i){let a=i[s];pm(a)&&!JM.includes(s)&&(i[s]=t.getVariable(a,[r.uuid,"geometry",...e,s]),pm(i[s])&&(i[s]=1))}}let o,l={parameters:a,type:a.type};if("PathGeometry"===a.type)l.path=a.path;else if("VectorGeometry"===a.type){let e=N_.createFromState(a.shape,a.width,a.height);l.shape=e}else if("NonParametricGeometry"===a.type){if(a.data.groups&&a.data.groups?.forEach(e=>e.materialIndex=Math.max(e.materialIndex??0,0)),l.geometry=(new bh).parse(a),0===l.geometry.groups.length){let e=l.geometry;e.addGroup(0,Math.max(e.getIndex()?.count??0,e.getAttribute("position").count),0)}}else{if("SubdivGeometry"===a.type){let t=new jM(a,i);return t.data=e,t}if("TextGeometry"===a.type||"InputGeometry"===a.type){let e=tb(a.type);if(e)return e.create(a,t);Kv("text",`a ${a.type}`);let i=N_.createFromState(Ug.defaultData(),100,100);return YM({...a,shape:i,type:"VectorGeometry"})}if("UIGeometry"===a.type)return JS.create({parameters:{width:a.width,height:a.height,cornerRadius:a.cornerRadius,cornerType:a.cornerType}})}try{o=YM(l)}catch(e){console.error(e),console.error(`Error generating geometry with inputs: ${l}`);let t=N_.createFromState(Ug.defaultData(),100,100);l.shape=t,l.type="VectorGeometry",o=YM(l)}return o}var JM,QM,eT,tT=n(()=>{Bv(),Mu(),KM(),hb(),hM(),R_(),XM(),JM=["font"]}),iT=n(()=>{md(),tT(),QM=class{constructor(){this.objects=new Map,this.unreachable=new Set}getCached(e){return this.objects.get(e)}get size(){return this.objects.size}get(e,t,i){let r=this.objects.get(e);return void 0===r?(r=this.createObject(e,t,i),this.objects.set(e,r)):r.isShared=!0,r}forceDelete(e){let t=this.objects.get(e);t&&(this.disposeObject(t),this.objects.delete(e))}adopt(e,t){this.objects.set(e,t)}mutateIfUnique(e,t){let i=this.objects.get(e);if(i&&!0!==i.isShared)return this.objects.delete(e),this.objects.set(t,i),i}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(e,t){t===this.objects.get(e)?this.unreachable.delete(e):Su&&console.warn("Reachable but deleted",e)}endGc(){this.unreachable.forEach(e=>{this.disposeObject(this.objects.get(e)),this.objects.delete(e)}),this.unreachable.clear()}dispose(){this.objects.forEach(e=>{this.disposeObject(e)}),this.objects.clear()}},eT=class extends QM{constructor(e){super(),this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,i){let r=ZM(e,t,this.flatShading,i);return r.computeBoundingSphere(),r}}});function rT(){return lT}function sT(){if("webgpu"===lT){if(void 0!==hT)return hT;dT||(dT=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered — import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(void 0===uT)throw new Error('[spe] Classic (WebGL) materials are not available in this build — it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return uT}function aT(e,t,i){return sT().createSharedMaterial(e,t,i)}function nT(e){return void 0===e.getLayersOfType&&Object.assign(e,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),e}function oT(){return pT}var lT,hT,uT,dT,cT,pT,mT,gT=n(()=>{lT="webgl",dT=!1}),fT=n(()=>{mT={markNeedsUpdateRendererDirty:()=>{}}});function yT(e,t){let i=0;if(!e.layers||0===e.layers.length)return!1;let r=e.layers?.find(e=>"light"===e.data.type);if(r){let e=r.data,i=Number(t.getVariable(e.alphaOverride));if(("string"==typeof e.alphaOverride?i/100:e.alphaOverride)<1)return!0}for(let r of e.layers){if("displace"!==r.data.type&&r.data.isMask)return!0;if("displace"!==r.data.type&&"alpha"in r.data&&"light"!==r.data.type&&"fresnel"!==r.data.type&&"cavity"!==r.data.type&&"dust"!==r.data.type&&"texture"!==r.data.type&&"matcap"!==r.data.type&&"rainbow"!==r.data.type&&"outline"!==r.data.type&&"pattern"!==r.data.type){let e=r.data.visible?r.data.alpha:0;if("string"==typeof e&&(e=Math.max(0,Math.min(1,Number(t.getVariable(e)??100)/100))),1===e&&"depth"===r.data.type||"gradient"===r.data.type){for(let t of r.data.colors)if(t[3]<1){e=t[3];break}}else if(1===e&&"noise"===r.data.type){let i=t.color(r.data.colorA).a,s=t.color(r.data.colorB).a,a=t.color(r.data.colorC).a,n=t.color(r.data.colorD).a,o=Math.min(i,Math.min(s,Math.min(a,n)));o<1&&(e=o)}i+=(1-i)*e}}return i<1}var vT=n(()=>{});function bT(e){return"string"==typeof e||"number"==typeof e&&0!==e}var xT,wT,_T,ST,MT,TT,CT,AT=n(()=>{xT=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable("number"==typeof e?100*e:e,i)??100)/100))??1,wT=(e,t,i)=>"number"==typeof e?e:t.getVariable(e,i),_T={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},ST={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),NT=n(()=>{Mu(),Sb(),MT=class extends(wb(ea)){},TT=e=>"Mesh"===e.type,CT=class extends MT{constructor(e){super(),this.object=e,this.isClone=!0,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new CT(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix,i.pivotMatrix=t.pivotMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return(void 0===e||this.parent!==e||!e.instancingActive)&&(void 0!==this.playModeVisible?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&!0===this.object.dataPatched.cloner?.hideBase)}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return TT(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}}});function PT(){return RT}var RT,ET,OT=n(()=>{RT=null,ET=null});function BT(e){return"variable_"+e}var VT,DT,IT,LT,zT,kT,UT,FT,jT,GT,WT,qT,HT,$T,YT,XT=n(()=>{Bv(),sw(),mw(),gw(),rw(),Pw(),Ow(),iT(),gT(),ow(),fT(),vT(),AT(),Qb(),NT(),um(),Mu(),OT(),hb(),VT=new As,DT=new ns,IT=new ss,LT=new ns,zT=new Ls,kT=class extends ew{constructor(e){super(),this.shared=e}create(e){return new dw(e,this.shared)}},(FT=UT=class{constructor(e,t={},i=!0,r=!1){if(this.data=e,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new eT(!0),this.geometryCache2=new eT(!1),this.imageHolderCache=new kT(this),this.thisContext={scene:mT,shared:this},this.deletedImage=new cw(ny.emptyImage,this),this.deletedVideo=new cw(Sg.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.timelineAnimations={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},this.transientGeometryKeys=new WeakSet,t.images)for(let[e,i]of Object.entries(t.images))this.addImage(e,i);if(t.videos)for(let[e,i]of Object.entries(t.videos))this.addVideo(e,i);if(t.audios)for(let[e,i]of Object.entries(t.audios))this.addAudio(e,i);if(t.particles)for(let[e,i]of Object.entries(t.particles))this.addParticle(e,i);this.reset(e)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=aT(Lg.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(e){this._requestRender=e}getImageLoadPromises(){return Object.values(this.images).map(e=>e.loadPromise)}setEntityOpContext(e){this.entityOpContext=e}reset(e,t=!1,i=!1){this.data=e,this.resetLib(e.lib);for(let{id:i,data:r}of e.variables)this.addVariableHolder(i,r),t&&this.updateVariableHolder(i,r);for(let[t,i]of Object.entries(e.userAPIs??{}))this.addUserAPI(t,i);for(let[t,i]of Object.entries(e.userWebhooks??{}))this.addUserWebhook(t,i);if(!i){for(let[t,i]of Object.entries(e.images))this.addImage(t,i);for(let[t,i]of Object.entries(e.videos))this.addVideo(t,i)}for(let[t,i]of Object.entries(e.colors))this.addColor(t,i);for(let[t,i]of Object.entries(e.materials))this.addMaterial(t,i);for(let[t,i]of Object.entries(e.audios))this.addAudio(t,i);for(let[t,i]of Object.entries(e.particles))this.addParticle(t,i);for(let[t,i]of Object.entries(e.fonts))this.addFont(t,i);for(let[t,i]of Object.entries(e.timelineAnimations??{}))this.addAnimation(t,i)}addMaterial(e,t){if(void 0===t.layers&&(t={...t,layers:Lg.defaultTwoLayerData("phong").layers}),this.materials[e]){let i=this.materials[e];i.reset(t,this.thisContext),i.dispose()}else{let i=aT(t,this.thisContext,e);this.materials[e]=i}}deleteMaterial(e){this.materials[e]&&(this.materials[e].nodeMaterialDispose(),delete this.materials[e])}getMaterial(e){return this.materials[e]}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return"string"==typeof e?this.getMaterialOrDeletedPlaceholder(e):null==e?(console.error("material is undefined or null"),this.deletedMaterial):(void 0===e.layers&&(e={...e,layers:Lg.defaultTwoLayerData("phong").layers}),function(e,t){return sT().createRootMaterial(e,t)}(e,this.thisContext))}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[e].updateSrc(t.data),!0):(this.images[e]=new cw(t,this),!1)}deleteImage(e){let t=this.images[e];t&&(t.dispose(),delete this.images[e])}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return"string"==typeof e?this.getImage(e):this.imageHolderCache.load(e)}addUIBuffer(e,t){return this.uiBuffers[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[e].updateSrc(t),!0):(this.uiBuffers[e]=new cw(t,this),!1)}uiBuffer(e){return this.uiBuffers[e]}addVideo(e,t){return this.videos[e]?(this.videos[e].updateSrc(t.data),!0):(this.videos[e]=new cw(t,this),!1)}deleteVideo(e){let t=this.videos[e];t&&(t.dispose(),delete this.videos[e])}getVideo(e){return this.videos[e]??this.deletedVideo}video(e){return"string"==typeof e?this.getVideo(e):this.imageHolderCache.load(e)}addColor(e,t){return this.colors[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):(this.colors[e]=new Xx(t.r,t.g,t.b,"a"in t?t.a:1),!1)}updateColor(e,t){if(this.colors[e]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[e];return this.colors[e].r=t.r??i.r,this.colors[e].g=t.g??i.g,this.colors[e].b=t.b??i.b,this.colors[e].a=t.a??i.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}getColorNames(){return Object.values(this.data.colors).map(e=>e.name)}getColorByName(e){for(let t in this.data.colors)if(this.data.colors[t].name===e)return{color:this.colors[t],id:t}}color(e){let t;if("string"!=typeof e)return new Yx(e.r,e.g,e.b,"a"in e?e.a:1);{let i=this.getColor(e);i?t=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new Yx(0,0,0,0))}return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof Nw)return t;{let i=new Nw({src:t.data});return this.audios[e]=i,i}}addParticle(e,t){this.particles[e]=t}getParticle(e){return this.particles[e]}deleteParticle(e){this.particles[e]&&delete this.particles[e]}deleteAudio(e){let t=this.audios[e];t&&(t instanceof Nw&&t.dispose(),delete this.audios[e])}addFont(e,t){let i=Ew;null!==i?(this.fonts[e]=new i(t),this.fonts[e].loadingPromise.then(()=>this.requestRender())):Kv("text","a font asset")}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}addAnimation(e,t){this.timelineAnimations[e]=t}getAnimation(e){return this.timelineAnimations[e]}deleteAniamtion(e){this.timelineAnimations[e]&&delete this.timelineAnimations[e]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Nw&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(e,t){if(void 0===this.variables[e]){let i=t.value;if(this.enableLocalStorageForPersistentVariables&&t.persistent){let r=localStorage.getItem(BT(e));i=null!==r?JSON.parse(r):t.value}return this.variables[e]={value:i,locations:[],persistent:t.persistent},"dynamicVariableType"in t&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0),!0}return this.variables[e].value=t.value,!1}resetDynamicVariablePlayState(){for(let e in this.variables)void 0!==this.variables[e].dynamicVariablePlayState&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(e,t){this.updateVariable(e,t.value)}updateVariable(e,t){if(void 0===this.variables[e])return!1;this.variables[e].value=t,this.enableLocalStorageForPersistentVariables&&this.variables[e].persistent&&localStorage.setItem(BT(e),JSON.stringify(t));let i=t;for(;"string"==typeof i;)i=this.variables[i].value;let r=this.entityOpContext.scene,s=!1;for(let t=this.variables[e].locations.length-1;t>=0;t--){let a=this.variables[e].locations[t];if("material"===a[0]){let e=a[1],t=i,s={scene:r,shared:this},n=a.slice(2);r.traverseMaterial(i=>{let r=i.root??i;r.uuid===e&&r.onVariableUpdate(n,t,s)});let o=this.materials[e];o&&o.onVariableUpdate(n,t,s)}else{let n=r.find(a[0]);if(void 0===n){this.variables[e].locations.splice(t,1);continue}if(s=!0,"geometry"!==a[1]&&"particles"!==a[1]){for(let e=1;e<a.length-1;e++)n=n[a[e]];"rotation"===a[1]?n[a[a.length-1]]=i*ts.DEG2RAD:n[a[a.length-1]]=i}if(n=r.find(a[0]),"ParticleEmitter"===n.type&&n.updateVariableState(i,a),Lb.is(n))if("position"===a[1]||"rotation"===a[1]||"scale"===a[1])n.onVariableUpdate();else if("geometry"===a[1]){let e=n;n.component&&(e=n.component);let t=e.dataPatched;e.chooseGeoemtryCache(this).forceDelete(t.geometry),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),e.instances.forEach(e=>{let t=e.dataPatched;e.chooseGeoemtryCache(this).forceDelete(t.geometry),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData()})}else"morphTargetInfluences"===a[1]&&n.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(e,t){let i=e;if(i.component&&(i=i.component),"function"!=typeof i.chooseGeoemtryCache)return!1;let r=i.dataPatched,s=r?.geometry;if(!s||"string"!=typeof s.type||"VectorGeometry"===s.type||"PathGeometry"===s.type)return!1;let a=e=>e.toLowerCase().replace(/[\s_.-]+/g,""),n=new Map;for(let e of Object.keys(s))n.set(a(e),e);let o={};for(let[e,i]of Object.entries(t??{})){let t=n.get(a(e));if(void 0===t||"type"===t||"font"===t||"shape"===t||"path"===t||"data"===t)continue;if("text"===t){("string"==typeof i||"number"==typeof i)&&(o[t]={textValue:String(i)});continue}let r=s[t];"number"==typeof i&&isFinite(i)&&("number"==typeof r||"string"==typeof r)&&(o[t]=i)}if(0===Object.keys(o).length)return!1;let l={...s,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(s)&&i.chooseGeoemtryCache(this).forceDelete(r.geometry),this.transientGeometryKeys.add(l),i.createGeometryDelayed(this.entityOpContext),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(e){let t=e;if(t.component&&(t=t.component),"function"!=typeof t.chooseGeoemtryCache)return!1;let i=t.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(t.dataPatched=t.data,t.chooseGeoemtryCache(this).forceDelete(i),t.createGeometryDelayed(this.entityOpContext),t.onVariableUpdate(!0),t.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(e,t){let i=e;if(i.component&&(i=i.component),"function"!=typeof i.chooseGeoemtryCache)return!1;let r=i.dataPatched,s=r?.geometry;if(!s||"NonParametricGeometry"!==s.type)return!1;let a=t?.vertices;if(void 0===a||"number"!=typeof a.length||a.length<9||a.length%3!=0||a.length/3>UT.MAX_TRANSIENT_VERTICES)return!1;let n,o,l,h=a instanceof Float32Array?a:Float32Array.from(a),u=h.length/3;if(void 0!==t.normals){if(t.normals.length!==h.length)return!1;n=t.normals instanceof Float32Array?t.normals:Float32Array.from(t.normals)}if(void 0!==t.uvs){if(t.uvs.length!==2*u)return!1;o=t.uvs instanceof Float32Array?t.uvs:Float32Array.from(t.uvs)}if(void 0!==t.indices){let e=u>65535?Uint32Array.from(t.indices):Uint16Array.from(t.indices);if(0===e.length||e.length%3!=0)return!1;for(let t=0;t<e.length;t++)if(e[t]>=u)return!1;l={array:e,itemSize:1,type:e.constructor.name,normalized:!1}}else{let e=s.data,t=e?.index;if(t?.array?.length){if(u<(e?.attributes?.position?.array?.length??0)/3){let e=t.array;for(let t=0;t<e.length;t++)if(e[t]>=u)return!1}l=t}}let d=1/0,c=1/0,p=1/0,m=-1/0,g=-1/0,f=-1/0;for(let e=0;e<h.length;e+=3){let t=h[e],i=h[e+1],r=h[e+2];t<d&&(d=t),t>m&&(m=t),i<c&&(c=i),i>g&&(g=i),r<p&&(p=r),r>f&&(f=r)}let y=(e,t)=>({array:e,itemSize:t,type:"Float32Array",normalized:!1}),v={position:y(h,3)};n&&(v.normal=y(n,3)),o&&(v.uv=y(o,2));let b={...s,width:m-d,height:g-c,depth:f-p,data:{attributes:v,...l?{index:l}:{}}},x=this.transientGeometryKeys.has(s);return i.dataPatched={...r,geometry:b},this.transientGeometryKeys.add(b),i.applyTransientGeometryData(this.entityOpContext,x),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(e,t){let i=e;i.component&&(i=i.component);let r=i.cloner;if(void 0===r)return-1;let s=r.children,a=Math.PI/180,n=!1;if(null===t)for(let e of s)void 0!==e.transformOverride&&(e.transformOverride=void 0,n=!0);else{if(!Array.isArray(t))return s.length;{let e=Math.min(t.length,s.length);for(let i=0;i<e;i++){let e=t[i],r=s[i];if(null==e){void 0!==r.transformOverride&&(r.transformOverride=void 0,n=!0);continue}let o=r.transformOverride??{position:[r.position.x,r.position.y,r.position.z],rotation:[r.rotation.x,r.rotation.y,r.rotation.z],scale:[r.scale.x,r.scale.y,r.scale.z]};e.position&&("number"==typeof e.position.x&&(o.position[0]=e.position.x),"number"==typeof e.position.y&&(o.position[1]=e.position.y),"number"==typeof e.position.z&&(o.position[2]=e.position.z)),e.rotation&&("number"==typeof e.rotation.x&&(o.rotation[0]=e.rotation.x*a),"number"==typeof e.rotation.y&&(o.rotation[1]=e.rotation.y*a),"number"==typeof e.rotation.z&&(o.rotation[2]=e.rotation.z*a)),e.scale&&("number"==typeof e.scale.x&&(o.scale[0]=e.scale.x),"number"==typeof e.scale.y&&(o.scale[1]=e.scale.y),"number"==typeof e.scale.z&&(o.scale[2]=e.scale.z)),r.transformOverride=o,r.position.fromArray(o.position),r.rotation.fromArray(o.rotation),r.scale.fromArray(o.scale),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}}}return n?r.update(this.entityOpContext):r.syncInstanceMatrices(),r.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),s.length}spawnRuntimeClone(e,t={}){if("function"!=typeof e.entityChildren)return;let i=e.parent;if(null===i)return;let r=new CT(e);r.playModeVisible=!1!==t.visible,r.expand(),"string"==typeof t.name&&(r.name=t.name);let s=Math.PI/180;return r.position.copy(e.position),r.rotation.copy(e.rotation),r.scale.copy(e.scale),r.hiddenMatrix.copy(e.hiddenMatrix),t.position&&("number"==typeof t.position.x&&(r.position.x=t.position.x),"number"==typeof t.position.y&&(r.position.y=t.position.y),"number"==typeof t.position.z&&(r.position.z=t.position.z)),t.rotation&&("number"==typeof t.rotation.x&&(r.rotation.x=t.rotation.x*s),"number"==typeof t.rotation.y&&(r.rotation.y=t.rotation.y*s),"number"==typeof t.rotation.z&&(r.rotation.z=t.rotation.z*s)),t.scale&&("number"==typeof t.scale.x&&(r.scale.x=t.scale.x),"number"==typeof t.scale.y&&(r.scale.y=t.scale.y),"number"==typeof t.scale.z&&(r.scale.z=t.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(e){e.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(e,t){let i=e.material;if(!i)return!1;let r=[];for(let e of Array.isArray(i)?i:[i]){let t=e.root??e;t&&Array.isArray(t.layers)&&t.data&&!r.includes(t)&&r.push(t)}if(0===r.length)return!1;let s={scene:this.entityOpContext.scene,shared:this},a=e=>e.toLowerCase().replace(/[\s_.-]+/g,""),n=e=>{if("string"==typeof e){let t=new Yx(1,1,1,1);try{t.set(e)}catch{return null}return{r:t.r,g:t.g,b:t.b,a:void 0}}if(e&&"object"==typeof e&&"r"in e){let t=e;if([t.r,t.g,t.b].some(e=>"number"!=typeof e||!isFinite(e)))return null;let i=Math.max(t.r,t.g,t.b)>1?1/255:1;return{r:t.r*i,g:t.g*i,b:t.b*i,a:"number"==typeof t.a?Math.max(0,Math.min(t.a,1)):void 0}}return null},o=(e,t,i)=>{if(!e.hasValue(t))return!1;let r=e.getValue(t);if(!r||"object"!=typeof r||!r.isColor)return!1;let s=i.a??("number"==typeof r.a?r.a:1);return r instanceof Xx?e.setValue(t,new Yx(i.r,i.g,i.b,s)):"function"==typeof r.setRGBA?r.setRGBA(i.r,i.g,i.b,s):r.setRGB(i.r,i.g,i.b),!0},l=!1;for(let e of r){let i=e.data.layers??[],r=t=>e.layers.find(e=>e.uuid===t);if(void 0!==t.color){let a=n(t.color),h=i.find(e=>"color"===e.data.type),u=h&&r(h.id);if(a&&u&&o(u,"color",a)&&(l=!0,void 0!==a.a)){let t=a.a<1||yT(e.data,this);e.setTransparent?e.setTransparent(t,s.scene):e.transparent=t}}"number"==typeof t.alpha&&isFinite(t.alpha)&&(e.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(t.alpha,100)),s),l=!0);for(let h of t.layers??[]){if(!h||"object"!=typeof h)continue;let t="string"==typeof h.id?i.find(e=>e.id===h.id):"number"==typeof h.index?i[h.index]:"string"==typeof h.type?i.find(e=>e.data.type===h.type):void 0,u=t&&r(t.id);if(!t||!u)continue;let d=_T[t.data.type]??[],c=Object.keys(t.data);for(let[i,r]of Object.entries(h)){if("id"===i||"index"===i||"type"===i)continue;let h=c.find(e=>e===i)??c.find(e=>a(e)===a(i))??i;if(d.includes(h))continue;let p=n(r);if(p&&o(u,h,p))l=!0;else if("number"==typeof r&&isFinite(r))e.onVariableUpdate?.(["layer",t.id,h],r,s),l=!0;else if(Array.isArray(r)&&r.length<=3&&r.every(e=>"number"==typeof e&&isFinite(e))){let i=["x","y","z"];r.forEach((r,a)=>{e.onVariableUpdate?.(["layer",t.id,h,i[a]],r,s)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(e){this.variables[e]&&delete this.variables[e]}getVariable(e,t){if(Array.isArray(e)){if("mouse"===e[0])return this.mouseProperty?.[e[1]]??0;if("raycast"===e[0])return this.raycastProperty?.[e[1]]??0;let t=this.entityOpContext.scene.find(e[0]);if("width"===e[1]||"height"===e[1]||"depth"===e[1])return t.geometry.userData.parameters[e[1]];if(("position"===e[1]||"rotation"===e[1])&&e.length>2&&t?.getPhysicsLocalMatrix?.(VT))return VT.decompose(DT,IT,LT),"position"===e[1]?DT[e[2]]:(zT.setFromQuaternion(IT,t.rotation.order),zT[e[2]]*ts.RAD2DEG);for(let i=1;i<e.length;i++)t=t[e[i]];return"rotation"===e[1]&&(t*=ts.RAD2DEG),t}for(let e in this.variables){if(void 0===t)break;let i=this.variables[e],r=i.locations?.findIndex(e=>Cc.equal(e,t));void 0!==r&&-1!==r&&i.locations.splice(r,1)}if("string"==typeof e){let i=e,r=e;do{if(r=i,void 0===this.variables[i])break;let e=this.variables[i].value;t&&void 0!==this.variables[r]&&this.variables[r].locations.push(t),i=e}while("string"==typeof i);return i}return e}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(e=>e.data.name)}getVariableByName(e){for(let t of this.data.variables)if(t.data.name===e)return{variable:t.data,id:t.id}}getDynamicVariablePlayState(e){return this.variables[e]?.dynamicVariablePlayState}setDynamicVariablePlayState(e,t){void 0!==this.variables[e]&&(this.variables[e].dynamicVariablePlayState=t)}getDynamicVariableToggleIsForward(e){return this.variables[e]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(e,t){void 0!==this.variables[e]&&(this.variables[e].dynamicVariableToggleIsForward=t)}resetLib(e){for(let[t,i]of Object.entries(e.images))this.addImage(t,i.asset);for(let[t,i]of Object.entries(e.audios))this.addAudio(t,i.asset);for(let[t,i]of Object.entries(e.particles))this.addParticle(t,i.asset);for(let[t,i]of Object.entries(e.colors))this.addColor(t,i.asset);for(let[t,i]of Object.entries(e.fonts))this.addFont(t,i.asset);for(let[t,i]of Object.entries(e.materials))this.addMaterial(t,i.asset);for(let[t,i]of Object.entries(e.videos))this.addVideo(t,i.asset);for(let[t,i]of Object.entries(e.variables))this.addVariableHolder(t,i.asset)}updateLibByOp(e,t){"images"===e.path[0]?1===e.path.length&&1===e.type?this.addImage(e.id,e.data.asset):1===e.path.length&&2===e.type&&this.deleteImage(e.id):"videos"===e.path[0]?1===e.path.length&&1===e.type?this.addVideo(e.id,e.data.asset):1===e.path.length&&2===e.type&&this.deleteVideo(e.id):"audios"===e.path[0]?1===e.path.length&&1===e.type?this.addAudio(e.id,e.data.asset):1===e.path.length&&2===e.type&&this.deleteAudio(e.id):"particles"===e.path[0]?1===e.path.length&&1===e.type?this.addParticle(e.id,e.data.asset):1===e.path.length&&2===e.type&&this.deleteParticle(e.id):"colors"===e.path[0]?1===e.path.length&&1===e.type?this.addColor(e.id,e.data.asset):1===e.path.length&&2===e.type&&this.deleteColor(e.id):"materials"===e.path[0]?1===e.path.length&&1===e.type?this.addMaterial(e.id,e.data.asset):1===e.path.length&&2===e.type&&this.deleteMaterial(e.id):"fonts"===e.path[0]?1===e.path.length&&1===e.type?this.addFont(e.id,e.data.asset):1===e.path.length&&2===e.type&&this.deleteFont(e.id):"variables"===e.path[0]?1===e.path.length&&1===e.type?this.addVariableHolder(e.id,e.data.asset):1===e.path.length&&2===e.type&&this.deleteVariable(e.id):"components"===e.path[0]&&t.updateByLibOp(e,this)}updateByOp(e,t,i){if(this.data=t,"images"===e.path[0])2===e.path.length&&0===e.type?e.props.data&&this.getImage(e.path[1]).updateSrc(e.props.data):1===e.path.length&&1===e.type?this.addImage(e.id,e.data):1===e.path.length&&2===e.type&&this.deleteImage(e.id);else if("videos"===e.path[0])2===e.path.length&&0===e.type?e.props.data&&this.getVideo(e.path[1]).updateSrc(e.props.data):1===e.path.length&&1===e.type?this.addVideo(e.id,e.data):1===e.path.length&&2===e.type&&this.deleteVideo(e.id);else if("audios"===e.path[0])2===e.path.length&&0===e.type?e.props.data&&this.addAudio(e.path[1],t.audios[e.path[1]]):1===e.path.length&&1===e.type?this.addAudio(e.id,e.data):1===e.path.length&&2===e.type&&this.deleteAudio(e.id);else if("particles"===e.path[0])2===e.path.length&&0===e.type?e.props.data&&this.addParticle(e.path[1],t.particles[e.path[1]]):1===e.path.length&&1===e.type?this.addParticle(e.id,e.data):1===e.path.length&&2===e.type&&this.deleteParticle(e.id);else if("colors"===e.path[0])2===e.path.length&&0===e.type?this.updateColor(e.path[1],e.props):1===e.path.length&&1===e.type?this.addColor(e.id,e.data):1===e.path.length&&2===e.type&&this.deleteColor(e.id);else if("materials"===e.path[0])1===e.path.length&&1===e.type?this.addMaterial(e.id,e.data):1===e.path.length&&2===e.type?this.deleteMaterial(e.id):e.path.length>1&&this.getMaterial(e.path[1]).updateByOp(ac.drop(e,2),t.materials[e.path[1]],{shared:this,scene:i});else if("fonts"===e.path[0])2===e.path.length&&0===e.type?this.updateFont(e.path[1],e,i):1===e.path.length&&1===e.type?this.addFont(e.id,e.data):1===e.path.length&&2===e.type&&this.deleteFont(e.id);else if("variables"===e.path[0])2===e.path.length&&0===e.type?"value"in e.props?this.updateVariable(e.path[1],e.props.value):"persistent"in e.props&&(this.variables[e.path[1]].persistent=e.props.persistent):1===e.path.length&&4===e.type?this.addVariableHolder(e.id,e.data):1===e.path.length&&5===e.type&&this.deleteVariable(e.id);else if("userAPIs"===e.path[0]){if(1===e.path.length&&1===e.type)this.addUserAPI(e.id,e.data);else if(1===e.path.length&&2===e.type)this.deleteUserAPI(e.id);else if("string"==typeof e.path[1]){let i=t.userAPIs[e.path[1]];if(i){let t=0===e.type&&void 0===e.props.debounce,r=this.getUserAPI(e.path[1]);void 0!==r&&r===this.openAIRealtime?r.update(i):r?.update(i,this,t)}}}else if("userWebhooks"===e.path[0]){if(1===e.path.length&&1===e.type)this.addUserWebhook(e.id,e.data);else if(1===e.path.length&&2===e.type)this.deleteUserWebhook(e.id);else if("string"==typeof e.path[1]){let i=t.userWebhooks[e.path[1]];i&&this.getUserWebhook(e.path[1])?.update(i)}}else"lib"===e.path[0]&&this.updateLibByOp(ac.drop(e,1),i)}updateFont(e,t,i){if(t.props.url){let r=this.getFont(e),s={...this.data.fonts[e],url:t.props.url};r.update(s),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(e,this)}}addUserAPI(e,t){if(this.userAPIs[e])return this.userAPIs[e].update(t,this),!0;if(this.openAIRealtime?.id===e)return this.openAIRealtime.update(t),!0;if("VoiceAssistant"===t.integration?.type){let i=ET;return null===i?(Kv("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(t,e,this),!1)}{let i=PT();return null===i?(Kv("api-services","a user API integration"),!1):(this.userAPIs[e]=i.createUserAPI(e,t,this),!1)}}getUserAPI(e){return this.openAIRealtime?.id===e?this.openAIRealtime:this.userAPIs[e]}getUserAPIs(){return this.userAPIs}deleteUserAPI(e){let t=this.userAPIs[e];t&&(t.dispose(),delete this.userAPIs[e])}addUserWebhook(e,t){if(this.userWebhooks[e])return this.userWebhooks[e].update(t),!0;{let i=PT();return null===i?(Kv("api-services","a user webhook"),!1):(this.userWebhooks[e]=i.createUserWebhook(e,t),!1)}}getUserWebhook(e){return this.userWebhooks[e]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(e){let t=this.userWebhooks[e];t&&(t.dispose(),delete this.userWebhooks[e])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new FT(sy.emptyData())}),KT=n(()=>{iw()}),ZT=n(()=>{Bv(),Hx(),gT(),KT(),um(),Od(),jT=class extends qx{setMaterialOverride(e,t){this.materialOverride=nT(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),t.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,t,i){if(super.updateByPatchedOp(e,t,i),Rc(e.path,["geometry"])&&this.syncShadowCatcher(i),null!==function(e,t){let i=[];if(t.length!==e.length)return null;{let r=0;for(;r<e.length;){if("*"===t[r])i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}}return i}(e.path,["materials"])&&0===e.type&&Array.isArray(this.material))for(let[t,r]of Object.entries(e.props)){let e=this.material[Number(t)],s=i.shared.material(r);s!==e&&jT.disposeOneMaterial(e),this.material[Number(t)]=s}else if(Rc(e.path,["material"])){let r=this.material;!Array.isArray(r)&&"function"==typeof r?.updateByOp&&"material"in t&&"string"!=typeof t.material&&r.updateByOp(ac.drop(e,1),t.material,i)}else if(Rc(e.path,["materials","*"])&&Array.isArray(this.material)){let r=e.path[1];if("materials"in t&&r<this.material.length){let s=t.materials[r];"string"!=typeof s&&this.material[r].updateByOp(ac.drop(e,2),s,i)}}}get needsAO(){return void 0!==this.material&&(Array.isArray(this.material)?this.material[0]:this.material).hasAO}syncShapeBlendNodeLayer(){"Mesh"===this.dataPatched.type&&this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):512&this.layers.mask&&this.layers.set(0)}updateState(e,t){super.updateState(e,t),void 0!==e.castShadow&&(this.castShadow=e.castShadow),void 0!==e.receiveShadow&&(this.receiveShadow=e.receiveShadow);let i,r=this.dataPatched;this.syncShapeBlendNodeLayer(),"Mesh"===this.dataPatched.type&&"ShapeBlendGeometry"===this.dataPatched.geometry.type&&(i={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let s=void 0!==this.materialOverride;!s&&"NonParametricGeometry"!==e.geometry?.type&&"material"in e&&void 0!==e.material&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe,i),t.scene.markNeedsUpdateRendererDirty()),!s&&("NonParametricGeometry"===e.geometry?.type||"materials"in e)&&("materials"in e&&void 0!==e.materials?(this.disposeMaterial(),this.material=e.materials.map(e=>t.shared.material(e).getFlavor(r.flatShading,r.side,r.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&void 0!==e.material&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(r.flatShading,r.side,r.wireframe)],t.scene.markNeedsUpdateRendererDirty()));let a=this.data;if(!s&&"NonParametricGeometry"!==a.geometry?.type&&"materials"in a&&void 0!==a.materials&&(this.disposeMaterial(),this.material=t.shared.material(a.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!s&&(void 0!==e.flatShading||void 0!==e.wireframe||void 0!==e.side))if(Array.isArray(this.material))for(let e=0;e<this.material.length;e++)this.material[e]=this.material[e].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe,i);this.syncShadowCatcher(t)}shadowCatcherActive(){let e=this.dataPatched,t=e.geometry?.type;return!0===e.shadowCatcher&&("RectangleGeometry"===t||"PlaneGeometry"===t)}syncShadowCatcher(e){let t=this.dataPatched;if(this.shadowCatcherActive()){if(void 0===this.shadowCatcherMaterial){let e=function(){let e="webgpu"===lT&&void 0!==cT?cT:void 0;return void 0===e?null:nT(e())}();if(null===e)return;this.shadowCatcherMaterial=e}this.shadowCatcherMaterial.side=t.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else void 0!==this.shadowCatcherMaterial&&this.material===this.shadowCatcherMaterial&&(void 0!==this.materialOverride?(this.material=this.materialOverride,e.scene.markNeedsUpdateRendererDirty()):"material"in t&&void 0!==t.material&&(this.material=e.shared.material(t.material).getFlavor(t.flatShading,t.side,t.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow)}static disposeOneMaterial(e){var t;($x(t=e)||!0===t?.isTSLNodeMaterial)&&!function(e){return function(e){return!0===e?.isClassicSharedMaterial}(e)||!0===e?.isTSLSharedMaterial}(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&fd(this.material).forEach(e=>{jT.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),JT=n(()=>{Bv(),um(),XT(),ZT(),Mu(),tT(),XM(),BM(),GT=new ns,WT=new Ss,qT=new Ss,HT=new ns,$T=new As,YT=class extends jT{constructor(e,t,i){super(e,t),this.data=t,this.isSkinnedMesh=!1,this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=(new As).fromArray(t.bindMatrix),this.bindMatrixInverse=new As)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return!0!==e.isTextGeometry}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof an&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(void 0===this.localGeometry)return this.geometryCreateDeleyed instanceof an?this.geometryCreateDeleyed:void 0}get geometry(){if(void 0!==this.localGeometry)return this.localGeometry;if(this.geometryCreateDeleyed instanceof FT){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=t.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Hg.is2DParametricMesh(e.type)&&0===e.depth}get is2DType(){return Hg.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return"NonParametricGeometry"===this.geometry.userData.type}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Rc(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ac.drop(e,1),t.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if("NonParametricGeometry"===i||"SubdivGeometry"===i){let i,r,s,a=e;if(void 0===this.localGeometry){let e={...this.data.geometry,...a};this.localGeometry=ZM(e,t,this.data.flatShading,this)}a.scaleBaked?[i,r,s]=a.scaleBaked:({width:i,height:r,depth:s}=a);let n=this.localGeometry.userData,o="number"==typeof i?i:1,l="number"==typeof r?r:1,h="number"==typeof s?s:1;void 0!==n.sxPrev&&EM(this.localGeometry.attributes,o/n.sxPrev,l/n.syPrev,h/n.szPrev),n.sxPrev=o,n.syPrev=l,n.szPrev=h}else{let i=ZM({...this.data.geometry,...e},t,this.data.flatShading,this);void 0!==this.localGeometry&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&RM(this.localGeometry,i)?i.dispose():(this.localGeometry?.dispose(),this.localGeometry=i)}}refreshAttachedClonersInteractions(e){for(let t of this.attachedSurfaceCloners)t.update(e)}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,i){let r=!1;if(0===e.type&&0===e.path.length&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof jM&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&0===e.type&&0===e.path.length&&VM(e.props)&&this.geometryCreateDeleyed instanceof jM&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(t),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&0===e.type&&0===e.path.length&&this.geometryCreateDeleyed instanceof an&&!(this.geometryCreateDeleyed instanceof jM)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&void 0!==this._geometryCacheKey){let e=i.shared,t=this.chooseGeoemtryCache(e),s=this.geometryCreateDeleyed;if(t.getCached(this._geometryCacheKey)===s&&!0!==s.isShared){let a=this.dataPatched.geometry,n=ZM(a,e,this.data.flatShading,this);RM(s,n)?(n.dispose(),s.computeBoundingSphere(),t.mutateIfUnique(this._geometryCacheKey,a)):(n.computeBoundingSphere(),t.forceDelete(this._geometryCacheKey),t.adopt(a,n),this.geometryCreateDeleyed=n),this._geometryCacheKey=a,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}applyTransientGeometryData(e,t){let i=e.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof an&&!(this.geometryCreateDeleyed instanceof jM)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&void 0!==this._geometryCacheKey){let t=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(t.getCached(this._geometryCacheKey)===s&&!0!==s.isShared){let a=ZM(r,i,this.data.flatShading,this);return RM(s,a)?(a.dispose(),s.computeBoundingSphere(),t.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),t.forceDelete(this._geometryCacheKey),t.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(e),void this.refreshAttachedPaths(e)}}t&&void 0!==this._geometryCacheKey&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,t){void 0!==e.geometry&&this.updateGeometryOnStateUpdate(e.geometry,t);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:e,value:r}}of i)this.updateMorphInfluences(e,t.shared.getVariable(r,[this.uuid,"morphTargetInfluences",e]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(void 0===this.morphTargetDictionary)return;let i=this.morphTargetDictionary[e];void 0!==i&&(this.morphTargetInfluences[i]=t)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&0===this.geometry.groups.length&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,t){let i=this.geometry.userData.parameters;this.is2DType?e.set(0,0,.5*i.depth):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?e.fromArray(i.centerOffset):e.setScalar(0),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new Ss,i=this.geometry.attributes.skinWeight;for(let e=0,r=i.count;e<r;e++){t.fromBufferAttribute(i,e);let r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),i.setXYZW(e,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let i=this.skeleton;if(void 0===i)return;let r=this.geometry;WT.fromBufferAttribute(r.attributes.skinIndex,e),qT.fromBufferAttribute(r.attributes.skinWeight,e),GT.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){let r=qT.getComponent(e);if(0!==r){let s=WT.getComponent(e);$T.multiplyMatrices(i.bones[s].matrixWorld,i.boneInverses[s]),t.addScaledVector(HT.copy(GT).applyMatrix4($T),r)}}return t.applyMatrix4(this.bindMatrixInverse)}}});function QT(e){if(Array.isArray(e.material)){for(let t of e.material)if(0===t.getLayersOfType("outline").length)return}else if(!$x(e.material)||0===e.material.getLayersOfType("outline").length)return;e instanceof YT&&e.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let t=e.geometry.attributes.position.array,i=new Float32Array(t.length),r=new ns;for(let e=0;e<t.length;e+=3)r.set(t[e],t[e+1],t[e+2]).normalize(),i[e]=r.x,i[e+1]=r.y,i[e+2]=r.z;e.geometry.setAttribute("extrudeNormal",new Ha(i,3))}(e):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let t=new Map,i=e.geometry.attributes,r=i.position.array,s=i.normal.array,a=new Float32Array(r.length);for(let e=0;e<r.length;e+=3){let i=`${r[e]}_${r[e+1]}_${r[e+2]}`,a=new ns(s[e],s[e+1],s[e+2]);t.has(i)?t.get(i)?.normals.push(a):t.set(i,{normals:[a],result:new ns})}t.forEach((e,t)=>{for(let t of e.normals)e.result.add(t);e.result.divideScalar(e.normals.length)});for(let e=0;e<r.length;e+=3){let i=`${r[e]}_${r[e+1]}_${r[e+2]}`,s=t.get(i)?.result;s&&(a[e]=s.x,a[e+1]=s.y,a[e+2]=s.z)}e.geometry.setAttribute("extrudeNormal",new Ha(a,3))}(e)}function eC(e){return Math.min(2047,Math.max(1,Math.round(2048*e)))/2048}function tC(e){if(!e.geometry.attributes.position)return;let t=e.geometry.attributes,i=t.position.array,r=t.randomColor;if(void 0!==r&&3*r.count===i.length)return;let s=new Float32Array(i.length),a=parseInt(e.uuid.replace(/\D/g,"")),n=[eC(ts.seededRandom(a)),eC(ts.seededRandom(a+1e4)),eC(ts.seededRandom(a+2e4))];for(let e=0;e<i.length;e++)s[e]=n[e%3];e.geometry.setAttribute("randomColor",new ja(s,3))}var iC=n(()=>{Mu(),iw(),JT()});function rC(e){let t=!1;return e.scene.objects.traverse((e,i)=>{"BooleanGeometry"===i.geometry?.type&&(t=!0)}),t}var sC,aC,nC,oC,lC,hC,uC,dC,cC=n(()=>{Hx(),Mu(),Dx(),iC(),ZT(),sC=new As,aC=new As,nC=class extends jT{constructor(e,t,i){super(e,t),this.data=t,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new an,this.onAfterRender=(e,t,i,r,s,a)=>{super.onAfterRender(e,t,i,r,s,a),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),1===e.path.length&&"geometry"===e.path[0]&&0===e.type&&void 0!==e.props.operation&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){if(-1!==this.booleanMeshSetAddress&&!e)return;for(let i=0;i<this.children.length;i++){let r=this.children[i];r instanceof nC&&!0===r.dataPatched.visible&&r.recomputeBoolean(!0===e,t)}this.meshSetAddresses=[];for(let t=0;t<this.children.length;t++){let i=this.children[t];if(i instanceof qx&&!0===i.dataPatched.visible&&i.geometry.attributes.position?.count>0&&i.geometry.drawRange.count>0&&0!==i.booleanMeshSetAddress){sC.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix);try{if(-1===i.booleanMeshSetAddress){if((i.geometry.index??i.geometry.getAttribute("position")).count/3<15e5&&(i.booleanMeshSetAddress=Ax(i.geometry,!0===e)),-1===i.booleanMeshSetAddress)return;Px(i.booleanMeshSetAddress,sC),i.booleanMatrixInvOld.copy(sC).invert(),i.booleanWasTransformed=!1}else i instanceof nC&&!0===i.needsTransformForDownstream?(Px(i.booleanMeshSetAddress,sC),i.needsTransformForDownstream=!1):!0===i.booleanWasTransformed&&(Px(i.booleanMeshSetAddress,aC.multiplyMatrices(sC,i.booleanMatrixInvOld)),i.booleanMatrixInvOld.copy(sC).invert(),i.booleanWasTransformed=!1)}catch(e){console.error(e),i.booleanMeshSetAddress=0,i.geometry.userData.booleanOperationDidFail=!0;continue}this.meshSetAddresses.push(i.booleanMeshSetAddress),i.geometry.userData.booleanOperationDidFail=!1}}if(0===this.meshSetAddresses.length){if(0!==this.geometry.getAttribute("position")?.array.length){let e=this.geometry;e.dispose(),this.geometry=new an,this.geometry.userData=e.userData,this.geometry.boundingSphere=e.boundingSphere,this.geometry.setAttribute("position",new Ha([],3))}return void this.geometry.setDrawRange(0,0)}if(!0===e)return function(e,t){let i=Mx(),r=Nx(e,t),s=i.mesh_topological_data(r),a=s.positions(),n=s.indices();return s.free(),r.free(),{positions:a,indices:n,verticesPerFace:new Uint8Array(n.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new an,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(e,t,i,r){let s=Mx(),a=Nx(e,t),n=s.mesh_render_data(a,Math.max(r,0));if(i.setAttribute("position",new Ha(n.positions(),3)),i.setAttribute("normal",new Ha(n.normals(),3)),n.free(),null===i.boundingSphere&&(i.boundingSphere=new Ka),0===a.tri_count())i.boundingSphere.center.set(0,0,0),i.boundingSphere.radius=0,i.userData.parameters={width:0,height:0,depth:0};else{let e=a.bounds();i.boundingSphere.center.set(e[0],e[1],e[2]),i.boundingSphere.radius=(e[3]**2+e[4]**2+e[5]**2)**.5,i.userData.parameters={width:2*e[3],height:2*e[4],depth:2*e[5]}}return Cx(a)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(e){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(e)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,QT(this),tC(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),pC=n(()=>{Mu(),Qb(),ex(),(oC||(oC={})).is=function(e){return Lb.is(e)&&e instanceof Hl},lC=(e,t)=>class extends(Kb(e,t)){updateState_Light(e,t){if(this.updateState_Entity(e,t),void 0!==e.color&&(this.color=t.shared.color(e.color)),void 0!==e.intensity&&(this.intensity=e.intensity*Math.PI),void 0!==e.depth){let t=this.shadow;t.camera.far=e.depth,t.needsUpdate=!0}void 0!==e.shadows&&(this.castShadow=e.shadows)}}}),mC=n(()=>{Mu(),cC(),Hx(),ex(),hC=e=>e instanceof qx,uC=e=>null!==e&&e instanceof nC,dC=e=>Xb.is(e)});function gC(e,t){return t.color(e)}var fC,yC,vC=n(()=>{}),bC=n(()=>{Mu(),Dv(),Iv(),fC=class extends(pv(nu)){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){yv(this.object,fC.geometryHelper,e,t)}}}),xC=n(()=>{Mu(),bC(),pC(),yC=class extends(lC(ch,fC)){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new hu(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof hu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=void 0!==e.depth&&e.depth!==this.shadow.camera.far||void 0!==e.size&&e.size/2!==this.shadow.camera.right;void 0!==e.size&&function(e,t){e.shadow.camera.right=t/2,e.shadow.camera.left=-t/2,e.shadow.camera.top=t/2,e.shadow.camera.bottom=-t/2,e.shadow.needsUpdate=!0}(this,e.size),void 0!==e.shadowRadius&&(this.shadow.radius=e.shadowRadius),void 0!==e.shadowResolution&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),void 0!==e.penumbraSize&&t.scene.markPenumbraSizeDirty(),i&&this.update()}}});function wC(e){return e instanceof jT&&e.needsAO&&!jv(e)&&!0!==e.isDecalObject}function _C(e){let t=e.cloner;if(t&&Array.isArray(t.children))for(let i of t.children)i?.layers&&(i.layers.mask=e.layers.mask)}function SC(e){return e.getLayersOfType("reflection").filter(e=>e.data.visible).length}function MC(e){let t=1/0,i=-1/0;for(let r of e.getLayersOfType("reflection")){let e=r.data;if(!e.visible||1===e.mirror)continue;let s="number"==typeof e.blur?e.blur:null;t=Math.min(t,s??0),i=Math.max(i,s??10)}return t===1/0?null:{min:t,max:i}}function TC(e){for(let t of e.getLayersOfType("reflection")){let e=t.data;if(!e.visible)continue;let{blur:i,thickness:r,steps:s,stepSize:a}=e;return"number"!=typeof i||"number"!=typeof r||"number"!=typeof s||"number"!=typeof a?"variable":{blur:i,thickness:r,steps:s,stepSize:a,tracingMode:1===e.tracingMode?1:0}}return null}function CC(e,t){let i={outline:!1,cavity:!1},r=e.layers.mask&RC,s=t.getLayersOfType("transmission"),a=t.getLayersOfType("outline"),n=SC(t),o=t.getLayersOfType("cavity");return(a.length>0||o.length>0)&&(e.layers.set(8),s.length>0&&e.layers.enable(3),n>0&&e.layers.enable(4),i.outline=a.length>0,i.cavity=o.length>0,tC(e),QT(e)),0===s.length&&0===a.length&&0===o.length&&0===n&&e.layers.set(0),r&&e.layers.set(9),!r&&wC(e)&&e.layers.enable(5),_C(e),i}function AC(e,t){if(!t.layers)return!1;let i=e.layers.mask&RC,r=!1,s=t.getLayersOfType("transmission").filter(e=>e.data.visible),a=t.getLayersOfType("outline").filter(e=>e.data.visible),n=SC(t),o=t.getLayersOfType("cavity").filter(e=>e.data.visible);return s.length>0&&(e.layers.set(3),(a.length>0||o.length>0)&&e.layers.enable(8),n>0&&e.layers.enable(4),r=!0),0===s.length&&0===a.length&&0===o.length&&0===n&&e.layers.set(0),i&&e.layers.set(9),!i&&wC(e)&&e.layers.enable(5),_C(e),r}function NC(e,t){var i;if(!t.layers)return!1;let r=e.layers.mask&RC,s=!1,a=SC(t),n=t.getLayersOfType("transmission").filter(e=>e.data.visible),o=t.getLayersOfType("outline").filter(e=>e.data.visible),l=t.getLayersOfType("cavity").filter(e=>e.data.visible);return a>0&&((i=e.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),e.layers.set(4),n.length>0&&e.layers.enable(3),(o.length>0||l.length>0)&&e.layers.enable(8),s=!0),0===a&&0===n.length&&0===o.length&&0===l.length&&e.layers.set(0),r&&e.layers.set(9),!r&&wC(e)&&e.layers.enable(5),_C(e),s}function PC(e,t,i,r=!1){let s=e.cloner;if(s){let a=null;if(e.raycast===Hn.prototype.raycast||e.raycast===qx.prototype.raycast){let t=e.geometry;t&&(null===t.boundingSphere&&t.computeBoundingSphere(),a=t.boundingSphere)}for(let n of s.children){if(null!==a&&(VC.copy(a).applyMatrix4(n.matrixWorld),!t.ray.intersectsSphere(VC)))continue;let s=OC.copy(n.matrixWorld).invert(),o=BC.copy(t.ray).applyMatrix4(s),l=e.matrixWorld;o.applyMatrix4(l);let h=EC;h.set(o.origin,o.direction),h.near=t.near,h.far=t.far,h.layers.mask=t.layers.mask;let u=h.intersectObject(e,!1);u.length>0&&i.push({...u[0],object:r?n:e})}}}var RC,EC,OC,BC,VC,DC,IC,LC,zC,kC,UC,FC,jC=n(()=>{Yv(),iC(),Hx(),ZT(),Mu(),RC=512,EC=new Uh,OC=new As,BC=new Bn,VC=new Ka}),GC=n(()=>{Mu(),Dv(),Iv(),DC=class extends(pv(tu)){constructor(e,t=6710886){super(e,t),this.object=e,this.matrix=e.matrixWorld,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){yv(this.object,DC.geometryHelper,e,t)}update(){if(void 0!==this.object){let e=DC._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=void 0!==this.color?this.color:this.light.color;if(this.cone.material instanceof Array)for(let e=0,t=this.cone.material.length;e<t;e++)this.cone.material[e].color.set(r);else this.cone.material.color.set(r)}}},(IC=DC)._vector=new ns}),WC=n(()=>{Mu(),GC(),pC(),LC=new ns,zC=new ns,kC=new ss,UC=class extends(lC(oh,IC)){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=2*ts.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new hu(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof hu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),zC.setFromMatrixPosition(this.matrixWorld),kC.setFromRotationMatrix(this.matrixWorld),LC.copy(this.up).applyQuaternion(kC).negate().multiplyScalar(this.distance),this.target.position.copy(zC).add(LC),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),void 0!==e.distance&&(this.distance=e.distance),void 0!==e.decay&&(this.decay=e.decay),void 0!==e.angle&&(this.angle=e.angle),void 0!==e.penumbra&&(this.penumbra=e.penumbra),void 0!==e.shadowRadius&&(this.shadow.radius=e.shadowRadius),void 0!==e.penumbraSize&&t.scene.markPenumbraSizeDirty(),void 0!==e.shadowResolution&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),qC=n(()=>{Bv(),yx(),Mu(),Qb(),rw(),vC(),Vv(),xC(),um(),gT(),Mu(),ZT(),mC(),jC(),WC(),hb(),cC(),FC=class extends(Yb(la)){constructor(e,t,i){if(super(),this.data=t,this.bgColor=new Yx(1,1,1,1),this.fog=null,this.backupFog=new oa(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=Xg.getDensity({}),this.fogHeightFalloff=Xg.getHeightFalloff({}),this.fogHeightBase=Xg.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new aa,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new fx(mm,{...If.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new $l(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene){let r=ib();null===r?Kv("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else t.uiFrame&&this.createUICanvas(t.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,t){let i=ib();null!==i?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})):Kv("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(e){this.bgColor=e,!0===this.fogUseBGColor&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){void 0!==e.color&&(this.ambientLight.color=gC(e.color,t)),void 0!==e.intensity&&(this.ambientLight.intensity=e.intensity*Math.PI),void 0!==e.enabled&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(e=>{e instanceof nC&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof jT)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){if(void 0===e.softShadowQuality&&void 0===e.type||!this.isActive)return;let t=this.data.shadow;bf.isSoft(t)}updateFog(e,t){e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=gC(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far,this.fogMode=Xg.getMode(e),this.fogDensity=Xg.getDensity(e),this.fogHeightFalloff=Xg.getHeightFalloff(e),this.fogHeightBase=Xg.getHeightBase(e)}updateSky(e,t){this.skyState=e??null,this.skyStateVersion++;let i=e?.hdri?.image;this.skyHdriHolder=null!=i?t.image(i):null}updateAo(e,t){void 0!==e.aoColor&&(this.aoColor=gC(e.aoColor,t))}updateByOp(e,t,i,r){let s=this.data.uiFrame;super.updateByOp(e,t,i,r);let a=t;Rc(e.path,["fog"])?this.updateFog(a.fog,i.shared):Rc(e.path,["sky"])?this.updateSky(a.sky,i.shared):Rc(e.path,["grading"])?this.gradingState=a.grading??null:Rc(e.path,["ao"])?this.updateAo(a.ao,i.shared):Rc(e.path,["ambient"])?this.updateAmbientLight(a.ambient,i.shared):Rc(e.path,["shadow"])?this.updateShadow(a.shadow):0===e.type&&0===e.path.length&&(void 0!==e.props.uiFrame||s!==a.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),void 0!==e.backgroundColor&&this.setBackgroundColor(gC(e.backgroundColor,t.shared)),void 0!==e.fog&&this.updateFog(e.fog,t.shared),void 0!==e.sky&&this.updateSky(e.sky,t.shared),void 0!==e.grading&&(this.gradingState=e.grading),void 0!==e.ambient&&this.updateAmbientLight(e.ambient,t.shared),void 0!==e.ao&&this.updateAo(e.ao,t.shared),void 0!==e.shadow&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return null===this.penumbraSizeArrayCache&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(uv).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof yC&&i.visible&&e<dv&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize??.5,e+=1),i instanceof UC&&i.visible&&e<uv-dv&&(this.penumbraSizeArrayCache[dv+t]=i.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let r=s.cloner;Lb.is(s)&&(s.visible||r?.object.data.visible)&&((hC(s)||dC(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),PC(s,e,t,!0)),i(s))}};return i(this),t}updateEntity2DByOp(e,t,i,r){this.uiCanvas?.updateEntity2DByOp(e,t,i,r)}}});function HC(e){let t=YC.get(e);return void 0===t&&(t=XC++,YC.set(e,t)),t}function $C(e,t,i,r){let s=e,a=t;return[HC(i),HC(r),s.layers?.mask??0,s.renderOrder??0,!0===(s.castShadow??a.castShadow)?1:0,!0===(s.receiveShadow??a.receiveShadow)?1:0].join(":")}var YC,XC,KC,ZC,JC,QC,eA,tA,iA=n(()=>{Yv(),YC=new WeakMap,XC=1}),rA=n(()=>{Mu(),ZC=(KC=[8,32,128,512])[KC.length-1],JC=(new As).makeScale(0,0,0),QC=class extends no{constructor(e,t,i,r){super(e,t,i),this.isInstanceGroup=!0,this.members=new Array(i).fill(null),this.raycast=()=>{},this.matrixAutoUpdate=!1,this.frustumCulled=!1,this.adoptPassState(r);for(let e=0;e<i;e++)this.setMatrixAt(e,JC);this.instanceMatrix.needsUpdate=!0}adoptPassState(e){this.layers.mask=e.layers.mask,this.renderOrder=e.renderOrder,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow}assign(e,t){this.members[e]=t}writeSlot(e,t){return!1===t.visible?(this.setMatrixAt(e,JC),!1):(this.setMatrixAt(e,t.matrixWorld),!0)}park(e){this.members[e]=null,this.setMatrixAt(e,JC)}get memberCount(){let e=0;for(let t of this.members)null!==t&&e++;return e}}}),sA=n(()=>{iA(),rA(),eA=8,tA=class{constructor(e=eA){this.minGroupSize=e,this.groups=[],this.groupKeys=new WeakMap,this.placements=new Map,this.page=null,this.stats={instancingGroups:0,instancedDrawsSaved:0,instancingRegroups:0,instancingParks:0,instancingIneligible:{}}}update(e,t){this.page!==e&&(this.teardown(),this.page=e,t=!0),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t&&this.reconcile(e),this.refresh()}reconcile(e){let t={},i=new Map;e.traverse(e=>{if(!0===e.isInstanceGroup)return;let r=function(e){if(!0!==e.isMesh)return"not-a-mesh";if(jv(e)||Wv(e)||Fv(e)||Uv(e))return"excluded-type";let t=function(e){let t=Hv(e)?e.object:e;return void 0!==t.geometry?t:void 0}(e);if(void 0===t)return"not-a-mesh";let i=t.material;if(void 0===i)return"not-a-mesh";if(Array.isArray(i))return"array-material";let r=t.builtSharedGeometry;if(void 0===r)return"unrealized-geometry";if(!function(e){return!0===e.isShared}(r))return"unshared-geometry";if(void 0===r.attributes.position)return"empty-geometry";if(void 0!==r.morphAttributes.position)return"morph";if(!0===t.isSkinnedMesh)return"skinned";let s=t.morphTargetInfluences;if(void 0!==s&&s.length>0)return"morph";if(0!==r.drawRange.start||r.drawRange.count!==Number.POSITIVE_INFINITY)return"draw-range";let a=i;return null!=a.positionNode||null!=a.castShadowPositionNode?"position-node":!0===a.transparent?"transparent":void 0!==t.userData?.__splinePlanarMirror?"reflection":function(e){let t=e;for(;null!==t;){let e=t.states;if(void 0!==e&&Object.keys(e).length>0)return!0;t=t.parent}return!1}(t)?"interaction-states":{object:e,owner:t,geometry:r,material:i,key:$C(e,t,r,i)}}(e);if("string"==typeof r)return void(t[r]=(t[r]??0)+1);let s=i.get(r.key);void 0===s?i.set(r.key,[r]):s.push(r)});let r=new Map;for(let[e,t]of i)for(let i of t)r.set(i.object,e);let s=!1;for(let[e,t]of this.placements)r.get(e)!==this.groupKeys.get(t.group)&&this.parkPlacement(e,t);for(let e=this.groups.length-1;e>=0;e--){let t=this.groups[e];t.memberCount>=this.minGroupSize||(this.destroyGroup(t),this.groups.splice(e,1),s=!0)}for(let[t,r]of i){let i=r.filter(e=>!this.placements.has(e.object));if(0===i.length)continue;let a=0;for(let e of this.groups){if(a>=i.length)break;if(this.groupKeys.get(e)!==t)continue;let{members:r}=e;for(let t=0;t<r.length&&a<i.length;t++)null===r[t]&&this.place(e,t,i[a++].object)}for(;i.length-a>=this.minGroupSize;){let r=i.slice(a,a+ZC);this.groups.push(this.createGroup(e,t,r)),a+=r.length,s=!0}}s&&this.stats.instancingRegroups++,this.publishGroupStats(),this.stats.instancingIneligible=t}createGroup(e,t,i){let r=i[0],s=new QC(r.geometry,r.material,function(e){for(let t of KC)if(e<=t)return t;return ZC}(i.length),r.object);this.groupKeys.set(s,t);for(let e=0;e<i.length;e++)this.place(s,e,i[e].object);return e.add(s),s}destroyGroup(e){for(let t=0;t<e.members.length;t++){let i=e.members[t];null!==i&&this.parkPlacement(i,{group:e,slot:t})}e.removeFromParent(),e.dispose()}place(e,t,i){e.assign(t,i),this.placements.set(i,{group:e,slot:t}),i.isDrawSuppressed=!0}parkPlacement(e,t){t.group.park(t.slot),t.group.instanceMatrix.needsUpdate=!0,this.placements.delete(e),e.isDrawSuppressed=!1,this.stats.instancingParks++}refresh(){for(let e of this.groups){let{members:t}=e,i=null;for(let r=0;r<t.length;r++){let s=t[r];null!==s&&(null===i&&(i=s),e.writeSlot(r,s))}null!==i&&(e.adoptPassState(i),e.instanceMatrix.needsUpdate=!0)}}teardown(){for(let e of this.groups)this.destroyGroup(e);this.groups.length=0;for(let e of this.placements.keys())e.isDrawSuppressed=!1;this.placements.clear(),this.publishGroupStats()}dispose(){this.teardown(),this.page=null}publishGroupStats(){let e=0;for(let t of this.groups){let i=t.memberCount;i>0&&(e+=i-1)}this.stats.instancingGroups=this.groups.length,this.stats.instancedDrawsSaved=e}}});function aA(e){let t=!1;return e.scene.objects.traverse((e,i)=>{"Mesh"===i.type&&"SubdivGeometry"===i.geometry.type&&(t=!0)}),t}var nA,oA,lA,hA=n(()=>{Hx(),Mu(),XM(),iC(),JT(),nA=new Sa,oA=new ns,lA=class extends YT{constructor(e,t,i){super(e,t,i),this.data=t,this.hiddenMatrixOld=new As,this.smoothShading=!0,this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return void 0!==this.localGeometry?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return void 0!==this.localGeometry?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let i=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(!0===this.skipReactionUpdate)return;let t=this.localGeometry?.uuid,{originalGeometry:i,subdividedGeometry:r,subdivPointer:s}=jM.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=s,void 0!==i&&(this.originalGeometry?.dispose(),this.originalGeometry=i),void 0!==r&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=r??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,QT(this),tC(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),void 0!==e.flatShading){let i=this.material;this.material=Array.isArray(i)?i.map(e=>e.getFlavor(!1,e.side,e.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1,t=!1,i=!1){t&&this.subdividedGeometry||jM.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,i),this.subdividedGeometry&&jM.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=jM.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=jM.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,QT(this),tC(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,t){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,qx.prototype.raycast.call(this,e,t),this.localGeometry=i}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;null===e.boundingSphere&&(e.boundingSphere=new Ka,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;nA.setFromBufferAttribute(t),nA.getCenter(i),e.boundingSphere.radius=i.distanceTo(nA.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nA.getSize(oA),this.hasNonUniformScale&&oA.divide(this.scale);let r={width:oA.x,height:oA.y,depth:oA.z};return this.geometry.userData.parameters=r,r}updateBoundingSphere(e){let t=this.originalGeometry;nA.min.set(e[0],e[2],e[4]),nA.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(nA.min.applyMatrix4(this.shearScaleInv),nA.max.applyMatrix4(this.shearScaleInv)),null===t.boundingSphere&&(t.boundingSphere=new Ka);let i=t.boundingSphere.center;nA.getCenter(i),t.boundingSphere.radius=i.distanceTo(nA.max)}freeSubdivPointer(){this.subdivPointer&&(jM.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(!0===this.skipReactionUpdate)return;let t=this.localGeometry,i=t?.uuid,r=t?.userData.parameters,s=e.subdivisions>0?jM.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,QT(this),tC(this),void 0!==r&&(this.localGeometry.userData.parameters=r),i&&(this.localGeometry.uuid=i)}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),this.localGeometry&&(0===e.type&&0===e.path.length&&VM(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(t):this.createGeometryByControls(t))}}});function uA(e,t,i){i.length=0;let{axis:r,sign:s,limit:a}=t;for(let t=0;t<e.length;t++){let n=e[t],o=e[(t+1)%e.length],l=(0===r?n.px:1===r?n.py:n.pz)*s-a,h=(0===r?o.px:1===r?o.py:o.pz)*s-a,u=l<=0,d=h<=0;if(u&&i.push(n),u!==d){let e=l/(l-h);i.push({px:n.px+(o.px-n.px)*e,py:n.py+(o.py-n.py)*e,pz:n.pz+(o.pz-n.pz)*e,nx:n.nx+(o.nx-n.nx)*e,ny:n.ny+(o.ny-n.ny)*e,nz:n.nz+(o.nz-n.nz)*e})}}return i}function dA(e,t,i,r,s,a,n,o,l){let h=e.geometry,u=h.getAttribute("position");if(void 0===u||0===u.count)return!0;let d=h.getAttribute("normal"),c=h.getIndex(),p=null!==c?c.count:u.count;if(p>cA)return!0;let m=h.drawRange.start,g=m+(h.drawRange.count===1/0?p-m:Math.min(h.drawRange.count,p-m));gA.copy(e.objectToDecal),fA.getNormalMatrix(gA);let f=[],y=[];for(let e=m;e+2<g;e+=3){let h=null!==c?c.getX(e):e,p=null!==c?c.getX(e+1):e+1,m=null!==c?c.getX(e+2):e+2;if(yA.fromBufferAttribute(u,h).applyMatrix4(gA),vA.fromBufferAttribute(u,p).applyMatrix4(gA),bA.fromBufferAttribute(u,m).applyMatrix4(gA),yA.z>i&&vA.z>i&&bA.z>i||yA.z<-i&&vA.z<-i&&bA.z<-i)continue;xA.subVectors(vA,yA),wA.subVectors(bA,yA),_A.crossVectors(xA,wA);let g=_A.length();if(!(0===g||_A.z/g<=mA)){if(f.length=0,void 0!==d)xA.fromBufferAttribute(d,h).applyMatrix3(fA),f.push({px:yA.x,py:yA.y,pz:yA.z,nx:xA.x,ny:xA.y,nz:xA.z}),xA.fromBufferAttribute(d,p).applyMatrix3(fA),f.push({px:vA.x,py:vA.y,pz:vA.z,nx:xA.x,ny:xA.y,nz:xA.z}),xA.fromBufferAttribute(d,m).applyMatrix3(fA),f.push({px:bA.x,py:bA.y,pz:bA.z,nx:xA.x,ny:xA.y,nz:xA.z});else{_A.divideScalar(g);for(let e of[yA,vA,bA])f.push({px:e.x,py:e.y,pz:e.z,nx:_A.x,ny:_A.y,nz:_A.z})}for(let e of t){if(0===f.length)break;let t=uA(f,e,y);y=f,f=t}if(!(f.length<3)){if(n.length/3+3*(f.length-2)>pA)return!1;for(let e=1;e+1<f.length;e++)for(let t of[f[0],f[e],f[e+1]]){l.push(t.px*r+.5,t.py*s+.5);let e=t.nx,i=t.ny,h=t.nz,u=Math.hypot(e,i,h);u>0?(e/=u,i/=u,h/=u):(e=0,i=0,h=1),n.push(t.px+e*a,t.py+i*a,t.pz+h*a),o.push(e,i,h)}}}}return!0}var cA,pA,mA,gA,fA,yA,vA,bA,xA,wA,_A,SA,MA,TA,CA,AA,NA,PA,RA,EA,OA=n(()=>{Mu(),cA=15e5,pA=3e5,mA=.01,gA=new As,fA=new us,yA=new ns,vA=new ns,bA=new ns,xA=new ns,wA=new ns,_A=new ns}),BA=n(()=>{Mu(),um(),ZT(),Hx(),Qb(),OA(),iC(),SA=new Sa,MA=new Sa,TA=new As,CA=new ns,AA=class extends jT{constructor(e,t,i){super(e,t),this.data=t,this.geometry=new an,this.lastSignature=[],this.nextSignature=[],this.scanned=[],this.lastParams={width:0,height:0,depth:0,offset:0},this.context=i;let r=this.data.geometry;this.lastParams={width:this.resolveNumber(r.width,0),height:this.resolveNumber(r.height,0),depth:this.resolveNumber(r.depth,0),offset:r.offset??0},this.geometry.userData={type:"DecalGeometry",parameters:{...this.lastParams}}}get isLOD(){return this.updateDecal(),!1}get isDecalObject(){return!0}resolveNumber(e,t){if("number"==typeof e)return e;let i=Number(this.context.shared.getVariable(e));return Number.isFinite(i)?i:t}currentParams(){let e=this.dataPatched.geometry;return{width:this.resolveNumber(e.width,this.lastParams.width),height:this.resolveNumber(e.height,this.lastParams.height),depth:this.resolveNumber(e.depth,this.lastParams.depth),offset:e.offset??0}}projectionRoot(){let e=this.parent;for(;null!==e&&Lb.is(e);){if("Page"===e.data?.type)return e;e=e.parent}return this.context.scene}scanTargets(e,t,i){let r=this.scanned;r.length=0;let s=this.projectionRoot();if(null===s)return r;SA.makeEmpty();for(let r=0;r<8;r++)CA.set((1&r?.5:-.5)*e,(2&r?.5:-.5)*t,(4&r?.5:-.5)*i).applyMatrix4(this.matrixWorld),SA.expandByPoint(CA);return s.traverse(e=>{if(e===this||!Lb.is(e)||!(e instanceof qx)||e instanceof AA||"Mesh"!==e.dataPatched?.type||!e.visible||e.destroyedInAction||512&e.layers.mask)return;let t=e.geometry,i=t?.getAttribute("position");void 0===i||0===i.count||0!==t.drawRange.count&&(null===t.boundingBox&&t.computeBoundingBox(),MA.copy(t.boundingBox).applyMatrix4(e.matrixWorld),SA.intersectsBox(MA)&&r.push(e))}),r}collectSignature(e,t,i){e.length=0,e.push(i.width,i.height,i.depth,i.offset);for(let t of this.matrixWorld.elements)e.push(t);for(let i of t){e.push(i.id,i.geometry.id);let t=i.geometry.getAttribute("position");e.push(void 0===t?-1:"version"in t?t.version:t.data.version);let r=i.geometry.getIndex();e.push(null!==r?r.version:-1),e.push(i.geometry.drawRange.count===1/0?-1:i.geometry.drawRange.count);for(let t of i.matrixWorld.elements)e.push(t)}}signaturesEqual(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}updateDecal(){if(this.disposed)return!1;this.updateWorldMatrix(!0,!1);let e=this.currentParams(),t=this.scanTargets(e.width,e.height,e.depth);if(this.collectSignature(this.nextSignature,t,e),this.signaturesEqual(this.nextSignature,this.lastSignature))return!1;let i=this.lastSignature;this.lastSignature=this.nextSignature,this.nextSignature=i,this.lastParams=e,TA.copy(this.matrixWorld).invert();let r=t.map(e=>({geometry:e.geometry,objectToDecal:(new As).multiplyMatrices(TA,e.matrixWorld)}));return this.geometry.dispose(),this.geometry=function(e,t){let i=Math.max(Math.abs(t.width),1e-6),r=Math.max(Math.abs(t.height),1e-6),s=Math.max(Math.abs(t.depth),1e-6),a=[{axis:0,sign:1,limit:i/2},{axis:0,sign:-1,limit:i/2},{axis:1,sign:1,limit:r/2},{axis:1,sign:-1,limit:r/2},{axis:2,sign:1,limit:s/2},{axis:2,sign:-1,limit:s/2}],n=[],o=[],l=[];for(let h of e)if(!dA(h,a,s/2,1/i,1/r,t.offset,n,o,l))break;let h=new an;return h.setAttribute("position",new Ha(n,3)),h.setAttribute("normal",new Ha(o,3)),h.setAttribute("uv",new Ha(l,2)),0===n.length?(h.setDrawRange(0,0),h.boundingSphere=new Ka):h.computeBoundingSphere(),h}(r,e),this.geometry.userData={type:"DecalGeometry",parameters:{width:e.width,height:e.height,depth:e.depth}},QT(this),tC(this),this.resetBBoxNeedsUpdate(),!0}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Rc(e.path,["geometry"])&&this.resetBBoxNeedsUpdate()}updateEntityBoxSize(e,t){let i=this.currentParams();e.setScalar(0),t.set(i.width,i.height,i.depth).multiplyScalar(.5)}dispose(){super.dispose(),this.geometry.dispose()}}}),VA=n(()=>{Mu(),Dv(),Iv(),NA=class extends(pv(iu)){constructor(e,t=15,i=6710886){super(e,t,i),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){yv(this.object,NA.geometryHelper,e,t)}}}),DA=n(()=>{Mu(),VA(),pC(),PA=class extends(lC(hh,NA)){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let s=new ns(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),a=new ns(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),n=new Sa(s,a),o=new uu(n,new aa(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let e in this.gizmos){let t=this.gizmos[e];if(t instanceof uu){let e=this.shadow.camera,i=new ns(-e.far+this.position.x,-e.far+this.position.y,-e.far+this.position.z),r=new ns(e.far+this.position.x,e.far+this.position.y,e.far+this.position.z);t.box.set(i,r),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),void 0!==e.distance&&(this.distance=e.distance),void 0!==e.decay&&(this.decay=e.decay),void 0!==e.shadowRadius&&(this.shadow.radius=e.shadowRadius),void 0!==e.shadowResolution&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),IA=n(()=>{Mu(),Lv(),ex(),RA=class extends(Kb($n,_v)){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(e,t){this.updateState_Entity(e,t)}}}),LA=n(()=>{Mu(),Lv(),ex(),EA=class extends(Kb(ta,_v)){constructor(e,t,i){super(),this.super_Entity(e,t),this.context=i,this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t)}}});function zA(e,t,i){if(console.assert(void 0!==t.type),"Mesh"===t.type)return function(e,t,i){let r;if(void 0!==UA&&t?.geometry&&"subdivisions"in t.geometry&&(t.geometry.subdivisions??0)>UA&&Object.assign(t.geometry,{subdivisions:UA}),"TextGeometry"===t.geometry.type||"InputGeometry"===t.geometry.type){let r=Qv(t.geometry.type);return r?r(e,t,i):(Kv("InputGeometry"===t.geometry.type?"textinputs":"text",`a Mesh with ${t.geometry.type}`),new YT(e,t,i))}if("SubdivGeometry"===t.geometry.type)r=new lA(e,t,i);else if("PathGeometry"===t.geometry.type||"VectorGeometry"===t.geometry.type||"ShapeBlendGeometry"===t.geometry.type){let s=Qv(t.geometry.type);s?r=s(e,t,i):(Kv("ShapeBlendGeometry"===t.geometry.type?"shape-blends":"PathGeometry"===t.geometry.type?"3d-paths":"vector-shapes",`a Mesh with ${t.geometry.type}`),r=new YT(e,t,i))}else if("BooleanGeometry"===t.geometry.type)r=new nC(e,t,i);else if("DecalGeometry"===t.geometry.type)r=new AA(e,t,i);else if("UIGeometry"===t.geometry.type){let s=Qv("UIGeometry");s?r=s(e,t,i):(Kv("ui-2d","a Mesh with UIGeometry"),r=new YT(e,t,i))}else r=new YT(e,t,i);return r}(e,t,i);if("Empty"===t.type)return new Zb(e,t);if("Particle"===t.type){let r=Zv("Particle");return r?r(e,t,i):(Kv("particles","a Particle system"),new Zb(e,t))}if("ParticleCollider"===t.type)return new EA(e,t,i);if("Hair"===t.type){let r=Zv("Hair");return r?r(e,t,i):(Kv("hair","a Hair System"),new Zb(e,t))}if("Splat"===t.type)return new Zb(e,t);if("Bone"===t.type)return new RA(e,t);if("Page"===t.type)return new FC(e,t,i);if("PointLight"===t.type)return new PA(e,t,i);if("SpotLight"===t.type)return new UC(e,t,i);if("DirectionalLight"===t.type)return new yC(e,t,i);if("Component"===t.type||"Instance"===t.type){let r=Zv(t.type);return r?r(e,t,i):(Kv("components",`a ${t.type}`),new Zb(e,t))}return rg.is(t.type)?new fx(e,t):(console.error(t),new Zb(e,t))}function kA(e,t,i){let r=zA(e.identity,t,i),s=e.children,a=e.attachedPaths,n=e.parent,o=e.component,l=e.instances,h=e.overrideData,u=e.uuid,d=e.stateSelection;e.dispose();for(let t of Object.keys(e))delete e[t];Object.setPrototypeOf(e,Object.getPrototypeOf(r));for(let t of Object.keys(r))e[t]=r[t];e.children=[...e.children,...s],e.attachedPaths=a,e.parent=n,e.component=o,e.instances=l,e.uuid=u,e.overrideData=h,e.updateState(e.data,i),d&&e.changeSelectedState(d,i),e.resetBBoxNeedsUpdate()}var UA,FA=n(()=>{Bv(),hA(),cC(),BA(),JT(),tx(),DA(),WC(),xC(),yx(),kv(),IA(),qC(),LA(),hb(),UA=function(){try{let e=window.location.href;if(e.includes("reducesubdiv=")){let t=e.indexOf("reducesubdiv=")+13;return parseInt(e.slice(t,t+1))}}catch{}}(),Ev.createEntity=zA,Ev.changeEntityProptotype=kA});function jA(e){if(e.component){let t=e.component.instances.indexOf(e);t>=0&&e.component.instances.splice(t,1);for(let t of e.children)Lb.is(t)&&jA(t)}}var GA,WA,qA,HA,$A,YA,XA,KA=n(()=>{Qb()}),ZA=n(()=>{GA=class{constructor(){this._constraints=new Map}setConstraint(e,t){null===t?this._constraints.delete(e):this._constraints.set(e,t)}removeDependencies(e){this._constraints.delete(e)}applyConstraints(e){let t=new Set;this._constraints.forEach((i,r)=>{let s=[r,i],a=i;for(;this._constraints.has(a);){if(a=this._constraints.get(a),s.includes(a)){console.warn(`circular dependency detected: ${s.join(" -> ")}`);break}t.has(a)||s.push(a)}for(let i=s.length-2;i>=0;i--)if(!t.has(s[i])){let r=e.find(s[i]);r?r.applyPathSnapping(e):console.warn(`missing entity ${s[i]}`),t.add(s[i])}})}findDependency(e,t){let i=e;for(;this._constraints.has(i);)if(i=this._constraints.get(i),i===t)return!0;return!1}}}),JA=n(()=>{WA="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL"}),QA=n(()=>{qA="\nfunction sortWorker(self) {\n\tlet wasmInstance;\n\tlet splatCount;\n\tlet splatRC;\n\tlet indexesOffset;\n\tlet positionsOffset;\n\tlet viewProjOffset;\n\tlet frequenciesOffset;\n\tlet indexesOutOffset;\n\tlet sortBuffersOffset;\n\tlet wasmMemory;\n\tlet positions;\n\n\tlet Constants;\n\tlet floatPositions;\n\tlet meshIndexIntervals;\n\tlet meshMatrixWorlds;\n\tlet cropsArray;\n\n\tfunction sort(viewProj) {\n\t\t// console.time('WASM SORT');\n\t\tconst viewProjArray = new Float64Array(wasmMemory, viewProjOffset, 16);\n\t\tfor (let i = 0; i < 16; i++) {\n\t\t\tviewProjArray[i] = viewProj[i];\n\t\t}\n\t\tlet indexesBuffer;\n\t\t// console.timeEnd('WASM SORT');\n\t\tif (splatRC > 1) {\n\t\t\twasmInstance.exports.sortIndexes(\n\t\t\t\tindexesOffset,\n\t\t\t\tpositionsOffset,\n\t\t\t\tsortBuffersOffset,\n\t\t\t\tviewProjOffset,\n\t\t\t\tfrequenciesOffset,\n\t\t\t\tindexesOutOffset,\n\t\t\t\tConstants.DepthMapRange,\n\t\t\t\tsplatRC\n\t\t\t);\n\t\t\tconst indexes = new Uint32Array(splatRC);\n\t\t\tindexesBuffer = indexes.buffer;\n\t\t\tindexes.set(new Uint32Array(wasmMemory, indexesOutOffset, splatRC));\n\t\t} else if (splatRC === 1) {\n\t\t\tconst indexes = new Uint32Array(splatRC);\n\t\t\tindexes[0] = new Uint32Array(wasmMemory, indexesOffset, splatCount)[0];\n\t\t\tindexesBuffer = indexes.buffer;\n\t\t} else {\n\t\t\tindexesBuffer = new ArrayBuffer(0);\n\t\t}\n\n\t\tself.postMessage(\n\t\t\t{\n\t\t\t\tsortDone: true,\n\t\t\t\tindexesBuffer,\n\t\t\t},\n\t\t\t[indexesBuffer]\n\t\t);\n\t}\n\tfunction updateRenderedSplats(\n\t\tmeshMatrixWorlds,\n\t\tcropsArray,\n\t\tmeshIndexIntervals\n\t) {\n\t\tconst renderedPositions = new Float32Array(\n\t\t\twasmMemory,\n\t\t\tpositionsOffset,\n\t\t\tsplatCount * 3\n\t\t);\n\t\tsplatRC = 0;\n\t\tconst wasmMemoryIndexes = new Uint32Array(\n\t\t\twasmMemory,\n\t\t\tindexesOffset,\n\t\t\tsplatCount\n\t\t);\n\t\tfor (let i = 0; i < meshIndexIntervals.length - 1; i++) {\n\t\t\tconst crops = cropsArray[i];\n\t\t\tconst matrixWorld = meshMatrixWorlds[i].elements;\n\t\t\tconst paramsIn = crops\n\t\t\t\t.filter((a) => a.enabled && a.mode === 'Include')\n\t\t\t\t.map((c) =>\n\t\t\t\t\tc.type === 'Box'\n\t\t\t\t\t\t? computeBoundingBoxVertices(c)\n\t\t\t\t\t\t: computeEllipsoidParams(c)\n\t\t\t\t);\n\t\t\tconst paramsOut = crops\n\t\t\t\t.filter((a) => a.enabled && a.mode === 'Exclude')\n\t\t\t\t.map((c) =>\n\t\t\t\t\tc.type === 'Box'\n\t\t\t\t\t\t? computeBoundingBoxVertices(c)\n\t\t\t\t\t\t: computeEllipsoidParams(c)\n\t\t\t\t);\n\t\t\tfor (let j = meshIndexIntervals[i]; j < meshIndexIntervals[i + 1]; j++) {\n\t\t\t\tconst x = floatPositions[j * 3];\n\t\t\t\tconst y = floatPositions[j * 3 + 1];\n\t\t\t\tconst z = floatPositions[j * 3 + 2];\n\t\t\t\tif (\n\t\t\t\t\t(paramsIn.length === 0 || isInBounds(x, y, z, paramsIn)) &&\n\t\t\t\t\t(paramsOut.length === 0 || !isInBounds(x, y, z, paramsOut))\n\t\t\t\t) {\n\t\t\t\t\tconst w =\n\t\t\t\t\t\t1 /\n\t\t\t\t\t\t(matrixWorld[3] * x +\n\t\t\t\t\t\t\tmatrixWorld[7] * y +\n\t\t\t\t\t\t\tmatrixWorld[11] * z +\n\t\t\t\t\t\t\tmatrixWorld[15]);\n\t\t\t\t\trenderedPositions[splatRC * 3] =\n\t\t\t\t\t\t(matrixWorld[0] * x +\n\t\t\t\t\t\t\tmatrixWorld[4] * y +\n\t\t\t\t\t\t\tmatrixWorld[8] * z +\n\t\t\t\t\t\t\tmatrixWorld[12]) *\n\t\t\t\t\t\tw;\n\t\t\t\t\trenderedPositions[splatRC * 3 + 1] =\n\t\t\t\t\t\t(matrixWorld[1] * x +\n\t\t\t\t\t\t\tmatrixWorld[5] * y +\n\t\t\t\t\t\t\tmatrixWorld[9] * z +\n\t\t\t\t\t\t\tmatrixWorld[13]) *\n\t\t\t\t\t\tw;\n\t\t\t\t\trenderedPositions[splatRC * 3 + 2] =\n\t\t\t\t\t\t(matrixWorld[2] * x +\n\t\t\t\t\t\t\tmatrixWorld[6] * y +\n\t\t\t\t\t\t\tmatrixWorld[10] * z +\n\t\t\t\t\t\t\tmatrixWorld[14]) *\n\t\t\t\t\t\tw;\n\t\t\t\t\twasmMemoryIndexes[splatRC] = j;\n\t\t\t\t\tsplatRC++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction getOutOfBoundsIndexes(floatPositions, crops) {\n\t\tconst outOfBoundsIndexes = [];\n\t\tconst paramsIn = crops\n\t\t\t.filter((a) => a.enabled && a.mode === 'Include')\n\t\t\t.map((c) =>\n\t\t\t\tc.type === 'Box'\n\t\t\t\t\t? computeBoundingBoxVertices(c)\n\t\t\t\t\t: computeEllipsoidParams(c)\n\t\t\t);\n\t\tconst paramsOut = crops\n\t\t\t.filter((a) => a.enabled && a.mode === 'Exclude')\n\t\t\t.map((c) =>\n\t\t\t\tc.type === 'Box'\n\t\t\t\t\t? computeBoundingBoxVertices(c)\n\t\t\t\t\t: computeEllipsoidParams(c)\n\t\t\t);\n\n\t\tconst len = floatPositions.length;\n\t\tfor (let j = 0; j < len; j += 3) {\n\t\t\tconst x = floatPositions[j];\n\t\t\tconst y = floatPositions[j + 1];\n\t\t\tconst z = floatPositions[j + 2];\n\t\t\tif (\n\t\t\t\t(paramsIn.length === 0 || isInBounds(x, y, z, paramsIn)) &&\n\t\t\t\t(paramsOut.length === 0 || !isInBounds(x, y, z, paramsOut))\n\t\t\t) {\n\t\t\t\t// in bounds: intentionally skip\n\t\t\t} else {\n\t\t\t\toutOfBoundsIndexes.push(j / 3);\n\t\t\t}\n\t\t}\n\t\t// console.log(outOfBoundsIndexes);\n\t\treturn outOfBoundsIndexes;\n\t}\n\n\tfunction isInBounds(x, y, z, params, mode) {\n\t\treturn params[mode === 'Intersect' ? 'every' : 'some']((param) => {\n\t\t\tconst t = applyRotationMatrix(\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tz,\n\t\t\t\tparam.invRotationMatrix,\n\t\t\t\tparam.cropCenter\n\t\t\t);\n\t\t\treturn Array.isArray(param)\n\t\t\t\t? isVertexInsideBoundingBox(t.x, t.y, t.z, param)\n\t\t\t\t: isPointInsideEllipsoid(t.x, t.y, t.z, param);\n\t\t});\n\t}\n\tfunction applyRotationMatrix(_x, _y, _z, e, pivot) {\n\t\tconst x = _x - pivot[0];\n\t\tconst y = _y - pivot[1];\n\t\tconst z = _z - pivot[2];\n\t\tconst w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);\n\t\treturn {\n\t\t\tx: (e[0] * x + e[4] * y + e[8] * z + e[12]) * w + pivot[0],\n\t\t\ty: (e[1] * x + e[5] * y + e[9] * z + e[13]) * w + pivot[1],\n\t\t\tz: (e[2] * x + e[6] * y + e[10] * z + e[14]) * w + pivot[2],\n\t\t};\n\t}\n\tfunction computeBoundingBoxVertices(box) {\n\t\tconst halfSizeX = box.cropSize[0] / 2;\n\t\tconst halfSizeY = box.cropSize[1] / 2;\n\t\tconst halfSizeZ = box.cropSize[2] / 2;\n\t\tconst bounds = [\n\t\t\tbox.cropCenter[0] - halfSizeX,\n\t\t\tbox.cropCenter[1] - halfSizeY,\n\t\t\tbox.cropCenter[2] - halfSizeZ,\n\t\t\tbox.cropCenter[0] + halfSizeX,\n\t\t\tbox.cropCenter[1] + halfSizeY,\n\t\t\tbox.cropCenter[2] + halfSizeZ,\n\t\t];\n\t\tconst invRotationMatrix = getInvRotationMatrix(box.cropRotation);\n\t\treturn Object.assign(bounds, {\n\t\t\tinvRotationMatrix,\n\t\t\tcropCenter: box.cropCenter,\n\t\t});\n\t}\n\tfunction getInvRotationMatrix(_rotation) {\n\t\tconst te = [];\n\t\tconst x = (_rotation[0] * Math.PI) / 180,\n\t\t\ty = (_rotation[1] * Math.PI) / 180,\n\t\t\tz = (_rotation[2] * Math.PI) / 180;\n\t\tconst a = Math.cos(x),\n\t\t\tb = Math.sin(x);\n\t\tconst c = Math.cos(y),\n\t\t\td = Math.sin(y);\n\t\tconst e = Math.cos(z),\n\t\t\tf = Math.sin(z);\n\t\tconst ae = a * e,\n\t\t\taf = a * f,\n\t\t\tbe = b * e,\n\t\t\tbf = b * f;\n\n\t\tte[0] = c * e;\n\t\tte[1] = -c * f;\n\t\tte[2] = d;\n\n\t\tte[4] = af + be * d;\n\t\tte[5] = ae - bf * d;\n\t\tte[6] = -b * c;\n\n\t\tte[8] = bf - ae * d;\n\t\tte[9] = be + af * d;\n\t\tte[10] = a * c;\n\n\t\tte[12] = 0;\n\t\tte[13] = 0;\n\t\tte[14] = 0;\n\n\t\tte[3] = 0;\n\t\tte[7] = 0;\n\t\tte[11] = 0;\n\t\tte[15] = 1;\n\n\t\treturn te;\n\t}\n\tfunction isVertexInsideBoundingBox(x, y, z, bounds) {\n\t\treturn (\n\t\t\tx >= bounds[0] &&\n\t\t\tx <= bounds[3] &&\n\t\t\ty >= bounds[1] &&\n\t\t\ty <= bounds[4] &&\n\t\t\tz >= bounds[2] &&\n\t\t\tz <= bounds[5]\n\t\t);\n\t}\n\tfunction computeEllipsoidParams(ellipsoid) {\n\t\t// Precompute the scaling factors\n\t\tconst invRadiusX = 2 / ellipsoid.cropSize[0];\n\t\tconst invRadiusY = 2 / ellipsoid.cropSize[1];\n\t\tconst invRadiusZ = 2 / ellipsoid.cropSize[2];\n\t\tconst invRotationMatrix = getInvRotationMatrix(ellipsoid.cropRotation);\n\t\treturn {\n\t\t\tinvRadiusX,\n\t\t\tinvRadiusY,\n\t\t\tinvRadiusZ,\n\t\t\tcropCenter: ellipsoid.cropCenter,\n\t\t\tinvRotationMatrix,\n\t\t};\n\t}\n\tfunction isPointInsideEllipsoid(x, y, z, ellipsoidParams) {\n\t\tconst _x = (x - ellipsoidParams.cropCenter[0]) * ellipsoidParams.invRadiusX;\n\t\tconst _y = (y - ellipsoidParams.cropCenter[1]) * ellipsoidParams.invRadiusY;\n\t\tconst _z = (z - ellipsoidParams.cropCenter[2]) * ellipsoidParams.invRadiusZ;\n\t\treturn _x * _x + _y * _y + _z * _z <= 1;\n\t}\n\n\tself.onmessage = (e) => {\n\t\tif (e.data.getCroppedIndexes) {\n\t\t\tconst outOfBoundsIndexes = new Uint32Array(\n\t\t\t\tgetOutOfBoundsIndexes(new Float32Array(e.data.positions), e.data.crops)\n\t\t\t).buffer;\n\t\t\tself.postMessage(\n\t\t\t\t{\n\t\t\t\t\toutOfBoundsIndexes,\n\t\t\t\t},\n\t\t\t\t[outOfBoundsIndexes]\n\t\t\t);\n\t\t} else if (e.data.positions) {\n\t\t\tpositions = e.data.positions;\n\t\t\tfloatPositions = new Float32Array(positions);\n\t\t\tmeshMatrixWorlds = e.data.meshMatrixWorlds;\n\t\t\tcropsArray = e.data.cropsArray;\n\t\t\tmeshIndexIntervals = e.data.meshIndexIntervals;\n\t\t\tupdateRenderedSplats(meshMatrixWorlds, cropsArray, meshIndexIntervals);\n\t\t\tself.postMessage({\n\t\t\t\tsortSetupComplete: true,\n\t\t\t});\n\t\t} else if (e.data.sort || e.data.newMatrixWorlds || e.data.newCropsArray) {\n\t\t\tif (e.data.newMatrixWorlds || e.data.newCropsArray) {\n\t\t\t\tcropsArray = e.data.newCropsArray || cropsArray;\n\t\t\t\tmeshMatrixWorlds = e.data.newMatrixWorlds || meshMatrixWorlds;\n\t\t\t\tupdateRenderedSplats(meshMatrixWorlds, cropsArray, meshIndexIntervals);\n\t\t\t}\n\t\t\tsort(e.data.sort.view, e.data.sort.cameraPosition);\n\t\t} else if (e.data.init) {\n\t\t\t// Yep, this is super hacky and gross :(\n\t\t\tConstants = e.data.init.Constants;\n\n\t\t\tsplatCount = e.data.init.splatCount;\n\n\t\t\tconst INDEXES_BYTES_PER_ENTRY = Constants.BytesPerInt;\n\t\t\tconst POSITIONS_BYTES_PER_ENTRY = Constants.BytesPerFloat * 3;\n\n\t\t\tconst sorterWasmBytes = new Uint8Array(e.data.init.sorterWasmBytes);\n\t\t\tconst memoryBytesPerVertex =\n\t\t\t\tINDEXES_BYTES_PER_ENTRY + POSITIONS_BYTES_PER_ENTRY;\n\t\t\tconst memoryRequiredForVertices = splatCount * memoryBytesPerVertex;\n\t\t\tconst memoryRequiredForSortBuffers =\n\t\t\t\tsplatCount * Constants.BytesPerInt * 2 +\n\t\t\t\tConstants.DepthMapRange * Constants.BytesPerInt * 2;\n\t\t\tconst extraMemory = Constants.MemoryPageSize * 32;\n\t\t\tconst totalRequiredMemory =\n\t\t\t\tmemoryRequiredForVertices + memoryRequiredForSortBuffers + extraMemory;\n\t\t\tconst totalPagesRequired =\n\t\t\t\tMath.floor(totalRequiredMemory / Constants.MemoryPageSize) + 1;\n\t\t\tconst sorterWasmImport = {\n\t\t\t\tmodule: {},\n\t\t\t\tenv: {\n\t\t\t\t\tmemory: new WebAssembly.Memory({\n\t\t\t\t\t\tinitial: totalPagesRequired * 2,\n\t\t\t\t\t\tmaximum: totalPagesRequired * 3,\n\t\t\t\t\t\tshared: true,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t};\n\t\t\tWebAssembly.compile(sorterWasmBytes)\n\t\t\t\t.then((wasmModule) => {\n\t\t\t\t\treturn WebAssembly.instantiate(wasmModule, sorterWasmImport);\n\t\t\t\t})\n\t\t\t\t.then((instance) => {\n\t\t\t\t\twasmInstance = instance;\n\t\t\t\t\tindexesOffset = 0;\n\t\t\t\t\tpositionsOffset = splatCount * INDEXES_BYTES_PER_ENTRY;\n\t\t\t\t\tviewProjOffset =\n\t\t\t\t\t\tpositionsOffset + splatCount * POSITIONS_BYTES_PER_ENTRY;\n\t\t\t\t\tsortBuffersOffset = viewProjOffset + 16 * Constants.BytesPerFloat * 2;\n\t\t\t\t\tfrequenciesOffset =\n\t\t\t\t\t\tsortBuffersOffset + splatCount * Constants.BytesPerInt;\n\t\t\t\t\tindexesOutOffset =\n\t\t\t\t\t\tfrequenciesOffset + Constants.DepthMapRange * Constants.BytesPerInt;\n\t\t\t\t\twasmMemory = sorterWasmImport.env.memory.buffer;\n\t\t\t\t\tself.postMessage({\n\t\t\t\t\t\tsortSetupPhase1Complete: true,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\t};\n}\n"}),eN=n(()=>{JA(),QA(),u(HA=class{},"DepthMapRange",65536),u(HA,"MemoryPageSize",65536),u(HA,"BytesPerFloat",4),u(HA,"BytesPerInt",4)}),tN=n(()=>{$A=function(){let e=new Float32Array(1),t=new Int32Array(e.buffer);return function(i){return e[0]=i,t[0]}}(),YA=function(e,t,i,r){return e+(t<<8)+(i<<16)+(r<<24)}}),iN=n(()=>{XA=null});function rN(e){let t=!1;return e.scene.objects.traverse((e,i)=>{if(!1===i.visible)return!0;"Splat"===i.type&&(t=!0)}),t}var sN,aN,nN=n(()=>{Mu(),tN(),gT(),iN(),sN=new rs,aN=class extends Hn{constructor(e,t,i,r,s=!1,a=1,n,o){super(i,r),this.splatCount=t,this.meshIndexIntervals=n,this.meshMatrixWorlds=o,this.splatBuffers=e,this.geometry=i,this.material=r,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=s,this.devicePixelRatio=a,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,i=!1,r=1,s,a){let n=aN.buildGeomtery(t),o=aN.buildMaterial(s);return new aN(e,t,n,o,i,r,s,a)}static buildMaterial(e){if("webgpu"===rT()&&XA)return XA.createSplatMaterial(e);let t={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new rs},viewport:{type:"v2",value:new rs},basisViewport:{type:"v2",value:new rs},debugColor:{type:"v3",value:new aa},covariancesTextureSize:{type:"v2",value:new rs(1024,1024)},centersColorsTextureSize:{type:"v2",value:new rs(1024,1024)},orthoZoom:{type:"f",value:-1}};return new fl({uniforms:t,vertexShader:"\n precision highp float;\n #include <common>\n\n attribute uint splatIndex;\n\n uniform highp sampler2D covariancesTexture;\n uniform highp usampler2D centersColorsTexture;\n uniform vec2 focal;\n uniform vec2 viewport;\n uniform vec2 basisViewport;\n uniform vec2 covariancesTextureSize;\n uniform vec2 centersColorsTextureSize;\n\t\t\t\t\t\tuniform highp sampler2D meshMatrixWorldsTexture;\n\t\t\t\t\t\tuniform uint meshIndexIntervals[257];\n\t\t\t\t\t\tuniform float orthoZoom;\n\n varying vec4 vColor;\n varying vec2 vUv;\n\n varying vec2 vPosition;\n\n const vec4 encodeNorm4 = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);\n const uvec4 mask4 = uvec4(uint(0x000000FF), uint(0x0000FF00), uint(0x00FF0000), uint(0xFF000000));\n const uvec4 shift4 = uvec4(0, 8, 16, 24);\n vec4 uintToRGBAVec (uint u) {\n uvec4 urgba = mask4 & u;\n urgba = urgba >> shift4;\n vec4 rgba = vec4(urgba) * encodeNorm4;\n return rgba;\n }\n\n vec2 getDataUV(in int stride, in int offset, in vec2 dimensions) {\n vec2 samplerUV = vec2(0.0, 0.0);\n float d = float(splatIndex * uint(stride) + uint(offset)) / dimensions.x;\n samplerUV.y = float(floor(d)) / dimensions.y;\n samplerUV.x = fract(d);\n return samplerUV;\n }\n\n void main () {\n uvec4 sampledCenterColor = texture(centersColorsTexture, getDataUV(1, 0, centersColorsTextureSize));\n vec3 splatCenter = uintBitsToFloat(uvec3(sampledCenterColor.gba));\n vColor = uintToRGBAVec(sampledCenterColor.r);\n\n vPosition = position.xy * 2.0;\n\n\t\t\t\t\t\t\t\tuint meshIndex;\n\t\t\t\t\t\t\t\tfor (int i = 1; i < 257; i++) {\n\t\t\t\t\t\t\t\t\tif (splatIndex < meshIndexIntervals[i]) {\n\t\t\t\t\t\t\t\t\t\tmeshIndex = uint(i - 1);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tfloat strideMulmeshIndex = float(4u*meshIndex);\n\t\t\t\t\t\t\t\tfloat meshMatrixWorldsTextureLength = float(256*4);\n\n\t\t\t\t\t\t\t\tmat4 modelMat = mat4(\n\t\t\t\t\t\t\t\t\ttexture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+0.0)/meshMatrixWorldsTextureLength, 0)),\n\t\t\t\t\t\t\t\t\ttexture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+1.0)/meshMatrixWorldsTextureLength, 0)),\n\t\t\t\t\t\t\t\t\ttexture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+2.0)/meshMatrixWorldsTextureLength, 0)),\n\t\t\t\t\t\t\t\t\ttexture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+3.0)/meshMatrixWorldsTextureLength, 0))\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tmat4 modelViewMat = viewMatrix * modelMat;\n\t\t\t\t\t\t\t\tvec4 viewCenter = modelViewMat * vec4(splatCenter, 1.0); \n vec4 clipCenter = projectionMatrix * viewCenter;\n\n vec2 sampledCovarianceA = texture(covariancesTexture, getDataUV(3, 0, covariancesTextureSize)).rg;\n vec2 sampledCovarianceB = texture(covariancesTexture, getDataUV(3, 1, covariancesTextureSize)).rg;\n vec2 sampledCovarianceC = texture(covariancesTexture, getDataUV(3, 2, covariancesTextureSize)).rg;\n\n vec3 cov3D_M11_M12_M13 = vec3(sampledCovarianceA.rg, sampledCovarianceB.r);\n vec3 cov3D_M22_M23_M33 = vec3(sampledCovarianceB.g, sampledCovarianceC.rg);\n\n \n mat3 Vrk = mat3(\n cov3D_M11_M12_M13.x, cov3D_M11_M12_M13.y, cov3D_M11_M12_M13.z,\n cov3D_M11_M12_M13.y, cov3D_M22_M23_M33.x, cov3D_M22_M23_M33.y,\n cov3D_M11_M12_M13.z, cov3D_M22_M23_M33.y, cov3D_M22_M23_M33.z\n );\n float s = 1.0 / (viewCenter.z * viewCenter.z);\n\n mat3 W = transpose(mat3(modelViewMat));\n mat3 T = orthoZoom > 0.0 ? W : W * mat3(\n\t\t\t\t\t\t\t\t\tfocal.x / viewCenter.z, 0., -(focal.x * viewCenter.x) * s,\n\t\t\t\t\t\t\t\t\t0., focal.y / viewCenter.z, -(focal.y * viewCenter.y) * s,\n\t\t\t\t\t\t\t\t\t0., 0., 0.\n\t\t\t\t\t\t\t\t);\n mat3 cov2Dm = transpose(T) * Vrk * T;\n cov2Dm[0][0] += 0.3;\n cov2Dm[1][1] += 0.3;\n\n \n \n \n \n vec3 cov2Dv = vec3(cov2Dm[0][0], cov2Dm[0][1], cov2Dm[1][1]);\n\n vec3 ndcCenter = clipCenter.xyz / clipCenter.w;\n\n \n \n \n \n \n \n \n \n float a = cov2Dv.x;\n float d = cov2Dv.z;\n float b = cov2Dv.y;\n float D = a * d - b * b;\n float trace = a + d;\n float traceOver2 = 0.5 * trace;\n float term2 = sqrt(trace * trace / 4.0 - D);\n float eigenValue1 = traceOver2 + term2;\n\t\t\t\t\t\t\t\tfloat eigenValue2 = max(traceOver2 - term2, 0.00); \n\n const float maxSplatSize = 1024.0;\n vec2 eigenVector1 = normalize(vec2(b, eigenValue1 - a));\n \n vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x);\n vec2 basisVector1 = eigenVector1 * min(sqrt(2.0 * eigenValue1), maxSplatSize);\n vec2 basisVector2 = eigenVector2 * min(sqrt(2.0 * eigenValue2), maxSplatSize);\n\n vec2 ndcOffset = vec2(vPosition.x * basisVector1 + vPosition.y * basisVector2) * basisViewport;\n\n\t\t\t\t\t\t\t\tif (orthoZoom > 0.0) {\n\t\t\t\t\t\t\t\t\tndcOffset *= orthoZoom;\n\t\t\t\t\t\t\t\t}\n\n gl_Position = vec4(ndcCenter.xy + ndcOffset, ndcCenter.z, 1.0);\n }",fragmentShader:"\n precision highp float;\n #include <common>\n\n uniform vec3 debugColor;\n\n varying vec4 vColor;\n varying vec2 vUv;\n\n varying vec2 vPosition;\n\t\t\t\t\t\tlayout(location = 1) out vec4 gVelocity; \n\n void main () {\n \n \n float A = -dot(vPosition, vPosition);\n if (A < -4.0) discard;\n vec3 color = vColor.rgb;\n A = exp(A) * vColor.a;\n gl_FragColor = vec4(color.rgb, A);\n\t\t\t\t\t\t\t\tgVelocity = vec4(0.0); \n }",transparent:!0,alphaTest:1,blending:$e,depthTest:!0,depthWrite:!1,side:qe})}static buildGeomtery(e){let t=new an;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(12),r=new ja(i,3);t.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=(new vh).copy(t),a=new Uint32Array(e),n=new Jn(a,1,!1);return n.setUsage(Fr),s.setAttribute("splatIndex",n),s.instanceCount=e,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(e=>e.buildPreComputedBuffers()),this.covariances=new Float32Array(6*this.splatCount),this.colors=new Uint8Array(4*this.splatCount),this.centers=new Float32Array(3*this.splatCount);let e=0,t=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(e,e+4*s).set(r.colorsA),e+=4*s,this.centers.subarray(t,t+3*s).set(r.decoded.xyz.denormDequant().data),t+=3*s,this.covariances.subarray(i,i+6*s).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=6*s}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new rs(4096,1024);for(;t.x*t.y*2<6*e;)t.y*=2;let i,r,s=new rs(4096,1024);for(;s.x*s.y*4<4*e;)s.y*=2;if(this.halfPrecisionCovariancesOnGPU){r=new Uint16Array(t.x*t.y*2);for(let e=0;e<this.covariances.length;e++)r[e]=za.toHalfFloat(this.covariances[e]);i=new Yn(r,t.x,t.y,gi,ii)}else r=new Float32Array(t.x*t.y*2),r.set(this.covariances),i=new Yn(r,t.x,t.y,gi,ti);i.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=i,this.material.uniforms.covariancesTextureSize.value.copy(t);let a=new Uint32Array(s.x*s.y*4);for(let t=0;t<e;t++){let e=4*t,i=3*t,r=4*t;a[r]=YA(this.colors[e],this.colors[e+1],this.colors[e+2],this.colors[e+3]),a[r+1]=$A(this.centers[i]),a[r+2]=$A(this.centers[i+1]),a[r+3]=$A(this.centers[i+2])}let n=new Yn(a,s.x,s.y,vi,ei);"webgpu"!==rT()&&(n.internalFormat="RGBA32UI"),n.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=n,this.material.uniforms.centersColorsTextureSize.value.copy(s);let o=new Float32Array(4096);for(let e=0;e<this.meshMatrixWorlds.length;e++)o.set(this.meshMatrixWorlds[e].elements,16*e);let l=new Yn(o,1024,1,ui,ti);l.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=l,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:r,texture:i,size:t},centerColors:{data:a,texture:n,size:s},meshMatrixWorlds:{data:o,texture:l}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&(sN.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(sN),this.material.uniforms.basisViewport.value.set(2/sN.x,2/sN.y),this.material.uniforms.focal.value.set(t,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}}});function oN(){if(!uN)return dN||(dN=async function(){let e=await import("./gaussian-splat-compression.js");lN(e),uN=!0}())}var lN,hN,uN,dN,cN,pN,mN,gN,fN,yN=n(()=>{hN=new Promise(e=>{lN=e}),uN=!1}),vN=n(()=>{eN(),Mu(),nN(),yN(),hN.then(e=>cN=e),pN=class{constructor(e={}){u(this,"updateView",function(){let e=new As,t=[],i=new ns(0,0,-1),r=new ns(0,0,-1),s=new ns,a=new ns;return function(n=!1,o){let l=this.updateMatrixWorldsInWorkerIfNeeded(),h=this.cropsChanged();if(!n){r.set(0,0,-1).applyQuaternion(o.quaternion);let e=!1,t=!1;if(r.dot(i)<=.95&&(e=!0),a.copy(o.position).sub(s).length()>=1&&(t=!0),!(e||t||l||h||this.needsInitialRender))return}this.needsInitialRender=!1,s.copy(o.position),i.copy(r),e.copy(o.matrixWorld).invert(),e.premultiply(this.dummyPerspectiveMatrix),t[0]=o.position.x,t[1]=o.position.y,t[2]=o.position.z;let u={sort:{view:e.elements,cameraPosition:t,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...h?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=u:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(u))}}()),this.scene=e.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=(new As).makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(e,t){let i=new rs;null!==this.splatMesh&&this.splatMesh.getSplatCount()>0&&(e.getSize(i),this.cameraFocalLengthX=t.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=t.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,t.isPerspectiveCamera?-1:t.zoom*this.devicePixelRatio))}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=(new ns).fromArray(e.position)),e.orientation&&(e.orientation=(new ss).fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseVisibleEntity(e=>{"Splat"===e.data.type&&t.push(e)}),this.splatMesh&&this.splatMesh.dispose(),0===t.length)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(e=>e.matrixWorld),this.meshMatrixWorldsOld=t.map(e=>e.matrixWorld.clone()),this.cropsArray=t.map(e=>e.data.crops.map(e=>e.data)),this._splatBufferCache??(this._splatBufferCache=new WeakMap);let i=t.map(e=>{let t=this._splatBufferCache.get(e.data.buffer);return void 0===t&&(t=new cN.GSplineBuffer(new Uint8Array(e.data.buffer).buffer),this._splatBufferCache.set(e.data.buffer,t)),t}),r=0,s=[0];for(let e of i)r+=e.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,16*t);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,!this.meshMatrixWorlds.every((e,t)=>e.equals(this.meshMatrixWorldsOld[t]))&&(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{t.data.crops.forEach((t,r)=>{void 0===this.cropsArray[i][r]?(e=!0,this.cropsArray[i][r]=t.data):Object.entries(t.data).forEach(([t,s])=>{(Array.isArray(s)&&s.some((e,s)=>e!==this.cropsArray[i][r][t][s])||s!==this.cropsArray[i][r]?.[t])&&(e=!0,this.cropsArray[i][r][t]=s)})}),t.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new ns,r=new ss,s=!1,a=1,n,o){this.splatMesh=aN.buildMesh(e,t,s,a,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=t,this.splatMesh.onBeforeRender=(e,t,i)=>this.update(e,i)}setupSortWorker(e){this.sortWorker=function(e){let t=new Worker(URL.createObjectURL(new Blob(["(",qA,")(self)"],{type:"application/javascript"}))),i=atob(WA),r=new Uint8Array(i.length);for(let e=0;e<i.length;e++)r[e]=i.charCodeAt(e);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:e,Constants:{BytesPerFloat:HA.BytesPerFloat,BytesPerInt:HA.BytesPerInt,DepthMapRange:HA.DepthMapRange,MemoryPageSize:HA.MemoryPageSize}}}),t}(e),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(e,t){null!==this.splatMesh&&(this.updateSplatMeshUniforms(e,t),this.updateView(!1,t))}getSplatMesh(){return this.splatMesh}}}),bN=n(()=>{Mu(),yx(),Qb(),mC(),Bv(),sA(),um(),jC(),iw(),Hx(),cC(),FA(),tx(),JT(),Yv(),qC(),KA(),Yv(),Od(),Sb(),ZA(),vN(),(mN=new Vn).wireframe=!0,gN=new ns,fN=class extends la{constructor(e,t){super(),this.data=e,this.sharedAssets=t,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this.needsReflectionDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this._normalPassNeeds={outline:!1,cavity:!1},this._needsReflection=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.shapeBlendIntances=[],this.hairInstances=[],this.shadowsDirty=!0,this.instanceGroupsDirty=!0,this._autoInstancing=null,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new GA,this.invisibleObjects=new Zb("jflkdsafjasdifjaslk",{...Rf.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new FC("fdasfa",{...Uf.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markShadowsDirty(){this.shadowsDirty=!0}markInstanceGroupsDirty(){this.instanceGroupsDirty=!0}get autoInstancing(){return this._autoInstancing}updateInstanceGroups(e,t){let i=this._autoInstancing;(null===i||i.minGroupSize!==t)&&(i?.dispose(),i=new tA(t),this._autoInstancing=i);let r=this.instanceGroupsDirty;return this.instanceGroupsDirty=!1,i.update(e,r),i.stats}releaseInstanceGroups(){this._autoInstancing?.teardown(),this.instanceGroupsDirty=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this.needsReflectionDirty=!0,this.shadowsDirty=!0,this.instanceGroupsDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=function(e){let t=!1;return e.traverseEntity(e=>{if(e instanceof jT)if(Array.isArray(e.material))for(let i=0;i<e.material.length;i++)AC(e,e.material[i])&&(t=!0);else AC(e,e.material)&&(t=!0)}),t}(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._normalPassNeeds=function(e){let t={outline:!1,cavity:!1},i=e=>{t.outline=t.outline||e.outline,t.cavity=t.cavity||e.cavity};return e.traverseEntity(e=>{if(e instanceof jT)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)i(CC(e,e.material[t]));else i(CC(e,e.material))}),t}(this),this._needsNormal=this._normalPassNeeds.outline||this._normalPassNeeds.cavity,this.needsNormalDirty=!1),this._needsNormal}normalPassNeeds(){return this.needsNormal(),this._normalPassNeeds}needsReflection(){return this.needsReflectionDirty&&(this._needsReflection=function(e){let t=!1;return e.traverseEntity(e=>{if(e instanceof jT)if(Array.isArray(e.material))for(let i=0;i<e.material.length;i++)NC(e,e.material[i])&&(t=!0);else NC(e,e.material)&&(t=!0)}),t}(this),this.needsReflectionDirty=!1),this._needsReflection}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof FC&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(void 0===t)return;let i=[],r=t;for(;r!==this;){let e=r;r=r.parent;let t=r.children.indexOf(e);i.splice(0,0,t)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let e=this.getWithSortKey(i.id);void 0!==e&&t.push(e)}return t.sort((e,t)=>yd(e.sortKey,t.sortKey)),t.map(e=>e.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(void 0===i)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if("f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera"===e)return this.activePage.personalCamera;if(e===mm)return this.activePage.personalCamera}if(""===e||void 0===e)return;let t=this.entityByUuid[e];return void 0===t?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof FC&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof FC&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{void 0===t&&Wv(i)&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof FC&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);t?Array.isArray(t.identity)&&void 0===this.findInstance(t.identity)&&console.error("not found instance"):console.error("not found")}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(e=>{this.toExpandCloner.add(e)})}doPendingExpandCloner(e){this.toExpandCloner.forEach(t=>{t.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(t=>{t.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){1===e.path.length&&"components"===e.path[0]&&1===e.type&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(0===e.path.length&&7===e.type){let i=null===e.parent?this:this.find(e.parent);if(void 0===i)throw new Error(`scene tree add: parent ${e.parent} not found for object ${e.id}`);let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(this),r.resetBBoxNeedsUpdate(),hC(r)&&uC(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(0===e.path.length&&8===e.type){let t=this.find(e.id);if(void 0===t)throw new Error(`scene tree delete: object ${e.id} not found`);t.traverseEntity(e=>{jv(e)&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(t=>t!==e)),Fv(e)&&(this.hairInstances=this.hairInstances.filter(t=>t!==e))}),this.markToExpandCloner(t),t.resetBBoxNeedsUpdate(),this.unregisterObject(t);let r=t.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(t),this.markPenumbraSizeDirty(),t.parent.remove(t),uC(t.parent)&&(t.parent.invalidateUpstreamBooleanData(),t.parent.invalidateDownstreamBooleanData().recomputeBoolean()),hC(t)&&(t.freeBooleanPointer(),r instanceof nC&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i=t,!0===i?.isPathObject&&t.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(t),this.pathConstraints.removeDependencies(t.uuid),t.updatePathSnapping()}else if(0===e.path.length&&9===e.type){let t=this.find(e.id);if(void 0===t)throw new Error(`scene tree move: object ${e.id} not found`);this.markNeedsRecomputeInstancesForChildren(t);let i=t.parent;this.markNeedsRecomputeInstancesForAncessors(i),t.cloner?.resetOnMove(),this.markToExpandCloner(t);let r=null===e.parent?this:this.find(e.parent);if(void 0===r)throw new Error(`scene tree move: new parent ${e.parent} not found for object ${e.id}`);r.add(t),this.markNeedsRecomputeInstancesForAncessors(r),this.markToExpandCloner(t),t.invalidateClonerTransform(t),t.updateVisible(this),t.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;r.children.splice(s,0,r.children.pop()),hC(t)&&(t.invalidateUpstreamBooleanData(),uC(t.parent)?t.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof nC&&i.invalidateDownstreamBooleanData().recomputeBoolean()),t.updatePathSnapping()}var i;this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.shadowsDirty=!0,this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof FC&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(this.shadowsDirty=!0,0===t.type){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:e}=t.props;t={...t,props:e},this.markNeedsRecomputeInstances()}"pathSnapping"===t.path[0]&&void 0!==t.props.pathId&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{(function(e,t,i,r){e.updateByOp(t,i,r,!1)})(s,t,i,{scene:this,shared:r}),s instanceof YT&&s.updateGeometryGroupsIfNeeded()}catch(e){console.error(e)}}updateEntity2DByOp(e,t,i,r,s,a=[]){e.updateEntityByOp(t,i,r,s),this.traverseEntity(e=>{(Wv(e)||e instanceof FC)&&(a.includes(e.frameId??"")||e.frameId===t)&&e.updateEntity2DByOp(t,i,r,s)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((e,t)=>({data:e[1].asset.data,children:e[1].asset.children,id:e[0],fi:t}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(e=>{e instanceof fx&&e.updateUp()}),this.doPendingExpandCloner({scene:this,shared:t}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(e=>{("Component"===e.data.type||"Instance"===e.data.type)&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Lb.is(e)&&("Component"===e.data.type&&this.markNeedsRecomputeInstances(),e.traverseAncestors(e=>{Lb.is(e)&&"Component"===e.data.type&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,a,n){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(r=>{r.data=cc(r.data,s=>{let o=s.events.data(n.id),l=r.goUp(a);if(l){let r=[...fd(l.identity),e].join("-"),s=this.entityIdentityToEntity[r];if(s){let e=s.uuid;Cc.zoom(o,t)[i]=e}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,a){e.forEach(e=>{"Transition"===e.data.type||"Animation"===e.data.type?this.relativeizeInner(e.data.object,[...t,e.id],"object",i,r,s,a):"Conditional"===e.data.type&&(this.rewriteActions(e.data.ifActions,[...t,e.id,"ifActions"],i,r,s,a),this.rewriteActions(e.data.elseActions,[...t,e.id,"elseActions"],i,r,s,a))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if($v(e)&&"string"==typeof e.identity&&"Component"===e.data.type)return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if("GameControl"===r.data.type){let s=!1;if(t.forInstancesRec(e=>{e.data=cc(e.data,t=>{e.isInstanceRoot||(t.events.delete(r.id),s=!0)}).data}),!1===s)for(let s of _y.list)this.rewriteActions(r.data.gameActions[s],["gameActions",s],e,t,i,r)}else"Conditional"===r.data.type?("Distance"===r.data.condition.type?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):"State"===r.data.condition.type?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):"Comparison"===r.data.condition.type&&("Property"===r.data.condition.lOperand.type&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),"Property"===r.data.condition.rOperand.type&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if($v(s)&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(e=>{i.addClip(e)}),!0});for(let e of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(e),jA(e)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(e=>{$v(e)&&e.isInstanceRoot&&(e.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(e=>{let t="string"==typeof e.identity?e.identity:e.identity.join("-");this.entityIdentityToEntity[t]===e&&(delete this.entityByUuid[e.uuid],delete this.entityIdentityToEntity[t]),e.dispose()})}clearScene(){this._autoInstancing?.dispose(),this._autoInstancing=null,this.instanceGroupsDirty=!0;for(let e of this.children)Lb.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let a of s.children){let s=a.cloner;if(Lb.is(a)&&!a.raycastLock&&(a.visible||s?.object.data.visible))if(!0===t&&a.isInstanceRoot){let t=[];if(e.intersectObject(a,!0,t),t.length){let e=t[0];e.object=a,e.point.applyMatrix4(e.object.matrixWorld);let r=a.matrixWorld.clone().invert();e.point.applyMatrix4(r),i.push(e)}}else(hC(a)||dC(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),PC(a,e,i)),r(a)}};return r(this.activePage),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let r=s.cloner;Lb.is(s)&&(s.visible||r?.object.data.visible)&&((hC(s)||dC(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),PC(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)Lb.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Lb.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Lb.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof YT&&"Mesh"===i.data.type&&("TextGeometry"===i.data.geometry.type||"InputGeometry"===i.data.geometry.type)&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s,t);let e=i.invalidateDownstreamBooleanData();uC(e)&&e.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)xb.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Lb.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,a){let n={scene:this,shared:a},o=zA(e,t,n);return jv(o)&&this.shapeBlendIntances.push(o),Fv(o)&&this.hairInstances.push(o),o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,a)),o.updateState(t,n),o instanceof YT&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),"Empty"===t.type&&t.animations&&o.traverseEntity(e=>{let t=e.dataPatched;if(e instanceof YT&&t.bones&&t.boneInverses){let i=t.bones.map(e=>this.find(e)),r=t.boneInverses.map(e=>(new As).fromArray(e)),s=new Zn(i,r);e.bind(s,e.bindMatrix)}else e.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let i=0,r=e.length;i<r;++i){let{id:r,recursive:s}=e[i],a=this.find(r),n=s?a.recursiveBBox:a.singleBBox;t.push(...n.vertices)}let i=new Sa;return i.setFromPoints(t),i.getCenter(gN),gN}copyMatrixWorld(e,t){if(null===e)return void t.identity();let i=this.find(e);i?(i.updateWorldMatrix(!0,!1),t.copy(i.matrixWorld)):t.identity()}copyParentMatrixWorld(e,t){if(null===e)return void t.identity();let i=this.find(e)?.parent;i?(i.updateWorldMatrix(!0,!1),t.copy(i.matrixWorld)):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof qx)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)$x(t.material[i])&&e(t.material[i]);else $x(t.material)&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof fx&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(){this.splatViewer=new pN({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}}}),xN={};function wN(){let e,t;function i(e,t,i,r,s,a){let n=i.num_points(),o=a.num_components(),l=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,s),h=o*s.BYTES_PER_ELEMENT,u=4*Math.ceil(h/4),d=u/s.BYTES_PER_ELEMENT,c=n*h,p=n*u,m=e._malloc(c);t.GetAttributeDataArrayForAllPoints(i,a,l,c,m);let g,f=new s(e.HEAPF32.buffer,m,c/s.BYTES_PER_ELEMENT);if(h===u)g=f.slice();else{g=new s(p/s.BYTES_PER_ELEMENT);let e=0;for(let t=0,i=f.length;t<i;t++){for(let i=0;i<o;i++)g[e+i]=f[t*o+i];e+=d}}return e._free(m),{name:r,count:n,itemSize:o,array:g,stride:d}}onmessage=function(r){let s=r.data;switch(s.type){case"init":e=s.decoderConfig,t=new Promise(function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)});break;case"decode":let r=s.buffer,a=s.taskConfig;t.then(e=>{let t=e.draco,n=new t.Decoder;try{let e=function(e,t,r,s){let a,n,o=s.attributeIDs,l=s.attributeTypes,h=t.GetEncodedGeometryType(r);if(h===e.TRIANGULAR_MESH)a=new e.Mesh,n=t.DecodeArrayToMesh(r,r.byteLength,a);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,n=t.DecodeArrayToPointCloud(r,r.byteLength,a)}if(!n.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+n.error_msg());let u={index:null,attributes:[]};for(let r in o){let n,h,d=self[l[r]];if(s.useUniqueIDs)h=o[r],n=t.GetAttributeByUniqueId(a,h);else{if(h=t.GetAttributeId(a,e[o[r]]),-1===h)continue;n=t.GetAttribute(a,h)}let c=i(e,t,a,r,d,n);"color"===r&&(c.vertexColorSpace=s.vertexColorSpace),u.attributes.push(c)}return h===e.TRIANGULAR_MESH&&(u.index=function(e,t,i){let r=3*i.num_faces(),s=4*r,a=e._malloc(s);t.GetTrianglesUInt32Array(i,s,a);let n=new Uint32Array(e.HEAPF32.buffer,a,r).slice();return e._free(a),{array:n,itemSize:1}}(e,t,a)),e.destroy(a),u}(t,n,new Int8Array(r),a),o=e.attributes.map(e=>e.array.buffer);e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}finally{t.destroy(n)}})}}}l(xN,{DRACOLoader:()=>AN,DRACO_GLTF_CONFIG:()=>CN});var _N,SN,MN,TN,CN,AN,NN=n(()=>{Mu(),_N=new WeakMap,SN=new URL("../libs/draco/draco_decoder.wasm",import.meta.url).toString(),MN=new URL("../libs/draco/draco_wasm_wrapper.js",import.meta.url).toString(),TN=new URL("../libs/draco/draco_decoder.js",import.meta.url).toString(),CN={js:new URL("../libs/draco/gltf/draco_wasm_wrapper.js",import.meta.url).toString(),wasm:new URL("../libs/draco/gltf/draco_decoder.wasm",import.meta.url).toString()},AN=class extends Fl{constructor(e){super(e),this.decoderPaths={js:MN,wasm:SN,dep_js:TN},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(e){let{decoderPaths:t}=this;return"object"==typeof e?(t.js=e.js,t.wasm=e.wasm,t.dep_js=null):(t.js=yh.resolveURL("draco_wasm_wrapper.js",e),t.wasm=yh.resolveURL("draco_decoder.wasm",e),t.dep_js=yh.resolveURL("draco_decoder.js",e)),this}setDecoderConfig(e){return console.warn("THREE.DRACOLoader: setDecoderConfig to has been deprecated and will be removed in r194."),this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let s=new Wl(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,e=>{this.parse(e,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,hr,i).catch(i)}decodeDracoFile(e,t,i,r,s=ur,a=()=>{}){let n={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:s};return this.decodeGeometry(e,n).then(t).catch(a)}decodeGeometry(e,t){let i=JSON.stringify(t);if(_N.has(e)){let t=_N.get(e);if(t.key===i)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,a=e.byteLength,n=this._getWorker(s,a).then(i=>(r=i,new Promise((i,a)=>{r._callbacks[s]={resolve:i,reject:a},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return n.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),_N.set(e,{key:i,promise:n}),n}_createGeometry(e){let t=new an;e.index&&t.setIndex(new ja(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r,{name:s,array:a,itemSize:n,stride:o,vertexColorSpace:l}=e.attributes[i];if(n===o)r=new ja(a,n);else{let e=new nn(a,o);r=new ln(e,n,0)}"color"===s&&(this._assignVertexColorSpace(r,l),r.normalized=!(a instanceof Float32Array)),t.setAttribute(s,r)}return t}_assignVertexColorSpace(e,t){if(t!==hr)return;let i=new aa;for(let t=0,r=e.count;t<r;t++)i.fromBufferAttribute(e,t),ms.colorSpaceToWorking(i,hr),e.setXYZ(t,i.r,i.g,i.b)}_loadLibrary(e,t){let i=new Wl(this.manager);return i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((t,r)=>{i.load(e,t,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[],{decoderPaths:i}=this;if(e){if(null===i.dep_js)throw new Error("THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.");t.push(this._loadLibrary(i.dep_js,"text"))}else t.push(this._loadLibrary(i.js,"text")),t.push(this._loadLibrary(i.wasm,"arraybuffer"));return this.decoderPending=Promise.all(t).then(t=>{let i=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let r=wN.toString(),s=["/* draco decoder */",i,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){let i=t.data;switch(i.type){case"decode":e._callbacks[i.id].resolve(i);break;case"error":e._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort(function(e,t){return e._taskLoad>t._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}});function PN(e){if(void 0!==RN)return`${RN}/${e}`;let t="string"==typeof import.meta.url?import.meta.url:"",i=t.lastIndexOf("/");return i>0?t.slice(0,i+1)+e:e}var RN,EN=n(()=>{});function ON(e,t){DN.set(e,t)}function BN(e){return DN.get(e)}function VN(e,t){let i=`${t}:${e}`;IN.has(i)||IN.add(i)}var DN,IN,LN=n(()=>{DN=new Map,IN=new Set});function zN(e,t=0){let i=3735928559^t,r=1103547991^t;if(Array.isArray(e))for(let t,s=0;s<e.length;s++)t=e[s],i=Math.imul(i^t,2654435761),r=Math.imul(r^t,1597334677);else for(let t,s=0;s<e.length;s++)t=e.charCodeAt(s),i=Math.imul(i^t,2654435761),r=Math.imul(r^t,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&r)+(i>>>0)}function kN(e){return dR.get(e)}function UN(e){if(/[iu]?vec\d/.test(e))return e.startsWith("ivec")?Int32Array:e.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function FN(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)?3:/vec4/.test(e)||/mat2/.test(e)?4:/mat3/.test(e)?9:/mat4/.test(e)?16:void y(`TSL: Unsupported type: ${e}`,new oR)}function jN(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)?3:/vec4/.test(e)||/mat2/.test(e)?4:/mat3/.test(e)?12:/mat4/.test(e)?16:void y(`TSL: Unsupported type: ${e}`,new oR)}function GN(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)||/vec4/.test(e)?4:/mat2/.test(e)?2:/mat3/.test(e)||/mat4/.test(e)?4:void y(`TSL: Unsupported type: ${e}`,new oR)}function WN(e){if(null==e)return null;let t=typeof e;return!0===e.isNode?"node":"number"===t?"float":"boolean"===t?"bool":"string"===t?"string":"function"===t?"shader":!0===e.isVector2?"vec2":!0===e.isVector3?"vec3":!0===e.isVector4?"vec4":!0===e.isMatrix2?"mat2":!0===e.isMatrix3?"mat3":!0===e.isMatrix4?"mat4":!0===e.isColor?"color":e instanceof ArrayBuffer?"ArrayBuffer":null}function qN(e,...t){let i=e?e.slice(-4):void 0;return 1===t.length&&("vec2"===i?t=[t[0],t[0]]:"vec3"===i?t=[t[0],t[0],t[0]]:"vec4"===i&&(t=[t[0],t[0],t[0],t[0]])),"color"===e?new aa(...t):"vec2"===i?new rs(...t):"vec3"===i?new ns(...t):"vec4"===i?new Ss(...t):"mat2"===i?new Gh(...t):"mat3"===i?new us(...t):"mat4"===i?new As(...t):"bool"===e?t[0]||!1:"float"===e||"int"===e||"uint"===e?t[0]||0:"string"===e?t[0]||"":"ArrayBuffer"===e?function(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}(t[0]):null}function HN(e){let t=cR.get(e);return void 0===t&&(t={},cR.set(e,t)),t}function $N(e,t){if(LR.has(e))f(`TSL: Redefinition of method chaining '${e}'.`);else{if("function"!=typeof t)throw new Error(`THREE.TSL: Node element ${e} is not a function`);LR.set(e,t),"assign"!==e&&(SR.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},SR.prototype[e+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}}function YN(e,t,i){UR[e]=UR[t]=UR[i]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new PR(this,e),this._cache[e]=t),t},set(t){this[e].assign(uE(t))}};let r=e.toUpperCase(),s=t.toUpperCase(),a=i.toUpperCase();SR.prototype["set"+r]=SR.prototype["set"+s]=SR.prototype["set"+a]=function(t){let i=kR(e);return new RR(this,i,uE(t))},SR.prototype["flip"+r]=SR.prototype["flip"+s]=SR.prototype["flip"+a]=function(){let t=kR(e);return new ER(this,t)}}function XN(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}function KN(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),Boolean(e)}function ZN(e,t){return new KR(e,t)}function JN(e,t=null){let i=new bE(e,t);return new Proxy(()=>{},{apply:(e,t,r)=>i.call(...r),get:(e,t,r)=>Reflect.get(i,t,r),set:(e,t,r,s)=>Reflect.set(i,t,r,s)})}function QN(e){return IR&&IR.addToStack(e),e}function eP(e,t,i=null){return zV(i,{getShadow:({light:i,shadowColorNode:r})=>t===i?r.mul(e):r})}function tP(e,t=null){return zV(t,{getAO:(t,{material:i})=>!0===i.transparent?t:null!==t?t.mul(e):e})}function iP(e,t){return f('TSL: "label()" has been deprecated. Use "setName()" instead.'),UV(e,t)}function rP(e,t){let i=dD.get(e);return void 0===i&&(i=new nn(e,t),dD.set(e,i)),i}function sP(e,t=null,i=0,r=0,s=Ur,a=!1){return"mat3"===t||null===t&&9===e.itemSize?jE(new cD(e,"vec3",9,0).setUsage(s).setInstanced(a),new cD(e,"vec3",9,3).setUsage(s).setInstanced(a),new cD(e,"vec3",9,6).setUsage(s).setInstanced(a)):"mat4"===t||null===t&&16===e.itemSize?GE(new cD(e,"vec4",16,0).setUsage(s).setInstanced(a),new cD(e,"vec4",16,4).setUsage(s).setInstanced(a),new cD(e,"vec4",16,8).setUsage(s).setInstanced(a),new cD(e,"vec4",16,12).setUsage(s).setInstanced(a)):new cD(e,t,i,r).setUsage(s)}function aP(e,t=!0){return f('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),ND(e).setParent(t)}function nP(e,t,i,r=TE(0),s=TE(1)){return RD(e,t,i,r,s,!0)}function oP(e,t="",i=null){return(e=uE(e)).before(new jD(e,t,i))}function lP(e){f("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)}function hP(e,t,i){let r;if(!0===t.isStorageInstancedBufferAttribute)r=Ik(t,"mat4",Math.max(i,1)).element(bD);else if(16*i*4<=e.getUniformBufferLimit())r=aI(t.array,"mat4",Math.max(i,1)).element(bD);else{let e=Lk.get(t);e||(e=new zh(t.array,16,1),Lk.set(t,e));let i=t.usage===Fr?fD:gD,s=[i(e,"vec4",16,0),i(e,"vec4",16,4),i(e,"vec4",16,8),i(e,"vec4",16,12)];r=GE(...s)}return r}function uP(e,t,i,r,s,a){let n=e.element(s.x),o=e.element(s.y),l=e.element(s.z),h=e.element(s.w),u=i.mul(t),d=GO(n.mul(a.x).mul(u),o.mul(a.y).mul(u),l.mul(a.z).mul(u),h.mul(a.w).mul(u));return r.mul(d).xyz}function dP(e,t,i,r,s,a,n){let o=e.element(a.x),l=e.element(a.y),h=e.element(a.z),u=e.element(a.w),d=GO(n.x.mul(o),n.y.mul(l),n.z.mul(h),n.w.mul(u));return d=s.mul(d).mul(r),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(i).xyz}}function cP(e,t,i,r,s){let a=e.skeleton,n=Yk.get(a);if(void 0===n){a.update();let e=new Float32Array(a.boneMatrices);n={previousBoneMatrices:e,node:aI(e,"mat4",a.bones.length)},Yk.set(a,n)}return uP(n.node,fL,t,i,r,s)}function pP(e){let t=e.target;t.removeEventListener("dispose",pP);let i=nF.get(t);void 0!==i&&(nF.delete(t),i.dispose())}function mP(e,t){t===It?e.mapping=Vt:t===Lt&&(e.mapping=Dt)}function gP(e,t,i){let r=new Ms(e,t,{magFilter:qt,minFilter:qt,generateMipmaps:!1,type:ii,format:ui,colorSpace:ur,depthBuffer:i});return r.texture.mapping=zt,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function fP(e){let t=new UU;return t.depthTest=!1,t.depthWrite=!1,t.blending=He,t.name=`PMREM_${e}`,t}function yP(e){let t=fP("cubemap");return t.fragmentNode=YL(e,tG),t}function vP(e){let t=fP("equirect");return t.fragmentNode=JD(e,rF(tG),0),t}function bP(e){return Object.freeze({isMaterial:!0,isDrawState:!0,id:e.id,name:e.name,type:e.type,transparent:e.transparent,blending:e.blending,premultipliedAlpha:e.premultipliedAlpha,blendSrc:e.blendSrc,blendDst:e.blendDst,blendEquation:e.blendEquation,blendSrcAlpha:e.blendSrcAlpha,blendDstAlpha:e.blendDstAlpha,blendEquationAlpha:e.blendEquationAlpha,blendColor:e.blendColor,blendAlpha:e.blendAlpha,colorWrite:e.colorWrite,depthWrite:e.depthWrite,depthTest:e.depthTest,depthFunc:e.depthFunc,stencilWrite:e.stencilWrite,stencilFunc:e.stencilFunc,stencilRef:e.stencilRef,stencilFail:e.stencilFail,stencilZFail:e.stencilZFail,stencilZPass:e.stencilZPass,stencilFuncMask:e.stencilFuncMask,stencilWriteMask:e.stencilWriteMask,side:e.side,wireframe:!0===e.wireframe,alphaToCoverage:e.alphaToCoverage,forceSinglePass:e.forceSinglePass,polygonOffset:e.polygonOffset,polygonOffsetFactor:e.polygonOffsetFactor,polygonOffsetUnits:e.polygonOffsetUnits})}function xP(e,t){if(null===e||null===t)return e===t;for(let i in e)if(e[i]!==t[i])return!1;return!0}function wP(e){return null!==e.index?e.index.version:e.attributes.position.version}function _P(e){return null!==e.index?e.index.id:e.attributes.position.id}function SP(e){let t=[],i=e.index,r=e.attributes.position;if(null!==i){let e=i.array;for(let i=0,r=e.length;i<r;i+=3){let r=e[i+0],s=e[i+1],a=e[i+2];t.push(r,s,s,a,a,r)}}else for(let e=0,i=r.array.length/3-1;e<i;e+=3){let i=e+0,r=e+1,s=e+2;t.push(i,r,r,s,s,i)}let s=new(r.count>=65535?Wa:Ga)(t,1);return s.version=wP(e),s.__id=_P(e),s}function MP(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function TP(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function CP(e){return!!(!0===e.transparent||e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode||e.backdropNode&&e.backdropNode.isNode)}function AP(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===qe&&!1===e.forceSinglePass}function NP(e,t=null,i=null){if(t&&t.isNode){let e=t;t=()=>e}return new uW(new Map([[e,t]]),i)}function PP(e,t=null){let i=new Map;for(let[t,r]of e){let e=null!==r?"function"==typeof r?r:()=>r:null;i.set(t,e)}return new uW(i,t)}function RP(e,t){for(let i=0;i<e.length;i++)if(e[i].name===t)return i;return-1}function EP(e,t=null){return zV(t,{getUV:"function"==typeof e?e:()=>e})}function OP(e){let t=hH.get(e);return void 0===t&&(t={},hH.set(e,t)),t}function BP(e,t=0){let i=OP(e),r=i[t];return void 0===r&&(i[t]=r=new As,i[t].copy(e.matrixWorld)),r}function VP(e){let t,i=e.context.getViewZ;return void 0!==i&&(t=i(this)),(t||bL.z).negate()}function DP(e){let t=(sY=sY||new WeakMap).get(e);return void 0===t&&sY.set(e,t={}),t}function IP(e){let t=DP(e);return t.shadowMatrix||(t.shadowMatrix=DO("mat4").setGroup(OO).onRenderUpdate(t=>((!0!==e.castShadow||!1===t.renderer.shadowMap.enabled)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function LP(e,t=yL){let i=IP(e).mul(t);return i.xyz.div(i.w)}function zP(e){let t=DP(e);return t.position||(t.position=DO(new ns).setGroup(OO).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(e.matrixWorld)))}function kP(e){let t=DP(e);return t.targetPosition||(t.targetPosition=DO(new ns).setGroup(OO).onRenderUpdate((t,i)=>i.value.setFromMatrixPosition(e.target.matrixWorld)))}function UP(e){let t=DP(e);return t.viewPosition||(t.viewPosition=DO(new ns).setGroup(OO).onRenderUpdate(({camera:t},i)=>{i.value=i.value||new ns,i.value.setFromMatrixPosition(e.matrixWorld),i.value.applyMatrix4(t.matrixWorldInverse)}))}function FP(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new aa),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function jP(e,t){return t=FP(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function GP(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function WP(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function qP(e,t){return t=WP(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function HP(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function $P(e,t,i={}){return WP(t,i=FP(e,i))}function YP(e,t,i){return qP(t,i=jP(e,i))}function XP(e,t,i){GP(e,i),HP(t,i)}function KP(e){return e+(jG-e%jG)%jG}function ZP(){return null===WJ&&((WJ=new Yn(new Uint8Array([255,255,255,255]),1,1)).needsUpdate=!0),WJ}function JP(e,t){AQ[0]=t,e.queue.submit(AQ),AQ[0]=null}function QP(e,t,i,r,s,a,n,o,l,h){o0.texture=t,o0.mipLevel=i,o0.origin.z=r,h0.offset=r*a,h0.bytesPerRow=n,h0.rowsPerImage=o,p0.width=l,p0.height=h,e.queue.writeTexture(o0,s.data,h0,p0),o0.reset(),h0.reset(),p0.reset()}function eR(e,t){let i,r=e.format,s=e.type,a=e.normalized,n=e.colorSpace,o=ms.getTransfer(n),l=!1;if(a&&(l=t.features.has(wQ.TextureFormatsTier1),!1===l&&f("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.")),!0===e.isCompressedTexture||!0===e.isCompressedArrayTexture)switch(r){case bi:case xi:i=o===cr?nQ.BC1RGBAUnormSRGB:nQ.BC1RGBAUnorm;break;case wi:i=o===cr?nQ.BC2RGBAUnormSRGB:nQ.BC2RGBAUnorm;break;case _i:i=o===cr?nQ.BC3RGBAUnormSRGB:nQ.BC3RGBAUnorm;break;case $i:i=nQ.BC4RUnorm;break;case Yi:i=nQ.BC4RSnorm;break;case Xi:i=nQ.BC5RGUnorm;break;case Ki:i=nQ.BC5RGSnorm;break;case Wi:i=o===cr?nQ.BC7RGBAUnormSRGB:nQ.BC7RGBAUnorm;break;case qi:i=nQ.BC6HRGBFloat;break;case Hi:i=nQ.BC6HRGBUFloat;break;case Mi:case Si:i=o===cr?nQ.ETC2RGB8UnormSRGB:nQ.ETC2RGB8Unorm;break;case Ti:i=o===cr?nQ.ETC2RGBA8UnormSRGB:nQ.ETC2RGBA8Unorm;break;case Ci:i=nQ.EACR11Unorm;break;case Ai:i=nQ.EACR11Snorm;break;case Ni:i=nQ.EACRG11Unorm;break;case Pi:i=nQ.EACRG11Snorm;break;case Ri:i=o===cr?nQ.ASTC4x4UnormSRGB:nQ.ASTC4x4Unorm;break;case Ei:i=o===cr?nQ.ASTC5x4UnormSRGB:nQ.ASTC5x4Unorm;break;case Oi:i=o===cr?nQ.ASTC5x5UnormSRGB:nQ.ASTC5x5Unorm;break;case Bi:i=o===cr?nQ.ASTC6x5UnormSRGB:nQ.ASTC6x5Unorm;break;case Vi:i=o===cr?nQ.ASTC6x6UnormSRGB:nQ.ASTC6x6Unorm;break;case Di:i=o===cr?nQ.ASTC8x5UnormSRGB:nQ.ASTC8x5Unorm;break;case Ii:i=o===cr?nQ.ASTC8x6UnormSRGB:nQ.ASTC8x6Unorm;break;case Li:i=o===cr?nQ.ASTC8x8UnormSRGB:nQ.ASTC8x8Unorm;break;case zi:i=o===cr?nQ.ASTC10x5UnormSRGB:nQ.ASTC10x5Unorm;break;case ki:i=o===cr?nQ.ASTC10x6UnormSRGB:nQ.ASTC10x6Unorm;break;case Ui:i=o===cr?nQ.ASTC10x8UnormSRGB:nQ.ASTC10x8Unorm;break;case Fi:i=o===cr?nQ.ASTC10x10UnormSRGB:nQ.ASTC10x10Unorm;break;case ji:i=o===cr?nQ.ASTC12x10UnormSRGB:nQ.ASTC12x10Unorm;break;case Gi:i=o===cr?nQ.ASTC12x12UnormSRGB:nQ.ASTC12x12Unorm;break;case ui:i=o===cr?nQ.RGBA8UnormSRGB:nQ.RGBA8Unorm;break;default:y("WebGPURenderer: Unsupported texture format.",r)}else switch(r){case ui:switch(s){case Kt:i=nQ.RGBA8Snorm;break;case Zt:i=l?nQ.RGBA16Snorm:nQ.RGBA16Sint;break;case Jt:i=l?nQ.RGBA16Unorm:nQ.RGBA16Uint;break;case ei:i=nQ.RGBA32Uint;break;case Qt:i=nQ.RGBA32Sint;break;case Xt:i=o===cr?nQ.RGBA8UnormSRGB:nQ.RGBA8Unorm;break;case ii:i=nQ.RGBA16Float;break;case ti:i=nQ.RGBA32Float;break;default:y("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case hi:switch(s){case ni:i=nQ.RGB9E5UFloat;break;case oi:i=nQ.RG11B10UFloat;break;default:y("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case pi:switch(s){case Kt:i=nQ.R8Snorm;break;case Zt:i=l?nQ.R16Snorm:nQ.R16Sint;break;case Jt:i=l?nQ.R16Unorm:nQ.R16Uint;break;case ei:i=nQ.R32Uint;break;case Qt:i=nQ.R32Sint;break;case Xt:i=nQ.R8Unorm;break;case ii:i=nQ.R16Float;break;case ti:i=nQ.R32Float;break;default:y("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case gi:switch(s){case Kt:i=nQ.RG8Snorm;break;case Zt:i=l?nQ.RG16Snorm:nQ.RG16Sint;break;case Jt:i=l?nQ.RG16Unorm:nQ.RG16Uint;break;case ei:i=nQ.RG32Uint;break;case Qt:i=nQ.RG32Sint;break;case Xt:i=nQ.RG8Unorm;break;case ii:i=nQ.RG16Float;break;case ti:i=nQ.RG32Float;break;default:y("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case di:switch(s){case Jt:i=nQ.Depth16Unorm;break;case ei:i=nQ.Depth24Plus;break;case ti:i=nQ.Depth32Float;break;default:y("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case ci:switch(s){case ai:i=nQ.Depth24PlusStencil8;break;case ti:t&&!1===t.features.has(wQ.Depth32FloatStencil8)&&y('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),i=nQ.Depth32FloatStencil8;break;default:y("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case mi:switch(s){case Qt:i=nQ.R32Sint;break;case ei:i=nQ.R32Uint;break;default:y("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case fi:switch(s){case Qt:i=nQ.RG32Sint;break;case ei:i=nQ.RG32Uint;break;default:y("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case vi:switch(s){case Qt:i=nQ.RGBA32Sint;break;case ei:i=nQ.RGBA32Uint;break;default:y("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:y("WebGPURenderer: Unsupported texture format.",r)}return i}var tR,iR,rR,sR,aR,nR,oR,lR,hR,uR,dR,cR,pR,mR,gR,fR,yR,vR,bR,xR,wR,_R,SR,MR,TR,CR,AR,NR,PR,RR,ER,OR,BR,VR,DR,IR,LR,zR,kR,UR,FR,jR,GR,WR,qR,HR,$R,YR,XR,KR,ZR,JR,QR,eE,tE,iE,rE,sE,aE,nE,oE,lE,hE,uE,dE,cE,pE,mE,gE,fE,yE,vE,bE,xE,wE,_E,SE,ME,TE,CE,AE,NE,PE,RE,EE,OE,BE,VE,DE,IE,LE,zE,kE,UE,FE,jE,GE,WE,qE,HE,$E,YE,XE,KE,ZE,JE,QE,eO,tO,iO,rO,sO,aO,nO,oO,lO,hO,uO,dO,cO,pO,mO,gO,fO,yO,vO,bO,xO,wO,_O,SO,MO,TO,CO,AO,NO,PO,RO,EO,OO,BO,VO,DO,IO,LO,zO,kO,UO,FO,jO,GO,WO,qO,HO,$O,YO,XO,KO,ZO,JO,QO,eB,tB,iB,rB,sB,aB,nB,oB,lB,hB,uB,dB,cB,pB,mB,gB,fB,yB,vB,bB,xB,wB,_B,SB,MB,TB,CB,AB,NB,PB,RB,EB,OB,BB,VB,DB,IB,LB,zB,kB,UB,FB,jB,GB,WB,qB,HB,$B,YB,XB,KB,ZB,JB,QB,eV,tV,iV,rV,sV,aV,nV,oV,lV,hV,uV,dV,cV,pV,mV,gV,fV,yV,vV,bV,xV,wV,_V,SV,MV,TV,CV,AV,NV,PV,RV,EV,OV,BV,VV,DV,IV,LV,zV,kV,UV,FV,jV,GV,WV,qV,HV,$V,YV,XV,KV,ZV,JV,QV,eD,tD,iD,rD,sD,aD,nD,oD,lD,hD,uD,dD,cD,pD,mD,gD,fD,yD,vD,bD,xD,wD,_D,SD,MD,TD,CD,AD,ND,PD,RD,ED,OD,BD,VD,DD,ID,LD,zD,kD,UD,FD,jD,GD,WD,qD,HD,$D,YD,XD,KD,ZD,JD,QD,eI,tI,iI,rI,sI,aI,nI,oI,lI,hI,uI,dI,cI,pI,mI,gI,fI,yI,vI,bI,xI,wI,_I,SI,MI,TI,CI,AI,NI,PI,RI,EI,OI,BI,VI,DI,II,LI,zI,kI,UI,FI,jI,GI,WI,qI,HI,$I,YI,XI,KI,ZI,JI,QI,eL,tL,iL,rL,sL,aL,nL,oL,lL,hL,uL,dL,cL,pL,mL,gL,fL,yL,vL,bL,xL,wL,_L,SL,ML,TL,CL,AL,NL,PL,RL,EL,OL,BL,VL,DL,IL,LL,zL,kL,UL,FL,jL,GL,WL,qL,HL,$L,YL,XL,KL,ZL,JL,QL,ez,tz,iz,rz,sz,az,nz,oz,lz,hz,uz,dz,cz,pz,mz,gz,fz,yz,vz,bz,xz,wz,_z,Sz,Mz,Tz,Cz,Az,Nz,Pz,Rz,Ez,Oz,Bz,Vz,Dz,Iz,Lz,zz,kz,Uz,Fz,jz,Gz,Wz,qz,Hz,$z,Yz,Xz,Kz,Zz,Jz,Qz,ek,tk,ik,rk,sk,ak,nk,ok,lk,hk,uk,dk,ck,pk,mk,gk,fk,yk,vk,bk,xk,wk,_k,Sk,Mk,Tk,Ck,Ak,Nk,Pk,Rk,Ek,Ok,Bk,Vk,Dk,Ik,Lk,zk,kk,Uk,Fk,jk,Gk,Wk,qk,Hk,$k,Yk,Xk,Kk,Zk,Jk,Qk,eU,tU,iU,rU,sU,aU,nU,oU,lU,hU,uU,dU,cU,pU,mU,gU,fU,yU,vU,bU,xU,wU,_U,SU,MU,TU,CU,AU,NU,PU,RU,EU,OU,BU,VU,DU,IU,LU,zU,kU,UU,FU,jU,GU,WU,qU,HU,$U,YU,XU,KU,ZU,JU,QU,eF,tF,iF,rF,sF,aF,nF,oF,lF,hF,uF,dF,cF,pF,mF,gF,fF,yF,vF,bF,xF,wF,_F,SF,MF,TF,CF,AF,NF,PF,RF,EF,OF,BF,VF,DF,IF,LF,zF,kF,UF,FF,jF,GF,WF,qF,HF,$F,YF,XF,KF,ZF,JF,QF,ej,tj,ij,rj,sj,aj,nj,oj,lj,hj,uj,dj,cj,pj,mj,gj,fj,yj,vj,bj,xj,wj,_j,Sj,Mj,Tj,Cj,Aj,Nj,Pj,Rj,Ej,Oj,Bj,Vj,Dj,Ij,Lj,zj,kj,Uj,Fj,jj,Gj,Wj,qj,Hj,$j,Yj,Xj,Kj,Zj,Jj,Qj,eG,tG,iG,rG,sG,aG,nG,oG,lG,hG,uG,dG,cG,pG,mG,gG,fG,yG,vG,bG,xG,wG,_G,SG,MG,TG,CG,AG,NG,PG,RG,EG,OG,BG,VG,DG,IG,LG,zG,kG,UG,FG,jG,GG,WG,qG,HG,$G,YG,XG,KG,ZG,JG,QG,eW,tW,iW,rW,sW,aW,nW,oW,lW,hW,uW,dW,cW,pW,mW,gW,fW,yW,vW,bW,xW,wW,_W,SW,MW,TW,CW,AW,NW,PW,RW,EW,OW,BW,VW,DW,IW,LW,zW,kW,UW,FW,jW,GW,WW,qW,HW,$W,YW,XW,KW,ZW,JW,QW,eq,tq,iq,rq,sq,aq,nq,oq,lq,hq,uq,dq,cq,pq,mq,gq,fq,yq,vq,bq,xq,wq,_q,Sq,Mq,Tq,Cq,Aq,Nq,Pq,Rq,Eq,Oq,Bq,Vq,Dq,Iq,Lq,zq,kq,Uq,Fq,jq,Gq,Wq,qq,Hq,$q,Yq,Xq,Kq,Zq,Jq,Qq,eH,tH,iH,rH,sH,aH,nH,oH,lH,hH,uH,dH,cH,pH,mH,gH,fH,yH,vH,bH,xH,wH,_H,SH,MH,TH,CH,AH,NH,PH,RH,EH,OH,BH,VH,DH,IH,LH,zH,kH,UH,FH,jH,GH,WH,qH,HH,$H,YH,XH,KH,ZH,JH,QH,e$,t$,i$,r$,s$,a$,n$,o$,l$,h$,u$,d$,c$,p$,m$,g$,f$,y$,v$,b$,x$,w$,_$,S$,M$,T$,C$,A$,N$,P$,R$,E$,O$,B$,V$,D$,I$,L$,z$,k$,U$,F$,j$,G$,W$,q$,H$,$$,Y$,X$,K$,Z$,J$,Q$,eY,tY,iY,rY,sY,aY,nY,oY,lY,hY,uY,dY,cY,pY,mY,gY,fY,yY,vY,bY,xY,wY,_Y,SY,MY,TY,CY,AY,NY,PY,RY,EY,OY,BY,VY,DY,IY,LY,zY,kY,UY,FY,jY,GY,WY,qY,HY,$Y,YY,XY,KY,ZY,JY,QY,eX,tX,iX,rX,sX,aX,nX,oX,lX,hX,uX,dX,cX,pX,mX,gX,fX,yX,vX,bX,xX,wX,_X,SX,MX,TX,CX,AX,NX,PX,RX,EX,OX,BX,VX,DX,IX,LX,zX,kX,UX,FX,jX,GX,WX,qX,HX,$X,YX,XX,KX,ZX,JX,QX,eK,tK,iK,rK,sK,aK,nK,oK,lK,hK,uK,dK,cK,pK,mK,gK,fK,yK,vK,bK,xK,wK,_K,SK,MK,TK,CK,AK,NK,PK,RK,EK,OK,BK,VK,DK,IK,LK,zK,kK,UK,FK,jK,GK,WK,qK,HK,$K,YK,XK,KK,ZK,JK,QK,eZ,tZ,iZ,rZ,sZ,aZ,nZ,oZ,lZ,hZ,uZ,dZ,cZ,pZ,mZ,gZ,fZ,yZ,vZ,bZ,xZ,wZ,_Z,SZ,MZ,TZ,CZ,AZ,NZ,PZ,RZ,EZ,OZ,BZ,VZ,DZ,IZ,LZ,zZ,kZ,UZ,FZ,jZ,GZ,WZ,qZ,HZ,$Z,YZ,XZ,KZ,ZZ,JZ,QZ,eJ,tJ,iJ,rJ,sJ,aJ,nJ,oJ,lJ,hJ,uJ,dJ,cJ,pJ,mJ,gJ,fJ,yJ,vJ,bJ,xJ,wJ,_J,SJ,MJ,TJ,CJ,AJ,NJ,PJ,RJ,EJ,OJ,BJ,VJ,DJ,IJ,LJ,zJ,kJ,UJ,FJ,jJ,GJ,WJ,qJ,HJ,$J,YJ,XJ,KJ,ZJ,JJ,QJ,eQ,tQ,iQ,rQ,sQ,aQ,nQ,oQ,lQ,hQ,uQ,dQ,cQ,pQ,mQ,gQ,fQ,yQ,vQ,bQ,xQ,wQ,_Q,SQ,MQ,TQ,CQ,AQ,NQ,PQ,RQ,EQ,OQ,BQ,VQ,DQ,IQ,LQ,zQ,kQ,UQ,FQ,jQ,GQ,WQ,qQ,HQ,$Q,YQ,XQ,KQ,ZQ,JQ,QQ,e0,t0,i0,r0,s0,a0,n0,o0,l0,h0,u0,d0,c0,p0,m0,g0,f0,y0,v0,b0,x0,w0,_0,S0,M0,T0,C0,A0,N0,P0,R0,E0,O0,B0,V0,D0,I0,L0,z0,k0,U0,F0,j0,G0,W0,q0,H0,$0,Y0,X0,K0,Z0,J0,Q0,e1,t1,i1,r1,s1,a1,n1,o1,l1,h1,u1,d1,c1,p1,m1,g1,f1,y1,v1,b1,x1,w1,_1,S1,M1,T1,C1,A1,N1,P1,R1,E1,O1,B1,V1,D1,I1,L1,z1,k1,U1,F1,j1,G1,W1,q1,H1,$1,Y1,X1,K1,Z1,J1,Q1,e2,t2,i2,r2,s2,a2,n2,o2,l2,h2,u2,d2,c2,p2,m2,g2,f2,y2,v2,b2,x2,w2,_2,S2,M2,T2,C2,A2,N2,P2,R2,E2,O2,B2,V2,D2,I2,L2,z2,k2,U2,F2,j2,G2,W2,q2,H2,$2,Y2,X2,K2,Z2,J2,Q2,e3,t3,i3,r3,s3,a3,n3,o3,l3,h3,u3,d3,c3,p3,m3,g3,f3,y3,v3,b3,x3,w3,_3,S3,M3,T3,C3,A3,N3,P3,R3,E3,O3,B3,V3,D3,I3,L3,z3,k3,U3,F3,j3,G3,W3,q3,H3,$3,Y3,X3,K3,Z3,J3,Q3,e5,t5,i5,r5,s5,a5,n5,o5,l5,h5,u5,d5,c5,p5,m5,g5,f5,y5,v5=n(()=>{Mu(),Mu(),tR=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],iR=new WeakMap,rR=new WeakMap,sR=new WeakMap,aR=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=tR,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){let t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){let{geometry:i,object:r}=e;if(t={geometryId:i.id,worldMatrix:r.matrixWorld.clone()},r.center&&(t.center=r.center.clone()),r.morphTargetInfluences&&(t.morphTargetInfluences=r.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),e.material.transmission>0){let{width:i,height:r}=e.context;t.bufferWidth=i,t.bufferHeight=r}let{environmentIntensity:s,environmentRotation:a}=e.scene;t.environmentIntensity=s,t.environmentRotation=a.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let i in e){let r=e[i];t[i]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=sR.get(e);return void 0===t&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},sR.set(e,t)),t}getMaterialData(e){let t=rR.get(e);if(void 0===t){t={_renderId:-1,_equal:!1};for(let i of this.refreshUniforms){let r=e[i];null!=r&&("object"==typeof r&&void 0!==r.clone?!0===r.isTexture?t[i]={id:r.id,version:0}:t[i]=r.clone():t[i]=r)}rR.set(e,t)}return t}equals(e,t,i){let{object:r,material:s,geometry:a}=e,n=this.getRenderObjectData(e);if(!0!==n.worldMatrix.equals(r.matrixWorld))return n.worldMatrix.copy(r.matrixWorld),!1;let o=this.getMaterialData(e.material);if(o._renderId!==i){o._renderId=i;for(let e in o){let t=o[e],i=s[e];if("_renderId"!==e&&"_equal"!==e)if(void 0!==t.equals){if(!1===t.equals(i))return t.copy(i),o._equal=!1,!1}else if(!0===i.isTexture){if(t.id!==i.id||t.version!==i.version)return t.id=i.id,t.version=i.version,o._equal=!1,!1}else if(t!==i)return o[e]=i,o._equal=!1,!1}if(o.transmission>0){let{width:t,height:i}=e.context;if(n.bufferWidth!==t||n.bufferHeight!==i)return n.bufferWidth=t,n.bufferHeight=i,o._equal=!1,!1}o._equal=!0}else if(!1===o._equal)return!1;if(n.geometryId!==a.id)return n.geometryId=a.id,!1;let l=this.getGeometryData(e.geometry);if(l._renderId!==i){l._renderId=i;let e=a.attributes,t=l.attributes,r=0,s=0;for(let t in e)r++;for(let i in t){s++;let r=t[i],a=e[i];if(void 0===a)return delete t[i],l._equal=!1,!1;let n=a.isInterleavedBufferAttribute?a.data.uuid:a.id,o=a.isInterleavedBufferAttribute?a.data.version:a.version;if(r.id!==n||r.version!==o)return r.id=n,r.version=o,l._equal=!1,!1}if(s!==r)return l.attributes=this.getAttributesData(e),l._equal=!1,!1;let n=a.index,o=l.indexId,h=l.indexVersion,u=n?n.id:null,d=n?n.version:null;if(o!==u||h!==d)return l.indexId=u,l.indexVersion=d,l._equal=!1,!1;if(l.drawRange.start!==a.drawRange.start||l.drawRange.count!==a.drawRange.count)return l.drawRange.start=a.drawRange.start,l.drawRange.count=a.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(!1===l._equal)return!1;if(n.morphTargetInfluences){let e=!1;for(let t=0;t<n.morphTargetInfluences.length;t++)n.morphTargetInfluences[t]!==r.morphTargetInfluences[t]&&(n.morphTargetInfluences[t]=r.morphTargetInfluences[t],e=!0);if(e)return!1}if(n.lights)for(let e=0;e<t.length;e++)if(n.lights[e].map!==t[e].map)return!1;let h=e.scene;return null===h.environment||null!==s.envMap||n.environmentIntensity===h.environmentIntensity&&!1!==n.environmentRotation.equals(h.environmentRotation)?n.center&&!1===n.center.equals(r.center)?(n.center.copy(r.center),!1):(null!==e.bundle&&(n.version=e.bundle.version),!0):(n.environmentIntensity=h.environmentIntensity,n.environmentRotation.copy(h.environmentRotation),!1)}getLightsData(e,t){t.length=0;for(let i of e)!0===i.isSpotLight&&null!==i.map&&t.push({map:i.map.version});return t}getLights(e,t){let i=iR.get(e);return void 0===i&&(i={renderId:-1,lightsData:[]},iR.set(e,i)),i.renderId===t||(i.renderId=t,this.getLightsData(e.getLights(),i.lightsData)),i.lightsData}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:i}=t;if(this.renderId!==i){this.renderId=i;let t=this.getRenderObjectData(e);if(t.worldMatrix.copy(e.object.matrixWorld),t.morphTargetInfluences){let i=e.object.morphTargetInfluences;for(let e=0;e<t.morphTargetInfluences.length;e++)t.morphTargetInfluences[e]=i[e]}return t.center&&e.object.center&&t.center.copy(e.object.center),!0}let r=!0===e.object.static,s=null!==e.bundle&&!0===e.bundle.static&&this.getRenderObjectData(e).version===e.bundle.version;if(r||s)return!1;let a=this.getLights(e.lightsNode,i);return!0!==this.equals(e,a,i)}},nR=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/],oR=class{constructor(e=null){this.isStackTrace=!0,this.stack=function(e){let t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split("\n").map(e=>{let i=e.match(t);if(!i)return null;let r=i[1]||i[2]||"",s=i[3].split("?")[0],a=parseInt(i[4],10),n=parseInt(i[5],10);return{fn:r,file:s.split("/").pop(),line:a,column:n}}).filter(e=>e&&!nR.some(t=>t.test(e.file)))}(e||(new Error).stack)}getLocation(){if(0===this.stack.length)return"[Unknown location]";let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){return 0===this.stack.length?e:`${e}\n${this.stack.map(e=>{let t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join("\n")}`}},lR=e=>zN(e),hR=e=>zN(e),uR=(...e)=>zN(e),dR=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),cR=new WeakMap,pR={VERTEX:"vertex",FRAGMENT:"fragment"},mR={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},gR={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},fR={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},yR=["fragment","vertex"],vR=["setup","analyze","generate"],bR=[...yR,"compute"],xR=["x","y","z","w"],wR={analyze:"setup",generate:"analyze"},_R=0,(SR=class extends Kr{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=mR.NONE,this.updateBeforeType=mR.NONE,this.updateAfterType=mR.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=_R++,this.stackTrace=null,!0===SR.captureStackTrace&&(this.stackTrace=new oR)}set needsUpdate(e){!0===e&&this.version++}get uuid(){return null===this._uuid&&(this._uuid=ts.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,mR.FRAME)}onRenderUpdate(e){return this.onUpdate(e,mR.RENDER)}onObjectUpdate(e){return this.onUpdate(e,mR.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let i of Object.getOwnPropertyNames(this)){let r=this[i];if(!0!==i.startsWith("_")&&!e.has(r))if(!0===Array.isArray(r))for(let e=0;e<r.length;e++){let s=r[e];s&&!0===s.isNode&&t.push({property:i,index:e,childNode:s})}else if(r&&!0===r.isNode)t.push({property:i,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let e in r){if(!0===e.startsWith("_"))continue;let s=r[e];s&&!0===s.isNode&&t.push({property:i,index:e,childNode:s})}}return t}getCacheKey(e=!1,t=null){if(!0===(e=e||this.version!==this._cacheKeyVersion)||null===this._cacheKey){null===t&&(t=new Set);let i=[];for(let{property:r,childNode:s}of this._getChildren(t))i.push(lR(r.slice(0,-4)),s.getCacheKey(e,t));this._cacheKey=uR(hR(i),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e,t=null){let i,r=e.getDataFromNode(this);return null!==t?(r.typeFromOutput=r.typeFromOutput||{},i=r.typeFromOutput[t],void 0===i&&(i=this.generateNodeType(e,t),r.typeFromOutput[t]=i)):(i=r.type,void 0===i&&(i=this.generateNodeType(e),r.type=i)),i}generateNodeType(e,t=null){let i=e.getNodeProperties(this);return i.outputNode?i.outputNode.getNodeType(e,t):this.nodeType}getShared(e){let t=this.getHash(e),i=e.getNodeFromHash(t),r=null;if(i&&i!==this)r=i;else if(e.context.overrideNodes){let t=e.context.overrideNodes.get(this);if(t){let i=e.getDataFromNode(this);!0!==i.isOverwritten?(i.isOverwritten=!0,r=t(e).overrideNode(this,null),i.sharedNode=r):r=i.sharedNode}}return r||this}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),i=0;for(let e of this.getChildren())t["node"+i++]=e;return t.outputNode||null}analyze(e,t=null){let i=e.increaseUsage(this);if(!0===this.parents){let i=e.getDataFromNode(this,"any");i.stages=i.stages||{},i.stages[e.shaderStage]=i.stages[e.shaderStage]||[],i.stages[e.shaderStage].push(t)}if(1===i){let t=e.getNodeProperties(this);for(let i of Object.values(t))i&&!0===i.isNode&&i.build(e,this)}}generate(e,t){let{outputNode:i}=e.getNodeProperties(this);if(i&&!0===i.isNode)return i.build(e,t)}updateBefore(){f("Abstract function.")}updateAfter(){f("Abstract function.")}update(){f("Abstract function.")}before(e){return null===this._beforeNodes&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){let i=this.getShared(e);if(this!==i)return i.build(e,t);if(null!==this._beforeNodes){let i=this._beforeNodes;this._beforeNodes=null;for(let r of i)r.build(e,t);this._beforeNodes=i}let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let s=wR[e.buildStage];if(s&&!0!==r.buildStages[s]){let t=e.getBuildStage();e.setBuildStage(s),this.build(e),e.setBuildStage(t)}e.addChain(this);let a=null,n=e.getBuildStage();if("setup"===n){e.addNode(this),this.updateReference(e);let t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let i of Object.values(t))if(i&&!0===i.isNode){if(!0===i.parents){let t=e.getNodeProperties(i);t.parents=t.parents||[],t.parents.push(this)}i.build(e)}e.addSequentialNode(this)}a=t.outputNode}else if("analyze"===n)this.analyze(e,t);else if("generate"===n){if(this.generate.length<2){let i=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,void 0===a?void 0===r.generated?(r.generated=!0,a=this.generate(e)||"",r.snippet=a):(f("Node: Recursion detected.",this),a="/* Recursion detected. */"):void 0!==r.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,i,t)}else a=this.generate(e,t)||"";""===a&&null!==t&&"void"!==t&&"OutputType"!==t&&(y(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){let t=this.getSerializeChildren(),i={};for(let{property:r,index:s,childNode:a}of t)void 0!==s?(void 0===i[r]&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=a.toJSON(e.meta).uuid):i[r]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(void 0!==e.inputNodes){let t=e.meta.nodes;for(let i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){let r=[];for(let s of e.inputNodes[i])r.push(t[s]);this[i]=r}else if("object"==typeof e.inputNodes[i]){let r={};for(let s in e.inputNodes[i]){let a=e.inputNodes[i][s];r[s]=t[a]}this[i]=r}else{let r=e.inputNodes[i];this[i]=t[r]}}}toJSON(e){let{uuid:t,type:i}=this,r=void 0===e||"string"==typeof e;r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];function a(e){let t=[];for(let i in e){let r=e[i];delete r.metadata,t.push(r)}return t}if(void 0===s&&(s={uuid:t,type:i,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==r&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta),r){let t=a(e.textures),i=a(e.images),r=a(e.nodes);t.length>0&&(s.textures=t),i.length>0&&(s.images=i),r.length>0&&(s.nodes=r)}return s}}).captureStackTrace=!1,MR=class extends SR{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}},TR=class extends SR{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){let t=this.node.getNodeType(e),i=null;for(let r of this.convertTo.split("|"))(null===i||e.getTypeLength(t)===e.getTypeLength(r))&&(i=r);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let i=this.node,r=this.getNodeType(e),s=i.build(e,r);return e.format(s,r,t)}},CR=class extends SR{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){let i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(void 0!==r.propertyName)return e.format(r.propertyName,i,t);if("void"!==i&&"void"!==t&&this.hasDependencies(e)){let s=super.build(e,i),a=e.getVarFromNode(this,null,i),n=e.getPropertyName(a);return e.addLineFlowCode(`${n} = ${s}`,this),r.snippet=s,r.propertyName=n,e.format(r.propertyName,i,t)}}return super.build(e,t)}},AR=class extends CR{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,i)=>t+e.getTypeLength(i.getNodeType(e)),0))}generate(e,t){let i=this.getNodeType(e),r=e.getTypeLength(i),s=this.nodes,a=e.getComponentType(i),n=[],o=0;for(let t of s){if(o>=r){y(`TSL: Length of parameters exceeds maximum length of function '${i}()' type.`,this.stackTrace);break}let s,l=t.getNodeType(e),h=e.getTypeLength(l);if(o+h>r&&(y(`TSL: Length of '${i}()' data exceeds maximum length of output type.`,this.stackTrace),h=r-o,l=e.getTypeFromLength(h)),o+=h,s=t.build(e,l),e.getComponentType(l)!==a){let t=e.getTypeFromLength(h,a);s=e.format(s,l,t)}n.push(s)}let l=`${e.getType(i)}( ${n.join(", ")} )`;return e.format(l,i,t)}},NR=xR.join(""),PR=class extends SR{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(xR.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let i=this.node,r=e.getTypeLength(i.getNodeType(e)),s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let n=i.build(e,a);s=this.components.length===r&&this.components===NR.slice(0,this.components.length)?e.format(n,a,t):e.format(`${n}.${this.components}`,this.getNodeType(e),t)}else s=i.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},RR=class extends CR{static get type(){return"SetNode"}constructor(e,t,i){super(),this.sourceNode=e,this.components=t,this.targetNode=i}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:i,targetNode:r}=this,s=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),n=e.getTypeFromLength(i.length,a),o=r.build(e,n),l=t.build(e,s),h=e.getTypeLength(s),u=[];for(let e=0;e<h;e++){let t=xR[e];t===i[0]?(u.push(o),e+=i.length-1):u.push(l+"."+t)}return`${e.getType(s)}( ${u.join(", ")} )`}},ER=class extends CR{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:i}=this,r=this.getNodeType(e),s=i.build(e),a=e.getVarFromNode(this),n=e.getPropertyName(a);e.addLineFlowCode(n+" = "+s,this);let o=e.getTypeLength(r),l=[],h=0;for(let e=0;e<o;e++){let i=xR[e];i===t[h]?(l.push("1.0 - "+n+"."+i),h++):l.push(n+"."+i)}return`${e.getType(r)}( ${l.join(", ")} )`}},OR=class extends SR{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}generateNodeType(){return null===this.nodeType?WN(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=WN(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=function(e){let t="",i=new Uint8Array(e);for(let e=0;e<i.length;e++)t+=String.fromCharCode(i[e]);return btoa(t)}(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?qN(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){f("Abstract function.")}},BR=/float|u?int/,VR=class extends OR{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let i=this.getNodeType(e);return BR.test(i)&&BR.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),i,t)}},DR=class extends SR{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return(!this.structNode.isMemberNode||!1!==this.structNode.hasMember(e))&&"void"!==this.structNode.getMemberType(e,this.property)}generateNodeType(e){return!1===this.hasMember(e)?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(!1===this.hasMember(e))return"float";let i=this.getNodeType(e);return e.getStructTypeNode(i).getMemberType(e,t)}generate(e){if(!1===this.hasMember(e)){f(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+"."+this.property}},IR=null,LR=new Map,zR=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),kR=e=>zR(e).split("").sort().join(""),SR.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==IR?IR.assign(this,...e):y("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new oR),this;{let t=LR.get("assign");return this.addToStack(t(...e))}},SR.prototype.toVarIntent=function(){return this},SR.prototype.get=function(e){return new DR(this,e)},UR={},FR=["x","y","z","w"],jR=["r","g","b","a"],GR=["s","t","p","q"];for(let e=0;e<4;e++){let t=FR[e],i=jR[e],r=GR[e];YN(t,i,r);for(let s=0;s<4;s++){t=FR[e]+FR[s],i=jR[e]+jR[s],r=GR[e]+GR[s],YN(t,i,r);for(let a=0;a<4;a++){t=FR[e]+FR[s]+FR[a],i=jR[e]+jR[s]+jR[a],r=GR[e]+GR[s]+GR[a],YN(t,i,r);for(let n=0;n<4;n++)t=FR[e]+FR[s]+FR[a]+FR[n],i=jR[e]+jR[s]+jR[a]+jR[n],r=GR[e]+GR[s]+GR[a]+GR[n],YN(t,i,r)}}}for(let e=0;e<32;e++)UR[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new MR(this,new VR(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(uE(t))}};Object.defineProperties(SR.prototype,UR),WR=function(e,t=null){let i=WN(e);return"node"===i?e:null===t&&("float"===i||"boolean"===i)||i&&"shader"!==i&&"string"!==i?uE(oE(e,t)):"shader"===i?e.isFn?e:JN(e):e},qR=function(e,t=null){for(let i in e)e[i]=uE(e[i],t);return e},HR=function(e,t=null){let i=e.length;for(let r=0;r<i;r++)e[r]=uE(e[r],t);return e},$R=function(e,t=null,i=null,r=null){function s(e){return null!==r?(e=uE(Object.assign(e,r)),!0===r.intent&&(e=e.toVarIntent())):e=uE(e),e}let a,n,o,l=t;function h(t){let i;return i=l?/[a-z]/i.test(l)?l+"()":l:e.type,void 0!==n&&t.length<n?(y(`TSL: "${i}" parameter length is less than minimum required.`,new oR),t.concat(new Array(n-t.length).fill(0))):void 0!==o&&t.length>o?(y(`TSL: "${i}" parameter length exceeds limit.`,new oR),t.slice(0,o)):t}return null===t?a=(...t)=>s(new e(...pE(h(t)))):null!==i?(i=uE(i),a=(...r)=>s(new e(t,...pE(h(r)),i))):a=(...i)=>s(new e(t,...pE(h(i)))),a.setParameterLength=(...e)=>(1===e.length?n=o=e[0]:2===e.length&&([n,o]=e),a),a.setName=e=>(l=e,a),a},YR=function(e,...t){return new e(...pE(t))},XR=class extends SR{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:i}=this,r=e.getNodeProperties(t),s=e.getClosestSubBuild(t.subBuilds)||"",a=s||"default";if(r[a])return r[a];let n=e.subBuildFn,o=e.fnCall;e.subBuildFn=s,e.fnCall=this;let l=null;if(t.layout){if(i){let r=t.layout.inputs;if(XN(i)){let t=i;for(let i=0;i<r.length;i++){let r=t[i];r&&r.isNode&&r.build(e)}}else{let t=i[0];for(let i of r){let r=t[i.name];r&&r.isNode&&r.build(e)}}}let r=e.buildFunctionNode(t);e.addInclude(r);let s=i?function(e){let t;return cE(e),t=XN(e)?[...e]:e[0],t}(i):null;l=r.call(s)}else{let r=new Proxy(e,{get:(e,t,i)=>{let r;return r=Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,i),r}}),s=i?function(e){let t=0;return cE(e),new Proxy(e,{get:(i,r,s)=>{let a;if("length"===r)return a=e.length,a;if(Symbol.iterator===r)a=function*(){for(let t of e)yield uE(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){let i=e[0];a=void 0===i[r]?i[t++]:Reflect.get(i,r,s)}else e[0]instanceof SR&&(a=void 0===e[r]?e[t++]:Reflect.get(e,r,s));else a=Reflect.get(i,r,s);a=uE(a)}return a}})}(i):null,a=Array.isArray(i)?i.length>0:null!==i,n=t.jsFunc,o=a||n.length>1?n(s,r):n(r);l=uE(o)}return e.subBuildFn=n,e.fnCall=o,t.once&&(r[a]=l),l}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),i=e.getSubBuildOutput(this);return t[i]=t[i]||this.setupOutput(e),t[i].subBuild=e.getClosestSubBuild(this),t[i]}build(e,t=null){let i=null,r=e.getBuildStage(),s=e.getNodeProperties(this),a=e.getSubBuildOutput(this),n=this.getOutputNode(e),o=e.fnCall;if(e.fnCall=this,"setup"===r){let t=e.getSubBuildProperty("initialized",this);if(!0!==s[t]&&(s[t]=!0,s[a]=this.getOutputNode(e),s[a].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let i=e.getDataFromNode(t,"any");i.subBuilds=i.subBuilds||new Set;for(let e of this.shaderNode.subBuilds)i.subBuilds.add(e)}i=s[a]}else"analyze"===r?n.build(e,t):"generate"===r&&(i=n.build(e,t)||"");return e.fnCall=o,i}},KR=class extends SR{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new XR(this,e)}setup(){return this.call()}},ZR=[!1,!0],JR=[0,1,2,3],QR=[-1,-2],eE=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],tE=new Map;for(let e of ZR)tE.set(e,new VR(e));iE=new Map;for(let e of JR)iE.set(e,new VR(e,"uint"));rE=new Map([...iE].map(e=>new VR(e.value,"int")));for(let e of QR)rE.set(e,new VR(e,"int"));sE=new Map([...rE].map(e=>new VR(e.value)));for(let e of eE)sE.set(e,new VR(e));for(let e of eE)sE.set(-e,new VR(-e));aE={bool:tE,uint:iE,ints:rE,float:sE},nE=new Map([...tE,...sE]),oE=(e,t)=>nE.has(e)?nE.get(e):!0===e.isNode?e:new VR(e,t),lE=function(e,t=null){return(...i)=>{for(let t of i)if(void 0===t)return y(`TSL: Invalid parameter for the type "${e}".`,new oR),new VR(0,e);if((0===i.length||!["bool","float","int","uint"].includes(e)&&i.every(e=>{let t=typeof e;return"object"!==t&&"function"!==t}))&&(i=[qN(e,...i)]),1===i.length&&null!==t&&t.has(i[0]))return dE(t.get(i[0]));if(1===i.length){let t=oE(i[0],e);return t.nodeType===e?dE(t):dE(new TR(t,e))}let r=i.map(e=>oE(e));return dE(new AR(r,e))}},hE=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null,uE=(e,t=null)=>WR(e,t),dE=(e,t=null)=>uE(e,t).toVarIntent(),cE=(e,t=null)=>new qR(e,t),pE=(e,t=null)=>new HR(e,t),mE=(e,t=null,i=null,r=null)=>new $R(e,t,i,r),gE=(e,...t)=>new YR(e,...t),fE=(e,t=null,i=null,r={})=>new $R(e,t,i,{...r,intent:!0}),yE=(e,t)=>new Proxy(e,{get:(e,i,r)=>Reflect.get(t,i,r),set:(e,i,r)=>Reflect.set(t,i,r)}),vE=0,bE=class extends SR{constructor(e,t=null){super();let i=null;null!==t&&("object"==typeof t?i=t.return:("string"==typeof t?i=t:y("TSL: Invalid layout type.",new oR),t=null)),this.shaderNode=new ZN(e,i),null!==t&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if("object"!=typeof e.inputs){let i={name:"fn"+vE++,type:t,inputs:[]};for(let t in e)"return"!==t&&i.inputs.push({name:t,type:e[t]});e=i}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){let t=this.shaderNode.call(e);return"void"===this.shaderNode.nodeType&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return y('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}},xE=e=>{IR=e},wE=()=>IR,_E=(...e)=>IR.If(...e),SE=(...e)=>IR.Switch(...e),$N("toStack",QN),ME=new lE("color"),TE=new lE("float",aE.float),CE=new lE("int",aE.ints),AE=new lE("uint",aE.uint),NE=new lE("bool",aE.bool),PE=new lE("vec2"),RE=new lE("ivec2"),EE=new lE("uvec2"),OE=new lE("bvec2"),BE=new lE("vec3"),VE=new lE("ivec3"),DE=new lE("uvec3"),IE=new lE("bvec3"),LE=new lE("vec4"),zE=new lE("ivec4"),kE=new lE("uvec4"),UE=new lE("bvec4"),FE=new lE("mat2"),jE=new lE("mat3"),GE=new lE("mat4"),$N("toColor",ME),$N("toFloat",TE),$N("toInt",CE),$N("toUint",AE),$N("toBool",NE),$N("toVec2",PE),$N("toIVec2",RE),$N("toUVec2",EE),$N("toBVec2",OE),$N("toVec3",BE),$N("toIVec3",VE),$N("toUVec3",DE),$N("toBVec3",IE),$N("toVec4",LE),$N("toIVec4",zE),$N("toUVec4",kE),$N("toBVec4",UE),$N("toMat2",FE),$N("toMat3",jE),$N("toMat4",GE),WE=mE(MR).setParameterLength(2),qE=(e,t)=>new TR(uE(e),t),HE=(e,t)=>new PR(uE(e),t),$N("element",WE),$N("convert",qE),$E=e=>(f("TSL: append() has been renamed to Stack().",new oR),QN(e)),$N("append",e=>(f("TSL: .append() has been renamed to .toStack().",new oR),QN(e))),XE=(e,t,i=null)=>new YE(e,t,!1,i),KE=(e,t,i=null)=>new YE(e,t,!0,i),ZE=gE(YE=class extends SR{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1,r=null){super(e),this.name=t,this.varying=i,this.placeholderNode=uE(r),this.isPropertyNode=!0,this.global=!0}getNodeType(e){let t=super.getNodeType(e);return"output"===t?e.getOutputType():t}customCacheKey(){return lR(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(!0===this.varying)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),null!==this.placeholderNode&&!1===e.hasWriteUsage(this)){let i=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${i}`,this)}return e.getPropertyName(t)}},"vec4","DiffuseColor"),JE=gE(YE,"vec3","DiffuseContribution"),QE=gE(YE,"vec3","EmissiveColor"),eO=gE(YE,"float","Roughness"),tO=gE(YE,"float","Metalness"),iO=gE(YE,"float","Clearcoat"),rO=gE(YE,"float","ClearcoatRoughness"),sO=gE(YE,"vec3","Sheen"),aO=gE(YE,"float","SheenRoughness"),nO=gE(YE,"float","Iridescence"),oO=gE(YE,"float","IridescenceIOR"),lO=gE(YE,"float","IridescenceThickness"),hO=gE(YE,"float","AlphaT"),uO=gE(YE,"float","Anisotropy"),dO=gE(YE,"vec3","AnisotropyT"),cO=gE(YE,"vec3","AnisotropyB"),pO=gE(YE,"color","SpecularColor"),mO=gE(YE,"color","SpecularColorBlended"),gO=gE(YE,"float","SpecularF90"),fO=gE(YE,"float","Shininess"),yO=gE(YE,"output","Output"),vO=gE(YE,"float","dashSize"),bO=gE(YE,"float","gapSize"),xO=gE(YE,"float","pointWidth"),wO=gE(YE,"float","IOR"),_O=gE(YE,"float","Transmission"),SO=gE(YE,"float","Thickness"),MO=gE(YE,"float","AttenuationDistance"),TO=gE(YE,"color","AttenuationColor"),CO=gE(YE,"float","Dispersion"),AO=gE(YE,"float","AmbientOcclusion",!1,1),NO=class extends SR{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1,r=null){super("string"),this.name=e,this.shared=t,this.order=i,this.updateType=r,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},PO=(e,t=1,i=null)=>new NO(e,!1,t,i),EO=(RO=(e,t=0,i=null)=>new NO(e,!0,t,i))("frame",0,mR.FRAME),OO=RO("render",0,mR.RENDER),BO=PO("object",1,mR.OBJECT),VO=class extends OR{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=BO}setName(e){return this.name=e,this}label(e){return f('TSL: "label()" has been deprecated. Use "setName()" instead.',new oR),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let i=e(t,this);void 0!==i&&(this.value=i)},t)}getInputType(e){let t=super.getInputType(e);return"bool"===t&&(t="uint"),t}generate(e,t){let i=this.getNodeType(e),r=this.getUniformHash(e),s=e.getNodeFromHash(r);void 0===s&&(e.setHashNode(this,r),s=this);let a=s.getInputType(e),n=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.nodeName),o=e.getPropertyName(n);void 0!==e.context.nodeName&&delete e.context.nodeName;let l=o;if("bool"===i){let t=e.getDataFromNode(this),r=t.propertyName;if(void 0===r){let s=e.getVarFromNode(this,null,"bool");r=e.getPropertyName(s),t.propertyName=r,l=e.format(o,a,i),e.addLineFlowCode(`${r} = ${l}`,this)}l=r}return e.format(l,i,t)}},DO=(e,t)=>{let i=hE(t||e);if(i===e&&(e=qN(i)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new VO(e,i)},IO=class extends CR{static get type(){return"ArrayNode"}constructor(e,t,i=null){super(e),this.count=t,this.values=i,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return null===this.nodeType?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return null===this.nodeType?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},LO=(...e)=>{let t;if(1===e.length){let i=e[0];t=new IO(null,i.length,i)}else{let i=e[0],r=e[1];t=new IO(i,r)}return uE(t)},$N("toArray",(e,t)=>LO(Array(t).fill(e))),$N("assign",zO=mE(class extends CR{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){let{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){let i=e.getTypeLength(t.node.getNodeType(e));return xR.join("").slice(0,i)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:i}=this,r=t.getScope();e.getDataFromNode(r).assign=!0;let s=e.getNodeProperties(this);s.sourceNode=i,s.targetNode=t.context({assign:!0})}generate(e,t){let i,{targetNode:r,sourceNode:s}=e.getNodeProperties(this),a=this.needsSplitAssign(e),n=r.build(e),o=r.getNodeType(e),l=s.build(e,o),h=s.getNodeType(e),u=e.getDataFromNode(this);if(!0===u.initialized)"void"!==t&&(i=n);else if(a){let s=e.getVarFromNode(this,null,o),a=e.getPropertyName(s);e.addLineFlowCode(`${a} = ${l}`,this);let h=r.node,u=h.node.context({assign:!0}).build(e);for(let t=0;t<h.components.length;t++){let i=h.components[t];e.addLineFlowCode(`${u}.${i} = ${a}[ ${t} ]`,this)}"void"!==t&&(i=n)}else i=`${n} = ${l}`,("void"===t||"void"===h)&&(e.addLineFlowCode(i,this),"void"!==t&&(i=n));return u.initialized=!0,e.format(i,o,t)}}).setParameterLength(2)),kO=class extends CR{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}generateNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],i=this.functionNode,r=i.getInputs(e),s=this.parameters,a=(t,i)=>{let r,s=i.type;return r="pointer"===s?"&"+t.build(e):t.build(e,s),r};if(Array.isArray(s)){if(s.length>r.length)y("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=r.length;else if(s.length<r.length)for(y("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<r.length;)s.push(TE(0));for(let e=0;e<s.length;e++)t.push(a(s[e],r[e]))}else for(let e of r){let i=s[e.name];void 0!==i?t.push(a(i,e)):(y(`TSL: Input '${e.name}' not found in 'Fn()'.`),t.push(a(TE(0),e)))}return`${i.build(e,"property")}( ${t.join(", ")} )`}},$N("call",UO=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?pE(t):cE(t[0]),new kO(uE(e),t))),FO={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"},GO=fE(jO=class extends CR{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let s=new jO(e,t,i);for(let t=0;t<r.length-1;t++)s=new jO(e,s,r[t]);t=s,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(FO[this.op],t)}generateNodeType(e,t=null){let i=this.op,r=this.aNode,s=this.bNode,a=r.getNodeType(e),n=s?s.getNodeType(e):null;if("void"===a||"void"===n)return t||"void";if("%"===i)return a;if("~"===i||"&"===i||"|"===i||"^"===i||">>"===i||"<<"===i)return e.getIntegerType(a);if("&&"===i||"||"===i||"^^"===i)return"bool";if("!"===i){let t=e.getTypeLength(a);return t>1?`bvec${t}`:"bool"}if("=="===i||"!="===i||"<"===i||">"===i||"<="===i||">="===i){let t=Math.max(e.getTypeLength(a),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(a)){if("float"===n)return a;if(e.isVector(n))return e.getVectorFromMatrix(a);if(e.isMatrix(n))return a}else if(e.isMatrix(n)){if("float"===a)return n;if(e.isVector(a))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(a)?n:a}generate(e,t){let i=this.op,{aNode:r,bNode:s}=this,a=this.getNodeType(e,t),n=null,o=null;"void"!==a?(n=r.getNodeType(e),o=s?s.getNodeType(e):null,"<"===i||">"===i||"<="===i||">="===i||"=="===i||"!="===i?e.isVector(n)?o=n:e.isVector(o)?n=o:n!==o&&(n=o="float"):">>"===i||"<<"===i?(n=a,o=e.changeComponentType(o,"uint")):"%"===i?(n=a,o=e.isInteger(n)&&e.isInteger(o)?o:n):e.isMatrix(n)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(n):e.isMatrix(o)||(n=o=a):n=e.isMatrix(o)?"float"===n?"float":e.isVector(n)?e.getVectorFromMatrix(o):o=a:o=a):n=o=a;let l=r.build(e,n),h=s?s.build(e,o):null,u=e.getFunctionOperator(i);if("void"!==t){let r=e.renderer.coordinateSystem===jr;if("=="===i||"!="===i||"<"===i||">"===i||"<="===i||">="===i)return r&&e.isVector(n)?e.format(`${this.getOperatorMethod(e,t)}( ${l}, ${h} )`,a,t):e.format(`( ${l} ${i} ${h} )`,a,t);if("%"===i)return e.isInteger(o)?e.format(`( ${l} % ${h} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${l}, ${h} )`,a,t);if("!"===i)return r&&e.isVector(n)?e.format(`not( ${l} )`,t):e.format(`( ${i} ${l} )`,n,t);if("~"===i)return e.format(`( ${i} ${l} )`,n,t);if(u)return e.format(`${u}( ${l}, ${h} )`,a,t);if(e.isMatrix(n)&&"float"===o)return e.format(`( ${h} ${i} ${l} )`,a,t);if("float"===n&&e.isMatrix(o))return e.format(`${l} ${i} ${h}`,a,t);{let s=`( ${l} ${i} ${h} )`;return!r&&"bool"===a&&e.isVector(n)&&e.isVector(o)&&(s=`all${s}`),e.format(s,a,t)}}if("void"!==n)return u?e.format(`${u}( ${l}, ${h} )`,a,t):e.isMatrix(n)&&"float"===o?e.format(`${h} ${i} ${l}`,a,t):e.format(`${l} ${i} ${h}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},"+").setParameterLength(2,1/0).setName("add"),WO=fE(jO,"-").setParameterLength(2,1/0).setName("sub"),qO=fE(jO,"*").setParameterLength(2,1/0).setName("mul"),HO=fE(jO,"/").setParameterLength(2,1/0).setName("div"),$O=fE(jO,"%").setParameterLength(2).setName("mod"),YO=fE(jO,"==").setParameterLength(2).setName("equal"),XO=fE(jO,"!=").setParameterLength(2).setName("notEqual"),KO=fE(jO,"<").setParameterLength(2).setName("lessThan"),ZO=fE(jO,">").setParameterLength(2).setName("greaterThan"),JO=fE(jO,"<=").setParameterLength(2).setName("lessThanEqual"),QO=fE(jO,">=").setParameterLength(2).setName("greaterThanEqual"),eB=fE(jO,"&&").setParameterLength(2,1/0).setName("and"),tB=fE(jO,"||").setParameterLength(2,1/0).setName("or"),iB=fE(jO,"!").setParameterLength(1).setName("not"),rB=fE(jO,"^^").setParameterLength(2).setName("xor"),sB=fE(jO,"&").setParameterLength(2).setName("bitAnd"),aB=fE(jO,"~").setParameterLength(1).setName("bitNot"),nB=fE(jO,"|").setParameterLength(2).setName("bitOr"),oB=fE(jO,"^").setParameterLength(2).setName("bitXor"),lB=fE(jO,"<<").setParameterLength(2).setName("shiftLeft"),hB=fE(jO,">>").setParameterLength(2).setName("shiftRight"),uB=JN(([e])=>(e.addAssign(1),e)),dB=JN(([e])=>(e.subAssign(1),e)),cB=JN(([e])=>{let t=CE(e).toConst();return e.addAssign(1),t}),pB=JN(([e])=>{let t=CE(e).toConst();return e.subAssign(1),t}),$N("add",GO),$N("sub",WO),$N("mul",qO),$N("div",HO),$N("mod",$O),$N("equal",YO),$N("notEqual",XO),$N("lessThan",KO),$N("greaterThan",ZO),$N("lessThanEqual",JO),$N("greaterThanEqual",QO),$N("and",eB),$N("or",tB),$N("not",iB),$N("xor",rB),$N("bitAnd",sB),$N("bitNot",aB),$N("bitOr",nB),$N("bitXor",oB),$N("shiftLeft",lB),$N("shiftRight",hB),$N("incrementBefore",uB),$N("decrementBefore",dB),$N("increment",cB),$N("decrement",pB),(mB=class extends CR{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){if(super(),(e===mB.MAX||e===mB.MIN)&&arguments.length>3){let s=new mB(e,t,i);for(let t=3;t<arguments.length-1;t++)s=new mB(e,s,arguments[t]);t=s,i=arguments[arguments.length-1],r=null}this.method=e,this.aNode=t,this.bNode=i,this.cNode=r,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),n=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>n?t:a>n?i:n>s?r:t}generateNodeType(e){let t=this.method;return t===mB.LENGTH||t===mB.DISTANCE||t===mB.DOT?"float":t===mB.CROSS?"vec3":t===mB.ALL||t===mB.ANY?"bool":t===mB.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:t,bNode:i,method:r}=this,s=null;if(r===mB.ONE_MINUS)s=WO(1,t);else if(r===mB.RECIPROCAL)s=HO(1,t);else if(r===mB.DIFFERENCE)s=$B(WO(t,i));else if(r===mB.TRANSFORM_DIRECTION){let r,a;e.isMatrix(t.getNodeType(e))?(r=t,a=i):(r=i,a=t),s=BB(qO(r,LE(BE(a),0)).xyz)}return null!==s?s:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let i=this.method,r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,n=this.bNode,o=this.cNode,l=e.renderer.coordinateSystem;if(i===mB.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);{let h=[];return i===mB.CROSS?h.push(a.build(e,r),n.build(e,r)):l===jr&&i===mB.STEP?h.push(a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":s),n.build(e,s)):l!==jr||i!==mB.MIN&&i!==mB.MAX?i===mB.REFRACT?h.push(a.build(e,s),n.build(e,s),o.build(e,"float")):i===mB.MIX?h.push(a.build(e,s),n.build(e,s),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":s)):(l===Gr&&i===mB.ATAN&&null!==n&&(i="atan2"),"fragment"!==e.shaderStage&&(i===mB.DFDX||i===mB.DFDY)&&(f(`TSL: '${i}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),h.push(a.build(e,s)),null!==n&&h.push(n.build(e,s)),null!==o&&h.push(o.build(e,s))):h.push(a.build(e,s),n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":s)),e.format(`${e.getMethod(i,r)}( ${h.join(", ")} )`,r,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}).ALL="all",mB.ANY="any",mB.RADIANS="radians",mB.DEGREES="degrees",mB.EXP="exp",mB.EXP2="exp2",mB.LOG="log",mB.LOG2="log2",mB.SQRT="sqrt",mB.INVERSE_SQRT="inversesqrt",mB.FLOOR="floor",mB.CEIL="ceil",mB.NORMALIZE="normalize",mB.FRACT="fract",mB.SIN="sin",mB.SINH="sinh",mB.COS="cos",mB.COSH="cosh",mB.TAN="tan",mB.TANH="tanh",mB.ASIN="asin",mB.ASINH="asinh",mB.ACOS="acos",mB.ACOSH="acosh",mB.ATAN="atan",mB.ATANH="atanh",mB.ABS="abs",mB.SIGN="sign",mB.LENGTH="length",mB.NEGATE="negate",mB.ONE_MINUS="oneMinus",mB.DFDX="dFdx",mB.DFDY="dFdy",mB.ROUND="round",mB.RECIPROCAL="reciprocal",mB.TRUNC="trunc",mB.FWIDTH="fwidth",mB.TRANSPOSE="transpose",mB.DETERMINANT="determinant",mB.INVERSE="inverse",mB.EQUALS="equals",mB.MIN="min",mB.MAX="max",mB.STEP="step",mB.REFLECT="reflect",mB.DISTANCE="distance",mB.DIFFERENCE="difference",mB.DOT="dot",mB.CROSS="cross",mB.POW="pow",mB.TRANSFORM_DIRECTION="transformDirection",mB.MIX="mix",mB.CLAMP="clamp",mB.REFRACT="refract",mB.SMOOTHSTEP="smoothstep",mB.FACEFORWARD="faceforward",gB=TE(1e-6),fB=TE(1e6),yB=TE(Math.PI),vB=TE(2*Math.PI),bB=TE(2*Math.PI),xB=TE(.5*Math.PI),wB=fE(mB,mB.ALL).setParameterLength(1),_B=fE(mB,mB.ANY).setParameterLength(1),SB=fE(mB,mB.RADIANS).setParameterLength(1),MB=fE(mB,mB.DEGREES).setParameterLength(1),TB=fE(mB,mB.EXP).setParameterLength(1),CB=fE(mB,mB.EXP2).setParameterLength(1),AB=fE(mB,mB.LOG).setParameterLength(1),NB=fE(mB,mB.LOG2).setParameterLength(1),PB=fE(mB,mB.SQRT).setParameterLength(1),RB=fE(mB,mB.INVERSE_SQRT).setParameterLength(1),EB=fE(mB,mB.FLOOR).setParameterLength(1),OB=fE(mB,mB.CEIL).setParameterLength(1),BB=fE(mB,mB.NORMALIZE).setParameterLength(1),VB=fE(mB,mB.FRACT).setParameterLength(1),DB=fE(mB,mB.SIN).setParameterLength(1),IB=fE(mB,mB.SINH).setParameterLength(1),LB=fE(mB,mB.COS).setParameterLength(1),zB=fE(mB,mB.COSH).setParameterLength(1),kB=fE(mB,mB.TAN).setParameterLength(1),UB=fE(mB,mB.TANH).setParameterLength(1),FB=fE(mB,mB.ASIN).setParameterLength(1),jB=fE(mB,mB.ASINH).setParameterLength(1),GB=fE(mB,mB.ACOS).setParameterLength(1),WB=fE(mB,mB.ACOSH).setParameterLength(1),qB=fE(mB,mB.ATAN).setParameterLength(1,2),HB=fE(mB,mB.ATANH).setParameterLength(1),$B=fE(mB,mB.ABS).setParameterLength(1),YB=fE(mB,mB.SIGN).setParameterLength(1),XB=fE(mB,mB.LENGTH).setParameterLength(1),KB=fE(mB,mB.NEGATE).setParameterLength(1),ZB=fE(mB,mB.ONE_MINUS).setParameterLength(1),JB=fE(mB,mB.DFDX).setParameterLength(1),QB=fE(mB,mB.DFDY).setParameterLength(1),eV=fE(mB,mB.ROUND).setParameterLength(1),tV=fE(mB,mB.RECIPROCAL).setParameterLength(1),iV=fE(mB,mB.TRUNC).setParameterLength(1),rV=fE(mB,mB.FWIDTH).setParameterLength(1),sV=fE(mB,mB.TRANSPOSE).setParameterLength(1),aV=fE(mB,mB.DETERMINANT).setParameterLength(1),nV=fE(mB,mB.INVERSE).setParameterLength(1),oV=fE(mB,mB.MIN).setParameterLength(2,1/0),lV=fE(mB,mB.MAX).setParameterLength(2,1/0),hV=fE(mB,mB.STEP).setParameterLength(2),uV=fE(mB,mB.REFLECT).setParameterLength(2),dV=fE(mB,mB.DISTANCE).setParameterLength(2),cV=fE(mB,mB.DIFFERENCE).setParameterLength(2),pV=fE(mB,mB.DOT).setParameterLength(2),mV=fE(mB,mB.CROSS).setParameterLength(2),gV=fE(mB,mB.POW).setParameterLength(2),fV=e=>qO(e,e),yV=e=>qO(e,e,e),vV=e=>qO(e,e,e,e),bV=fE(mB,mB.TRANSFORM_DIRECTION).setParameterLength(2),xV=(e,t)=>BB(qO(t,LE(BE(e),0)).xyz),wV=(e,t)=>BB(LE(BE(e),0).mul(t).xyz),_V=e=>qO(YB(e),gV($B(e),1/3)),SV=e=>pV(e,e),MV=fE(mB,mB.MIX).setParameterLength(3),TV=(e,t=0,i=1)=>new mB(mB.CLAMP,uE(e),uE(t),uE(i)),CV=e=>TV(e),AV=fE(mB,mB.REFRACT).setParameterLength(3),NV=fE(mB,mB.SMOOTHSTEP).setParameterLength(3),PV=fE(mB,mB.FACEFORWARD).setParameterLength(3),RV=JN(([e])=>{let t=pV(e.xy,PE(12.9898,78.233)),i=$O(t,yB);return VB(DB(i).mul(43758.5453))}),EV=(e,t,i)=>MV(t,i,e),OV=(e,t,i)=>NV(t,i,e),BV=(e,t)=>hV(t,e),VV=PV,DV=RB,$N("all",wB),$N("any",_B),$N("radians",SB),$N("degrees",MB),$N("exp",TB),$N("exp2",CB),$N("log",AB),$N("log2",NB),$N("sqrt",PB),$N("inverseSqrt",RB),$N("floor",EB),$N("ceil",OB),$N("normalize",BB),$N("fract",VB),$N("sin",DB),$N("sinh",IB),$N("cos",LB),$N("cosh",zB),$N("tan",kB),$N("tanh",UB),$N("asin",FB),$N("asinh",jB),$N("acos",GB),$N("acosh",WB),$N("atan",qB),$N("atanh",HB),$N("abs",$B),$N("sign",YB),$N("length",XB),$N("lengthSq",SV),$N("negate",KB),$N("oneMinus",ZB),$N("dFdx",JB),$N("dFdy",QB),$N("round",eV),$N("reciprocal",tV),$N("trunc",iV),$N("fwidth",rV),$N("min",oV),$N("max",lV),$N("step",BV),$N("reflect",uV),$N("distance",dV),$N("dot",pV),$N("cross",mV),$N("pow",gV),$N("pow2",fV),$N("pow3",yV),$N("pow4",vV),$N("transformDirection",bV),$N("transformNormalByViewMatrix",xV),$N("transformNormalByInverseViewMatrix",wV),$N("mix",EV),$N("clamp",TV),$N("refract",AV),$N("smoothstep",OV),$N("faceForward",PV),$N("difference",cV),$N("saturate",CV),$N("cbrt",_V),$N("transpose",sV),$N("determinant",aV),$N("inverse",nV),$N("rand",RV),$N("select",IV=mE(class extends SR{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}generateNodeType(e){let{ifNode:t,elseNode:i}=e.getNodeProperties(this);if(void 0===t)return e.flowBuildStage(this,"setup"),this.getNodeType(e);let r=t.getNodeType(e);if(null!==i){let t=i.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode,i=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,s=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=s,null!==r&&(e.getDataFromNode(r).parentNodeBlock=s);let a=e.context.uniformFlow,n=e.getNodeProperties(this);n.condNode=t,n.ifNode=a?i:i.context({nodeBlock:i}),n.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){let i=this.getNodeType(e),r=e.getDataFromNode(this);if(void 0!==r.nodeProperty)return r.nodeProperty;let{condNode:s,ifNode:a,elseNode:n}=e.getNodeProperties(this),o=e.currentFunctionNode,l="void"!==t,h=l?XE(i).build(e):"";r.nodeProperty=h;let u=s.build(e,"bool");if(e.context.uniformFlow&&null!==n){let r=a.build(e,i),s=n.build(e,i),o=e.getTernary(u,r,s);return e.format(o,i,t)}e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,i);if(d&&(l?d=h+" = "+d+";":(d="return "+d+";",null===o&&(f("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),d="// "+d))),e.removeFlowTab().addFlowCode(e.tab+"\t"+d+"\n\n"+e.tab+"}"),null!==n){e.addFlowCode(" else {\n\n").addFlowTab();let t=n.build(e,i);t&&(l?t=h+" = "+t+";":(t="return "+t+";",null===o&&(f("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(h,i,t)}}).setParameterLength(2,3)),LV=class extends SR{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{!0===t.isContextNode&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let i=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(i),r}},kV=e=>zV(e,{uniformFlow:!0}),UV=(e,t)=>zV(e,{nodeName:t}),$N("context",zV=(e=null,t={})=>{let i=e;return(null===i||!0!==i.isNode)&&(t=i||t,i=null),new LV(i,t)}),$N("label",iP),$N("uniformFlow",kV),$N("setName",UV),$N("builtinShadowContext",(e,t,i)=>eP(t,i,e)),$N("builtinAOContext",(e,t)=>tP(t,e)),jV=mE(FV=class extends SR{static get type(){return"VarNode"}constructor(e,t=null,i=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=i,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return!0!==e.getDataFromNode(this).forceDeclaration&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0],i=this.getShared(t);if(this!==i)return i.build(...e);if(!1===this._hasStack(t)&&"setup"===t.buildStage&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop&&(t.getDataFromNode(this).forceDeclaration=!0,e=!0);let i=t.getBaseStack();e?i.addToStackBefore(this):i.addToStack(this)}return this.isIntent(t)&&!0!==this.isAssign(t)?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:i,readOnly:r}=this,{renderer:s}=e,a=!0===s.backend.isWebGPUBackend,n=!1,o=!1;r&&(n=e.isDeterministic(t),o=a?r:n);let l=this.getNodeType(e);if("void"==l)return!0!==this.isIntent(e)&&y('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);let h=e.getVectorType(l),u=t.build(e,h),d=e.getVarFromNode(this,i,h,void 0,o),c=e.getPropertyName(d),p=c;if(o)if(a)p=n?`const ${c}`:`let ${c}`;else{let i=t.getArrayCount(e);p=`const ${e.getVar(d.type,c,i)}`}return e.addLineFlowCode(`${p} = ${u}`,this),c}_hasStack(e){return void 0!==e.getDataFromNode(this).stack}}),WV=(e,t=null)=>jV(e,t,!0).toStack(),qV=e=>jV(e).setIntent(!0).toStack(),$N("toVar",GV=(e,t=null)=>jV(e,t).toStack()),$N("toConst",WV),$N("toVarIntent",qV),HV=class extends SR{static get type(){return"SubBuild"}constructor(e,t,i=null){super(i),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(null!==this.nodeType)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let i=this.node.build(e,...t);return e.removeSubBuild(),i}},$V=(e,t,i=null)=>new HV(uE(e),t,i),YV=mE(class extends SR{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=$V(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),i=t.varying;if(void 0===i){let r=this.name,s=this.getNodeType(e),a=this.interpolationType,n=this.interpolationSampling;t.varying=i=e.getVaryingFromNode(this,r,s,a,n),t.node=$V(this.node,"VERTEX")}return i.needsInterpolation||(i.needsInterpolation="fragment"===e.shaderStage),i}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(pR.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(pR.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty("property",e.currentStack),i=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===i[t]){let s=this.getNodeType(e),a=e.getPropertyName(r,pR.VERTEX);if(e.shaderStage===pR.VERTEX){let t=i.node.build(e,s);e.addLineFlowCode(`${a} = ${t}`,this)}else e.flowNodeFromShaderStage(pR.VERTEX,i.node,s,a);i[t]=a}return e.getPropertyName(r)}}).setParameterLength(1,2),XV=e=>YV(e),$N("toVarying",YV),$N("toVertexStage",XV),KV=JN(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),i=e.mul(.0773993808),r=e.lessThanEqual(.04045);return MV(t,i,r)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),ZV=JN(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),i=e.mul(12.92),r=e.lessThanEqual(.0031308);return MV(t,i,r)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),JV="WorkingColorSpace",QV=class extends CR{static get type(){return"ColorSpaceNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this.source=t,this.target=i}resolveColorSpace(e,t){return t===JV?ms.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,i=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),s=t;return!1===ms.enabled||i===r||!i||!r||(ms.getTransfer(i)===cr&&(s=LE(KV(s.rgb),s.a)),ms.getPrimaries(i)!==ms.getPrimaries(r)&&(s=LE(jE(ms._getMatrix(new us,i,r)).mul(s.rgb),s.a)),ms.getTransfer(r)===cr&&(s=LE(ZV(s.rgb),s.a))),s}},tD=(e,t)=>new QV(uE(e),t,JV),iD=(e,t,i)=>new QV(uE(e),t,i),$N("workingToColorSpace",eD=(e,t)=>new QV(uE(e),JV,t)),$N("colorSpaceToWorking",tD),rD=class extends MR{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),i=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,i,r)}},sD=class extends SR{static get type(){return"ReferenceBaseNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=mR.OBJECT}setGroup(e){return this.group=e,this}element(e){return new rD(this,uE(e))}setNodeType(e){let t=DO(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,i=e[t[0]];for(let e=1;e<t.length;e++)i=i[t[e]];return i}updateReference(e){return this.reference=null!==this.object?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},aD=(e,t,i)=>new sD(e,t,i),nD=class extends sD{static get type(){return"RendererReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.renderer=i,this.setGroup(OO)}updateReference(e){return this.reference=null!==this.renderer?this.renderer:e.renderer,this.reference}},oD=(e,t,i=null)=>new nD(e,t,i),lD=class extends CR{static get type(){return"ToneMappingNode"}constructor(e,t=uD,i=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=i}customCacheKey(){return uR(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,i=this._toneMapping;if(i===Ct)return t;let r=null,s=e.renderer.library.getToneMappingFunction(i);return null!==s?r=LE(s(t.rgb,this.exposureNode),t.a):(y("ToneMappingNode: Unsupported Tone Mapping configuration.",i),r=t),r}},hD=(e,t,i)=>new lD(e,uE(t),uE(i)),uD=oD("toneMappingExposure","float"),$N("toneMapping",(e,t,i)=>hD(t,i,e)),dD=new WeakMap,cD=class extends OR{static get type(){return"BufferAttributeNode"}constructor(e,t=null,i=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=i,this.bufferOffset=r,this.usage=Ur,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(0===this.bufferStride&&0===this.bufferOffset){let i=e.globalCache.getData(this.value);void 0===i&&(i={node:this},e.globalCache.setData(this.value,i)),t=i.node.id}else t=this.id;return String(t)}generateNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;let t,i=this.getNodeType(e),r=e.getTypeLength(i),s=this.value,a=this.bufferStride||r,n=this.bufferOffset;t=!0===s.isInterleavedBuffer?s:!0===s.isBufferAttribute?rP(s.array,a):rP(s,a);let o=new ln(t,r,n);t.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),i=e.context.nodeName;void 0!==i&&delete e.context.nodeName;let r=e.getBufferAttributeFromNode(this,t,i),s=e.getPropertyName(r),a=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,a=s;else{let r;i&&(r=i+"Varying"),a=YV(this,r).build(e,t)}return a}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}},pD=(e,t=null,i=0,r=0)=>sP(e,t,i,r),mD=(e,t=null,i=0,r=0)=>sP(e,t,i,r,Fr),gD=(e,t=null,i=0,r=0)=>sP(e,t,i,r,Ur,!0),fD=(e,t=null,i=0,r=0)=>sP(e,t,i,r,Fr,!0),$N("toAttribute",e=>pD(e.value)),(yD=class extends SR{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){let t,i,r=this.getNodeType(e),s=this.scope;if(s===yD.VERTEX)t=e.getVertexIndex();else if(s===yD.INSTANCE)t=e.getInstanceIndex();else if(s===yD.DRAW)t=e.getDrawIndex();else if(s===yD.INVOCATION_LOCAL)t=e.getInvocationLocalIndex();else if(s===yD.INVOCATION_SUBGROUP)t=e.getInvocationSubgroupIndex();else{if(s!==yD.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+s);t=e.getSubgroupIndex()}return i="vertex"===e.shaderStage||"compute"===e.shaderStage?t:YV(this).build(e,r),i}}).VERTEX="vertex",yD.INSTANCE="instance",yD.SUBGROUP="subgroup",yD.INVOCATION_LOCAL="invocationLocal",yD.INVOCATION_SUBGROUP="invocationSubgroup",yD.DRAW="draw",vD=gE(yD,yD.VERTEX),bD=gE(yD,yD.INSTANCE),xD=gE(yD,yD.SUBGROUP),wD=gE(yD,yD.INVOCATION_SUBGROUP),_D=gE(yD,yD.INVOCATION_LOCAL),SD=gE(yD,yD.DRAW),MD=class extends SR{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=mR.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return f('TSL: "label()" has been deprecated. Use "setName()" instead.',new oR),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){null!==this.count&&null===this.countNode&&(this.countNode=DO(this.count,"uint").onObjectUpdate(()=>this.count));let t=this.computeNode.build(e);return t&&(e.getNodeProperties(this).outputComputeNode=t.outputNode,t.outputNode=null),t}generate(e,t){let{shaderStage:i}=e;if("compute"===i){let t=this.computeNode.build(e,"void");if(""!==t&&e.addLineFlowCode(t,this),null!==this.count&&!0===e.allowEarlyReturns){let t=this.countNode.build(e,"uint"),i=bD.build(e,"uint");e.flow.code=`${e.tab}if ( ${i} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{let i=e.getNodeProperties(this).outputComputeNode;if(i)return i.build(e,t)}}},TD=(e,t=[64])=>{(0===t.length||t.length>3)&&y("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new oR);for(let e=0;e<t.length;e++){let i=t[e];("number"!=typeof i||i<=0||!Number.isInteger(i))&&y(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new oR)}for(;t.length<3;)t.push(1);return new MD(uE(e),t)},$N("compute",CD=(e,t,i)=>{let r=TD(e,i);return"number"==typeof t?r.count=t:r.dispatchSize=t,r}),$N("computeKernel",TD),AD=class extends SR{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){let t=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let i=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let s=this.node.build(e,...t);return e.setCache(i),s}setParent(e){return this.parent=e,this}getParent(){return this.parent}},ND=e=>new AD(uE(e)),$N("cache",aP),$N("isolate",ND),$N("bypass",PD=mE(class extends SR{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2)),$N("remap",RD=JN(([e,t,i,r=TE(0),s=TE(1),a=NE(!1)])=>{let n=e.sub(t).div(i.sub(t));return KN(a)&&(n=n.clamp()),n.mul(s.sub(r)).add(r)})),$N("remapClamp",nP),OD=mE(ED=class extends SR{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){let i=this.getNodeType(e),r=this.snippet;if("void"!==i)return e.format(r,i,t);e.addLineFlowCode(r,this)}}).setParameterLength(1,2),VD=()=>OD("return").toStack(),$N("discard",BD=e=>(e?IV(e,OD("discard")):OD("discard")).toStack()),DD=JN(([e])=>LE(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),ID=JN(([e])=>e.a.equal(0).select(LE(0),LE(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"}),LD=class extends CR{static get type(){return"RenderOutputNode"}constructor(e,t,i){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=i,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=LE(t.rgb,t.a.clamp(0,1)),t=ID(t);let i=(null!==this._toneMapping?this._toneMapping:e.toneMapping)||Ct,r=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||lr;return i!==Ct&&(t=t.toneMapping(i)),r!==lr&&r!==ms.workingColorSpace&&(t=t.workingToColorSpace(r)),t=DD(t),t}},$N("renderOutput",zD=(e,t=null,i=null)=>new LD(uE(e),t,i)),kD=class extends CR{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,i=this.node.build(e);if(null!==t)t(e,i);else{let t="--- TSL debug - "+e.shaderStage+" shader ---",r="-".repeat(t.length),s="";s+="// #"+t+"#\n",s+=e.flow.code.replace(/^\t/gm,"")+"\n",s+="/* ... */ "+i+" /* ... */\n",s+="// #"+r+"#\n",m(s)}return i}},$N("debug",UD=(e,t=null)=>new kD(uE(e),t).toStack()),FD=class extends Kr{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},jD=class extends SR{static get type(){return"InspectorNode"}constructor(e,t="",i=null){super(),this.node=e,this.name=t,this.callback=i,this.updateType=mR.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==FD&&v('TSL: ".toInspector()" is only available with WebGPU.'),t}},$N("toInspector",oP),GD=class extends SR{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(null===t){let i=this.getAttributeName(e);if(e.hasGeometryAttribute(i)){let r=e.geometry.getAttribute(i);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),i=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){let r=e.geometry.getAttribute(t),s=e.getTypeFromAttribute(r),a=e.getAttribute(t,s);return"vertex"===e.shaderStage?e.format(a.name,s,i):YV(this).build(e,i)}return f(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(i)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},WD=(e,t=null)=>new GD(e,t),qD=(e=0)=>WD("uv"+(e>0?e:""),"vec2"),HD=mE(class extends SR{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let i=this.textureNode.build(e,"property"),r=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${i}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),$D=mE(class extends VO{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=mR.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,i=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(i&&void 0!==i.width){let{width:e,height:t}=i;this.value=Math.log2(Math.max(e,t))}}}).setParameterLength(1),YD=class extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}},XD=new ws,ZD=mE(KD=class extends VO{static get type(){return"TextureNode"}constructor(e=XD,t=null,i=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=i,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=mR.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return!0===this.value.isDepthTexture?null===this.gatherNode?"float":"vec4":this.value.type===ei?"uvec4":this.value.type===Qt?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return qD(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=DO(this.value.matrix)),this._matrixUniform.mul(BE(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=DO(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(CE(HD(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let i=this.value;if(!i||!0!==i.isTexture)throw new YD("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=JN(()=>{let t=this.uvNode;return(null===t||!0===e.context.forceUVContext)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),!0===this.updateMatrix&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=null!==this._matrixUniform||null!==this._flipYUniform?mR.OBJECT:mR.NONE,t})(),s=this.levelNode;null===s&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this));let a=null,n=null;if(null!==this.compareNode)if(e.renderer.hasCompatibility(qr.TEXTURE_COMPARE))a=this.compareNode;else{let e=i.compareFunction;null===e||e===Br||e===Dr||e===Ir||e===zr?n=this.compareNode:(a=this.compareNode,v('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=n,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,i,r,s,a,n,o,l,h,u){let d,c=this.value;return d=s?e.generateTextureBias(c,t,i,s,a,h):o?e.generateTextureGrad(c,t,i,o,a,h):l?n?e.generateTextureGatherCompare(c,t,i,n,a,h,u):e.generateTextureGather(c,t,i,l,a,h,u):n?e.generateTextureCompare(c,t,i,n,a,h):!1===this.sampler?e.generateTextureLoad(c,t,i,r,a,h):r?e.generateTextureLevel(c,t,i,r,a,h):e.generateTexture(c,t,i,a,h),d}generate(e,t){let i=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(/^sampler/.test(t))return s+"_sampler";if(e.isReference(t))return s;{let a=e.getDataFromNode(this),n=this.getNodeType(e),o=a.propertyName;if(void 0===o){let{uvNode:t,levelNode:l,biasNode:h,compareNode:u,compareStepNode:d,depthNode:c,gradNode:p,gatherNode:m,offsetNode:g}=r,f=this.generateUV(e,t),y=l?l.build(e,"float"):null,v=h?h.build(e,"float"):null,b=c?c.build(e,"int"):null,x=u?u.build(e,"float"):null,w=d?d.build(e,"float"):null,_=p?[p[0].build(e,"vec2"),p[1].build(e,"vec2")]:null,S=m?m.build(e,"int"):null,M=g?this.generateOffset(e,g):null,T=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;S&&(n="vec4");let C=b;null===C&&i.isArrayTexture&&!0!==this.isTexture3DNode&&(C="0");let A=e.getVarFromNode(this);o=e.getPropertyName(A);let N=this.generateSnippet(e,s,f,y,v,C,x,_,S,M,T);if(null!==w){let t=i.compareFunction;N=t===Ir||t===zr?hV(OD(N,n),OD(w,"float")).build(e,n):hV(OD(w,"float"),OD(N,n)).build(e,n)}e.addLineFlowCode(`${o} = ${N}`,this),a.snippet=N,a.propertyName=o}let l=o;return e.needsToWorkingColorSpace(i)&&(l=tD(OD(l,n),i.colorSpace).setup(e).build(e,n)),e.format(l,n,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=uE(e),t.referenceNode=this.getBase(),uE(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=uE(e).mul($D(t)),t.referenceNode=this.getBase();let i=t.value;return!1===t.generateMipmaps&&(i&&!1===i.generateMipmaps||i.minFilter===jt||i.magFilter===jt)&&(f("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),uE(t)}level(e){let t=this.clone();return t.levelNode=uE(e),t.referenceNode=this.getBase(),uE(t)}size(e){return HD(this,e)}bias(e){let t=this.clone();return t.biasNode=uE(e),t.referenceNode=this.getBase(),uE(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=uE(e),t.referenceNode=this.getBase(),uE(t)}grad(e,t){let i=this.clone();return i.gradNode=[uE(e),uE(t)],i.referenceNode=this.getBase(),uE(i)}gather(e=0){let t=this.clone();return t.gatherNode=uE(e),t.referenceNode=this.getBase(),uE(t)}depth(e){let t=this.clone();return t.depthNode=uE(e),t.referenceNode=this.getBase(),uE(t)}offset(e){let t=this.clone();return t.offsetNode=uE(e),t.referenceNode=this.getBase(),uE(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix();let i=this._flipYUniform;null!==i&&(i.value=e.image instanceof ImageBitmap&&!0===e.flipY||!0===e.isRenderTargetTexture||!0===e.isFramebufferTexture||!0===e.isDepthTexture)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}).setParameterLength(1,4).setName("texture"),JD=(e=XD,t=null,i=null,r=null)=>{let s;return e&&!0===e.isTextureNode?(s=uE(e.clone()),s.referenceNode=e.getBase(),null!==t&&(s.uvNode=uE(t)),null!==i&&(s.levelNode=uE(i)),null!==r&&(s.biasNode=uE(r))):s=ZD(e,t,i,r),s},QD=(e=XD)=>JD(e),eI=(...e)=>JD(...e).setSampler(!1),tI=(e,t,i)=>JD(e,t).level(i),iI=e=>(!0===e.isNode?e:JD(e)).convert("sampler"),rI=e=>(!0===e.isNode?e:JD(e)).convert("samplerComparison"),sI=class extends VO{static get type(){return"BufferNode"}constructor(e,t,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=i,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}},aI=(e,t,i)=>new sI(e,t,i),nI=class extends MR{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),i=this.getNodeType(e),r=this.node.getPaddedType();return e.format(t,r,i)}},oI=class extends sI{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?WN(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=mR.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){let{array:e,value:t}=this,i=this.elementType;if("float"===i||"int"===i||"uint"===i)for(let i=0;i<e.length;i++)t[4*i]=e[i];else if("color"===i)for(let i=0;i<e.length;i++){let r=4*i,s=e[i];t[r]=s.r,t[r+1]=s.g,t[r+2]=s.b||0}else if("mat2"===i)for(let i=0;i<e.length;i++){let r=4*i,s=e[i];t[r]=s.elements[0],t[r+1]=s.elements[1],t[r+2]=s.elements[2],t[r+3]=s.elements[3]}else if("mat3"===i)for(let i=0;i<e.length;i++){let r=16*i,s=e[i];t[r]=s.elements[0],t[r+1]=s.elements[1],t[r+2]=s.elements[2],t[r+4]=s.elements[3],t[r+5]=s.elements[4],t[r+6]=s.elements[5],t[r+8]=s.elements[6],t[r+9]=s.elements[7],t[r+10]=s.elements[8],t[r+15]=1}else if("mat4"===i)for(let i=0;i<e.length;i++){let r=16*i,s=e[i];for(let e=0;e<s.elements.length;e++)t[r+e]=s.elements[e]}else for(let i=0;i<e.length;i++){let r=4*i,s=e[i];t[r]=s.x,t[r+1]=s.y,t[r+2]=s.z||0,t[r+3]=s.w||0}}setup(e){let t=this.array.length,i=this.elementType,r=Float32Array,s=this.paddedType,a=e.getTypeLength(s);return"i"===i.charAt(0)&&(r=Int32Array),"u"===i.charAt(0)&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=s,this.update(),super.setup(e)}element(e){return new nI(this,uE(e))}},lI=(e,t)=>new oI(e,t),hI=mE(class extends SR{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),(cI=class extends SR{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===cI.DPR?"float":this.scope===cI.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=mR.NONE;return(this.scope===cI.SIZE||this.scope===cI.VIEWPORT||this.scope===cI.DPR)&&(e=mR.RENDER),this.updateType=e,e}update({renderer:e}){let t=e.getRenderTarget();this.scope===cI.VIEWPORT?null!==t?dI.copy(t.viewport):(e.getViewport(dI),dI.multiplyScalar(e.getPixelRatio())):this.scope===cI.DPR?this._output.value=e.getPixelRatio():null!==t?(uI.width=t.width,uI.height=t.height):e.getDrawingBufferSize(uI)}setup(){let e=this.scope,t=null;return t=e===cI.SIZE?DO(uI||(uI=new rs)):e===cI.VIEWPORT?DO(dI||(dI=new Ss)):e===cI.DPR?null!==this._output?this._output:DO(1):PE(fI.div(gI)),this._output=t,t}generate(e){if(this.scope===cI.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){let i=e.getNodeProperties(gI).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${i}.y - ${t}.y )`}return t}return super.generate(e)}}).COORDINATE="coordinate",cI.VIEWPORT="viewport",cI.SIZE="size",cI.UV="uv",cI.DPR="dpr",pI=gE(cI,cI.DPR),mI=gE(cI,cI.UV),gI=gE(cI,cI.SIZE),fI=gE(cI,cI.COORDINATE),yI=gE(cI,cI.VIEWPORT),vI=yI.zw,bI=fI.sub(yI.xy),xI=bI.div(vI),wI=JN(()=>(f('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new oR),gI),"vec2").once()(),_I=null,SI=null,MI=null,TI=null,CI=null,AI=null,NI=null,PI=null,RI=null,EI=null,OI=null,BI=null,VI=null,DI=null,II=DO(0,"uint").setName("u_cameraIndex").setGroup(RO("cameraIndex")).toVarying("v_cameraIndex"),LI=DO("float").setName("cameraNear").setGroup(OO).onRenderUpdate(({camera:e})=>e.near),zI=DO("float").setName("cameraFar").setGroup(OO).onRenderUpdate(({camera:e})=>e.far),kI=JN(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let t of e.cameras)i.push(t.projectionMatrix);null===SI?SI=lI(i).setGroup(OO).setName("cameraProjectionMatrices"):SI.array=i,t=SI.element(e.isMultiViewCamera?hI("gl_ViewID_OVR"):II)}else null===_I&&(_I=DO(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(OO).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=_I;return t}).once()(),UI=JN(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let t of e.cameras)i.push(t.projectionMatrixInverse);null===TI?TI=lI(i).setGroup(OO).setName("cameraProjectionMatricesInverse"):TI.array=i,t=TI.element(e.isMultiViewCamera?hI("gl_ViewID_OVR"):II)}else null===MI&&(MI=DO(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(OO).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=MI;return t}).once()(),FI=JN(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let t of e.cameras)i.push(t.matrixWorldInverse);null===AI?AI=lI(i).setGroup(OO).setName("cameraViewMatrices"):AI.array=i,t=AI.element(e.isMultiViewCamera?hI("gl_ViewID_OVR"):II)}else null===CI&&(CI=DO(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(OO).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=CI;return t}).once()(),jI=JN(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let t of e.cameras)i.push(t.matrixWorld);null===PI?PI=lI(i).setGroup(OO).setName("cameraWorldMatrices"):PI.array=i,t=PI.element(e.isMultiViewCamera?hI("gl_ViewID_OVR"):II)}else null===NI&&(NI=DO(e.matrixWorld).setName("cameraWorldMatrix").setGroup(OO).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=NI;return t}).once()(),GI=JN(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let t of e.cameras)i.push(t.normalMatrix);null===EI?EI=lI(i).setGroup(OO).setName("cameraNormalMatrices"):EI.array=i,t=EI.element(e.isMultiViewCamera?hI("gl_ViewID_OVR"):II)}else null===RI&&(RI=DO(e.normalMatrix).setName("cameraNormalMatrix").setGroup(OO).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=RI;return t}).once()(),WI=JN(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let t=0,r=e.cameras.length;t<r;t++)i.push(new ns);null===BI?BI=lI(i).setGroup(OO).setName("cameraPositions").onRenderUpdate(({camera:e},t)=>{let i=e.cameras,r=t.array;for(let e=0,t=i.length;e<t;e++)r[e].setFromMatrixPosition(i[e].matrixWorld)}):BI.array=i,t=BI.element(e.isMultiViewCamera?hI("gl_ViewID_OVR"):II)}else null===OI&&(OI=DO(new ns).setName("cameraPosition").setGroup(OO).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),t=OI;return t}).once()(),qI=JN(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let i=[];for(let t of e.cameras)i.push(t.viewport);null===DI?DI=lI(i,"vec4").setGroup(OO).setName("cameraViewports"):DI.array=i,t=DI.element(II)}else null===VI&&(VI=LE(0,0,gI.x,gI.y).toConst("cameraViewport")),t=VI;return t}).once()(),HI=new Ka,($I=class extends SR{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=mR.OBJECT,this.uniformNode=new VO(null)}generateNodeType(){let e=this.scope;return e===$I.WORLD_MATRIX?"mat4":e===$I.POSITION||e===$I.VIEW_POSITION||e===$I.DIRECTION||e===$I.SCALE?"vec3":e===$I.RADIUS?"float":void 0}update(e){let t=this.object3d,i=this.uniformNode,r=this.scope;if(r===$I.WORLD_MATRIX)i.value=t.matrixWorld;else if(r===$I.POSITION)i.value=i.value||new ns,i.value.setFromMatrixPosition(t.matrixWorld);else if(r===$I.SCALE)i.value=i.value||new ns,i.value.setFromMatrixScale(t.matrixWorld);else if(r===$I.DIRECTION)i.value=i.value||new ns,t.getWorldDirection(i.value);else if(r===$I.VIEW_POSITION){let r=e.camera;i.value=i.value||new ns,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(r.matrixWorldInverse)}else if(r===$I.RADIUS){let r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),HI.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),i.value=HI.radius}}generate(e){let t=this.scope;return t===$I.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===$I.POSITION||t===$I.VIEW_POSITION||t===$I.DIRECTION||t===$I.SCALE?this.uniformNode.nodeType="vec3":t===$I.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}).WORLD_MATRIX="worldMatrix",$I.POSITION="position",$I.SCALE="scale",$I.VIEW_POSITION="viewPosition",$I.DIRECTION="direction",$I.RADIUS="radius",YI=mE($I,$I.DIRECTION).setParameterLength(1),XI=mE($I,$I.WORLD_MATRIX).setParameterLength(1),KI=mE($I,$I.POSITION).setParameterLength(1),ZI=mE($I,$I.SCALE).setParameterLength(1),JI=mE($I,$I.VIEW_POSITION).setParameterLength(1),QI=mE($I,$I.RADIUS).setParameterLength(1),tL=gE(eL=class extends $I{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},eL.DIRECTION),iL=gE(eL,eL.WORLD_MATRIX),rL=gE(eL,eL.POSITION),sL=gE(eL,eL.SCALE),aL=gE(eL,eL.VIEW_POSITION),nL=gE(eL,eL.RADIUS),oL=DO(new us).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),lL=DO(new As).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),hL=JN(e=>e.context.modelViewMatrix||uL).once()().toVar("modelViewMatrix"),uL=FI.mul(iL),dL=JN(e=>(e.context.isHighPrecisionModelViewMatrix=!0,DO("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),cL=JN(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return DO("mat3").onObjectUpdate(({object:e,camera:i})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),pL=JN(e=>"fragment"!==e.shaderStage?(v("TSL: `clipSpace` is only available in fragment stage."),LE()):e.context.clipSpace.toVarying("v_clipSpace")).once()(),mL=WD("position","vec3"),gL=mL.toVarying("positionLocal"),fL=mL.toVarying("positionPrevious"),yL=JN(e=>iL.mul(gL).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),vL=JN(()=>gL.transformDirection(iL).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),bL=JN(e=>{if("fragment"===e.shaderStage&&e.material.vertexNode){let e=UI.mul(pL);return e.xyz.div(e.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),xL=JN(e=>{let t;return t=e.camera.isOrthographicCamera?BE(0,0,1):bL.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])(),wL=gE(class extends SR{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";let{material:t}=e;return t.side===We?"false":e.getFrontFacing()}}),_L=TE(wL).mul(2).sub(1),SL=JN(([e],{material:t})=>{let i=t.side;return i===We?e=e.mul(-1):i===qe&&(e=e.mul(_L)),e}),ML=e=>(v('TSL: "directionToFaceDirection()" has been renamed to "negateOnBackSide()".'),SL(e)),TL=WD("normal","vec3"),CL=JN(e=>!1===e.geometry.hasAttribute("normal")?(f('TSL: Vertex attribute "normal" not found on geometry.'),BE(0,1,0)):TL,"vec3").once()().toVar("normalLocal"),AL=bL.dFdx().cross(bL.dFdy()).normalize().toVar("normalFlat"),NL=JN(e=>{let t;return t=e.isFlatShading()?AL:VL(CL).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),PL=JN(e=>{let t=NL.transformNormalByInverseViewMatrix(FI);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),RL=JN(e=>{let t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=NL,!0!==e.isFlatShading()&&(t=SL(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),EL=RL.transformNormalByInverseViewMatrix(FI).toVar("normalWorld"),OL=JN(({subBuildFn:e,context:t})=>{let i;return i="NORMAL"===e||"VERTEX"===e?RL:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),i},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),$N("transformNormal",BL=JN(([e,t=iL])=>jE(t).inverse().transpose().mul(e).normalize())),VL=JN(([e],t)=>{let i=t.context.modelNormalViewMatrix;return i?e.transformNormalByViewMatrix(i):oL.mul(e).transformNormalByViewMatrix(FI)}),DL=JN(()=>(f('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),RL)).once(["NORMAL","VERTEX"])(),IL=JN(()=>(f('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),EL)).once(["NORMAL","VERTEX"])(),LL=JN(()=>(f('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),OL)).once(["NORMAL","VERTEX"])(),zL=new As,kL=DO(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),UL=DO(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),FL=DO(new As).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let i=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return i?zL.makeRotationFromEuler(i).transpose():zL.identity(),zL}),jL=xL.negate().reflect(RL),GL=xL.negate().refract(RL,kL),WL=jL.transformDirection(jI).toVar("reflectVector"),qL=GL.transformDirection(jI).toVar("refractVector"),HL=new Bo,$L=mE(class extends KD{static get type(){return"CubeTextureNode"}constructor(e,t=null,i=null,r=null){super(e,t,i,r),this.isCubeTextureNode=!0}getInputType(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){let e=this.value;return e.mapping===Vt?WL:e.mapping===Dt?qL:(y('CubeTextureNode: Mapping "%s" not supported.',e.mapping),BE(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let i=this.value;return!0===i.isDepthTexture?e.renderer.coordinateSystem===Gr?BE(t.x,t.y.negate(),t.z):t:(t=FL.mul(t),(e.renderer.coordinateSystem===Gr||!i.isRenderTargetTexture)&&(t=BE(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}).setParameterLength(1,4).setName("cubeTexture"),YL=(e=HL,t=null,i=null,r=null)=>{let s;return e&&!0===e.isCubeTextureNode?(s=uE(e.clone()),s.referenceNode=e,null!==t&&(s.uvNode=uE(t)),null!==i&&(s.levelNode=uE(i)),null!==r&&(s.biasNode=uE(r))):s=$L(e,t,i,r),s},XL=(e=HL)=>$L(e),KL=class extends MR{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),i=this.referenceNode.getNodeType(e),r=this.getNodeType(e);return e.format(t,i,r)}},ZL=class extends SR{static get type(){return"ReferenceNode"}constructor(e,t,i=null,r=null){super(),this.property=e,this.uniformType=t,this.object=i,this.count=r,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=mR.OBJECT}element(e){return new KL(this,uE(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return f('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;null!==this.count?t=aI(null,e,this.count):Array.isArray(this.getValueFromReference())?(t=lI(null,e),t.updateType=mR.OBJECT):t="texture"===e?JD(null):"cubeTexture"===e?YL(null):DO(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,i=e[t[0]];for(let e=1;e<t.length;e++)i=i[t[e]];return i}updateReference(e){return this.reference=null!==this.object?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},JL=(e,t,i)=>new ZL(e,t,i),QL=(e,t,i,r)=>new ZL(e,t,r,i),ez=class extends ZL{static get type(){return"MaterialReferenceNode"}constructor(e,t,i=null){super(e,t,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}},tz=(e,t,i=null)=>new ez(e,t,i),iz=qD(),rz=bL.dFdx(),sz=bL.dFdy(),az=iz.dFdx(),nz=iz.dFdy(),oz=RL,lz=sz.cross(oz),hz=oz.cross(rz),uz=lz.mul(az.x).add(hz.mul(nz.x)),dz=lz.mul(az.y).add(hz.mul(nz.y)),cz=uz.dot(uz).max(dz.dot(dz)),pz=cz.equal(0).select(0,cz.inverseSqrt()),mz=uz.mul(pz).toVar("tangentViewFrame"),gz=dz.mul(pz).toVar("bitangentViewFrame"),fz=WD("tangent","vec4"),yz=fz.xyz.toVar("tangentLocal"),vz=JN(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?hL.mul(LE(yz,0)).xyz.toVarying("v_tangentView").normalize():mz,!0!==e.isFlatShading()&&(t=SL(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),bz=vz.transformDirection(jI).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),xz=JN(([e,t],i)=>{let r=e.mul(fz.w).xyz;return"NORMAL"===i.subBuildFn&&!0!==i.isFlatShading()&&(r=r.toVarying(t)),r}).once(["NORMAL"]),wz=xz(TL.cross(fz),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),_z=xz(CL.cross(yz),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Sz=JN(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?xz(RL.cross(vz),"v_bitangentView").normalize():gz,!0!==e.isFlatShading()&&(t=SL(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),Mz=xz(EL.cross(bz),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Tz=jE(vz,Sz,RL).toVar("TBNViewMatrix"),Cz=xL.mul(Tz),Az=(e,t)=>e.sub(Cz.mul(t)),Nz=JN(()=>{let e=cO.cross(xL);return e=e.cross(cO).normalize(),e=MV(e,RL,uO.mul(eO.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),Pz=e=>uE(e).mul(.5).add(.5),Rz=e=>uE(e).mul(2).sub(1),Ez=e=>BE(e,PB(CV(TE(1).sub(pV(e,e))))),Oz=e=>(v('TSL: "directionToColor()" has been renamed to "packNormalToRGB()".'),Pz(e)),Bz=e=>(v('TSL: "colorToDirection()" has been renamed to "unpackRGBToNormal()".'),Rz(e)),Vz=mE(class extends CR{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=nr,this.unpackNormalMode=pr}setup(e){let{normalMapType:t,scaleNode:i,unpackNormalMode:r}=this,s=this.node.mul(2).sub(1);if(t===nr?r===mr?s=Ez(s.xy):r===gr?s=Ez(s.yw):r!==pr&&y(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==pr&&y(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),null!==i){let t=i;!0===e.isFlatShading()&&(t=SL(t)),s=BE(s.xy.mul(t),s.z)}let a=null;return t===or?a=VL(s):t===nr?a=Tz.mul(s).normalize():(y(`NodeMaterial: Unsupported normal map type: ${t}`),a=RL),a}}).setParameterLength(1,2),Dz=JN(({textureNode:e,bumpScale:t})=>{let i=t=>e.isolate().context({getUV:e=>t(e.uvNode||qD()),forceUVContext:!0}),r=TE(i(e=>e));return PE(TE(i(e=>e.add(e.dFdx()))).sub(r),TE(i(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),Iz=JN(e=>{let{surf_pos:t,surf_norm:i,dHdxy:r}=e,s=t.dFdx().normalize(),a=i,n=t.dFdy().normalize().cross(a),o=a.cross(s),l=s.dot(n).mul(_L),h=l.sign().mul(r.x.mul(n).add(r.y.mul(o)));return l.abs().mul(i).sub(h).normalize()}),Lz=mE(class extends CR{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(e){if(!0===e.material.wireframe)return RL;let t=null!==this.scaleNode?this.scaleNode:1,i=Dz({textureNode:this.textureNode,bumpScale:t});return Iz({surf_pos:bL,surf_norm:RL,dHdxy:i})}}).setParameterLength(1,2),zz=new Map,(kz=class extends SR{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let i=zz.get(e);return void 0===i&&(i=tz(e,t),zz.set(e,i)),i}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){let t=e.context.material,i=this.scope,r=null;if(i===kz.COLOR){let e=void 0!==t.color?this.getColor(i):BE();r=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(i===kz.OPACITY){let e=this.getFloat(i);r=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(i===kz.SPECULAR_STRENGTH)r=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:TE(1);else if(i===kz.SPECULAR_INTENSITY){let e=this.getFloat(i);r=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(i).a):e}else if(i===kz.SPECULAR_COLOR){let e=this.getColor(i);r=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(i).rgb):e}else if(i===kz.ROUGHNESS){let e=this.getFloat(i);r=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(i).g):e}else if(i===kz.METALNESS){let e=this.getFloat(i);r=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(i).b):e}else if(i===kz.EMISSIVE){let e=this.getFloat("emissiveIntensity"),s=this.getColor(i).mul(e);r=t.emissiveMap&&!0===t.emissiveMap.isTexture?s.mul(this.getTexture(i)):s}else if(i===kz.NORMAL)t.normalMap?(r=Vz(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType,(t.normalMap.format==gi||t.normalMap.format==Xi||t.normalMap.format==Ni)&&(r.unpackNormalMode=mr)):r=t.bumpMap?Lz(this.getTexture("bump").r,this.getFloat("bumpScale")):RL;else if(i===kz.CLEARCOAT){let e=this.getFloat(i);r=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(i).r):e}else if(i===kz.CLEARCOAT_ROUGHNESS){let e=this.getFloat(i);r=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(i).r):e}else if(i===kz.CLEARCOAT_NORMAL)r=t.clearcoatNormalMap?Vz(this.getTexture(i),this.getCache(i+"Scale","vec2")):RL;else if(i===kz.SHEEN){let e=this.getColor("sheenColor").mul(this.getFloat("sheen"));r=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(i===kz.SHEEN_ROUGHNESS){let e=this.getFloat(i);r=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(i).a):e,r=r.clamp(1e-4,1)}else if(i===kz.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){let e=this.getTexture(i);r=FE(Sk.x,Sk.y,Sk.y.negate(),Sk.x).mul(e.rg.mul(2).sub(PE(1)).normalize().mul(e.b))}else r=Sk;else if(i===kz.IRIDESCENCE_THICKNESS){let e=JL("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){let s=JL("0","float",t.iridescenceThicknessRange);r=e.sub(s).mul(this.getTexture(i).g).add(s)}else r=e}else if(i===kz.TRANSMISSION){let e=this.getFloat(i);r=t.transmissionMap?e.mul(this.getTexture(i).r):e}else if(i===kz.THICKNESS){let e=this.getFloat(i);r=t.thicknessMap?e.mul(this.getTexture(i).g):e}else if(i===kz.IOR)r=this.getFloat(i);else if(i===kz.LIGHT_MAP)r=t.lightMap?this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity")):BE(0);else if(i===kz.AO)r=t.aoMap?this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1):TE(1);else if(i===kz.LINE_DASH_OFFSET)r=t.dashOffset?this.getFloat(i):TE(0);else{let t=this.getNodeType(e);r=this.getCache(i,t)}return r}}).ALPHA_TEST="alphaTest",kz.COLOR="color",kz.OPACITY="opacity",kz.SHININESS="shininess",kz.SPECULAR="specular",kz.SPECULAR_STRENGTH="specularStrength",kz.SPECULAR_INTENSITY="specularIntensity",kz.SPECULAR_COLOR="specularColor",kz.REFLECTIVITY="reflectivity",kz.ROUGHNESS="roughness",kz.METALNESS="metalness",kz.NORMAL="normal",kz.CLEARCOAT="clearcoat",kz.CLEARCOAT_ROUGHNESS="clearcoatRoughness",kz.CLEARCOAT_NORMAL="clearcoatNormal",kz.EMISSIVE="emissive",kz.ROTATION="rotation",kz.SHEEN="sheen",kz.SHEEN_ROUGHNESS="sheenRoughness",kz.ANISOTROPY="anisotropy",kz.IRIDESCENCE="iridescence",kz.IRIDESCENCE_IOR="iridescenceIOR",kz.IRIDESCENCE_THICKNESS="iridescenceThickness",kz.IOR="ior",kz.TRANSMISSION="transmission",kz.THICKNESS="thickness",kz.ATTENUATION_DISTANCE="attenuationDistance",kz.ATTENUATION_COLOR="attenuationColor",kz.LINE_SCALE="scale",kz.LINE_DASH_SIZE="dashSize",kz.LINE_GAP_SIZE="gapSize",kz.LINE_WIDTH="linewidth",kz.LINE_DASH_OFFSET="dashOffset",kz.POINT_SIZE="size",kz.DISPERSION="dispersion",kz.LIGHT_MAP="light",kz.AO="ao",Uz=gE(kz,kz.ALPHA_TEST),Fz=gE(kz,kz.COLOR),jz=gE(kz,kz.SHININESS),Gz=gE(kz,kz.EMISSIVE),Wz=gE(kz,kz.OPACITY),qz=gE(kz,kz.SPECULAR),Hz=gE(kz,kz.SPECULAR_INTENSITY),$z=gE(kz,kz.SPECULAR_COLOR),Yz=gE(kz,kz.SPECULAR_STRENGTH),Xz=gE(kz,kz.REFLECTIVITY),Kz=gE(kz,kz.ROUGHNESS),Zz=gE(kz,kz.METALNESS),Jz=gE(kz,kz.NORMAL),Qz=gE(kz,kz.CLEARCOAT),ek=gE(kz,kz.CLEARCOAT_ROUGHNESS),tk=gE(kz,kz.CLEARCOAT_NORMAL),ik=gE(kz,kz.ROTATION),rk=gE(kz,kz.SHEEN),sk=gE(kz,kz.SHEEN_ROUGHNESS),ak=gE(kz,kz.ANISOTROPY),nk=gE(kz,kz.IRIDESCENCE),ok=gE(kz,kz.IRIDESCENCE_IOR),lk=gE(kz,kz.IRIDESCENCE_THICKNESS),hk=gE(kz,kz.TRANSMISSION),uk=gE(kz,kz.THICKNESS),dk=gE(kz,kz.IOR),ck=gE(kz,kz.ATTENUATION_DISTANCE),pk=gE(kz,kz.ATTENUATION_COLOR),mk=gE(kz,kz.LINE_SCALE),gk=gE(kz,kz.LINE_DASH_SIZE),fk=gE(kz,kz.LINE_GAP_SIZE),yk=gE(kz,kz.LINE_WIDTH),vk=gE(kz,kz.LINE_DASH_OFFSET),bk=gE(kz,kz.POINT_SIZE),xk=gE(kz,kz.DISPERSION),wk=gE(kz,kz.LIGHT_MAP),_k=gE(kz,kz.AO),Sk=DO(new rs).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),Mk=JN(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection"),(Tk=class extends SR{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===Tk.OBJECT?this.updateType=mR.OBJECT:e===Tk.MATERIAL?this.updateType=mR.RENDER:e===Tk.FRAME?this.updateType=mR.FRAME:e===Tk.BEFORE_OBJECT?this.updateBeforeType=mR.OBJECT:e===Tk.BEFORE_MATERIAL?this.updateBeforeType=mR.RENDER:e===Tk.BEFORE_FRAME?this.updateBeforeType=mR.FRAME:e===Tk.AFTER_OBJECT&&(this.updateAfterType=mR.OBJECT)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}updateAfter(e){this.callback(e)}}).OBJECT="object",Tk.MATERIAL="material",Tk.FRAME="frame",Tk.BEFORE_OBJECT="beforeObject",Tk.BEFORE_MATERIAL="beforeMaterial",Tk.BEFORE_FRAME="beforeFrame",Tk.AFTER_OBJECT="afterObject",Ck=(e,t)=>new Tk(e,t).toStack(),Ak=e=>Ck(Tk.OBJECT,e),Nk=e=>Ck(Tk.MATERIAL,e),Pk=e=>Ck(Tk.FRAME,e),Rk=e=>Ck(Tk.BEFORE_OBJECT,e),Ek=e=>Ck(Tk.BEFORE_MATERIAL,e),Ok=e=>Ck(Tk.BEFORE_FRAME,e),Bk=e=>Ck(Tk.AFTER_OBJECT,e),Vk=mE(class extends MR{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let i=this.storageBufferNode.structTypeNode;return i?i.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let i,r=e.isContextAssign();if(i=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===r||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==r){let r=this.getNodeType(e);i=e.format(i,r,t)}return i}}).setParameterLength(2),Dk=class extends sI{static get type(){return"StorageBufferNode"}constructor(e,t=null,i=0){let r,s=null;t&&t.isStructTypeNode?(r="struct",s=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(i=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=kN(e.itemSize),i=e.count):r=t,super(e,r,i),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=fR.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(0===this.bufferCount){let i=e.globalCache.getData(this.value);void 0===i&&(i={node:this},e.globalCache.setData(this.value,i)),t=i.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Vk(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(fR.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=pD(this.value),this._varying=YV(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);let{attribute:t,varying:i}=this.getAttributeData(),r=i.build(e);return e.registerTransform(r,t),r}},Ik=(e,t=null,i=0)=>new Dk(e,t,i),Lk=new WeakMap,zk=new WeakMap,kk=new WeakMap,Uk=KE("vec3","vInstanceColor"),Fk=JN(([e,t,i=null],r)=>{e=e.value;let s=!0===t.isStorageInstancedBufferAttribute,a=i&&!0===i.isStorageInstancedBufferAttribute,n=hP(r,t,e);r.spInstanceMatrixNode=n;let o=null;s||16*e*4>r.getUniformBufferLimit()&&(o=Lk.get(t));let l=null,h=null;if(i)if(a)l=Ik(i,"vec3",Math.max(i.count,1)).element(bD);else{let e=zk.get(i);e||(e=new Jn(i.array,3),zk.set(i,e)),h=e;let t=i.usage===Fr?fD:gD;l=BE(t(e,"vec3",3,0))}(null!==o||null!==h)&&Pk(()=>{null!==o&&(o.clearUpdateRanges(),o.updateRanges.push(...t.updateRanges),t.version!==o.version&&(o.version=t.version)),i&&null!==h&&(h.clearUpdateRanges(),h.updateRanges.push(...i.updateRanges),i.version!==h.version&&(h.version=i.version))});let u=n.mul(gL).xyz;if(gL.assign(u),r.needsPreviousData()){let i=r.object;Bk(({object:e})=>{kk.get(e).previousInstanceMatrix.array.set(t.array)});let s=function(e,t,i,r){let s=kk.get(e);if(void 0===s){let a=t.clone();s={previousInstanceMatrix:a,node:hP(i,a,r)},kk.set(e,s)}return s.node}(i,t,r,e);fL.assign(s.mul(fL).xyz)}if(r.hasGeometryAttribute("normal")){let e=BL(CL,n);CL.assign(e)}null!==l&&Uk.assign(l)},"void"),jk=JN(([e])=>{let{count:t,instanceMatrix:i,instanceColor:r}=e;Fk(t,i,r)},"void"),Gk=JN(([e,t])=>{let i=CE(HD(eI(e),0).x).toConst(),r=CE(t),s=r.mod(i).toConst(),a=r.div(i).toConst();return eI(e,RE(s,a))}),Wk=JN(([e,t])=>{let i=CE(HD(eI(e),0).x).toConst(),r=CE(t).mod(i).toConst(),s=CE(t).div(i).toConst();return eI(e,RE(r,s)).x}),qk=KE("vec4","vBatchColor"),Hk=JN(([e],t)=>{let i=null===t.getDrawIndex()?bD:SD,r=Wk(e._indirectTexture,CE(i)),s=e._matricesTexture,a=CE(HD(eI(s),0).x).toConst(),n=TE(r).mul(4).toInt().toConst(),o=n.mod(a).toConst(),l=n.div(a).toConst(),h=GE(eI(s,RE(o,l)),eI(s,RE(o.add(1),l)),eI(s,RE(o.add(2),l)),eI(s,RE(o.add(3),l))),u=e._colorsTexture;if(null!==u){let e=Gk(u,r);qk.assign(e)}let d=jE(h);gL.assign(h.mul(gL));let c=CL.div(BE(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),p=d.mul(c).xyz;CL.assign(p),t.hasGeometryAttribute("tangent")&&yz.mulAssign(d)},"void"),$k=new WeakMap,Yk=new WeakMap,Xk=JN(([e],t)=>{let i=WD("skinIndex","uvec4"),r=WD("skinWeight","vec4"),s=JL("bindMatrix","mat4"),a=JL("bindMatrixInverse","mat4"),n=QL("skeleton.boneMatrices","mat4",e.skeleton.bones.length);if(Ak(({object:e,frameId:t})=>{let i=e.skeleton;if($k.get(i)!==t){$k.set(i,t);let e=Yk.get(i);void 0!==e&&e.previousBoneMatrices.set(i.boneMatrices),i.update()}}),t.needsPreviousData()){let t=cP(e,s,a,i,r);fL.assign(t)}let o=uP(n,gL,s,a,i,r);if(gL.assign(o),t.hasGeometryAttribute("normal")){let{skinNormal:e,skinTangent:o}=dP(n,CL,yz,s,a,i,r);CL.assign(e),t.hasGeometryAttribute("tangent")&&yz.assign(o)}},"void"),Kk=JN(([e,t=null],i)=>{let r=Ik(new Jn(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(bD).toVar(),s=Ik(new Jn(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(bD).toVar(),a=Ik(new Jn(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(bD).toVar(),n=DO(e.bindMatrix,"mat4"),o=DO(e.bindMatrixInverse,"mat4"),l=aI(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),h=e.skeleton;if(Ak(({frameId:e})=>{if($k.get(h)!==e){$k.set(h,e);let t=Yk.get(h);void 0!==t&&t.previousBoneMatrices.set(h.boneMatrices),h.update()}}),i.needsPreviousData()){let t=cP(e,n,o,s,a);fL.assign(t)}let u=uP(l,r,n,o,s,a);if(null!==t&&t.assign(u),i.hasGeometryAttribute("normal")){let{skinNormal:e,skinTangent:t}=dP(l,CL,yz,n,o,s,a);CL.assign(e),i.hasGeometryAttribute("tangent")&&yz.assign(t)}return u}),Zk=class extends SR{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){let t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;let i={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=!0!==t.isNode&&t.name||this.getVarName(e),s=!0!==t.isNode&&t.type||"int";i[r]=OD(r,s)}let r=e.addStack(),s=this.params[this.params.length-1](i);t.returnsNode=s.context({nodeLoop:s}),t.stackNode=r;let a=this.params[0];if(!0!==a.isNode&&"function"==typeof a.update){let e=JN(this.params[0].update)(i);t.updateNode=e.context({nodeLoop:e})}return e.removeStack(),t}setup(e){this.getProperties(e),e.fnCall&&(e.getDataFromNode(e.fnCall.shaderNode).hasLoop=!0)}generate(e){let t=this.getProperties(e),i=this.params,r=t.stackNode;for(let r=0,s=i.length-1;r<s;r++){let s,a=i[r],n=!1,o=null,l=null,h=null,u=null,d=null,c=null;if(a.isNode?"bool"===a.getNodeType(e)?(n=!0,u="bool",l=a.build(e,u)):(u="int",h=this.getVarName(r),o="0",l=a.build(e,u),d="<"):(u=a.type||"int",h=a.name||this.getVarName(r),o=a.start,l=a.end,d=a.condition,c=a.update,"number"==typeof o?o=e.generateConst(u,o):o&&o.isNode&&(o=o.build(e,u)),"number"==typeof l?l=e.generateConst(u,l):l&&l.isNode&&(l=l.build(e,u)),void 0!==o&&void 0===l?(o+=" - 1",l="0",d=">="):void 0!==l&&void 0===o&&(o="0",d="<"),void 0===d&&(d=Number(o)>Number(l)?">=":"<")),n)s=`while ( ${l} )`;else{let i,r={start:o,end:l},a=r.start,n=r.end,p=()=>d.includes("<")?"+=":"-=";if(null!=c)switch(typeof c){case"function":i=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":i=h+" "+p()+" "+e.generateConst(u,c);break;case"string":i=h+" "+c;break;default:c.isNode?i=h+" "+p()+" "+c.build(e):(y("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),i="break /* invalid update */")}else c="int"===u||"uint"===u?d.includes("<")?"++":"--":p()+" 1.",i=h+" "+c;s=`for ( ${e.getVar(u,h)+" = "+a}; ${h+" "+d+" "+n}; ${i} )`}e.addFlowCode((0===r?"\n":"")+e.tab+s+" {\n\n").addFlowTab()}let s=r.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode("\n"+e.tab+s);for(let t=0,i=this.params.length-1;t<i;t++)e.addFlowCode((0===t?"":e.tab)+"}\n\n").removeFlowTab();e.addFlowTab()}},Jk=(...e)=>new Zk(pE(e,"int")).toStack(),Qk=()=>OD("continue").toStack(),eU=()=>OD("break").toStack(),tU=new WeakMap,iU=new Ss,rU=new WeakMap,sU=JN(({bufferMap:e,influence:t,stride:i,width:r,depth:s,offset:a})=>{let n=CE(vD).mul(i).add(a),o=n.div(r),l=n.sub(o.mul(r));return eI(e,RE(l,o)).depth(s).xyz.mul(t)}),aU=JN(([e])=>{let{geometry:t}=e,i=void 0!==t.morphAttributes.position,r=t.hasAttribute("normal")&&void 0!==t.morphAttributes.normal,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=void 0!==s?s.length:0;if(0===a)return;let n=rU.get(e);(void 0===n||n.count!==a)&&(n={base:DO(1),influences:e.morphTargetInfluences?lI(e.morphTargetInfluences,"float"):null,count:a},rU.set(e,n));let{base:o,influences:l}=n,{texture:h,stride:u,size:d}=function(e){let t=void 0!==e.morphAttributes.position,i=void 0!==e.morphAttributes.normal,r=void 0!==e.morphAttributes.color,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==s?s.length:0,n=tU.get(e);if(void 0===n||n.count!==a){let s=function(){g.dispose(),tU.delete(e),e.removeEventListener("dispose",s)};void 0!==n&&n.texture.dispose();let o=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],h=e.morphAttributes.color||[],u=0;!0===t&&(u=1),!0===i&&(u=2),!0===r&&(u=3);let d=e.attributes.position.count*u,c=1,p=4096;d>p&&(c=Math.ceil(d/p),d=p);let m=new Float32Array(d*c*4*a),g=new Ts(m,d,c,a);g.type=ti,g.needsUpdate=!0;let f=4*u;for(let e=0;e<a;e++){let s=o[e],a=l[e],n=h[e],u=d*c*4*e;for(let e=0;e<s.count;e++){let o=e*f;!0===t&&(iU.fromBufferAttribute(s,e),m[u+o+0]=iU.x,m[u+o+1]=iU.y,m[u+o+2]=iU.z,m[u+o+3]=0),!0===i&&(iU.fromBufferAttribute(a,e),m[u+o+4]=iU.x,m[u+o+5]=iU.y,m[u+o+6]=iU.z,m[u+o+7]=0),!0===r&&(iU.fromBufferAttribute(n,e),m[u+o+8]=iU.x,m[u+o+9]=iU.y,m[u+o+10]=iU.z,m[u+o+11]=4===n.itemSize?iU.w:1)}}n={count:a,texture:g,stride:u,size:new rs(d,c)},tU.set(e,n),e.addEventListener("dispose",s)}return n}(t);!0===i&&gL.mulAssign(o),!0===r&&CL.mulAssign(o);let c=CE(d.width);Jk(a,({i:t})=>{let s=TE(0).toVar();e.count>1&&null!==e.morphTexture&&void 0!==e.morphTexture?s.assign(eI(e.morphTexture,RE(CE(t).add(1),CE(bD))).r):s.assign(l.element(t).toVar()),_E(s.notEqual(0),()=>{!0===i&&gL.addAssign(sU({bufferMap:h,influence:s,stride:u,width:c,depth:t,offset:CE(0)})),!0===r&&CL.addAssign(sU({bufferMap:h,influence:s,stride:u,width:c,depth:t,offset:CE(1)}))})}),Ak(({object:e})=>{let{base:t,influences:i}=n;e.geometry.morphTargetsRelative?t.value=1:t.value=1-e.morphTargetInfluences.reduce((e,t)=>e+t,0),i&&(i.array=e.morphTargetInfluences,i.update())})},"void"),nU=class extends SR{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}},oU=class extends nU{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},lU=mE(class extends LV{static get type(){return"LightingContextNode"}constructor(e,t=null,i=[],r=null,s=null){super(e),this.lightingModel=t,this.materialLightings=i,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){let{materialLightings:e,backdropNode:t,backdropAlphaNode:i}=this,r={directDiffuse:BE().toVar("directDiffuse"),directSpecular:BE().toVar("directSpecular"),indirectDiffuse:BE().toVar("indirectDiffuse"),indirectSpecular:BE().toVar("indirectSpecular")};return{radiance:BE().toVar("radiance"),irradiance:BE().toVar("irradiance"),iblIrradiance:BE().toVar("iblIrradiance"),ambientOcclusion:TE(1).toVar("ambientOcclusion"),reflectedLight:r,materialLightings:e,backdrop:t,backdropAlpha:i}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),hU=class extends nU{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},uU=new rs,cU=mE(dU=class extends KD{static get type(){return"ViewportTextureNode"}constructor(e=mI,t=null,i=null){let r=null;null===i?(r=new Oo,r.minFilter=$t,i=r):r=i,super(i,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=mR.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,i;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,i=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,i=this._cacheTextures),null===e)return t;if(!1===i.has(e)){let r=t.clone();i.set(e,r)}return i.get(e)}updateReference(e){let t=e.renderer,i=t.getRenderTarget(),r=t.getCanvasTarget(),s=i||r;return this.value=this.getTextureForReference(s),this.value}updateBefore(e){let t=e.renderer,i=t.getRenderTarget(),r=t.getCanvasTarget(),s=i||r;null===s?t.getDrawingBufferSize(uU):s.getDrawingBufferSize?s.getDrawingBufferSize(uU):uU.set(s.width,s.height);let a=this.getTextureForReference(s);(a.image.width!==uU.width||a.image.height!==uU.height)&&(a.image.width=uU.width,a.image.height=uU.height,a.needsUpdate=!0);let n=a.generateMipmaps;a.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(a),a.generateMipmaps=n}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}).setParameterLength(0,3),pU=mE(dU,null,null,{generateMipmaps:!0}).setParameterLength(0,3),mU=pU(),gU=(e=mI,t=null)=>mU.sample(e,t),fU=null,yU=mE(class extends dU{static get type(){return"ViewportDepthTextureNode"}constructor(e=mI,t=null,i=null){null===i&&(null===fU&&(fU=new Do),i=fU),super(e,t,i)}}).setParameterLength(0,3),(vU=class extends SR{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){let{scope:t}=this;return t===vU.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){let{scope:t}=this,i=this.valueNode,r=null;if(t===vU.DEPTH_BASE)null!==i&&(r=AU().assign(i));else if(t===vU.DEPTH)r=e.isPerspectiveCamera?_U(bL.z,LI,zI):bU(bL.z,LI,zI);else if(t===vU.LINEAR_DEPTH)if(null!==i)if(e.isPerspectiveCamera){let e=MU(i,LI,zI);r=bU(e,LI,zI)}else r=i;else r=bU(bL.z,LI,zI);return r}}).DEPTH_BASE="depthBase",vU.DEPTH="depth",vU.LINEAR_DEPTH="linearDepth",bU=(e,t,i)=>e.add(t).div(t.sub(i)),xU=(e,t,i)=>e.add(i).div(i.sub(t)),wU=JN(([e,t,i],r)=>!0===r.renderer.reversedDepthBuffer?i.sub(t).mul(e).sub(i):t.sub(i).mul(e).sub(t)),_U=(e,t,i)=>t.add(e).mul(i).div(i.sub(t).mul(e)),SU=(e,t,i)=>t.mul(e.add(i)).div(e.mul(t.sub(i))),MU=JN(([e,t,i],r)=>!0===r.renderer.reversedDepthBuffer?t.mul(i).div(t.sub(i).mul(e).sub(t)):t.mul(i).div(i.sub(t).mul(e).sub(i))),TU=(e,t,i)=>{t=t.max(1e-6).toVar();let r=NB(e.negate().div(t)),s=NB(i.div(t));return r.div(s)},CU=(e,t,i)=>{let r=e.mul(AB(i.div(t)));return TE(Math.E).pow(r).mul(t).negate()},AU=mE(vU,vU.DEPTH_BASE),NU=gE(vU,vU.DEPTH),PU=mE(vU,vU.LINEAR_DEPTH).setParameterLength(0,1),RU=PU(yU()),NU.assign=e=>AU(e),(EU=class extends SR{static get type(){return"ClippingNode"}constructor(e=EU.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);let t=e.clippingContext,{intersectionPlanes:i,unionPlanes:r}=t;return this.hardwareClipping=e.hardwareClipping,this.scope===EU.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(i,r):this.scope===EU.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(i,r)}setupAlphaToCoverage(e,t){return JN(()=>{let i=TE().toVar("distanceToPlane"),r=TE().toVar("distanceToGradient"),s=TE(1).toVar("clipOpacity"),a=t.length;if(!1===this.hardwareClipping&&a>0){let e=lI(t).setGroup(OO);Jk(a,({i:t})=>{let a=e.element(t);i.assign(bL.dot(a.xyz).negate().add(a.w)),r.assign(i.fwidth().div(2)),s.mulAssign(NV(r.negate(),r,i))})}let n=e.length;if(n>0){let t=lI(e).setGroup(OO),a=TE(1).toVar("intersectionClipOpacity");Jk(n,({i:e})=>{let s=t.element(e);i.assign(bL.dot(s.xyz).negate().add(s.w)),r.assign(i.fwidth().div(2)),a.mulAssign(NV(r.negate(),r,i).oneMinus())}),s.mulAssign(a.oneMinus())}ZE.a.mulAssign(s),ZE.a.equal(0).discard()})()}setupDefault(e,t){return JN(()=>{let i=t.length;if(!1===this.hardwareClipping&&i>0){let e=lI(t).setGroup(OO);Jk(i,({i:t})=>{let i=e.element(t);bL.dot(i.xyz).greaterThan(i.w).discard()})}let r=e.length;if(r>0){let t=lI(e).setGroup(OO),i=NE(!0).toVar("clipped");Jk(r,({i:e})=>{let r=t.element(e);i.assign(bL.dot(r.xyz).greaterThan(r.w).and(i))}),i.discard()}})()}setupHardwareClipping(e,t){let i=e.length;return t.enableHardwareClipping(i),JN(()=>{let r=lI(e).setGroup(OO),s=hI(t.getClipDistance());Jk(i,({i:e})=>{let t=r.element(e),i=bL.dot(t.xyz).sub(t.w).negate();s.element(e).assign(i)})})()}}).ALPHA_TO_COVERAGE="alphaToCoverage",EU.DEFAULT="default",EU.HARDWARE="hardware",OU=()=>new EU,BU=()=>new EU(EU.ALPHA_TO_COVERAGE),VU=()=>new EU(EU.HARDWARE),DU=JN(([e])=>VB(qO(1e4,DB(qO(17,e.x).add(qO(.1,e.y)))).mul(GO(.1,$B(DB(qO(13,e.y).add(e.x))))))),IU=JN(([e])=>DU(PE(DU(e.xy),e.z))),LU=JN(([e])=>{let t=lV(XB(JB(e.xyz)),XB(QB(e.xyz))),i=TE(1).div(TE(.05).mul(t)).toVar("pixScale"),r=PE(CB(EB(NB(i))),CB(OB(NB(i)))),s=PE(IU(EB(r.x.mul(e.xyz))),IU(EB(r.y.mul(e.xyz)))),a=VB(NB(i)),n=GO(qO(a.oneMinus(),s.x),qO(a,s.y)),o=oV(a,a.oneMinus()),l=BE(n.mul(n).div(qO(2,o).mul(WO(1,o))),n.sub(qO(.5,o)).div(WO(1,o)),WO(1,WO(1,n).mul(WO(1,n)).div(qO(2,o).mul(WO(1,o))))),h=n.lessThan(o.oneMinus()).select(n.lessThan(o).select(l.x,l.y),l.z);return TV(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]}),zU=class extends GD{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return"color"+(e>0?e:"")}generate(e){let t,i=this.getAttributeName(e);return t=!0===e.hasGeometryAttribute(i)?super.generate(e):e.generateConst(this.nodeType,new Ss(1,1,1,1)),t}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},kU=(e=0)=>new zU(e),UU=class extends un{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(!0===t.startsWith("_"))continue;let i=this[t];i&&!0===i.isNode&&e.push({property:t,childNode:i})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:i}of this._getNodeChildren())e.push(lR(t.slice(0,-4)),i.getCacheKey());return this.type+hR(e)}build(e){this.setup(e)}setupObserver(e){return new aR(e)}setup(e){e.context.setupNormal=()=>$V(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,i=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),s=$V(this.vertexNode||r,"VERTEX");e.context.clipSpace=s,e.stack.outputNode=s,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a,n=this.setupClipping(e);if((!0===this.depthWrite||!0===this.depthTest)&&(null!==i?!0===i.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);let r=this.setupLighting(e);null!==n&&e.stack.addToStack(n);let s=LE(r,ZE.a).max(0);a=this.setupOutput(e,s),yO.assign(a);let o=null!==this.outputNode;if(o&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),null!==i){let e=t.getMRT(),i=this.mrtNode;null!==e?(o&&yO.assign(a),a=e,null!==i&&(a=e.merge(i))):null!==i&&(a=i)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=t.convert(e.getOutputType())),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;let{unionPlanes:t,intersectionPlanes:i}=e.clippingContext,r=null;if(t.length>0||i.length>0){let t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?r=BU():e.stack.addToStack(OU())}return r}setupHardwareClipping(e){if(e.hardwareClipping=!1,null===e.clippingContext)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(VU()),e.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:i}=e,r=this.depthNode;if(null===r){let e=t.getMRT();e&&e.has("depth")?r=e.get("depth"):!0===t.logarithmicDepthBuffer&&(r=i.isPerspectiveCamera?TU(bL.z,LI,zI):bU(bL.z,LI,zI))}null!==r&&NU.assign(r).toStack()}setupPositionView(){return hL.mul(gL).xyz}setupModelViewProjection(){return kI.mul(bL)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),Mk}setupPosition(e){let{object:t,geometry:i}=e;if((i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&aU(t),!0===t.isSkinnedMesh&&Xk(t),this.displacementMap){let e=tz("displacementMap","texture"),t=tz("displacementScale","float"),i=tz("displacementBias","float");gL.addAssign(CL.normalize().mul(e.x.mul(t).add(i)))}return t.isBatchedMesh&&Hk(t),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&jk(t),null!==this.positionNode&&gL.assign($V(this.positionNode,"POSITION","vec3")),gL}setupDiffuseColor(e){let{object:t,geometry:i}=e;null!==this.maskNode&&NE(this.maskNode).not().discard();let r=this.colorNode?LE(this.colorNode):Fz;!0===this.vertexColors&&i.hasAttribute("color")&&(r=r.mul(kU())),t.instanceColor&&(r=Uk.mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=qk.mul(r)),ZE.assign(r);let s=this.opacityNode?TE(this.opacityNode):Wz;ZE.a.assign(ZE.a.mul(s));let a=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(a=null!==this.alphaTestNode?TE(this.alphaTestNode):Uz,!0===this.alphaToCoverage?(ZE.a=NV(a,a.add(rV(ZE.a)),ZE.a),ZE.a.lessThanEqual(0).discard()):ZE.a.lessThanEqual(a).discard()),!0===this.alphaHash&&ZE.a.lessThan(LU(gL)).discard(),e.isOpaque()&&ZE.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?BE(0):ZE.rgb}setupNormal(){return this.normalNode?BE(this.normalNode):Jz}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?tz("envMap","cubeTexture"):tz("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new hU(wk)),t}setupMaterialLightings(e){let t=[];if(!1===e.renderer.lighting.enabled)return t;let i=this.setupEnvironment(e);i&&i.isLightingNode&&t.push(i);let r=this.setupLightMap(e);return r&&r.isLightingNode&&t.push(r),e.context.ambientOcclusion&&t.push(new oU(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;null===t&&e.material.aoMap&&(t=_k),e.context.getAO&&(t=e.context.getAO(t,e)),null!==t&&(AO.assign(t),e.context.ambientOcclusion=AO)}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:i,backdropAlphaNode:r,emissiveNode:s}=this,a=!0===this.lights||null!==this.lightsNode,n=!0===this.lights?this.setupMaterialLightings(e):[],o=a?this.lightsNode||e.lightsNode:null,l=this.setupOutgoingLight(e);if(o&&(n.length>0||o.getScope().hasLights)){let t=this.setupLightingModel(e)||null;l=lU(o,t,n,i,r)}else null!==i&&(l=BE(null!==r?MV(l,i,r):i));return(s&&!0===s.isNode||t.emissive&&!0===t.emissive.isColor)&&(QE.assign(BE(s||Gz)),l=l.add(QE)),l}setupFog(e,t){let i=e.fogNode;return i&&(yO.assign(t),t=LE(i.toVar())),t}setupPremultipliedAlpha(e,t){return DD(t)}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),!0===this.premultipliedAlpha&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let i=e[t];void 0===this[t]&&(this[t]=i,i&&i.clone&&(this[t]=i.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});let i=un.prototype.toJSON.call(this,e);i.inputNodes={};for(let{property:t,childNode:r}of this._getNodeChildren())i.inputNodes[t]=r.toJSON(e).uuid;function r(e){let t=[];for(let i in e){let r=e[i];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),s=r(e.images),a=r(e.nodes);t.length>0&&(i.textures=t),s.length>0&&(i.images=s),a.length>0&&(i.nodes=a)}return i}copy(e){let t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(let i in t)if(void 0!==t[i].set&&void 0!==e[i]){let t=e[i];this[i]&&void 0!==this[i].copy?this[i].copy(t):this[i]=t}for(let t in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(t)&&void 0!==this[t]&&void 0!==e[t]){let i=e[t];this[t]&&void 0!==this[t].copy?this[t].copy(i):this[t]=i}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(e=>e.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}},FU=new vo,jU=class extends UU{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(FU),this.setValues(e)}},GU=new Ml,WU=class extends UU{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(GU),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?TE(this.offsetNode):vk,t=this.dashScaleNode?TE(this.dashScaleNode):mk,i=this.dashSizeNode?TE(this.dashSizeNode):gk,r=this.gapSizeNode?TE(this.gapSizeNode):fk;vO.assign(i),bO.assign(r);let s=YV(WD("lineDistance").mul(t));(e?s.add(e):s).mod(vO.add(bO)).greaterThan(vO).discard()}},qU=new Ml,HU=KE("vec3","worldStart"),$U=KE("vec3","worldEnd"),YU=KE("float","lineDistance"),XU=KE("vec4","worldPos"),KU=JN(({start:e,end:t})=>{let i=kI.element(2).element(2),r=kI.element(3).element(2);return i.greaterThan(0).select(r.negate().div(i.add(1)),r.mul(-.5).div(i)).sub(e.z).div(t.z.sub(e.z))},{start:"vec4",end:"vec4",return:"float"}),ZU=JN(({p1:e,p2:t,p3:i,p4:r})=>{let s=e.sub(i),a=r.sub(i),n=t.sub(e),o=s.dot(a),l=a.dot(n),h=s.dot(n),u=a.dot(a),d=n.dot(n).mul(u).sub(l.mul(l)),c=o.mul(l).sub(h.mul(u)).div(d).clamp(),p=o.add(l.mul(c)).div(u).clamp();return PE(c,p)},{p1:"vec3",p2:"vec3",p3:"vec3",p4:"vec3",return:"vec2"}),JU=JN(({material:e})=>{let t,i,r=e._useDash,s=e._useWorldUnits,a=WD("instanceStart"),n=WD("instanceEnd"),o=LE(hL.mul(LE(a,1))).toVar("start"),l=LE(hL.mul(LE(n,1))).toVar("end");r&&(t=TE(WD("instanceDistanceStart")).toVar("distanceStart"),i=TE(WD("instanceDistanceEnd")).toVar("distanceEnd")),s&&(HU.assign(o.xyz),$U.assign(l.xyz));let h=yI.z.div(yI.w),u=kI.element(2).element(3).equal(-1);if(_E(u,()=>{_E(o.z.lessThan(0).and(l.z.greaterThan(0)),()=>{let e=KU({start:o,end:l});l.assign(LE(MV(o.xyz,l.xyz,e),l.w)),r&&i.assign(MV(t,i,e))}).ElseIf(l.z.lessThan(0).and(o.z.greaterThanEqual(0)),()=>{let e=KU({start:l,end:o});o.assign(LE(MV(l.xyz,o.xyz,e),o.w)),r&&t.assign(MV(i,t,e))})}),r){let r=e.dashScaleNode?TE(e.dashScaleNode):mk,s=e.offsetNode?TE(e.offsetNode):vk,a=mL.y.lessThan(.5).select(r.mul(t),r.mul(i));a=a.add(s),YU.assign(a)}let d=kI.mul(o),c=kI.mul(l),p=d.xyz.div(d.w),m=c.xyz.div(c.w),g=m.xy.sub(p.xy).toVar();g.x.assign(g.x.mul(h)),g.assign(g.dot(g).greaterThan(1e-12).select(g.normalize(),PE(1,0)));let f=LE().toVar();if(s){let e=l.xyz.sub(o.xyz).normalize(),t=MV(o.xyz,l.xyz,.5).normalize(),i=e.cross(t).normalize(),s=e.cross(i);XU.assign(mL.y.lessThan(.5).select(o,l));let a=yk.mul(.5);XU.addAssign(LE(mL.x.lessThan(0).select(i.mul(a),i.mul(a).negate()),0)),r||(XU.addAssign(LE(mL.y.lessThan(.5).select(e.mul(a).negate(),e.mul(a)),0)),XU.addAssign(LE(s.mul(a),0)),_E(mL.y.greaterThan(1).or(mL.y.lessThan(0)),()=>{XU.subAssign(LE(s.mul(2).mul(a),0))})),f.assign(kI.mul(XU));let n=BE().toVar();n.assign(mL.y.lessThan(.5).select(p,m)),f.z.assign(n.z.mul(f.w))}else{let e=PE(g.y,g.x.negate()).toVar("offset");g.x.assign(g.x.div(h)),e.x.assign(e.x.div(h)),e.assign(mL.x.lessThan(0).select(e.negate(),e)),_E(mL.y.lessThan(0),()=>{e.assign(e.sub(g))}).ElseIf(mL.y.greaterThan(1),()=>{e.assign(e.add(g))}),e.assign(e.mul(yk)),e.assign(e.div(yI.w.div(pI))),f.assign(mL.y.lessThan(.5).select(d,c)),e.assign(e.mul(f.w)),f.assign(f.add(LE(e,0,0))),_E(u.and(f.w.lessThanEqual(0)),()=>{f.assign(LE(0,0,2,1))})}return f})(),QU=JN(({material:e,renderer:t})=>{let i=e._useAlphaToCoverage,r=e._useDash,s=e._useWorldUnits,a=qD();if(r){let t=e.dashSizeNode?TE(e.dashSizeNode):gk,i=e.gapSizeNode?TE(e.gapSizeNode):fk;vO.assign(t),bO.assign(i),a.y.lessThan(-1).or(a.y.greaterThan(1)).discard(),YU.mod(vO.add(bO)).greaterThan(vO).discard()}let n=TE(1).toVar("alpha");if(s){let e=XU.xyz.normalize().mul(1e5),s=$U.sub(HU),a=ZU({p1:HU,p2:$U,p3:BE(0,0,0),p4:e}),o=HU.add(s.mul(a.x)),l=e.mul(a.y),h=o.sub(l).length().div(yk);if(!r)if(i&&t.currentSamples>0){let e=h.fwidth();n.assign(NV(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(i&&t.currentSamples>0){let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1)),i=e.mul(e).add(t.mul(t)),r=TE(i.fwidth()).toVar("dlen");_E(a.y.abs().greaterThan(1),()=>{n.assign(NV(r.oneMinus(),r.add(1),i).oneMinus())})}else _E(a.y.abs().greaterThan(1),()=>{let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()});return n})(),eF=class extends UU{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(qU),this.vertexColors=e.vertexColors,this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=He,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setupDiffuseColor(e){if(super.setupDiffuseColor(e),ZE.a.mulAssign(QU),!0===this.vertexColors&&e.geometry.hasAttribute("instanceColorStart")){let e=WD("instanceColorStart"),t=WD("instanceColorEnd"),i=mL.y.lessThan(.5).select(e,t);ZE.rgb.mulAssign(i)}this.transparent&&ZE.rgb.assign(ZE.rgb.mul(ZE.a).add(gU().rgb.mul(ZE.a.oneMinus())))}setupModelViewProjection(){return JU}get lineColorNode(){return this.colorNode}set lineColorNode(e){v('Line2NodeMaterial: "lineColorNode" has been deprecated. Use "colorNode" instead.'),this.colorNode=e}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},tF=new wl,iF=class extends UU{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(tF),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?TE(this.opacityNode):Wz;ZE.assign(tD(LE(Pz(RL),e),hr))}},rF=JN(([e=vL])=>{let t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),i=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return PE(t,i)}),sF=JN(([e=qD()])=>{let t=e.x.sub(.5).mul(2*Math.PI),i=e.y.sub(.5).mul(Math.PI),r=i.cos(),s=r.mul(t.cos()),a=i.sin(),n=r.mul(t.sin());return BE(s,a,n)}),aF=class extends Ms{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Bo(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let i=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let s=new Lo(5,5,5),a=rF(vL),n=new UU;n.colorNode=JD(t,a,0),n.side=We,n.blending=He;let o=new Hn(s,n),l=new la;l.add(o),t.minFilter===$t&&(t.minFilter=qt);let h=new wh(1,10,this),u=e.getMRT();return e.setMRT(null),h.update(e,l),e.setMRT(u),t.minFilter=i,t.generateMipmaps=r,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){let s=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,r);e.setRenderTarget(s)}},nF=new WeakMap,oF=mE(class extends CR{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=YL(null);let t=new Bo;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=mR.RENDER}updateBefore(e){let{renderer:t,material:i}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:i[r.property];if(e&&e.isTexture){let i=e.mapping;if(i===It||i===Lt){if(nF.has(e)){let t=nF.get(e);mP(t,e.mapping),this._cubeTexture=t}else{let i=e.image;if(null!=(s=i)&&s.height>0){let r=new aF(i.height);r.fromEquirectangularTexture(t,e),mP(r.texture,e.mapping),this._cubeTexture=r.texture,nF.set(e,r.texture),e.addEventListener("dispose",pP)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}var s}setup(e){return this.updateBefore(e),this._cubeTextureNode}}).setParameterLength(1),lF=class extends nU{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=oF(this.envNode)}},hF=class extends nU{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=TE(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},uF=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},dF=class extends uF{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,i=e.reflectedLight,r=e.irradianceLightMap;i.indirectDiffuse.assign(LE(0)),r?i.indirectDiffuse.addAssign(r):i.indirectDiffuse.addAssign(LE(1,1,1,0)),i.indirectDiffuse.mulAssign(t),i.indirectDiffuse.mulAssign(ZE.rgb)}finish(e){let{material:t,context:i}=e,r=i.outgoingLight,s=e.context.environment;if(s)switch(t.combine){case St:r.rgb.assign(MV(r.rgb,r.rgb.mul(s.rgb),Yz.mul(Xz)));break;case Mt:r.rgb.assign(MV(r.rgb,s.rgb,Yz.mul(Xz)));break;case Tt:r.rgb.addAssign(s.rgb.mul(Yz.mul(Xz)));break;default:f("BasicLightingModel: Unsupported .combine value:",t.combine)}}},cF=new Vn,pF=class extends UU{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(cF),this.setValues(e)}setupNormal(){return SL(NL)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new lF(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new hF(wk)),t}setupOutgoingLight(){return ZE.rgb}setupLightingModel(){return new dF}},mF=JN(({f0:e,f90:t,dotVH:i})=>{let r=i.mul(-5.55473).sub(6.98316).mul(i).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),gF=JN(e=>e.diffuseColor.mul(1/Math.PI)),fF=()=>TE(.25),yF=JN(({dotNH:e})=>fO.mul(TE(.5)).add(1).mul(TE(1/Math.PI)).mul(e.pow(fO))),vF=JN(({lightDirection:e})=>{let t=e.add(xL).normalize(),i=RL.dot(t).clamp(),r=xL.dot(t).clamp(),s=mF({f0:pO,f90:1,dotVH:r}),a=fF(),n=yF({dotNH:i});return s.mul(a).mul(n)}),bF=class extends dF{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:i}){let r=RL.dot(e).clamp().mul(t);i.directDiffuse.addAssign(r.mul(gF({diffuseColor:ZE.rgb}))),!0===this.specular&&i.directSpecular.addAssign(r.mul(vF({lightDirection:e})).mul(Yz))}indirect(e){let{ambientOcclusion:t,irradiance:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(i.mul(gF({diffuseColor:ZE}))),r.indirectDiffuse.mulAssign(t)}},xF=new _l,wF=class extends UU{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(xF),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new lF(t):null}setupLightingModel(){return new bF(!1)}},_F=new bl,SF=class extends UU{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(_F),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new lF(t):null}setupLightingModel(){return new bF}setupVariants(){let e=(this.shininessNode?TE(this.shininessNode):jz).max(1e-4);fO.assign(e);let t=this.specularNode||qz;pO.assign(t)}},MF=JN(e=>{if(!1===e.geometry.hasAttribute("normal"))return TE(0);let t=NL.dFdx().abs().max(NL.dFdy().abs());return t.x.max(t.y).max(t.z)}),TF=JN(e=>{let{roughness:t}=e,i=MF(),r=t.max(.0525);return r=r.add(i),r=r.min(1),r}),CF=JN(({alpha:e,dotNL:t,dotNV:i})=>{let r=e.pow2(),s=t.mul(r.add(r.oneMinus().mul(i.pow2())).sqrt()),a=i.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return HO(.5,s.add(a).max(gB))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),AF=JN(({alphaT:e,alphaB:t,dotTV:i,dotBV:r,dotTL:s,dotBL:a,dotNV:n,dotNL:o})=>{let l=o.mul(BE(e.mul(i),t.mul(r),n).length()),h=n.mul(BE(e.mul(s),t.mul(a),o).length());return HO(.5,l.add(h).max(gB))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),NF=JN(({alpha:e,dotNH:t})=>{let i=e.pow2(),r=t.pow2().mul(i.oneMinus()).oneMinus();return i.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),PF=TE(1/Math.PI),RF=JN(({alphaT:e,alphaB:t,dotNH:i,dotTH:r,dotBH:s})=>{let a=e.mul(t),n=BE(t.mul(r),e.mul(s),a.mul(i)),o=n.dot(n),l=a.div(o);return PF.mul(a.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),EF=JN(({lightDirection:e,f0:t,f90:i,roughness:r,f:s,normalView:a=RL,USE_IRIDESCENCE:n,USE_ANISOTROPY:o})=>{let l,h,u=r.pow2(),d=e.add(xL).normalize(),c=a.dot(e).clamp(),p=a.dot(xL).clamp(),m=a.dot(d).clamp(),g=xL.dot(d).clamp(),f=mF({f0:t,f90:i,dotVH:g});if(KN(n)&&(f=nO.mix(f,s)),KN(o)){let t=dO.dot(e),i=dO.dot(xL),r=dO.dot(d),s=cO.dot(e),a=cO.dot(xL),n=cO.dot(d);l=AF({alphaT:hO,alphaB:u,dotTV:i,dotBV:a,dotTL:t,dotBL:s,dotNV:p,dotNL:c}),h=RF({alphaT:hO,alphaB:u,dotNH:m,dotTH:r,dotBH:n})}else l=CF({alpha:u,dotNL:c,dotNV:p}),h=NF({alpha:u,dotNH:m});return f.mul(l).mul(h)}),OF=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),BF=null,VF=JN(({roughness:e,dotNV:t})=>{null===BF&&((BF=new Yn(OF,16,16,gi,ii)).name="DFG_LUT",BF.minFilter=qt,BF.magFilter=qt,BF.wrapS=Ut,BF.wrapT=Ut,BF.generateMipmaps=!1,BF.needsUpdate=!0);let i=PE(e,t);return JD(BF,i).rg}),DF=JN(({lightDirection:e,f0:t,f90:i,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:n})=>{let o=EF({lightDirection:e,f0:t,f90:i,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:n}),l=RL.dot(e).clamp(),h=RL.dot(xL).clamp(),u=VF({roughness:r,dotNV:h}),d=VF({roughness:r,dotNV:l}),c=t.mul(u.x).add(i.mul(u.y)),p=t.mul(d.x).add(i.mul(d.y)),m=u.x.add(u.y),g=d.x.add(d.y),f=TE(1).sub(m),y=TE(1).sub(g),v=t.add(t.oneMinus().mul(.047619)),b=c.mul(p).mul(v).div(TE(1).sub(f.mul(y).mul(v).mul(v)).add(gB)),x=f.mul(y),w=b.mul(x);return o.add(w)}),IF=JN(e=>{let{dotNV:t,specularColor:i,specularF90:r,roughness:s}=e,a=VF({dotNV:t,roughness:s});return i.mul(a.x).add(r.mul(a.y))}),LF=JN(({f:e,f90:t,dotVH:i})=>{let r=i.oneMinus().saturate(),s=r.mul(r),a=r.mul(s,s).clamp(0,.9999);return e.sub(BE(t).mul(a)).div(a.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),zF=JN(({roughness:e,dotNH:t})=>{let i=e.pow2(),r=TE(1).div(i),s=t.pow2().oneMinus().max(.0078125);return TE(2).add(r).mul(s.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),kF=JN(({dotNV:e,dotNL:t})=>TE(1).div(TE(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),UF=JN(({lightDirection:e})=>{let t=e.add(xL).normalize(),i=RL.dot(e).clamp(),r=RL.dot(xL).clamp(),s=RL.dot(t).clamp(),a=zF({roughness:aO,dotNH:s}),n=kF({dotNV:r,dotNL:i});return sO.mul(a).mul(n)}),FF=JN(({N:e,V:t,roughness:i})=>{let r=e.dot(t).saturate(),s=PE(i,r.oneMinus().sqrt());return s.assign(s.mul(.984375).add(.0078125)),s}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),jF=JN(({f:e})=>{let t=e.length();return lV(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),GF=JN(({v1:e,v2:t})=>{let i=e.dot(t),r=i.abs().toVar(),s=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),n=s.div(a),o=i.greaterThan(0).select(n,lV(i.mul(i).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(n));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),WF=JN(({N:e,V:t,P:i,mInv:r,p0:s,p1:a,p2:n,p3:o})=>{let l=a.sub(s).toVar(),h=o.sub(s).toVar(),u=l.cross(h),d=BE().toVar();return _E(u.dot(i.sub(s)).greaterThanEqual(0),()=>{let l=t.sub(e.mul(t.dot(e))).normalize(),h=e.cross(l).negate(),u=r.mul(jE(l,h,e).transpose()).toVar(),c=u.mul(s.sub(i)).normalize().toVar(),p=u.mul(a.sub(i)).normalize().toVar(),m=u.mul(n.sub(i)).normalize().toVar(),g=u.mul(o.sub(i)).normalize().toVar(),f=BE(0).toVar();f.addAssign(GF({v1:c,v2:p})),f.addAssign(GF({v1:p,v2:m})),f.addAssign(GF({v1:m,v2:g})),f.addAssign(GF({v1:g,v2:c})),d.assign(BE(jF({f:f})))}),d}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),qF=1/6,HF=e=>qO(qF,qO(e,qO(e,e.negate().add(3)).sub(3)).add(1)),$F=e=>qO(qF,qO(e,qO(e,qO(3,e).sub(6))).add(4)),YF=e=>qO(qF,qO(e,qO(e,qO(-3,e).add(3)).add(3)).add(1)),XF=e=>qO(qF,gV(e,3)),KF=e=>HF(e).add($F(e)),ZF=e=>YF(e).add(XF(e)),JF=e=>GO(-1,$F(e).div(HF(e).add($F(e)))),QF=e=>GO(1,XF(e).div(YF(e).add(XF(e)))),ej=(e,t,i)=>{let r=e.uvNode,s=qO(r,t.zw).add(.5),a=EB(s),n=VB(s),o=KF(n.x),l=ZF(n.x),h=JF(n.x),u=QF(n.x),d=JF(n.y),c=QF(n.y),p=PE(a.x.add(h),a.y.add(d)).sub(.5).mul(t.xy),m=PE(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),g=PE(a.x.add(h),a.y.add(c)).sub(.5).mul(t.xy),f=PE(a.x.add(u),a.y.add(c)).sub(.5).mul(t.xy),y=KF(n.y).mul(GO(o.mul(e.sample(p).level(i)),l.mul(e.sample(m).level(i)))),v=ZF(n.y).mul(GO(o.mul(e.sample(g).level(i)),l.mul(e.sample(f).level(i))));return y.add(v)},tj=JN(([e,t])=>{let i=PE(e.size(CE(t))),r=PE(e.size(CE(t.add(1)))),s=HO(1,i),a=HO(1,r),n=ej(e,LE(s,i),EB(t)),o=ej(e,LE(a,r),OB(t));return VB(t).mix(n,o)}),ij=JN(([e,t])=>{let i=t.mul($D(e));return tj(e,i)}),rj=JN(([e,t,i,r,s])=>{let a=BE(AV(t.negate(),BB(e),HO(1,r))),n=BE(XB(s[0].xyz),XB(s[1].xyz),XB(s[2].xyz));return BB(a).mul(i.mul(n))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),sj=JN(([e,t])=>e.mul(TV(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),aj=pU(),nj=gU(),oj=JN(([e,t,i],{material:r})=>{let s=(r.side===We?aj:nj).sample(e),a=NB(gI.x).mul(sj(t,i));return tj(s,a)}),lj=JN(([e,t,i])=>(_E(i.notEqual(0),()=>{let r=AB(t).negate().div(i);return TB(r.negate().mul(e))}),BE(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),hj=JN(([e,t,i,r,s,a,n,o,l,h,u,d,c,p,m])=>{let g,f;if(m){g=LE().toVar(),f=BE().toVar();let s=u.sub(1).mul(m.mul(.025)),a=BE(u.sub(s),u,u.add(s));Jk({start:0,end:3},({i:s})=>{let u=a.element(s),m=rj(e,t,d,u,o),y=n.add(m),v=h.mul(l.mul(LE(y,1))),b=PE(v.xy.div(v.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(PE(b.x,b.y.oneMinus()));let x=oj(b,i,u);g.element(s).assign(x.element(s)),g.a.addAssign(x.a),f.element(s).assign(r.element(s).mul(lj(XB(m),c,p).element(s)))}),g.a.divAssign(3)}else{let s=rj(e,t,d,u,o),a=n.add(s),m=h.mul(l.mul(LE(a,1))),y=PE(m.xy.div(m.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(PE(y.x,y.y.oneMinus())),g=oj(y,i,u),f=r.mul(lj(XB(s),c,p))}let y=f.rgb.mul(g.rgb),v=e.dot(t).clamp(),b=BE(IF({dotNV:v,specularColor:s,specularF90:a,roughness:i})),x=f.r.add(f.g,f.b).div(3);return LE(b.oneMinus().mul(y),g.a.oneMinus().mul(x).oneMinus())}),uj=jE(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),dj=e=>{let t=e.sqrt();return BE(1).add(t).div(BE(1).sub(t))},cj=(e,t)=>e.sub(t).div(e.add(t)).pow2(),pj=(e,t)=>{let i=e.mul(2*Math.PI*1e-9),r=BE(54856e-17,44201e-17,52481e-17),s=BE(1681e3,1795300,2208400),a=BE(43278e5,93046e5,66121e5),n=TE(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(i.mul(2239900).add(t.x).cos()).mul(i.pow2().mul(-45282e5).exp()),o=r.mul(a.mul(2*Math.PI).sqrt()).mul(s.mul(i).add(t).cos()).mul(i.pow2().negate().mul(a).exp());return o=BE(o.x.add(n),o.y,o.z).div(1.0685e-7),uj.mul(o)},mj=JN(({outsideIOR:e,eta2:t,cosTheta1:i,thinFilmThickness:r,baseF0:s})=>{let a=MV(e,t,NV(0,.03,r)),n=e.div(a).pow2().mul(i.pow2().oneMinus()).oneMinus();_E(n.lessThan(0),()=>BE(1));let o=n.sqrt(),l=cj(a,e),h=mF({f0:l,f90:1,dotVH:i}),u=h.oneMinus(),d=a.lessThan(e).select(Math.PI,0),c=TE(Math.PI).sub(d),p=dj(s.clamp(0,.9999)),m=cj(p,a.toVec3()),g=mF({f0:m,f90:1,dotVH:o}),f=BE(p.x.lessThan(a).select(Math.PI,0),p.y.lessThan(a).select(Math.PI,0),p.z.lessThan(a).select(Math.PI,0)),y=a.mul(r,o,2),v=BE(c).add(f),b=h.mul(g).clamp(1e-5,.9999),x=b.sqrt(),w=u.pow2().mul(g).div(BE(1).sub(b)),_=h.add(w).toVar(),S=w.sub(u).toVar();return Jk({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{S.mulAssign(x);let t=pj(TE(e).mul(y),TE(e).mul(v)).mul(2);_.addAssign(S.mul(t))}),_.max(BE(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),gj=JN(({normal:e,viewDir:t,roughness:i})=>{let r=e.dot(t).saturate(),s=i.mul(i),a=i.add(.1).reciprocal(),n=TE(-1.9362).add(i.mul(1.0678)).add(s.mul(.4573)).sub(a.mul(.8469)),o=TE(-.6014).add(i.mul(.5538)).sub(s.mul(.467)).sub(a.mul(.1255));return n.mul(r).add(o).exp().saturate()}),fj=BE(.04),yj=TE(1),vj=class extends uF{constructor(e=!1,t=!1,i=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=i,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=BE().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=BE().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=BE().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=BE().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=BE().toVar("sheenSpecularIndirect")),!0===this.iridescence){let e=RL.dot(xL).clamp(),t=mj({outsideIOR:TE(1),eta2:oO,cosTheta1:e,thinFilmThickness:lO,baseF0:pO}),i=mj({outsideIOR:TE(1),eta2:oO,cosTheta1:e,thinFilmThickness:lO,baseF0:ZE.rgb});this.iridescenceFresnel=MV(t,i,tO),this.iridescenceF0Dielectric=LF({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=LF({f:i,f90:1,dotVH:e}),this.iridescenceF0=MV(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,tO)}if(!0===this.transmission){let t=yL,i=WI.sub(yL).normalize(),r=EL,s=e.context;s.backdrop=hj(r,i,eO,JE,mO,gO,t,iL,FI,kI,wO,SO,TO,MO,this.dispersion?CO:null),s.backdropAlpha=_O,ZE.a.mulAssign(MV(1,s.backdrop.a,_O))}super.start(e)}computeMultiscattering(e,t,i,r,s=null){let a=RL.dot(xL).clamp(),n=VF({roughness:eO,dotNV:a}),o=s?nO.mix(r,s):r,l=o.mul(n.x).add(i.mul(n.y)),h=n.x.add(n.y).oneMinus(),u=o.add(o.oneMinus().mul(.047619)),d=l.mul(u).div(h.mul(u).oneMinus());e.addAssign(l),t.addAssign(d.mul(h))}direct({lightDirection:e,lightColor:t,reflectedLight:i}){let r=RL.dot(e).clamp().mul(t).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(r.mul(UF({lightDirection:e})));let t=gj({normal:RL,viewDir:xL,roughness:aO}),i=gj({normal:RL,viewDir:e,roughness:aO}),s=sO.r.max(sO.g).max(sO.b).mul(t.max(i)).oneMinus();r.mulAssign(s)}if(!0===this.clearcoat){let i=OL.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(i.mul(EF({lightDirection:e,f0:fj,f90:yj,roughness:rO,normalView:OL})))}i.directDiffuse.addAssign(r.mul(gF({diffuseColor:JE}))),i.directSpecular.addAssign(r.mul(DF({lightDirection:e,f0:mO,f90:1,roughness:eO,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:i,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:n}){let o=t.add(i).sub(r),l=t.sub(i).sub(r),h=t.sub(i).add(r),u=t.add(i).add(r),d=RL,c=xL,p=bL.toVar(),m=FF({N:d,V:c,roughness:eO}),g=a.sample(m).toVar(),f=n.sample(m).toVar(),y=jE(BE(g.x,0,g.y),BE(0,1,0),BE(g.z,0,g.w)).toVar(),v=mO.mul(f.x).add(gO.sub(mO).mul(f.y)).toVar();if(s.directSpecular.addAssign(e.mul(v).mul(WF({N:d,V:c,P:p,mInv:y,p0:o,p1:l,p2:h,p3:u}))),s.directDiffuse.addAssign(e.mul(JE).mul(WF({N:d,V:c,P:p,mInv:jE(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:h,p3:u}))),!0===this.clearcoat){let t=OL,i=FF({N:t,V:c,roughness:rO}),r=a.sample(i),s=n.sample(i),d=jE(BE(r.x,0,r.y),BE(0,1,0),BE(r.z,0,r.w)),m=fj.mul(s.x).add(yj.sub(fj).mul(s.y));this.clearcoatSpecularDirect.addAssign(e.mul(m).mul(WF({N:t,V:c,P:p,mInv:d,p0:o,p1:l,p2:h,p3:u})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:i}=e.context,r=t.mul(gF({diffuseColor:JE})).toVar();if(!0===this.sheen){let e=gj({normal:RL,viewDir:xL,roughness:aO}),t=sO.r.max(sO.g).max(sO.b).mul(e).oneMinus();r.mulAssign(t)}i.indirectDiffuse.addAssign(r)}indirectSpecular(e){let{radiance:t,iblIrradiance:i,reflectedLight:r}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(i.mul(sO,gj({normal:RL,viewDir:xL,roughness:aO}))),!0===this.clearcoat){let e=OL.dot(xL).clamp(),t=IF({dotNV:e,specularColor:fj,specularF90:yj,roughness:rO});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}let s=BE().toVar("singleScatteringDielectric"),a=BE().toVar("multiScatteringDielectric"),n=BE().toVar("singleScatteringMetallic"),o=BE().toVar("multiScatteringMetallic");this.computeMultiscattering(s,a,gO,pO,this.iridescenceF0Dielectric),this.computeMultiscattering(n,o,gO,ZE.rgb,this.iridescenceF0Metallic);let l=MV(s,n,tO),h=MV(a,o,tO),u=s.add(a),d=JE.mul(u.oneMinus()),c=i.mul(1/Math.PI),p=t.mul(l).add(h.mul(c)).toVar(),m=d.mul(c).toVar();if(!0===this.sheen){let e=gj({normal:RL,viewDir:xL,roughness:aO}),t=sO.r.max(sO.g).max(sO.b).mul(e).oneMinus();p.mulAssign(t),m.mulAssign(t)}r.indirectSpecular.addAssign(p),r.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:i}=e.context,r=RL.dot(xL).clamp().add(t),s=eO.mul(-16).oneMinus().negate().exp2(),a=t.sub(r.pow(s).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),i.indirectDiffuse.mulAssign(t),i.indirectSpecular.mulAssign(a)}finish({context:e}){let{outgoingLight:t}=e;if(!0===this.clearcoat){let e=OL.dot(xL).clamp(),i=mF({dotVH:e,f0:fj,f90:yj}),r=t.mul(iO.mul(i).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(iO));t.assign(r)}if(!0===this.sheen){let e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}},bj=TE(1),xj=TE(-2),wj=TE(.8),_j=TE(-1),Sj=TE(.4),Mj=TE(2),Tj=TE(.305),Cj=TE(3),Aj=TE(.21),Nj=TE(4),Pj=TE(4),Rj=TE(16),Ej=JN(([e])=>{let t=BE($B(e)).toVar(),i=TE(-1).toVar();return _E(t.x.greaterThan(t.z),()=>{_E(t.x.greaterThan(t.y),()=>{i.assign(IV(e.x.greaterThan(0),0,3))}).Else(()=>{i.assign(IV(e.y.greaterThan(0),1,4))})}).Else(()=>{_E(t.z.greaterThan(t.y),()=>{i.assign(IV(e.z.greaterThan(0),2,5))}).Else(()=>{i.assign(IV(e.y.greaterThan(0),1,4))})}),i}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Oj=JN(([e,t])=>{let i=PE().toVar();return _E(t.equal(0),()=>{i.assign(PE(e.z,e.y).div($B(e.x)))}).ElseIf(t.equal(1),()=>{i.assign(PE(e.x.negate(),e.z.negate()).div($B(e.y)))}).ElseIf(t.equal(2),()=>{i.assign(PE(e.x.negate(),e.y).div($B(e.z)))}).ElseIf(t.equal(3),()=>{i.assign(PE(e.z.negate(),e.y).div($B(e.x)))}).ElseIf(t.equal(4),()=>{i.assign(PE(e.x.negate(),e.z).div($B(e.y)))}).Else(()=>{i.assign(PE(e.x,e.y).div($B(e.z)))}),qO(.5,i.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Bj=JN(([e])=>{let t=TE(0).toVar();return _E(e.greaterThanEqual(wj),()=>{t.assign(bj.sub(e).mul(_j.sub(xj)).div(bj.sub(wj)).add(xj))}).ElseIf(e.greaterThanEqual(Sj),()=>{t.assign(wj.sub(e).mul(Mj.sub(_j)).div(wj.sub(Sj)).add(_j))}).ElseIf(e.greaterThanEqual(Tj),()=>{t.assign(Sj.sub(e).mul(Cj.sub(Mj)).div(Sj.sub(Tj)).add(Mj))}).ElseIf(e.greaterThanEqual(Aj),()=>{t.assign(Tj.sub(e).mul(Nj.sub(Cj)).div(Tj.sub(Aj)).add(Cj))}).Else(()=>{t.assign(TE(-2).mul(NB(qO(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Vj=JN(([e,t])=>{let i=e.toVar();i.assign(qO(2,i).sub(1));let r=BE(i,1).toVar();return _E(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),Dj=JN(([e,t,i,r,s,a])=>{let n=TE(i),o=BE(t),l=TV(Bj(n),xj,a),h=VB(l),u=EB(l),d=BE(Ij(e,o,u,r,s,a)).toVar();return _E(h.notEqual(0),()=>{let t=BE(Ij(e,o,u.add(1),r,s,a)).toVar();d.assign(MV(d,t,h))}),d}),Ij=JN(([e,t,i,r,s,a])=>{let n=TE(i).toVar(),o=BE(t),l=TE(Ej(o)).toVar(),h=TE(lV(Pj.sub(n),0)).toVar();n.assign(lV(n,Pj));let u=TE(CB(n)).toVar(),d=PE(Oj(o,l).mul(u.sub(2)).add(1)).toVar();return _E(l.greaterThan(2),()=>{d.y.addAssign(u),l.subAssign(3)}),d.x.addAssign(l.mul(u)),d.x.addAssign(h.mul(qO(3,Rj))),d.y.addAssign(qO(4,CB(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(s),e.sample(d).grad(PE(),PE())}),Lj=JN(({envMap:e,mipInt:t,outputDirection:i,theta:r,axis:s,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:n,CUBEUV_MAX_MIP:o})=>{let l=LB(r),h=i.mul(l).add(s.cross(i).mul(DB(r))).add(s.mul(s.dot(i).mul(l.oneMinus())));return Ij(e,h,t,a,n,o)}),zj=JN(({n:e,latitudinal:t,poleAxis:i,outputDirection:r,weights:s,samples:a,dTheta:n,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let c=BE(IV(t,i,mV(i,r))).toVar();_E(c.equal(BE(0)),()=>{c.assign(BE(r.z,0,r.x.negate()))}),c.assign(BB(c));let p=BE().toVar();return p.addAssign(s.element(0).mul(Lj({theta:0,axis:c,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),Jk({start:CE(1),end:e},({i:e})=>{_E(e.greaterThanEqual(a),()=>{eU()});let t=TE(n.mul(TE(e))).toVar();p.addAssign(s.element(e).mul(Lj({theta:t.mul(-1),axis:c,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(s.element(e).mul(Lj({theta:t,axis:c,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),LE(p,1)}),kj=JN(([e])=>{let t=AE(e).toVar();return t.assign(t.shiftLeft(AE(16)).bitOr(t.shiftRight(AE(16)))),t.assign(t.bitAnd(AE(1431655765)).shiftLeft(AE(1)).bitOr(t.bitAnd(AE(2863311530)).shiftRight(AE(1)))),t.assign(t.bitAnd(AE(858993459)).shiftLeft(AE(2)).bitOr(t.bitAnd(AE(3435973836)).shiftRight(AE(2)))),t.assign(t.bitAnd(AE(252645135)).shiftLeft(AE(4)).bitOr(t.bitAnd(AE(4042322160)).shiftRight(AE(4)))),t.assign(t.bitAnd(AE(16711935)).shiftLeft(AE(8)).bitOr(t.bitAnd(AE(4278255360)).shiftRight(AE(8)))),TE(t).mul(2.3283064365386963e-10)}),Uj=JN(([e,t])=>PE(TE(e).div(TE(t)),kj(e))),Fj=JN(([e,t,i])=>{let r=i.mul(i).toConst(),s=BE(1,0,0).toConst(),a=mV(t,s).toConst(),n=PB(e.x).toConst(),o=qO(2,3.14159265359).mul(e.y).toConst(),l=n.mul(LB(o)).toConst(),h=n.mul(DB(o)).toVar(),u=qO(.5,t.z.add(1)).toConst();h.assign(u.oneMinus().mul(PB(l.mul(l).oneMinus())).add(u.mul(h)));let d=s.mul(l).add(a.mul(h)).add(t.mul(PB(lV(0,l.mul(l).add(h.mul(h)).oneMinus()))));return BB(BE(r.mul(d.x),r.mul(d.y),lV(0,d.z)))}),jj=JN(({roughness:e,mipInt:t,envMap:i,N_immutable:r,GGX_SAMPLES:s,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:n,CUBEUV_MAX_MIP:o})=>{let l=BE(r).toVar(),h=BE(0).toVar(),u=TE(0).toVar();return _E(e.lessThan(.001),()=>{h.assign(Ij(i,l,t,a,n,o))}).Else(()=>{let r=IV($B(l.z).lessThan(.999),BE(0,0,1),BE(1,0,0)),d=BB(mV(r,l)).toVar(),c=mV(l,d).toVar();Jk({start:AE(0),end:s},({i:r})=>{let p=Uj(r,s),m=Fj(p,BE(0,0,1),e),g=BB(d.mul(m.x).add(c.mul(m.y)).add(l.mul(m.z))),f=BB(g.mul(pV(l,g).mul(2)).sub(l)),y=lV(pV(l,f),0);_E(y.greaterThan(0),()=>{let e=Ij(i,f,t,a,n,o);h.addAssign(e.mul(y)),u.addAssign(y)})}),_E(u.greaterThan(0),()=>{h.assign(h.div(u))})}),LE(h,1)}),Gj=[.125,.215,.35,.446,.526,.582],Wj=20,qj=new uh(-1,1,1,-1,0,1),Hj=new ah(90,1),$j=new aa,Yj=null,Xj=0,Kj=0,Zj=new ns,Jj=new WeakMap,Qj=[3,1,5,0,4,2],eG=Vj(qD(),WD("faceIndex")).normalize(),tG=BE(eG.x,eG.y,eG.z),iG=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,i=.1,r=100,s={}){let{size:a=256,position:n=Zj,renderTarget:o=null}=s;if(this._setSize(a),!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');Yj=this._renderer.getRenderTarget(),Xj=this._renderer.getActiveCubeFace(),Kj=this._renderer.getActiveMipmapLevel();let l=o||this._allocateTarget(!0);return this._init(l),this._sceneToCubeUV(e,i,r,l,n),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(e,t=0,i=.1,r=100,s={}){return v('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,i,r,s)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return v('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return v('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=yP(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=vP(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Vt||e.mapping===Dt?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Yj,Xj,Kj),e.scissorTest=!1,this._setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),Yj=this._renderer.getRenderTarget(),Xj=this._renderer.getActiveCubeFace(),Kj=this._renderer.getActiveMipmapLevel();let i=t||this._allocateTarget(!1);return this._init(i),this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTarget(e){return gP(3*Math.max(this._cubeSize,112),4*this._cubeSize,e)}_init(e){if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=gP(e.width,e.height);let{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){let t=[],i=[],r=[],s=e,a=e-4+1+Gj.length;for(let n=0;n<a;n++){let a=Math.pow(2,s);t.push(a);let o=1/a;n>e-4?o=Gj[n-e+4-1]:0===n&&(o=0),i.push(o);let l=1/(a-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],c=6,p=6,m=3,g=2,f=1,y=new Float32Array(m*p*c),v=new Float32Array(g*p*c),b=new Float32Array(f*p*c);for(let e=0;e<c;e++){let t=e%3*2/3-1,i=e>2?0:-1,r=[t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0],s=Qj[e];y.set(r,m*p*s),v.set(d,g*p*s);let a=[s,s,s,s,s,s];b.set(a,f*p*s)}let x=new an;x.setAttribute("position",new ja(y,m)),x.setAttribute("uv",new ja(v,g)),x.setAttribute("faceIndex",new ja(b,f)),r.push(new Hn(x,null)),s>4&&s--}return{lodMeshes:r,sizeLods:t,sigmas:i}}(t)),this._blurMaterial=function(e,t,i){let r=lI(new Array(Wj).fill(0)),s=DO(new ns(0,1,0)),a=DO(0),n=TE(Wj),o=DO(0),l=DO(1),h=JD(),u=DO(0),d=TE(1/t),c=TE(1/i),p=TE(e),m={n:n,latitudinal:o,weights:r,poleAxis:s,outputDirection:tG,dTheta:a,samples:l,envMap:h,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:p},g=fP("blur");return g.fragmentNode=zj({...m,latitudinal:o.equal(1)}),Jj.set(g,m),g}(t,e.width,e.height),this._ggxMaterial=function(e,t,i){let r={envMap:JD(),roughness:DO(0),mipInt:DO(0),CUBEUV_TEXEL_WIDTH:TE(1/t),CUBEUV_TEXEL_HEIGHT:TE(1/i),CUBEUV_MAX_MIP:TE(e)},s=fP("ggx");return s.fragmentNode=jj({...r,N_immutable:tG,GGX_SAMPLES:AE(512)}),Jj.set(s,r),s}(t,e.width,e.height)}}async _compileMaterial(e){let t=new Hn(new an,e);await this._renderer.compile(t,qj)}_sceneToCubeUV(e,t,i,r,s){let a=Hj;a.near=t,a.far=i;let n=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],l=this._renderer,h=l.autoClear;l.getClearColor($j),l.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new Hn(new Lo,new Vn({name:"PMREM.Background",side:We,depthWrite:!1,depthTest:!1})));let u=this._backgroundBox,d=u.material,c=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,c=!0):(d.color.copy($j),c=!0),l.setRenderTarget(r),l.clear(),c&&l.render(u,a);for(let t=0;t<6;t++){let i=t%3;0===i?(a.up.set(0,n[t],0),a.position.set(s.x,s.y,s.z),a.lookAt(s.x+o[t],s.y,s.z)):1===i?(a.up.set(0,0,n[t]),a.position.set(s.x,s.y,s.z),a.lookAt(s.x,s.y+o[t],s.z)):(a.up.set(0,n[t],0),a.position.set(s.x,s.y,s.z),a.lookAt(s.x,s.y,s.z+o[t]));let h=this._cubeSize;this._setViewport(r,i*h,t>2?h:0,h,h),l.render(e,a)}l.autoClear=h,e.background=p}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===Vt||e.mapping===Dt;r?null===this._cubemapMaterial&&(this._cubemapMaterial=yP(e)):null===this._equirectMaterial&&(this._equirectMaterial=vP(e));let s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=s;let n=this._cubeSize;this._setViewport(t,0,0,3*n,2*n),i.setRenderTarget(t),i.render(a,qj)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;t<r;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=i}_applyGGXFilter(e,t,i){let r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,n=this._lodMeshes[i];n.material=a;let o=Jj.get(a),l=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h)*(0+1.25*l),{_lodMax:d}=this,c=this._sizeLods[i],p=3*c*(i>d-4?i-d+4:0),m=4*(this._cubeSize-c);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=u,o.mipInt.value=d-t,this._setViewport(s,p,m,3*c,2*c),r.setRenderTarget(s),r.render(n,qj),s.texture.frame=(s.texture.frame||0)+1,o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=d-i,this._setViewport(e,p,m,3*c,2*c),r.setRenderTarget(e),r.render(n,qj)}_blur(e,t,i,r,s){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,n){let o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&y("blur direction must be either latitudinal or longitudinal!");let h=this._lodMeshes[r];h.material=l;let u=Jj.get(l),d=this._sizeLods[i]-1,c=isFinite(s)?Math.PI/(2*d):2*Math.PI/39,p=s/c,m=isFinite(s)?1+Math.floor(3*p):Wj;m>Wj&&f(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);let g=[],v=0;for(let e=0;e<Wj;++e){let t=e/p,i=Math.exp(-t*t/2);g.push(i),0===e?v+=i:e<m&&(v+=2*i)}for(let e=0;e<g.length;e++)g[e]=g[e]/v;e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.samples.value=m,u.weights.array=g,u.latitudinal.value="latitudinal"===a?1:0,n&&(u.poleAxis.value=n);let{_lodMax:b}=this;u.dTheta.value=c,u.mipInt.value=b-i;let x=this._sizeLods[r],w=3*x*(r>b-4?r-b+4:0),_=4*(this._cubeSize-x);this._setViewport(t,w,_,3*x,2*x),o.setRenderTarget(t),o.render(h,qj)}_setViewport(e,t,i,r,s){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-s-i,r,s),e.scissor.set(t,e.height-s-i,r,s)):(e.viewport.set(t,i,r,s),e.scissor.set(t,i,r,s))}},rG=new WeakMap,sG=mE(class extends CR{static get type(){return"PMREMNode"}constructor(e,t=null,i=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=i,this._generator=null;let r=new ws;r.isRenderTargetTexture=!0,this._texture=JD(r),this._width=DO(0),this._height=DO(0),this._maxMip=DO(0),this.updateBeforeType=mR.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=function(e){let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,i=t?t.pmremVersion:-1,r=this._value;i!==r.pmremVersion&&(t=!0===r.isPMREMTexture||r.mapping===zt?r:function(e,t,i){let r=function(e){let t=rG.get(e);return void 0===t&&(t=new WeakMap,rG.set(e,t)),t}(t),s=r.get(e);if((void 0!==s?s.pmremVersion:-1)!==e.pmremVersion){let t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;for(let i=0;i<6;i++)void 0!==e[i]&&t++;return 6===t}(t))return null;s=i.fromCubemap(e,s)}else{if(!function(e){return null!=e&&e.height>0}(t))return null;s=i.fromEquirectangular(e,s)}if(s.pmremVersion=e.pmremVersion,!1===r.has(e)){let t=()=>{e.removeEventListener("dispose",t);let i=r.get(e);void 0!==i&&(i.dispose(),r.delete(e))};e.addEventListener("dispose",t)}r.set(e,s)}return s.texture}(r,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new iG(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?FL.mul(BE(t.x,t.y.negate(),t.z)):FL.mul(t);let i=this.levelNode;return null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),Dj(this._texture,t,i,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}).setParameterLength(1,3),aG=new WeakMap,nG=class extends nU{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){let r=i.isTextureNode?i.value:t[i.property],s=this._getPMREMNodeCache(e.renderer),a=s.get(r);void 0===a&&(a=sG(r),s.set(r,a)),i=a}let r=!0===t.useAnisotropy||t.anisotropy>0?Nz:RL,s=i.context(oG(eO,r)).mul(UL),a=i.context(lG(EL)).mul(Math.PI).mul(UL),n=ND(s),o=ND(a);e.context.radiance.addAssign(n),e.context.iblIrradiance.addAssign(o);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=i.context(oG(rO,OL)).mul(UL),t=ND(e);l.addAssign(t)}}_getPMREMNodeCache(e){let t=aG.get(e);return void 0===t&&(t=new WeakMap,aG.set(e,t)),t}},oG=(e,t)=>{let i=null;return{getUV:()=>(null===i&&(i=xL.negate().reflect(t),i=vV(e).mix(i,t).normalize(),i=i.transformDirection(jI)),i),getTextureLevel:()=>e}},lG=e=>({getUV:()=>e,getTextureLevel:()=>TE(1)}),hG=new yl,uG=class extends UU{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(hG),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new nG(t):null}setupLightingModel(){return new vj}setupSpecular(){let e=MV(BE(.04),ZE.rgb,tO);pO.assign(BE(.04)),mO.assign(e),gO.assign(1)}setupVariants(){let e=this.metalnessNode?TE(this.metalnessNode):Zz;tO.assign(e);let t=this.roughnessNode?TE(this.roughnessNode):Kz;t=TF({roughness:t}),eO.assign(t),this.setupSpecular(),JE.assign(ZE.rgb.mul(e.oneMinus()))}},dG=new vl,cG=class extends uG{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(dG),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){let e=this.iorNode?TE(this.iorNode):dk;wO.assign(e),pO.assign(oV(fV(wO.sub(1).div(wO.add(1))).mul($z),BE(1)).mul(Hz)),mO.assign(MV(pO,ZE.rgb,tO)),gO.assign(MV(Hz,1,tO))}setupLightingModel(){return new vj(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?TE(this.clearcoatNode):Qz,t=this.clearcoatRoughnessNode?TE(this.clearcoatRoughnessNode):ek;iO.assign(e),rO.assign(TF({roughness:t}))}if(this.useSheen){let e=this.sheenNode?BE(this.sheenNode):rk,t=this.sheenRoughnessNode?TE(this.sheenRoughnessNode):sk;sO.assign(e),aO.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?TE(this.iridescenceNode):nk,t=this.iridescenceIORNode?TE(this.iridescenceIORNode):ok,i=this.iridescenceThicknessNode?TE(this.iridescenceThicknessNode):lk;nO.assign(e),oO.assign(t),lO.assign(i)}if(this.useAnisotropy){let e=(this.anisotropyNode?PE(this.anisotropyNode):ak).toVar();uO.assign(e.length()),_E(uO.equal(0),()=>{e.assign(PE(1,0))}).Else(()=>{e.divAssign(PE(uO)),uO.assign(uO.saturate())}),hO.assign(uO.pow2().mix(eO.pow2(),1)),dO.assign(Tz[0].mul(e.x).add(Tz[1].mul(e.y))),cO.assign(Tz[1].mul(e.x).sub(Tz[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?TE(this.transmissionNode):hk,t=this.thicknessNode?TE(this.thicknessNode):uk,i=this.attenuationDistanceNode?TE(this.attenuationDistanceNode):ck,r=this.attenuationColorNode?BE(this.attenuationColorNode):pk;if(_O.assign(e),SO.assign(t),MO.assign(i),TO.assign(r),this.useDispersion){let e=this.dispersionNode?TE(this.dispersionNode):xk;CO.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?BE(this.clearcoatNormalNode):tk}setup(e){e.context.setupClearcoatNormal=()=>$V(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}},pG=JN(({normal:e,lightDirection:t,builder:i})=>{let r=e.dot(t),s=PE(r.mul(.5).add(.5),0);if(i.material.gradientMap){let e=tz("gradientMap","texture").context({getUV:()=>s});return BE(e.r)}{let e=s.fwidth().mul(.5);return MV(BE(.7),BE(1),NV(TE(.7).sub(e.x),TE(.7).add(e.x),s.x))}}),mG=class extends uF{direct({lightDirection:e,lightColor:t,reflectedLight:i},r){let s=pG({normal:TL,lightDirection:e,builder:r}).mul(t);i.directDiffuse.addAssign(s.mul(gF({diffuseColor:ZE.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:i,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(i.mul(gF({diffuseColor:ZE}))),r.indirectDiffuse.mulAssign(t)}},gG=new xl,fG=class extends UU{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(gG),this.setValues(e)}setupLightingModel(){return new mG}},yG=JN(()=>{let e=BE(xL.z,0,xL.x.negate()).normalize(),t=xL.cross(e);return PE(e.dot(RL),t.dot(RL)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),vG=new Sl,bG=class extends UU{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(vG),this.setValues(e)}setupVariants(e){let t,i=yG;t=e.material.matcap?tz("matcap","texture").context({getUV:()=>i}):BE(MV(.2,.8,i.y)),ZE.rgb.mulAssign(t.rgb)}},xG=mE(class extends CR{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:i}=this;if("vec2"===this.getNodeType(e)){let e=t.cos(),r=t.sin();return FE(e,r,r.negate(),e).mul(i)}{let e=t,r=GE(LE(1,0,0,0),LE(0,LB(e.x),DB(e.x).negate(),0),LE(0,DB(e.x),LB(e.x),0),LE(0,0,0,1)),s=GE(LE(LB(e.y),0,DB(e.y),0),LE(0,1,0,0),LE(DB(e.y).negate(),0,LB(e.y),0),LE(0,0,0,1)),a=GE(LE(LB(e.z),DB(e.z).negate(),0,0),LE(DB(e.z),LB(e.z),0,0),LE(0,0,1,0),LE(0,0,0,1));return r.mul(s).mul(a).mul(LE(i,1)).xyz}}}).setParameterLength(2),wG=new dn,_G=class extends UU{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(wG),this.setValues(e)}setupPositionView(e){let{object:t,camera:i}=e,{positionNode:r,rotationNode:s,scaleNode:a,sizeAttenuation:n}=this,o=hL.mul(BE(r||0)),l=PE(iL[0].xyz.length(),iL[1].xyz.length());null!==a&&(l=l.mul(PE(a))),i.isPerspectiveCamera&&!1===n&&(l=l.mul(o.z.negate()));let h=mL.xy;if(t.center&&!0===t.center.isVector2){let e=aD("center","vec2",t);h=h.sub(e.sub(.5))}h=h.mul(l);let u=TE(s||ik),d=xG(h,u);return LE(o.xy.add(d),o.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},SG=new Ro,MG=new rs,TG=class extends _G{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(SG),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return hL.mul(BE(e||gL)).xyz}setupVertexSprite(e){let{material:t,camera:i}=e,{rotationNode:r,scaleNode:s,sizeNode:a,sizeAttenuation:n}=this,o=super.setupVertex(e);if(!0!==t.isNodeMaterial)return o;let l=null!==a?PE(a):bk;l=l.mul(pI),i.isPerspectiveCamera&&!0===n&&(l=l.mul(CG.div(bL.z.negate()))),s&&s.isNode&&(l=l.mul(PE(s)));let h=mL.xy;if(r&&r.isNode){let e=TE(r);h=xG(h,e)}return h=h.mul(l),h=h.div(vI.div(2)),h=h.mul(o.w),o=o.add(LE(h,0,0)),o}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},CG=DO(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(MG);this.value=.5*t.y}),AG=class extends uF{constructor(){super(),this.shadowNode=TE(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){ZE.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(ZE.rgb)}},NG=new gl,PG=class extends UU{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(NG),this.setValues(e)}setupLightingModel(){return new AG}},XE("vec3"),XE("vec3"),XE("vec3"),RG=class{constructor(e,t,i){this.renderer=e,this.nodes=t,this.info=i,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,i)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),null!==this._animationLoop&&this._animationLoop(t,i),this.renderer._inspector.finish()};e()}stop(){null!==this._context&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},EG=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,i=this.weakMaps[t];return void 0===i&&(i=new WeakMap,this.weakMaps[t]=i),i}get(e){let t=this._getWeakMap(e);for(let i=0;i<e.length-1;i++)if(t=t.get(e[i]),void 0===t)return;return t.get(e[e.length-1])}set(e,t){let i=this._getWeakMap(e);for(let t=0;t<e.length-1;t++){let r=e[t];!1===i.has(r)&&i.set(r,new WeakMap),i=i.get(r)}return i.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let i=0;i<e.length-1;i++)if(t=t.get(e[i]),void 0===t)return!1;return t.delete(e[e.length-1])}},OG=0,BG=new WeakMap,VG=["colorNode","depthNode","positionNode","side","transparent","alphaTest","alphaMap","displacementMap","displacementScale","displacementBias"],DG=class{constructor(e,t,i,r){this.target=e,this.owner=t,this.passId=i,this.priority=r,this.lightsNode=null,this.lights=null,this.buildState=null,this.builder=null,this.pipeline=null,this.prewarm=!1,this.status=null,this._settledCallbacks=null}onSettled(e){null===this.status?(null===this._settledCallbacks&&(this._settledCallbacks=[]),this._settledCallbacks.push(e)):e(this)}},IG=class{constructor(e=null){this.renderer=e,this.timeBudget=2,this.burstTimeBudget=12,this._burst=!1,this.burstDutyCycle=.85,this._dutyWindowStart=-1,this._dutyWindowBusy=0,this.stats=null!==e?e.info.asyncCompilation:{queued:0,pipelines:0,promotions:0,failed:0,mainThreadTime:0},this._entries=new Map,this._queue=[],this._current=null,this._promotions=[],this._failures=new Map,this._pipelinesInFlight=0,this._prewarms=0,this._didBuild=!1,this._updating=!1,this._updateScheduled=!1,this._notifyRequested=!1,this._idleHandle=null,this._timeoutHandle=null,this._onServiceCallback=this._service.bind(this)}get burst(){return this._burst}set burst(e){(e=!0===e)!==this._burst&&(this._burst=e,this._dutyWindowStart=-1,this._dutyWindowBusy=0)}request(e,t){let i=null!==e.pending?e.pending:e,r=this._entries.get(i);if(void 0!==r)return r;if(void 0!==this.renderer._pipelines.get(i).pipeline||!0===this.isFailed(i.initialCacheKey))return null;let s,a=i.object,n=i.material,o=void 0!==a.compilePriority?a.compilePriority:void 0!==n.compilePriority?n.compilePriority:0,l=i!==e?e:null;s=o>0?0:o<0?3:null===l&&null===this.renderer._compilationPromises?1:2;let h=new DG(i,l,t,s);null!==this.renderer._compilationPromises&&(h.prewarm=!0,this._prewarms++);let u=i.lightsNode;return null!=u&&(h.lightsNode=u,h.lights=u.getLights().slice()),h.buildState=function(e){let t=null;for(let i of VG){let r=e[i];void 0!==r&&(null===t&&(t={}),t[i]=r)}return t}(n),this._entries.set(i,h),this._insert(h),this.requestUpdate(),this._syncInfo(),h}update(){if(!0===this._updating||0===this._queue.length&&null===this._current)return;this._updating=!0;let e=!0===this.burst,t=performance.now(),i=t+(!0===e?this.burstTimeBudget:this.timeBudget);try{do{let t,r=this._current;if(null===r){if(r=this._queue.shift(),void 0===r)break;if(null!==r.status)continue;if(!0===this._isStale(r)){this._settle(r,"stale");continue}this._current=r}try{t=this._advance(r,i)}catch(e){this._fail(r,e),t=!0}if(!0===t&&(this._current=null,!0===this._didBuild&&(this._didBuild=!1,!1===e)))break}while(performance.now()<i)}finally{this._updating=!1}let r=performance.now();this.stats.mainThreadTime+=r-t,this._noteDuty(r,r-t),this._queue.length>0||null!==this._current?this.requestUpdate():(this._dutyWindowStart=-1,this._dutyWindowBusy=0),this._syncInfo()}_noteDuty(e,t){this._dutyWindowStart<0&&(this._dutyWindowStart=e-t),this._dutyWindowBusy+=t;let i=e-this._dutyWindowStart;i>=500&&(this._dutyWindowStart=e-i/2,this._dutyWindowBusy*=.5)}_dutyCycle(e){if(this._dutyWindowStart<0)return 0;let t=e-this._dutyWindowStart;return t<100?0:Math.min(1,this._dutyWindowBusy/t)}applyPromotions(){let e=this._promotions;if(0===e.length)return;let t=this.renderer._objects;for(let i=0;i<e.length;i++){let r=e[i];try{!0===t.promote(r.owner,r.target,r.passId)&&this.stats.promotions++}catch(e){y("AsyncCompilation: Promotion failed.",e)}}e.length=0}rememberFailure(e){let t=this._failures;for(!0===t.has(e)&&t.delete(e),t.set(e,!0);t.size>256;)t.delete(t.keys().next().value)}isFailed(e){return this._failures.has(e)}requestUpdate(){!0!==this._updateScheduled&&(this._updateScheduled=!0,this._prewarms>0||!0===this._burst&&this._dutyCycle(performance.now())<this.burstDutyCycle?typeof self<"u"&&void 0!==self.scheduler&&void 0!==self.scheduler.yield?self.scheduler.yield().then(this._onServiceCallback):this._timeoutHandle=setTimeout(this._onServiceCallback,0):0==(typeof document<"u"&&"hidden"===document.visibilityState)&&typeof requestIdleCallback<"u"?(this._idleHandle=requestIdleCallback(this._onServiceCallback,{timeout:100}),this._timeoutHandle=setTimeout(this._onServiceCallback,150)):this._timeoutHandle=setTimeout(this._onServiceCallback,0))}clear(e="cancelled"){this._queue.length=0,this._current=null,this._promotions.length=0;for(let t of Array.from(this._entries.values()))this._settle(t,e);this._entries.clear(),this._notifyRequested=!1,this._didBuild=!1,this._cancelServiceCallback(),this._syncInfo()}dispose(){this.clear("disposed"),this._failures.clear()}_advance(e,t){let i=this.renderer,r=e.target;if(!0===this._isStale(e))return this._settle(e,"stale"),!0;let s=i._nodes;if(void 0===s.get(r).nodeBuilderState){let a=r.material,n=e.buildState,o=null;if(null!==n){o={};for(let e in n)o[e]=a[e],a[e]=n[e]}try{let a=s.getForRenderCacheKey(r);if(void 0===s.nodeBuilderCache.get(a)&&void 0===s._spResurrectRetired(a)){let n=e.lightsNode,o=null!==n?n.getLights():null;null!==n&&n.setLights(e.lights);let l=r.context,h=i._mrt,u=i._renderTarget,d=i._activeCubeFace,c=i._activeMipmapLevel;i._mrt=void 0!==l.mrt?l.mrt:null,i._renderTarget=void 0!==l.renderTarget?l.renderTarget:null,i._activeCubeFace=l.activeCubeFace||0,i._activeMipmapLevel=l.activeMipmapLevel||0;let p=!1;try{null===e.builder&&(e.builder=s._createNodeBuilder(r,r.material)),p=e.builder.buildStep(t)}finally{null!==n&&n.setLights(o),i._mrt=h,i._renderTarget=u,i._activeCubeFace=d,i._activeMipmapLevel=c}if(!1===p)return!1;s.adoptNodeBuilder(a,e.builder),e.builder=null,this._didBuild=!0}s.getForRender(r)}finally{if(null!==o)for(let e in o)a[e]=o[e]}}i._bindings.getForRender(r);let{pipeline:a,promise:n}=i._pipelines.getForRenderAsync(r);if(e.pipeline=a,null!==n){this._pipelinesInFlight++;let t=()=>{this._pipelinesInFlight--,this._settlePipeline(e)};n.then(t,t)}else this._settlePipeline(e);return!0}_settlePipeline(e){if(null!==e.status)return;let t=this.renderer,i=e.target;!0===this._isStale(e)?this._settle(e,"stale"):!0===t._pipelines.isPipelineFailed(e.pipeline)?this._fail(e,new Error("Async render pipeline creation failed.")):(t.backend.syncRenderUpdateState(i,null!==i.drawState?i.drawState:i.material),null!==e.owner?this._promotions.push(e):this.stats.promotions++,this._settle(e,"ready"),this._requestNotify()),this._syncInfo()}_fail(e,t){let i=t.stackTrace;!i&&t.stack&&(i=new oR(t.stack)),y("TSL: "+t,i),e.builder=null,this.rememberFailure(e.target.initialCacheKey),this.stats.failed++;let r=e.owner;this._settle(e,"failed"),null!==r&&r.pending===e.target&&(r.pending=null,e.target.dispose())}_settle(e,t){if(null!==e.status)return;e.status=t,!0===e.prewarm&&(e.prewarm=!1,this._prewarms--),this._entries.delete(e.target),this._current===e&&(this._current=null);let i=e._settledCallbacks;if(null!==i){e._settledCallbacks=null;for(let t=0;t<i.length;t++)i[t](e)}}_isStale(e){let{target:t,owner:i}=e;return!0===t.disposed||null!==i&&(!0===i.disposed||i.pending!==t)}_insert(e){let t=this._queue,i=t.length;for(;i>0&&t[i-1].priority>e.priority;)i--;t.splice(i,0,e)}_service(){if(!1!==this._updateScheduled&&(this._updateScheduled=!1,this._cancelServiceCallback(),this.update(),!0===this._notifyRequested)){this._notifyRequested=!1;let e=this.renderer;null!==e&&"function"==typeof e.onBackgroundWorkReady&&e.onBackgroundWorkReady()}}_cancelServiceCallback(){null!==this._idleHandle&&(typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=null),null!==this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=null),this._updateScheduled=!1}_requestNotify(){this._notifyRequested=!0,this.requestUpdate()}_syncInfo(){let e=this.stats;e.queued=this._queue.length+(null!==this._current?1:0),e.pipelines=this._pipelinesInFlight}},LG=class{constructor(e,t,i,r,s,a,n,o,l,h){this.id=OG++,this._nodes=e,this._geometries=t,this.renderer=i,this.object=r,this.material=s,this.scene=a,this.camera=n,this.lightsNode=o,this.context=l,this.geometry=r.geometry,this.version=s.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=h,this.clippingContextCacheKey=null!==h?h.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this._sourceMaterial=i._currentSourceMaterial,this.pending=null,this.drawState=null,this.disposed=!1,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose),null!==this._sourceMaterial&&this._sourceMaterial.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.getNodeBuilderState().hardwareClipping?this.clippingContext.unionClippingCount:0}get drawMaterial(){return null!==this.drawState&&!0===this.renderer._asyncCompilation?this.drawState:this.material}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(null!==this.attributes)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,i=[],r=new Set,s={};for(let a of e){let e;if(a.node&&a.node.attribute?e=a.node.attribute:(e=t.getAttribute(a.name),void 0!==e&&(e.isInterleavedBufferAttribute?s[a.name]=e.data.uuid:s[a.name]=e.id)),void 0===e)continue;i.push(e);let n=e.isInterleavedBufferAttribute?e.data:e;r.add(n)}return this.attributes=i,this.attributesId=s,this.vertexBuffers=Array.from(r.values()),i}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,geometry:t,group:i,drawRange:r}=this,s=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),n=null!==a,o=1;if(!0===t.isInstancedBufferGeometry){if(o=t.instanceCount,!1===Number.isFinite(o)){let e=1/0;for(let i in t.attributes){let r=t.attributes[i];!0===r.isInterleavedBufferAttribute&&!0===r.data.isInstancedInterleavedBuffer?e=Math.min(e,r.data.meshPerAttribute*r.data.count):!0===r.isInstancedBufferAttribute&&(e=Math.min(e,r.meshPerAttribute*r.count))}o=Number.isFinite(e)?e:0}}else void 0!==e.count&&(o=Math.max(0,e.count));if(0===o)return null;if(s.instanceCount=o,!0===e.isBatchedMesh)return s;let l=1;!0===this.drawMaterial.wireframe&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(l=2);let h=r.start*l,u=(r.start+r.count)*l;null!==i&&(h=Math.max(h,i.start*l),u=Math.min(u,(i.start+i.count)*l));let d=t.attributes.position,c=1/0;n?c=a.count:null!=d&&(c=d.count),h=Math.max(h,0),u=Math.min(u,c);let p=u-h;return p<0||p===1/0?null:(s.vertexCount=p,s.firstVertex=h,s)}getGeometryCacheKey(){let{geometry:e}=this,t="";for(let i of Object.keys(e.attributes).sort()){let r=e.attributes[i];t+=i+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}for(let i of Object.keys(e.morphAttributes).sort()){let r=e.morphAttributes[i];t+="morph-"+i+",";for(let e=0,i=r.length;e<i;e++)t+=r[e].id+","}return e.index&&(t+="index,"),t}getMaterialCacheKey(){let e,{object:t,material:i,renderer:r}=this,s=null!=r._currentSourceMaterial?r._currentSourceMaterial:this._sourceMaterial;if(!0===i.isShadowPassMaterial&&null!=s&&s!==i){let t=s,i=t.castShadowNode&&t.castShadowNode.isNode,a=t.maskShadowNode&&t.maskShadowNode.isNode||t.maskNode&&t.maskNode.isNode,n=t.alphaTest>0||!0===r.shadowMap.transmitted||i||a,o=(n&&t.map&&t.map.isTexture?"m":"")+(n&&t.colorNode&&t.colorNode.isNode?"o":"")+(i?"c":"")+(a?"k":"")+(t.depthNode&&t.depthNode.isNode?"d":"")+(t.castShadowPositionNode&&t.castShadowPositionNode.isNode?"p":t.positionNode&&t.positionNode.isNode?"q":"");e=""===o?"shadow()":"shadow("+o+"):"+t.customProgramCacheKey()}else e=i.customProgramCacheKey();for(let t of function(e){let t=Object.keys(e),i=BG.get(e.constructor);if(void 0===i){i=[];let t=Object.getPrototypeOf(e);for(;t;){let e=Object.getOwnPropertyDescriptors(t);for(let t in e){let r=e[t];r&&"function"==typeof r.get&&i.push(t)}t=Object.getPrototypeOf(t)}BG.set(e.constructor,i)}for(let e=0;e<i.length;e++)t.push(i[e]);return t}(i)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(t))continue;let s,a=i[t];if(null!==a){let e=typeof a;"number"===e?s="side"===t?String(a):0!==a?"1":"0":"object"===e?(s="{",a.isTexture&&(s+=a.mapping,!0===r.backend.isWebGPUBackend&&(s+=a.magFilter,s+=a.minFilter,s+=a.wrapS,s+=a.wrapT,s+=a.wrapR)),s+="}"):s=String(a)}else s=String(a);e+=s+","}return e+=this.clippingContextCacheKey+",",t.geometry&&(e+=this.getGeometryCacheKey()),t.skeleton&&(e+=t.skeleton.bones.length+","),t.isBatchedMesh&&(e+=t._matricesTexture.uuid+",",null!==t._colorsTexture&&(e+=t._colorsTexture.uuid+",")),(t.isInstancedMesh||t.count>1)&&(e+=t.uuid+","),e+=this.context.nodeCacheKey+",",e+=t.receiveShadow+",",lR(e)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(null!==this.attributes){let e=this.attributesId;for(let t in e){let i=this.geometry.getAttribute(t);if(void 0===i)return!0;let r=i.isInterleavedBufferAttribute?i.data.uuid:i.id;if(e[t]!==r)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=uR(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=uR(e,1)),e=uR(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){!0!==this.disposed&&(this.disposed=!0,this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),null!==this._sourceMaterial&&this._sourceMaterial.removeEventListener("dispose",this.onMaterialDispose),this.onDispose())}},zG=[],kG=class{constructor(e,t,i,r,s,a){this.renderer=e,this.nodes=t,this.geometries=i,this.pipelines=r,this.bindings=s,this.info=a,this.chainMaps={},this._classifications=new WeakMap}updateClassification(e){let t=this._classifications.get(e);void 0===t&&(t={transparent:!1,doublePass:!1},this._classifications.set(e,t)),t.transparent=CP(e),t.doublePass=AP(e)}resetClassifications(){this._classifications=new WeakMap}getClassification(e){if(!0!==this.renderer._asyncCompilation)return null;let t=this._classifications.get(e);return void 0!==t?t:null}get(e,t,i,r,s,a,n,o){let l=this.getChainMap(o);zG[0]=e,zG[1]=t,zG[2]=a,zG[3]=s;let h=l.get(zG);if(void 0===h)h=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,i,r,s,a,n,o),l.set(zG,h),!0===this.renderer._asyncCompilation&&!1===this.renderer._compilation._updating&&!0!==e.isQuadMesh&&(h.drawState=bP(t),this.renderer._compilation.request(h,o));else{h.camera=r,h.updateClipping(n);let l=!1,u=!1;if(h.needsGeometryUpdate&&(l=!0,h.setGeometry(e.geometry),u=h.initialCacheKey!==h.getCacheKey()),u||h.version!==t.version||h.needsUpdate)if(!0===this.renderer._asyncCompilation&&!1===this.renderer._compilation._updating&&!0!==e.isQuadMesh&&!0===this.pipelines.isReady(h)&&!1===l){let e=h.getCacheKey();h.initialCacheKey!==e&&this.requestPending(h,e,!1,o),h.version=t.version}else h.initialCacheKey!==h.getCacheKey()?(h.dispose(),h=this.get(e,t,i,r,s,a,n,o)):h.version=t.version}return zG[0]=null,zG[1]=null,zG[2]=null,zG[3]=null,h}requestPending(e,t,i=!1,r){let s=this.renderer._compilation,a=e.material;e.initialCacheKey=t,e.initialNodesCacheKey=e.getDynamicCacheKey();let n=bP(a),o=e.pending;if(null!==o){if(o.initialCacheKey===t&&(!1===i||xP(o.drawState,n)))return;e.pending=null,o.dispose()}if(this.nodes.get(e).cacheKey===t&&(!1===i||xP(e.drawState,n))&&!1===this.renderer.backend.detectAttachmentMismatch(e)||!0===s.isFailed(t))return;let l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e.object,a,e.scene,e.camera,e.lightsNode,e.context,e.clippingContext,r);l.drawState=n,e.pending=l,s.request(e,r)}promote(e,t,i){return e.pending===t&&!0!==e.disposed&&(e.pending=null,this.getChainMap(i).set(t.getChainArray(),t),this.updateClassification(t.material),null!==e.bundle&&(e.bundle.needsUpdate=!0),e.dispose(),!0)}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new EG)}dispose(){this.chainMaps={}}createRenderObject(e,t,i,r,s,a,n,o,l,h,u){let d=this.getChainMap(u),c=new LG(e,t,i,r,s,a,n,o,l,h);return c.onDispose=()=>{this.pipelines.delete(c),this.bindings.deleteForRender(c),this.nodes.delete(c);let e=c.pending;null!==e&&(c.pending=null,e.dispose());let t=c.getChainArray();d.get(t)===c&&d.delete(t)},c}},UG=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},FG={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},jG=16,GG=class extends UG{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){let t=super.delete(e);return null!==t&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){let i=this.get(e);if(void 0===i.version)t===FG.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===FG.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===FG.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===FG.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),i.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(i.version<t.version||t.usage===Fr)&&(this.backend.updateAttribute(e),i.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},WG=class extends UG{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){let t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;let i=()=>{this.info.memory.geometries--;let r=t.index,s=e.getAttributes();null!==r&&this.attributes.delete(r);for(let e in t.attributes)this.attributes.delete(t.attributes[e]);for(let e of s)this.attributes.delete(e);let a=this.wireframes.get(t);void 0!==a&&this.attributes.delete(a),t.removeEventListener("dispose",i),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",i),this._geometryDisposeListeners.set(t,i)}releaseReplacedAttributes(e){let t=this.get(e),i=t.uploadedAttributes;void 0===i&&(i=new Map,t.uploadedAttributes=i);for(let[t,r]of i)e.attributes[t]!==r&&(this.attributes.delete(r),i.delete(t));for(let t in e.attributes)i.set(t,e.attributes[t]);let r=e.index;void 0!==t.uploadedIndex&&t.uploadedIndex!==r&&this.attributes.delete(t.uploadedIndex),t.uploadedIndex=r}updateAttributes(e){let t=e.getAttributes();this.releaseReplacedAttributes(e.geometry);for(let e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,FG.STORAGE):this.updateAttribute(e,FG.VERTEX);let i=this.getIndex(e);null!==i&&this.updateAttribute(i,FG.INDEX);let r=e.geometry.indirect;null!==r&&this.updateAttribute(r,FG.INDIRECT)}updateAttribute(e,t){let i=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,i)):this.attributeCall.get(e.data)!==i&&(this.attributes.update(e,t),this.attributeCall.set(e.data,i),this.attributeCall.set(e,i)):this.attributeCall.get(e)!==i&&(this.attributes.update(e,t),this.attributeCall.set(e,i))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){let{geometry:t}=e,i=t.index;if(!0===e.drawMaterial.wireframe){let e=this.wireframes,r=e.get(t);void 0===r?(r=SP(t),e.set(t,r)):(r.version!==wP(t)||r.__id!==_P(t))&&(this.attributes.delete(r),r=SP(t),e.set(t,r)),i=r}return i}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}},qG=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.asyncCompilation={queued:0,pipelines:0,promotions:0,failed:0,mainThreadTime:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,i){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=i*(t/3):e.isPoints?this.render.points+=i*t:e.isLineSegments?this.render.lines+=i*(t/2):e.isLine?this.render.lines+=i*(t-1):y("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(let e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){let t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){let i=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:i,type:t}),this.memory[t]++,this.memory.total+=i,this.memory[t+"Size"]+=i}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){let t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){let{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){let t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){let t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===Kt||e.type===Xt?t=1:e.type===Zt||e.type===Jt||e.type===ii?t=2:(e.type===Qt||e.type===ei||e.type===ti)&&(t=4);let i=4;e.format===li||e.format===pi||e.format===mi||e.format===di||e.format===ci?i=1:e.format===gi||e.format===fi?i=2:(e.format===hi||e.format===yi)&&(i=3);let r=t*i;e.type===ri||e.type===si?r=2:(e.type===ai||e.type===ni||e.type===oi)&&(r=4);let s=e.width||1,a=e.height||1,n=e.isCubeTexture?6:e.depth||1,o=s*a*n*r,l=e.mipmaps;if(l&&l.length>0){let e=0;for(let t=0;t<l.length;t++){let i=l[t];i.data?e+=i.data.byteLength:e+=(i.width||Math.max(1,s>>t))*(i.height||Math.max(1,a>>t))*n*r}o+=e}else e.generateMipmaps&&(o*=1.333);return Math.round(o)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}},HG=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},$G=class extends HG{constructor(e,t,i){super(e),this.vertexProgram=t,this.fragmentProgram=i}},YG=class extends HG{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},XG=0,KG=class{constructor(e,t,i,r=null,s=null){this.id=XG++,this.code=e,this.stage=t,this.name=i,this.transforms=r,this.attributes=s,this.usedTimes=0}},ZG=class extends UG{constructor(e,t,i){super(),this.backend=e,this.nodes=t,this.info=i,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map},this._inFlight=new Map}getForCompute(e,t){let{backend:i}=this,r=this.get(e);if(this._needsComputeUpdate(e)){let s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);let a=this.nodes.getForCompute(e),n=this.programs.compute.get(a.computeShader);void 0===n&&(s&&0===s.computeProgram.usedTimes&&this._releaseProgram(s.computeProgram),n=new KG(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,n),i.createProgram(n),this.info.createProgram(n));let o=this._getComputeCacheKey(e,n),l=this.caches.get(o);void 0===l&&(s&&0===s.usedTimes&&this._releasePipeline(s),l=this._getComputePipeline(e,n,o,t)),l.usedTimes++,n.usedTimes++,r.version=e.version,r.pipeline=l}return r.pipeline}getForRender(e){let t=this.get(e);if(this._needsRenderUpdate(e)){let i=t.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);let r=e.getNodeBuilderState(),s=e.material?e.material.name:"",a=this._getProgramStage("vertex",r.vertexShader,s,i?i.vertexProgram:null),n=this._getProgramStage("fragment",r.fragmentShader,s,i?i.fragmentProgram:null),o=this._getRenderCacheKey(e,a,n),l=this.caches.get(o);void 0===l?(i&&0===i.usedTimes&&this._releasePipeline(i),l=this._getRenderPipeline(e,a,n,o)):e.pipeline=l,l.usedTimes++,a.usedTimes++,n.usedTimes++,t.pipeline=l,this.backend.get(e).compiledAttachmentKey=this.backend.getAttachmentStateKey(e)}return t.pipeline}getForRenderAsync(e){let t=this.get(e),i=t.pipeline;if(void 0===i){let r=e.getNodeBuilderState(),s=e.material?e.material.name:"",a=this._getProgramStage("vertex",r.vertexShader,s),n=this._getProgramStage("fragment",r.fragmentShader,s),o=this._getRenderCacheKey(e,a,n);if(i=this.caches.get(o),void 0===i){i=new $G(o,a,n),this.caches.set(o,i),e.pipeline=i;let t=[];if(this.backend.createRenderPipeline(e,t),t.length>0){let e=Promise.all(t).finally(()=>{this._inFlight.delete(i)});this._inFlight.set(i,e)}}else e.pipeline=i;i.usedTimes++,a.usedTimes++,n.usedTimes++,t.pipeline=i,this.backend.get(e).compiledAttachmentKey=this.backend.getAttachmentStateKey(e)}let r=this._inFlight.get(i);return{pipeline:i,promise:void 0!==r?r:null}}isReady(e){let t=this.get(e).pipeline;return void 0!==t&&this.isPipelineReady(t)}isPipelineReady(e){let t=this.backend.get(e);return void 0!==t.pipeline&&null!==t.pipeline}isPipelineFailed(e){return!0===this.backend.get(e).error}delete(e){let t=this.get(e).pipeline;return t&&(t.isComputePipeline?(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):this.releaseRenderPipeline(t)),super.delete(e)}releaseRenderPipeline(e){e.usedTimes--,0===e.usedTimes&&this._releasePipeline(e),e.vertexProgram.usedTimes--,e.fragmentProgram.usedTimes--,0===e.vertexProgram.usedTimes&&this._releaseProgram(e.vertexProgram),0===e.fragmentProgram.usedTimes&&this._releaseProgram(e.fragmentProgram)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map},this._inFlight=new Map}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,i,r){i=i||this._getComputeCacheKey(e,t);let s=this.caches.get(i);return void 0===s&&(s=new YG(i,t),this.caches.set(i,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,i,r){r=r||this._getRenderCacheKey(e,t,i);let s=this.caches.get(r);return void 0===s&&(s=new $G(r,t,i),this.caches.set(r,s),e.pipeline=s,this.backend.createRenderPipeline(e,null)),s}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,i){return t.id+","+i.id+","+this.backend.getRenderCacheKey(e)}_getProgramStage(e,t,i,r=null){let s=this.programs[e].get(t);return void 0===s&&(null!==r&&0===r.usedTimes&&this._releaseProgram(r),s=new KG(t,e,i),this.programs[e].set(t,s),this.backend.createProgram(s),this.info.createProgram(s)),s}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,i=e.stage;this.programs[i].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){let t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}},JG=class extends UG{constructor(e,t,i,r,s,a){super(),this.backend=e,this.textures=i,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings(),i=this.get(e);return!0!==i.initialized&&(this._createBindings(t),i.initialized=!0,e._spBindingsFresh=!0),t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings,i=this.get(e);return(!0!==i.initialized||i.bindings!==t)&&(void 0!==i.bindings&&this._destroyBindings(i.bindings),this._createBindings(t),i.initialized=!0,i.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){let t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){let t=e._bindings;null!==t&&this._destroyBindings(t),this.delete(e)}_createBindings(e){for(let t of e){let i=this.get(t);if(void 0===i.bindGroup){for(let e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)(null===e.texture||void 0===e.texture)&&(e.texture=e.textureNode&&e.textureNode.value||ZP()),this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e);else if(e.isStorageBuffer){let t=e.attribute,i=t.isIndirectStorageBufferAttribute?FG.INDIRECT:FG.STORAGE;this.attributes.update(t,i)}this.backend.createBindings(t,e,0),i.bindGroup=t,i.usedTimes=1}else i.usedTimes++}}_destroyBindings(e){for(let t of e){let e=this.get(t);if(e.usedTimes--,0===e.usedTimes){for(let e of t.bindings)e.isUniformBuffer?(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release()):e.isSampler&&(!0!==e.isSampledTexture&&this.backend.destroySampler(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(let t of e)this._update(t,e)}_update(e,t){let{backend:i}=this,r=!1,s=!0,a=0,n=0;for(let t of e.bindings)if(!1!==this.nodes.updateGroup(t)){if(t.isStorageBuffer){let e=t.attribute,s=e.isIndirectStorageBufferAttribute?FG.INDIRECT:FG.STORAGE,a=i.get(t);this.attributes.update(e,s),a.attribute!==e&&(a.attribute=e,r=!0)}if(t.isUniformBuffer)t.update()&&i.updateBinding(t);else if(t.isSampledTexture){let o=t.update(),l=t.texture,h=this.textures.get(l);if(o&&(this.textures.updateTexture(l),t.generation!==h.generation&&(t.generation=h.generation,r=!0),h.bindGroups.add(e)),void 0!==i.get(l).externalTexture||h.isDefaultTexture?s=!1:(a=a+":"+l.id,n+=l.version),!0===l.isStorageTexture&&!0===l.mipmapsAutoUpdate){let e=this.get(l);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(l)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(l),e.needsMipmap=!1)}}else if(t.isSampler&&t.update()){let e=this.textures.updateSampler(t);t.samplerKey!==e&&(t.samplerKey=e,r=!0)}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}!0===r&&this.backend.updateBindings(e,t,s?a:0,n)}},QG=Object.freeze([]),eW={transparent:!1,doublePass:!1},tW=class{constructor(e,t,i,r=null){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=i,this.occlusionQueryCount=0,this._lastOcclusionObject=null,this.objects=r}_classify(e){if(null!==this.objects){let t=this.objects.getClassification(e);if(null!==t)return t}return eW.transparent=CP(e),eW.doublePass=eW.transparent&&AP(e),eW}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,i,r,s,a,n){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:i,groupOrder:r,renderOrder:e.renderOrder,z:s,group:a,clippingContext:n},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=i,o.groupOrder=r,o.renderOrder=e.renderOrder,o.z=s,o.group=a,o.clippingContext=n),this.renderItemsIndex++,o}push(e,t,i,r,s,a,n){let o=this.getNextRenderItem(e,t,i,r,s,a,n);!0===e.occlusionTest&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e);let l=this._classify(i);!0===l.transparent?(!0===l.doublePass&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,i,r,s,a,n){let o=this.getNextRenderItem(e,t,i,r,s,a,n),l=this._classify(i);!0===l.transparent?(!0===l.doublePass&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t,i){this.opaque.length>1&&this.opaque.sort(e||MP),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||TP),this.transparent.length>1&&this.transparent.sort(t||TP),i&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:QG);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){let t=this.renderItems[e];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.groupOrder=null,t.renderOrder=null,t.z=null,t.group=null,t.clippingContext=null}this._lastOcclusionObject=null}},iW=[],rW=class{constructor(e,t=null){this.lighting=e,this.objects=t,this.lists=new EG}get(e,t){let i=this.lists;iW[0]=e,iW[1]=t;let r=i.get(iW);return void 0===r&&(r=new tW(this.lighting,e,t,this.objects),i.set(iW,r)),iW[0]=null,iW[1]=null,r}dispose(){this.lists=new EG}},sW=0,aW=class{constructor(){this.id=sW++,this.nodeCacheKey="",this.mrt=null,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Ss,this.scissor=!1,this.scissorValue=new Ss,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.camera=null,this.isRenderContext=!0}getCacheKey(){return function(e){let{textures:t,activeCubeFace:i,activeMipmapLevel:r}=e,s=[i,r];for(let e of t)s.push(e.id);return hR(s)}(this)}},nW=class{constructor(e){this.renderer=e,this._renderContexts={}}get(e=null,t=null,i=0){let r;if(null===e)r="default";else{let t=e.texture.format,i=e.texture.type;r=`${e.textures.length}:${t}:${i}:${e.samples}:${e.depthBuffer}:${e.stencilBuffer}`}let s=null!==t?t.id:"default",a=r+"-"+s+"-"+i,n=this._renderContexts[a];return void 0===n&&(n=new aW,n.mrt=t,n.nodeCacheKey=r+"-"+s,this._renderContexts[a]=n),null!==e&&(n.sampleCount=0===e.samples?1:e.samples),n.clearDepthValue=this.renderer.getClearDepth(),n.clearStencilValue=this.renderer.getClearStencil(),n}dispose(){this._renderContexts={}}},oW=new ns,lW=class extends UG{constructor(e,t,i){super(),this.renderer=e,this.backend=t,this.info=i,this._htmlTextures=new Set}updateRenderTarget(e,t=0){let i=this.get(e),r=0===e.samples?1:e.samples,s=i.depthTextureMips||(i.depthTextureMips={}),a=e.textures,n=this.getSize(a[0]),o=n.width>>t,l=n.height>>t,h=e.depthTexture||s[t],u=!0===e.depthBuffer||!0===e.stencilBuffer,d=!1,c=void 0!==h&&void 0!==h.image&&h.image.depth>1,p=n.depth>1&&(e.useArrayDepthTexture||e.multiview||c);void 0===h&&u&&(h=new Do,h.format=e.stencilBuffer?ci:di,h.type=e.stencilBuffer?ai:ei,h.image.width=o,h.image.height=l,h.image.depth=n.depth,h.renderTarget=e,s[t]=h),h&&(h.isArrayTexture=p),(i.width!==n.width||n.height!==i.height)&&(d=!0,h&&(h.needsUpdate=!0,h.image.width=o,h.image.height=l,h.image.depth=p?n.depth:1)),i.width=n.width,i.height=n.height,i.textures=a,i.depthTexture=h||null,i.depth=e.depthBuffer,i.stencil=e.stencilBuffer,i.renderTarget=e,i.sampleCount!==r&&(d=!0,h&&(h.needsUpdate=!0),i.sampleCount=r);let m={sampleCount:r};if(!0!==e.isXRRenderTarget){for(let e=0;e<a.length;e++){let t=a[e];d&&(t.needsUpdate=!0),this.updateTexture(t,m)}h&&this.updateTexture(h,m)}!0!==i.initialized&&(i.initialized=!0,this.info.memory.renderTargets++,i.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener("dispose",i.onDispose))}updateTexture(e,t={}){let i=this.get(e);if(!0===i.initialized&&i.version===e.version)return;let r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,s=this.backend;if(r&&!0===i.initialized&&s.destroyTexture(e),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();e.type=t?t.texture.type:Xt}if(e.isHTMLTexture&&e.image){let t=this.renderer.domElement;if("requestPaint"in t){if(t.hasAttribute("layoutsubtree")||t.setAttribute("layoutsubtree","true"),e.image.parentNode!==t&&t.appendChild(e.image),0===this._htmlTextures.size){let e=this._htmlTextures;t.onpaint=t=>{let i=t&&t.changedElements;for(let t of e)(!i||i.includes(t.image))&&(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}let{width:a,height:n,depth:o}=this.getSize(e);if(t.width=a,t.height=n,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,n):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||!0===e.isStorageTexture||!0===e.isExternalTexture)s.createTexture(e,t),i.generation=e.version;else if(e.version>0){let r=e.image;if(void 0===r||!1===r.complete)f(void 0===r?"Renderer: Texture marked for update but image is undefined.":"Renderer: Texture marked for update but image is incomplete."),void 0===s.get(e).texture&&(s.createDefaultTexture(e),i.isDefaultTexture=!0,i.generation=e.version);else{if(e.images){let i=[];for(let t of e.images)i.push(t);t.images=i}else t.image=r;(void 0===i.isDefaultTexture||!0===i.isDefaultTexture)&&(s.createTexture(e,t),i.isDefaultTexture=!1,i.generation=e.version),!0===e.source.dataReady&&s.updateTexture(e,t);let a=!0===e.isStorageTexture&&!1===e.mipmapsAutoUpdate;t.needsMipmaps&&0===e.mipmaps.length&&!a&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),i.isDefaultTexture=!0,i.generation=e.version;!0!==i.initialized&&(i.initialized=!0,i.generation=e.version,i.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&!0===ms.enabled&&ms.getTransfer(e.colorSpace)!==cr&&f("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),i.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",i.onDispose)),i.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=oW){let i=e.images?e.images[0]:e.image;return i?(void 0!==i.image&&(i=i.image),e.isHTMLTexture?(t.width=i.offsetWidth||1,t.height=i.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement?(t.width=i.videoWidth||1,t.height=i.videoHeight||1,t.depth=1):typeof VideoFrame<"u"&&i instanceof VideoFrame?(t.width=i.displayWidth||1,t.height=i.displayHeight||1,t.depth=1):(t.width=i.width||1,t.height=i.height||1,t.depth=e.isCubeTexture?6:i.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,i){let r;return r=e.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,i)))+1,r}needsMipmaps(e){return!0===e.generateMipmaps||e.mipmaps.length>0}_destroyRenderTarget(e){if(!0===this.has(e)){let t=this.get(e),i=t.textures,r=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let e=0;e<i.length;e++)this._destroyTexture(i[e]);r&&this._destroyTexture(r),this.delete(e),this.backend.delete(e),this.info.memory.renderTargets--}}_destroyTexture(e){if(!0===this.has(e)){let t=this.get(e);e.removeEventListener("dispose",t.onDispose);let i=t.isDefaultTexture;if(this.backend.destroyTexture(e,i),t.bindGroups)for(let i of t.bindGroups){let t=this.backend.get(i);t.groups=void 0,t.versions=void 0;for(let t of i.bindings)t.isSampler&&t.texture===e&&(!0!==t.isSampledTexture&&this.backend.destroySampler(t),t.reset(),t.release())}this._htmlTextures.delete(e),this.delete(e),this.info.destroyTexture(e)}}},hW=class extends aa{constructor(e,t,i,r=1){super(e,t,i),this.a=r}set(e,t,i,r=1){return this.a=r,super.set(e,t,i)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}},uW=class extends LV{static get type(){return"OverrideContextNode"}constructor(e,t=null){super(t,{overrideNodes:e}),this.isOverrideContextNode=!0}getFlowContextData(){let e=[];this.traverse(t=>{!0===t.isOverrideContextNode&&e.push(t.value.overrideNodes)});let t=new Map(e.flatMap(e=>Array.from(e.entries()))),i=super.getFlowContextData();return i.overrideNodes=t,i}},$N("overrideNode",(e,t,i)=>NP(t,i,e)),$N("overrideNodes",(e,t)=>PP(t,e)),dW=class extends YE{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let i,r=this.getNodeType(e),s=e.getStructTypeNode(r);return null!==s?i=s.getMemberType(e,t):(y(`TSL: Member "${t}" not found in struct "${r}".`,new oR),i="float"),i}getHash(){return String(this.id)}generate(){return this.name}},cW=(e,t)=>new dW(e,t),pW=mE(class extends SR{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):"void"}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=-1){if(!0!==e.isNode)return y("TSL: Invalid node added to stack.",new oR),this;if(-1===t)if(this._currentNode){let e=this._nodeDataLibrary.get(this._currentNode);void 0===e&&(e={delta:0},this._nodeDataLibrary.set(this._currentNode,e)),e.delta++,t=this.nodes.indexOf(this._currentNode)+e.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){let i=new ZN(t);return this._currentCond=IV(e,i),this.addToStack(this._currentCond)}ElseIf(e,t){let i=new ZN(t),r=IV(e,i);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new ZN(e),this}Switch(e){return this._expressionNode=uE(e),this}Case(...e){let t=[];if(e.length>=2)for(let i=0;i<e.length-1;i++)t.push(this._expressionNode.equal(uE(e[i])));else y("TSL: Invalid parameter length. Case() requires at least two parameters.",new oR);let i=new ZN(e[e.length-1]),r=t[0];for(let e=1;e<t.length;e++)r=r.or(t[e]);let s=IV(r,i);return null===this._currentCond?(this._currentCond=s,this.addToStack(this._currentCond)):(this._currentCond.elseNode=s,this._currentCond=s,this)}Default(e){return this.Else(e),this}setup(e){let t=e.getNodeProperties(this),i=0;for(let r of this.getChildren())r.isVarNode&&r.isIntent(e)&&!0!==r.isAssign(e)||(t["node"+i++]=r);return t.outputNode||null}build(e,...t){let i,r=wE(),s=e.buildStage;xE(this),e.setActiveStack(this);for(let t=0;t<this.nodes.length;t++){let i=this.nodes[t],r=this._currentNode;if(this._currentNode=i,!i.isVarNode||!i.isIntent(e)||!0===i.isAssign(e)){if("setup"===s)i.build(e);else if("analyze"===s)i.build(e,this);else if("generate"===s){let t=e.getDataFromNode(i,"any").stages,r=t&&t[e.shaderStage];if(i.isVarNode&&r&&1===r.length&&r[0]&&r[0].isStackNode)continue;i.build(e,"void")}this._currentNode=r}}if(this.outputNode){let r=this.outputNode.build(e,...t);("generate"!==e.buildStage||"void"!==this.outputNode.getNodeType(e))&&(i=r)}else i=super.build(e,...t);return xE(r),e.removeActiveStack(this),i}}).setParameterLength(0,1),mW=class extends SR{static get type(){return"StructTypeNode"}constructor(e,t=null){var i;super("struct"),this.membersLayout=(i=e,Object.entries(i).map(([e,t])=>"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(let i of this.membersLayout){let r=i.type,s=jN(r),a=GN(r);e=Math.max(e,a);let n=t%e%a;0!==n&&(t+=a-n),t+=s}return Math.ceil(t/e)*e}getMemberType(e,t){let i=this.membersLayout.find(e=>e.name===t);return i?i.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}},gW=class extends SR{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){let e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){let t=e.getVarFromNode(this),i=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(i,this.structTypeNode.membersLayout,this.values)}`,this),t.name}},fW=(e,t=null)=>{let i=new mW(e,t);return yE((...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let i=Object.keys(e);for(let e=0;e<t.length;e++)r[i[e]]=t[e]}else r=t[0];return new gW(i,r)},i)},vW=mE(yW=class extends SR{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}generateNodeType(){return"OutputType"}generate(e){let t=e.getDataFromNode(this);if(void 0===t.membersLayout){let i=this.members,r=[];for(let t=0;t<i.length;t++){let s="m"+t,a=i[t].getNodeType(e);r.push({name:s,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}let i=e.getOutputStructName(),r=this.members,s=""!==i?i+".":"";for(let i=0;i<r.length;i++){let a=r[i].build(e,t.membersLayout[i].type);e.addLineFlowCode(`${s}m${i} = ${a}`,this)}return i}}),xW=new(bW=class{constructor(e=$e){this.blending=e,this.blendSrc=lt,this.blendDst=ht,this.blendEquation=Qe,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return(new this.constructor).copy(this)}})(He),wW=new bW(Je),_W=class extends yW{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.blendModes={output:wW},this.isMRTNode=!0}setBlendMode(e,t){return this.blendModes[e]=t,this}getBlendMode(e){return this.blendModes[e]||xW}has(e){return void 0!==this.outputNodes[e]}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes},i={...this.blendModes,...e.blendModes},r=SW(t);return r.blendings=i,r}setup(e){let t=this.outputNodes,i=[],r=e.renderer.getRenderTarget().textures;for(let s in t){let a=RP(r,s),n=e.getOutputType(a);i[a]=t[s].convert(n)}return this.members=i,super.setup(e)}},SW=mE(_W),TW=fE(MW=class extends CR{static get type(){return"BitcastNode"}constructor(e,t,i=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=i,this.isBitcastNode=!0}generateNodeType(e){if(null!==this.inputType){let t=this.valueNode.getNodeType(e),i=e.getTypeLength(t);return e.getTypeFromLength(i,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),i="";if(null!==this.inputType){let t=this.valueNode.getNodeType(e);i=1===e.getTypeLength(t)?this.inputType:e.changeComponentType(t,this.inputType)}else i=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,i)}( ${this.valueNode.build(e,i)} )`}}).setParameterLength(2),CW=e=>new MW(e,"int","float"),AW=e=>new MW(e,"uint","float"),NW=e=>new MW(e,"float","int"),PW=e=>new MW(e,"float","uint"),RW={},(EW=class extends mB{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,i){"int"===i?t.assign(TW(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return AE;case"int":return CE;case"uvec2":return EE;case"uvec3":return DE;case"uvec4":return kE;case"ivec2":return RE;case"ivec3":return VE;case"ivec4":return zE}}_createTrailingZerosBaseLayout(e,t){let i=this._returnDataNode(t);return JN(([e])=>{let r=AE(0);this._resolveElementType(e,r,t);let s=TE(r.bitAnd(KB(r))),a=AW(s).shiftRight(23).sub(127);return i(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){let i=this._returnDataNode(t);return JN(([e])=>{_E(e.equal(AE(0)),()=>AE(32));let r=AE(0),s=AE(0);return this._resolveElementType(e,r,t),_E(r.shiftRight(16).equal(0),()=>{s.addAssign(16),r.shiftLeftAssign(16)}),_E(r.shiftRight(24).equal(0),()=>{s.addAssign(8),r.shiftLeftAssign(8)}),_E(r.shiftRight(28).equal(0),()=>{s.addAssign(4),r.shiftLeftAssign(4)}),_E(r.shiftRight(30).equal(0),()=>{s.addAssign(2),r.shiftLeftAssign(2)}),_E(r.shiftRight(31).equal(0),()=>{s.addAssign(1)}),i(s)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){let i=this._returnDataNode(t);return JN(([e])=>{let r=AE(0);this._resolveElementType(e,r,t),r.assign(r.sub(r.shiftRight(AE(1)).bitAnd(AE(1431655765)))),r.assign(r.bitAnd(AE(858993459)).add(r.shiftRight(AE(2)).bitAnd(AE(858993459))));let s=r.add(r.shiftRight(AE(4))).bitAnd(AE(252645135)).mul(AE(16843009)).shiftRight(AE(24));return i(s)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,i,r){let s=this._returnDataNode(t);return JN(([e])=>{if(1===i)return s(r(e));{let t=s(0),a=["x","y","z","w"];for(let s=0;s<i;s++){let i=a[s];t[i].assign(r(e[i]))}return t}}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}setup(e){let{method:t,aNode:i}=this,{renderer:r}=e;if(r.backend.isWebGPUBackend)return super.setup(e);let s=this.getInputType(e),a=e.getElementType(s),n=e.getTypeLength(s),o=`${t}_base_${a}`,l=`${t}_${s}`,h=RW[o];if(void 0===h){switch(t){case EW.COUNT_LEADING_ZEROS:h=this._createLeadingZerosBaseLayout(o,a);break;case EW.COUNT_TRAILING_ZEROS:h=this._createTrailingZerosBaseLayout(o,a);break;case EW.COUNT_ONE_BITS:h=this._createOneBitsBaseLayout(o,a)}RW[o]=h}let u=RW[l];return void 0===u&&(u=this._createMainLayout(l,s,n,h),RW[l]=u),JN(()=>u(i))()}}).COUNT_TRAILING_ZEROS="countTrailingZeros",EW.COUNT_LEADING_ZEROS="countLeadingZeros",EW.COUNT_ONE_BITS="countOneBits",OW=fE(EW,EW.COUNT_TRAILING_ZEROS).setParameterLength(1),BW=fE(EW,EW.COUNT_LEADING_ZEROS).setParameterLength(1),VW=fE(EW,EW.COUNT_ONE_BITS).setParameterLength(1),DW=JN(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),i=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return i.shiftRight(22).bitXor(i).toFloat().mul(1/2**32)}),IW=(e,t)=>gV(qO(4,e.mul(WO(1,e))),t),LW=(e,t)=>e.lessThan(.5)?IW(e.mul(2),t).div(2):WO(1,IW(qO(WO(1,e),2),t).div(2)),zW=(e,t,i)=>gV(HO(gV(e,t),GO(gV(e,t),gV(WO(1,e),i))),1/t),kW=(e,t)=>DB(yB.mul(t.mul(e).sub(1))).div(yB.mul(t.mul(e).sub(1))),FW=fE(UW=class extends CR{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){let t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}},"snorm").setParameterLength(1),jW=fE(UW,"unorm").setParameterLength(1),GW=fE(UW,"float16").setParameterLength(1),qW=fE(WW=class extends CR{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return"vec2"}generate(e){let t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}},"snorm").setParameterLength(1),HW=fE(WW,"unorm").setParameterLength(1),$W=fE(WW,"float16").setParameterLength(1),YW=JN(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),XW=JN(([e])=>BE(YW(e.z.add(YW(e.y.mul(1)))),YW(e.z.add(YW(e.x.mul(1)))),YW(e.y.add(YW(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),KW=JN(([e,t,i])=>{let r=BE(e).toVar(),s=TE(1.4).toVar(),a=TE(0).toVar(),n=BE(r).toVar();return Jk({start:TE(0),end:TE(3),type:"float",condition:"<="},()=>{let e=BE(XW(n.mul(2))).toVar();r.addAssign(e.add(i.mul(TE(.1).mul(t)))),n.mulAssign(1.8),s.mulAssign(1.5),r.mulAssign(1.2);let o=TE(YW(r.z.add(YW(r.x.add(YW(r.y)))))).toVar();a.addAssign(o.div(s)),n.addAssign(.14)}),a}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]}),ZW=mE(class extends SR{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){let t=this.parametersNodes,i=this._candidateFn;if(null===i){let r=null,s=-1;for(let i of this.functionNodes){let a=i.shaderNode.layout;if(null===a)throw new Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");let n=a.inputs;if(t.length===n.length){let a=0;for(let i=0;i<t.length;i++){let r=t[i],s=n[i];r.getNodeType(e)===s.type&&a++}a>s&&(r=i,s=a)}}this._candidateFn=i=r}return i}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}),JW=e=>(...t)=>ZW(e,...t),QW=DO(0).setGroup(OO).onRenderUpdate(e=>e.time),eq=DO(0).setGroup(OO).onRenderUpdate(e=>e.deltaTime),tq=DO(0,"uint").setGroup(OO).onRenderUpdate(e=>e.frameId),iq=(e=QW)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),rq=(e=QW)=>e.fract().round(),sq=(e=QW)=>e.add(.5).fract().mul(2).sub(1).abs(),aq=(e=QW)=>e.fract(),nq=JN(([e,t,i=PE(.5)])=>xG(e.sub(i),t).add(i)),oq=JN(([e,t,i=PE(.5)])=>{let r=e.sub(i),s=r.dot(r),a=s.mul(s).mul(t);return e.add(r.mul(a))}),lq=JN(({position:e=null,horizontal:t=!0,vertical:i=!1})=>{let r;null!==e?(r=iL.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z):r=iL;let s=FI.mul(r);return KN(t)&&(s[0][0]=iL[0].length(),s[0][1]=0,s[0][2]=0),KN(i)&&(s[1][0]=0,s[1][1]=iL[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,kI.mul(s).mul(gL)}),hq=JN(([e=null])=>{let t=PU();return PU(yU(e)).sub(t).lessThan(0).select(mI,e)}),uq=JN(([e,t=qD(),i=TE(0)])=>{let r=e.x,s=e.y,a=i.mod(r.mul(s)).floor(),n=a.mod(r),o=s.sub(a.add(1).div(r).ceil()),l=e.reciprocal(),h=PE(n,o);return t.add(h).mul(l)}),dq=JN(([e,t=null,i=null,r=TE(1),s=gL,a=CL])=>{let n=a.abs().normalize();n=n.div(n.dot(BE(1)));let o=s.yz.mul(r),l=s.zx.mul(r),h=s.xy.mul(r),u=e.value,d=null!==t?t.value:u,c=null!==i?i.value:u,p=JD(u,o).mul(n.x),m=JD(d,l).mul(n.y),g=JD(c,h).mul(n.z);return GO(p,m,g)}),cq=(...e)=>dq(...e),pq=new uo,mq=new ns,gq=new ns,fq=new ns,yq=new As,vq=new ns(0,0,-1),bq=new Ss,xq=new ns,wq=new ns,_q=new Ss,Sq=new rs,Mq=new Ms,Tq=mI.flipX(),Mq.depthTexture=new Do(1,1),Cq=!1,Aq=class extends KD{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||Mq.texture,Tq),this._reflectorBaseNode=e.reflector||new Nq(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new Aq({defaultTexture:Mq.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},Nq=class extends SR{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();let{target:i=new ea,resolutionScale:r=1,generateMipmaps:s=!1,bounces:a=!0,depth:n=!1,samples:o=0}=t;this.textureNode=e,this.target=i,this.resolutionScale=r,void 0!==t.resolution&&(v('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=s,this.bounces=a,this.depth=n,this.samples=o,this.updateBeforeType=a?mR.RENDER:mR.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let i=this.resolutionScale;t.getDrawingBufferSize(Sq),e.setSize(Math.round(Sq.width*i),Math.round(Sq.height*i))}setup(e){return this._updateResolution(Mq,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new Ms(0,0,{type:ii,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=Yt,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new Do),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&Cq)return!1;Cq=!0;let{scene:t,camera:i,renderer:r,material:s}=e,{target:a}=this,n=this.getVirtualCamera(i),o=this.getRenderTarget(n);r.getDrawingBufferSize(Sq),this._updateResolution(o,r),gq.setFromMatrixPosition(a.matrixWorld),fq.setFromMatrixPosition(i.matrixWorld),yq.extractRotation(a.matrixWorld),mq.set(0,0,1),mq.applyMatrix4(yq),xq.subVectors(gq,fq);let l=!1;if(!0==xq.dot(mq)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(Cq=!1);l=!0}xq.reflect(mq).negate(),xq.add(gq),yq.extractRotation(i.matrixWorld),vq.set(0,0,-1),vq.applyMatrix4(yq),vq.add(fq),wq.subVectors(gq,vq),wq.reflect(mq).negate(),wq.add(gq),n.coordinateSystem=i.coordinateSystem,n.position.copy(xq),n.up.set(0,1,0),n.up.applyMatrix4(yq),n.up.reflect(mq),n.lookAt(wq),n.near=i.near,n.far=i.far,n.updateMatrixWorld(),n.projectionMatrix.copy(i.projectionMatrix),pq.setFromNormalAndCoplanarPoint(mq,gq),pq.applyMatrix4(n.matrixWorldInverse),bq.set(pq.normal.x,pq.normal.y,pq.normal.z,pq.constant);let h=n.projectionMatrix;_q.x=(Math.sign(bq.x)+h.elements[8])/h.elements[0],_q.y=(Math.sign(bq.y)+h.elements[9])/h.elements[5],_q.z=-1,_q.w=(1+h.elements[10])/h.elements[14],bq.multiplyScalar(1/bq.dot(_q)),h.elements[2]=bq.x,h.elements[6]=bq.y,h.elements[10]=r.coordinateSystem===Gr?bq.z-0:bq.z+1-0,h.elements[14]=bq.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),s.visible=!1;let u=r.getRenderTarget(),d=r.getMRT(),c=r.autoClear;r.setMRT(null),r.setRenderTarget(o),r.autoClear=!0;let p=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",l?(r.clear(),this.hasOutput=!1):(r.render(t,n),this.hasOutput=!0),t.name=p,r.setMRT(d),r.setRenderTarget(u),r.autoClear=c,s.visible=!0,Cq=!1,this.forceUpdate=!1}get resolution(){return v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}},Pq=e=>new Aq(e),Rq=new uh(-1,1,1,-1,0,1),Eq=new class extends an{constructor(e=!1){super();let t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Ha([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ha(t,2))}},Oq=class extends Hn{constructor(e=null){super(Eq,e),this.camera=Rq,this.isQuadMesh=!0}async renderAsync(e){v('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,Rq)}render(e){e.render(this,Rq)}},Bq=new rs,Vq=class extends KD{static get type(){return"RTTNode"}constructor(e,t=null,i=null,r={type:ii}){let s=new Ms(t,i,r);super(s.texture,qD()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=i,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new Oq(new UU),this.updateBeforeType=mR.RENDER}get autoResize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){let i=Math.floor(e*this._resolutionScale),r=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(i,r),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,!1===this.autoResize&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;this.textureNeedsUpdate=!1;let t=e.getRenderTarget();if(!0===this.autoResize){let t=e.getDrawingBufferSize(Bq),i=Math.floor(t.width*this._resolutionScale),r=Math.floor(t.height*this._resolutionScale);(i!==this.renderTarget.width||r!==this.renderTarget.height)&&(this.renderTarget.setSize(i,r),this.textureNeedsUpdate=!0)}let i="RTT";this.node.name&&(i=this.node.name+" [ "+i+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=i,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new KD(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}},Dq=(e,...t)=>new Vq(uE(e),...t),Iq=(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():Dq(e,...t),Lq=JN(([e,t,i],r)=>{let s;r.renderer.coordinateSystem===Gr?(e=PE(e.x,e.y.oneMinus()).mul(2).sub(1),s=LE(BE(e,t),1)):s=LE(BE(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=LE(i.mul(s));return a.xyz.div(a.w)}),zq=JN(([e,t])=>{let i=t.mul(LE(e,1)),r=i.xy.div(i.w).mul(.5).add(.5).toVar();return PE(r.x,r.y.oneMinus())}),kq=JN(([e,t,i])=>{let r=HD(eI(t)),s=RE(e.mul(r)).toVar(),a=eI(t,s).toVar(),n=eI(t,s.sub(RE(2,0))).toVar(),o=eI(t,s.sub(RE(1,0))).toVar(),l=eI(t,s.add(RE(1,0))).toVar(),h=eI(t,s.add(RE(2,0))).toVar(),u=eI(t,s.add(RE(0,2))).toVar(),d=eI(t,s.add(RE(0,1))).toVar(),c=eI(t,s.sub(RE(0,1))).toVar(),p=eI(t,s.sub(RE(0,2))).toVar(),m=$B(WO(TE(2).mul(o).sub(n),a)).toVar(),g=$B(WO(TE(2).mul(l).sub(h),a)).toVar(),f=$B(WO(TE(2).mul(d).sub(u),a)).toVar(),y=$B(WO(TE(2).mul(c).sub(p),a)).toVar(),v=Lq(e,a,i).toVar(),b=m.lessThan(g).select(v.sub(Lq(e.sub(PE(TE(1).div(r.x),0)),o,i)),v.negate().add(Lq(e.add(PE(TE(1).div(r.x),0)),l,i))),x=f.lessThan(y).select(v.sub(Lq(e.add(PE(0,TE(1).div(r.y))),d,i)),v.negate().add(Lq(e.sub(PE(0,TE(1).div(r.y))),c,i)));return BB(mV(b,x))}),Uq=JN(([e])=>VB(TE(52.9829189).mul(VB(pV(e,PE(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),Fq=JN(([e,t,i])=>{let r=TE(2.399963229728653),s=PB(TE(e).add(.5).div(TE(t))),a=TE(e).mul(r).add(i);return PE(LB(a),DB(a)).mul(s)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),jq=class extends SR{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(qD())}sample(e){return this.callback(e)}},Gq=(e,t=null)=>new jq(e,uE(t)),Wq=class extends Jn{constructor(e,t,i=Float32Array){super(ArrayBuffer.isView(e)?e:new i(e*t),t),this.isStorageInstancedBufferAttribute=!0}},qq=class extends ja{constructor(e,t,i=Float32Array){super(ArrayBuffer.isView(e)?e:new i(e*t),t),this.isStorageBufferAttribute=!0}},Hq=(e,t="float")=>{let i,r;!0===t.isStructTypeNode?(i=t.getLength(),r=UN("float")):(i=FN(t),r=UN(t));let s=new qq(e,i,r);return Ik(s,t,e)},$q=(e,t="float")=>{let i,r;!0===t.isStructTypeNode?(i=t.getLength(),r=UN("float")):(i=FN(t),r=UN(t));let s=new Wq(e,i,r);return Ik(s,t,s.count)},Yq=gE(class extends SR{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}),Xq=new As,Kq=DO(0).setGroup(OO).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),Zq=DO(1).setGroup(OO).onRenderUpdate(({scene:e})=>e.backgroundIntensity),Jq=DO(new As).setGroup(OO).onRenderUpdate(({scene:e})=>{let t=e.background;return null!==t&&t.isTexture&&t.mapping!==Bt?Xq.makeRotationFromEuler(e.backgroundRotation).transpose():Xq.identity(),Xq}),eH=mE(Qq=class extends KD{static get type(){return"StorageTextureNode"}constructor(e,t,i=null){super(e,t),this.storeNode=i,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=fR.WRITE_ONLY}getInputType(){return"storageTexture"}getTransformedUV(e){return e}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return null!==this.storeNode?(this.generateStore(e),""):super.generate(e,t)}generateSnippet(e,t,i,r,s,a,n,o,l){let h=this.value;return e.generateStorageTextureLoad(h,t,i,r,a,l)}toReadWrite(){return this.setAccess(fR.READ_WRITE)}toReadOnly(){return this.setAccess(fR.READ_ONLY)}toWriteOnly(){return this.setAccess(fR.WRITE_ONLY)}store(e,t){let i=this.clone();return i.referenceNode=this.getBase(),i.uvNode=e,i.storeNode=t,null!==t&&i.toStack(),i}generateStore(e){let t=e.getNodeProperties(this),{uvNode:i,storeNode:r,depthNode:s}=t,a=super.generate(e,"property"),n=i.build(e,!0===this.value.is3DTexture?"uvec3":"uvec2"),o=r.build(e,"vec4"),l=s?s.build(e,"int"):null,h=e.generateTextureStore(this.value,a,n,l,o);e.addLineFlowCode(h,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}).setParameterLength(1,3),tH=(e,t,i)=>{let r;return!0===e.isStorageTextureNode?r=e.store(t,i):(r=eH(e,t,i),null!==i&&r.toStack()),r},iH=mE(class extends Qq{static get type(){return"StorageTexture3DNode"}constructor(e,t,i=null){super(e,t,i),this.isStorageTexture3DNode=!0}getDefaultUV(){return BE(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}}).setParameterLength(1,3),rH=JN(({texture:e,uv:t})=>{let i=BE().toVar();return _E(t.x.lessThan(1e-4),()=>{i.assign(BE(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{i.assign(BE(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{i.assign(BE(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{i.assign(BE(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{i.assign(BE(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{i.assign(BE(0,0,-1))}).Else(()=>{let r=e.sample(t.add(BE(-.01,0,0))).r.sub(e.sample(t.add(BE(.01,0,0))).r),s=e.sample(t.add(BE(0,-.01,0))).r.sub(e.sample(t.add(BE(0,.01,0))).r),a=e.sample(t.add(BE(0,0,-.01))).r.sub(e.sample(t.add(BE(0,0,.01))).r);i.assign(BE(r,s,a))}),i.normalize()}),sH=mE(class extends KD{static get type(){return"Texture3DNode"}constructor(e,t=null,i=null){super(e,t,i),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return BE(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return rH({texture:this,uv:e})}}).setParameterLength(1,3),aH=(...e)=>sH(...e).setSampler(!1),nH=(e,t,i)=>sH(e,t).level(i),oH=class extends ZL{static get type(){return"UserDataNode"}constructor(e,t,i=null){super(e,t,i),this.userData=i}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}},lH=(e,t,i)=>new oH(e,t,i),hH=new WeakMap,uH=gE(class extends CR{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=mR.OBJECT,this.updateAfterType=mR.OBJECT,this.previousModelWorldMatrix=DO(new As),this.previousProjectionMatrix=DO(new As).setGroup(OO),this.previousCameraViewMatrix=DO(new As)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:i}){let r=BP(i);this.previousModelWorldMatrix.value.copy(r);let s=OP(t);s.frameId!==e&&(s.frameId=e,void 0===s.previousProjectionMatrix?(s.previousProjectionMatrix=new As,s.previousCameraViewMatrix=new As,s.currentProjectionMatrix=new As,s.currentCameraViewMatrix=new As,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){BP(e).copy(e.matrixWorld)}setup(){let e=null===this.projectionMatrix?kI:DO(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),i=e.mul(hL).mul(gL),r=this.previousProjectionMatrix.mul(t).mul(fL),s=i.xy.div(i.w),a=r.xy.div(r.w);return WO(s,a)}}),dH=JN(([e,t])=>oV(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),cH=JN(([e,t])=>oV(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),pH=JN(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),mH=JN(([e,t])=>MV(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),hV(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),gH=JN(([e,t])=>{let i=t.a.add(e.a.mul(t.a.oneMinus()));return LE(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(i),i)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),fH=JN(([e])=>xH(e.rgb)),yH=JN(([e,t=TE(1)])=>t.mix(xH(e.rgb),e.rgb).max(0)),vH=JN(([e,t=TE(0)])=>{let i=GO(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),s=r.sub(i).mul(t).mul(-3);return MV(e.rgb,r,s).max(0)}),bH=JN(([e,t=TE(1)])=>{let i=BE(.57735,.57735,.57735),r=t.cos();return BE(e.rgb.mul(r).add(i.cross(e.rgb).mul(t.sin()).add(i.mul(pV(i,e.rgb).mul(r.oneMinus()))))).max(0)}),xH=(e,t=BE(ms.getLuminanceCoefficients(new ns)))=>pV(e,t),wH=JN(([e,t=BE(1),i=BE(0),r=BE(1),s=TE(1),a=BE(ms.getLuminanceCoefficients(new ns,ur))])=>{let n=e.rgb.dot(BE(a)),o=lV(e.rgb.mul(t).add(i),0),l=o.pow(r);return _E(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),_E(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),_E(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(n.add(o.sub(n).mul(s)).max(0)),LE(o.rgb,e.a)}),_H=JN(([e,t])=>e.mul(t).floor().div(t)),SH=null,MH=mE(class extends dU{static get type(){return"ViewportSharedTextureNode"}constructor(e=mI,t=null){null===SH&&(SH=new Oo),super(e,t,SH)}getTextureForReference(){return SH}updateReference(){return this}}).setParameterLength(0,2),TH=new rs,CH=class extends KD{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){return e.getNodeProperties(this).passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},AH=class extends CH{static get type(){return"PassMultipleTextureNode"}constructor(e,t,i=!1){super(e,null),this.textureName=t,this.previousTexture=i,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}},(NH=class extends CR{static get type(){return"PassNode"}constructor(e,t,i,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=i,this.options=r,this._width=1,this._height=1;let s=new Ms(this._width,this._height,{type:ii,...r});s.texture.name="output";let a=null;(this.scope===NH.DEPTH||!1!==r.depthBuffer)&&(a=new Do,a.isRenderTargetTexture=!0,a.name="depth",s.depthTexture=a),this.renderTarget=s,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:s.texture},null!==a&&(this._textures.depth=a),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=DO(0),this._cameraFar=DO(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=mR.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return f("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return f("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){if("depth"===e)throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(void 0!==t){let i=this._textures[e],r=this.renderTarget.textures.indexOf(i);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=i,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=new AH(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=new AH(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){let i=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=MU(this.getTextureNode(e),i,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){let i=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=bU(s,i,r)}return t}async compileAsync(e){let t=e.getRenderTarget(),i=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(i)}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),!0===e.reversedDepthBuffer&&null!==this.renderTarget.depthTexture&&(this.renderTarget.depthTexture.type=ti),this.scope===NH.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let t,{renderer:i}=e,{scene:r}=this,s=i.getOutputRenderTarget();s&&!0===s.isXRRenderTarget?(t=i.xr.getCamera(),i.xr.updateCamera(t),TH.set(s.width,s.height)):(t=this.camera,i.getDrawingBufferSize(TH)),this.setSize(TH.width,TH.height);let a=i.getRenderTarget(),n=i.getMRT(),o=i.autoClear,l=i.transparent,h=i.opaque,u=t.layers.mask,d=i.contextNode,c=r.overrideMaterial;this._cameraNear.value=t.near,this._cameraFar.value=t.far,null!==this._layers&&(t.layers.mask=this._layers.mask);for(let e in this._previousTextures)this.toggleTexture(e);null!==this.overrideMaterial&&(r.overrideMaterial=this.overrideMaterial),i.setRenderTarget(this.renderTarget),i.setMRT(this._mrt),i.autoClear=!0,i.transparent=this.transparent,i.opaque=this.opaque,null!==this.contextNode&&((null===this._contextNodeCache||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:zV({...i.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),i.contextNode=this._contextNodeCache.context);let p=r.name;r.name=this.name?this.name:r.name,i.render(r,t),r.name=p,r.overrideMaterial=c,i.setRenderTarget(a),i.setMRT(n),i.autoClear=o,i.transparent=l,i.opaque=h,i.contextNode=d,t.layers.mask=u}setSize(e,t){this._width=e,this._height=t;let i=Math.floor(this._width*this._resolutionScale),r=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(i,r),null!==this._scissor?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,i,r){null===e?this._scissor=null:(null===this._scissor&&(this._scissor=new Ss),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,i,r))}setViewport(e,t,i,r){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new Ss),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,i,r))}dispose(){this.renderTarget.dispose()}}).COLOR="color",NH.DEPTH="depth",PH=(e,t,i)=>new NH(NH.COLOR,e,t,i),RH=(e,t)=>new CH(e,t),EH=(e,t,i)=>new NH(NH.DEPTH,e,t,i),OH=class extends NH{static get type(){return"ToonOutlinePassNode"}constructor(e,t,i,r,s){super(NH.COLOR,e,t),this.colorNode=i,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){let{renderer:t}=e,i=t.getRenderObjectFunction();t.setRenderObjectFunction((e,i,r,s,a,n,o,l)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&!1===a.wireframe){let h=this._getOutlineMaterial(a);t.renderObject(e,i,r,s,h,n,o,l)}t.renderObject(e,i,r,s,a,n,o,l)}),super.updateBefore(e),t.setRenderObjectFunction(i)}_createMaterial(){let e=new UU;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=We;let t=CL.negate(),i=kI.mul(hL),r=TE(1),s=i.mul(LE(gL,1)),a=i.mul(LE(gL.add(t),1)),n=BB(s.sub(a));return e.vertexNode=s.add(n.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=LE(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}},BH=(e,t,i=new aa(0,0,0),r=.003,s=1)=>new OH(e,t,uE(i),uE(r),uE(s)),VH=JN(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),DH=JN(([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp()).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),IH=JN(([e,t])=>{let i=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return i.div(r).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),LH=JN(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),i=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(i)}),zH=JN(([e,t])=>{let i=jE(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=jE(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=i.mul(e),e=LH(e),(e=r.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),kH=jE(BE(1.6605,-.1246,-.0182),BE(-.5876,1.1329,-.1006),BE(-.0728,-.0083,1.1187)),UH=jE(BE(.6274,.0691,.0164),BE(.3293,.9195,.088),BE(.0433,.0113,.8956)),FH=JN(([e])=>{let t=BE(e).toVar(),i=BE(t.mul(t)).toVar(),r=BE(i.mul(i)).toVar();return TE(15.5).mul(r.mul(i)).sub(qO(40.14,r.mul(t))).add(qO(31.96,r).sub(qO(6.868,i.mul(t))).add(qO(.4298,i).add(qO(.1191,t).sub(.00232))))}),jH=JN(([e,t])=>{let i=BE(e).toVar(),r=jE(BE(.856627153315983,.137318972929847,.11189821299995),BE(.0951212405381588,.761241990602591,.0767994186031903),BE(.0482516061458583,.101439036467562,.811302368396859)),s=jE(BE(1.1271005818144368,-.1413297634984383,-.14132976349843826),BE(-.11060664309660323,1.157823702216272,-.11060664309660294),BE(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=TE(-12.47393),n=TE(4.026069);return i.mulAssign(t),i.assign(UH.mul(i)),i.assign(r.mul(i)),i.assign(lV(i,1e-10)),i.assign(NB(i)),i.assign(i.sub(a).div(n.sub(a))),i.assign(TV(i,0,1)),i.assign(FH(i)),i.assign(s.mul(i)),i.assign(gV(lV(BE(0),i),BE(2.2))),i.assign(kH.mul(i)),i.assign(TV(i,0,1)),i}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),GH=JN(([e,t])=>{let i=TE(.76),r=TE(.15);e=e.mul(t);let s=oV(e.r,oV(e.g,e.b)),a=IV(s.lessThan(.08),s.sub(qO(6.25,s.mul(s))),.04);e.subAssign(a);let n=lV(e.r,lV(e.g,e.b));_E(n.lessThan(i),()=>e);let o=WO(1,i),l=WO(1,o.mul(o).div(n.add(o.sub(i))));e.mulAssign(l.div(n));let h=WO(1,HO(1,r.mul(n.sub(l)).add(1)));return MV(e,BE(l),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),qH=mE(WH=class extends SR{static get type(){return"CodeNode"}constructor(e="",t=[],i=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=i}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let i of t)i.build(e);let i=e.getCodeFromNode(this,this.getNodeType(e));return i.code=this.code,i.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}).setParameterLength(1,3),HH=(e,t)=>qH(e,t,"js"),$H=(e,t)=>qH(e,t,"wgsl"),YH=(e,t)=>qH(e,t,"glsl"),XH=class extends WH{static get type(){return"FunctionNode"}constructor(e="",t=[],i=""){super(e,t,i)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let i=this.getNodeType(e);return e.getStructTypeNode(i).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),i=t.nodeFunction;return void 0===i&&(i=e.parser.parseFunction(this.code),t.nodeFunction=i),i}generate(e,t){super.generate(e);let i=this.getNodeFunction(e),r=i.name,s=i.type,a=e.getCodeFromNode(this,s);""!==r&&(a.name=r);let n=e.getPropertyName(a),o=this.getNodeFunction(e).getCode(n);return a.code=o+"\n","property"===t?n:e.format(`${n}()`,s,t)}},KH=(e,t=[],i="")=>{let r=new XH(e,t,i);return yE((...e)=>r.call(...e),r)},ZH=(e,t)=>KH(e,t,"glsl"),JH=(e,t)=>KH(e,t,"wgsl"),QH=JN(([e,t],i)=>{let r=VP(i);return NV(e,t,r)}),e$=JN(([e],t)=>{let i=VP(t);return e.mul(e,i,i).negate().exp().oneMinus()}),t$=JN(([e,t],i)=>{let r=VP(i),s=t.sub(yL.y).max(0).toConst().mul(r).toConst();return e.mul(e,s,s).negate().exp().oneMinus()}),i$=JN(([e,t])=>LE(t.toFloat().mix(yO.rgb,e.toVec3()),yO.a)),r$=null,s$=null,a$=mE(class extends SR{static get type(){return"RangeNode"}constructor(e=TE(),t=TE()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),i=this.getConstNode(this.maxNode),r=e.getTypeLength(WN(t.value)),s=e.getTypeLength(WN(i.value));return r>s?r:s}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(e=>{!0===e.isConstNode&&(t=e)}),null===t)throw new YD('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){let t=e.object,i=null;if(t.count>1){let r=this.getConstNode(this.minNode),s=this.getConstNode(this.maxNode),a=r.value,n=s.value,o=e.getTypeLength(WN(a)),l=e.getTypeLength(WN(n));r$=r$||new Ss,s$=s$||new Ss,r$.setScalar(0),s$.setScalar(0),1===o?r$.setScalar(a):a.isColor?r$.set(a.r,a.g,a.b,1):r$.set(a.x,a.y,a.z||0,a.w||0),1===l?s$.setScalar(n):n.isColor?s$.set(n.r,n.g,n.b,1):s$.set(n.x,n.y,n.z||0,n.w||0);let h=4,u=h*t.count,d=new Float32Array(u);for(let e=0;e<u;e++){let t=e%h,i=r$.getComponent(t),r=s$.getComponent(t);d[e]=ts.lerp(i,r,Math.random())}let c=this.getNodeType(e);if(4*t.count*4<=e.getUniformBufferLimit())i=aI(d,"vec4",t.count).element(bD).convert(c);else{let t=new Jn(d,4);e.geometry.setAttribute("__range"+this.id,t),i=gD(t).convert(c)}}else i=TE(0);return i}}).setParameterLength(2),n$=class extends SR{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}generateNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let i=this.getBuiltinName(e),r=this.getNodeType(e);return"compute"===e.shaderStage?e.format(i,r,t):(f(`ComputeBuiltinNode: Compute built-in value ${i} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}},l$=(o$=(e,t)=>new n$(e,t))("numWorkgroups","uvec3"),h$=o$("workgroupId","uvec3"),u$=o$("globalId","uvec3"),d$=o$("localId","uvec3"),c$=o$("subgroupSize","uint"),p$=mE(class extends SR{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){let{scope:t}=this,{renderer:i}=e;!0===i.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}),m$=()=>p$("workgroup").toStack(),g$=()=>p$("storage").toStack(),f$=()=>p$("texture").toStack(),y$=class extends MR{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let i,r=e.isContextAssign();if(i=super.generate(e),!0!==r){let r=this.getNodeType(e);i=e.format(i,r,t)}return i}},v$=class extends SR{constructor(e,t,i=0){super(t),this.bufferType=t,this.bufferCount=i,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return f('TSL: "label()" has been deprecated. Use "setName()" instead.',new oR),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new y$(this,e)}generate(e){let t=""!==this.name?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},b$=(e,t)=>new v$("Workgroup",e,t),(x$=class extends SR{static get type(){return"AtomicFunctionNode"}constructor(e,t,i){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=i,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),i=t.parents,r=this.method,s=this.getNodeType(e),a=this.getInputType(e),n=this.pointerNode,o=this.valueNode,l=[];l.push(`&${n.build(e,a)}`),null!==o&&l.push(o.build(e,a));let h=`${e.getMethod(r,s)}( ${l.join(", ")} )`;if(!i||1!==i.length||!0!==i[0].isStackNode)return void 0===t.constNode&&(t.constNode=OD(h,s).toConst()),t.constNode.build(e);e.addLineFlowCode(h,this)}}).ATOMIC_LOAD="atomicLoad",x$.ATOMIC_STORE="atomicStore",x$.ATOMIC_ADD="atomicAdd",x$.ATOMIC_SUB="atomicSub",x$.ATOMIC_MAX="atomicMax",x$.ATOMIC_MIN="atomicMin",x$.ATOMIC_AND="atomicAnd",x$.ATOMIC_OR="atomicOr",x$.ATOMIC_XOR="atomicXor",w$=mE(x$),_$=(e,t,i)=>w$(e,t,i).toStack(),S$=e=>_$(x$.ATOMIC_LOAD,e,null),M$=(e,t)=>_$(x$.ATOMIC_STORE,e,t),T$=(e,t)=>_$(x$.ATOMIC_ADD,e,t),C$=(e,t)=>_$(x$.ATOMIC_SUB,e,t),A$=(e,t)=>_$(x$.ATOMIC_MAX,e,t),N$=(e,t)=>_$(x$.ATOMIC_MIN,e,t),P$=(e,t)=>_$(x$.ATOMIC_AND,e,t),R$=(e,t)=>_$(x$.ATOMIC_OR,e,t),E$=(e,t)=>_$(x$.ATOMIC_XOR,e,t),(O$=class extends CR{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,i=null){super(),this.method=e,this.aNode=t,this.bNode=i}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,i=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(i)?0:e.getTypeLength(i))?t:i}generateNodeType(e){let t=this.method;return t===O$.SUBGROUP_ELECT?"bool":t===O$.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){let i=this.method,r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,n=this.bNode,o=[];if(i===O$.SUBGROUP_BROADCAST||i===O$.SUBGROUP_SHUFFLE||i===O$.QUAD_BROADCAST){let t=n.getNodeType(e);o.push(a.build(e,r),n.build(e,"float"===t?"int":r))}else i===O$.SUBGROUP_SHUFFLE_XOR||i===O$.SUBGROUP_SHUFFLE_DOWN||i===O$.SUBGROUP_SHUFFLE_UP?o.push(a.build(e,r),n.build(e,"uint")):(null!==a&&o.push(a.build(e,s)),null!==n&&o.push(n.build(e,s)));let l=0===o.length?"()":`( ${o.join(", ")} )`;return e.format(`${e.getMethod(i,r)}${l}`,r,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}).SUBGROUP_ELECT="subgroupElect",O$.SUBGROUP_BALLOT="subgroupBallot",O$.SUBGROUP_ADD="subgroupAdd",O$.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",O$.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",O$.SUBGROUP_MUL="subgroupMul",O$.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",O$.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",O$.SUBGROUP_AND="subgroupAnd",O$.SUBGROUP_OR="subgroupOr",O$.SUBGROUP_XOR="subgroupXor",O$.SUBGROUP_MIN="subgroupMin",O$.SUBGROUP_MAX="subgroupMax",O$.SUBGROUP_ALL="subgroupAll",O$.SUBGROUP_ANY="subgroupAny",O$.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",O$.QUAD_SWAP_X="quadSwapX",O$.QUAD_SWAP_Y="quadSwapY",O$.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",O$.SUBGROUP_BROADCAST="subgroupBroadcast",O$.SUBGROUP_SHUFFLE="subgroupShuffle",O$.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",O$.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",O$.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",O$.QUAD_BROADCAST="quadBroadcast",B$=fE(O$,O$.SUBGROUP_ELECT).setParameterLength(0),V$=fE(O$,O$.SUBGROUP_BALLOT).setParameterLength(1),D$=fE(O$,O$.SUBGROUP_ADD).setParameterLength(1),I$=fE(O$,O$.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),L$=fE(O$,O$.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),z$=fE(O$,O$.SUBGROUP_MUL).setParameterLength(1),k$=fE(O$,O$.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),U$=fE(O$,O$.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),F$=fE(O$,O$.SUBGROUP_AND).setParameterLength(1),j$=fE(O$,O$.SUBGROUP_OR).setParameterLength(1),G$=fE(O$,O$.SUBGROUP_XOR).setParameterLength(1),W$=fE(O$,O$.SUBGROUP_MIN).setParameterLength(1),q$=fE(O$,O$.SUBGROUP_MAX).setParameterLength(1),H$=fE(O$,O$.SUBGROUP_ALL).setParameterLength(0),$$=fE(O$,O$.SUBGROUP_ANY).setParameterLength(0),Y$=fE(O$,O$.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),X$=fE(O$,O$.QUAD_SWAP_X).setParameterLength(1),K$=fE(O$,O$.QUAD_SWAP_Y).setParameterLength(1),Z$=fE(O$,O$.QUAD_SWAP_DIAGONAL).setParameterLength(1),J$=fE(O$,O$.SUBGROUP_BROADCAST).setParameterLength(2),Q$=fE(O$,O$.SUBGROUP_SHUFFLE).setParameterLength(2),eY=fE(O$,O$.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),tY=fE(O$,O$.SUBGROUP_SHUFFLE_UP).setParameterLength(2),iY=fE(O$,O$.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),rY=fE(O$,O$.QUAD_BROADCAST).setParameterLength(1),aY=e=>FI.transformDirection(zP(e).sub(kP(e))),nY=XE("vec3","totalDiffuse"),oY=XE("vec3","totalSpecular"),lY=XE("vec3","outgoingLight"),hY=e=>e.sort((e,t)=>e.id-t.id),uY=(e,t)=>{for(let i of t)if(i.isAnalyticLightNode&&i.light.id===e)return i;return null},dY=new WeakMap,cY=[],pY=class extends SR{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=nY,this.totalSpecularNode=oY,this.outgoingLightNode=lY,this._lights=[],this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let i=e[t];if(cY.push(i.id),cY.push(i.castShadow?1:0),!0===i.isSpotLight){let e=null!==i.map?i.map.id:-1,t=i.colorNode?i.colorNode.getCacheKey():-1;cY.push(e,t)}}let t=hR(cY);return cY.length=0,t}getHash(e){let t=e.getDataFromNode(this);if(void 0===t.lightNodesHash){let i=this.setupLightsNode(e);t.lightNodes=i;let r=[];for(let e of i)r.push(e.getHash());t.lightNodesHash="lights-"+r.join(",")}return t.lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let i of t.nodes)i.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],i=e.getDataFromNode(this).lightNodes||null,r=e.context.materialLightings,s=hY([...r,...this._lights]),a=e.renderer.library;for(let e of s)if(e.isNode)t.push(e);else{let r=null;if(null!==i&&(r=uY(e.id,i)),null===r){let t=a.getLightNodeClass(e.constructor);if(null===t){f(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}!1===dY.has(e)&&dY.set(e,new t(e)),r=dY.get(e)}t.push(r)}return t}setupDirectLight(e,t,i){let{lightingModel:r,reflectedLight:s}=e.context;r.direct({...i,lightNode:t,reflectedLight:s},e)}setupDirectRectAreaLight(e,t,i){let{lightingModel:r,reflectedLight:s}=e.context;r.directRectArea({...i,lightNode:t,reflectedLight:s},e)}setupLights(e,t){for(let i of t)i.build(e)}getLightNodes(e){let t=e.getDataFromNode(this);return void 0===t.lightNodes&&(t.lightNodes=this.setupLightsNode(e)),t.lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let i=this.outgoingLightNode,r=e.context,s=r.lightingModel,a=e.getNodeProperties(this);if(s){let{totalDiffuseNode:t,totalSpecularNode:n}=this;r.outgoingLight=i;let o=e.addStack();a.nodes=o.nodes,s.start(e);let{backdrop:l,backdropAlpha:h}=r,{directDiffuse:u,directSpecular:d,indirectDiffuse:c,indirectSpecular:p}=r.reflectedLight,m=u.add(c);null!==l&&(m=BE(null!==h?h.mix(m,l):l)),t.assign(m),n.assign(d.add(p)),i.assign(t.add(n)),s.finish(e),i=i.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,i}setLights(e){return this._lights=e,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}},mY=(e=[])=>(new pY).setLights(e),gY=class extends SR{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=mR.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){fY.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||yL)}},fY=XE("vec3","shadowPositionWorld"),yY=Object.freeze({__proto__:null,resetRendererAndSceneState:YP,resetRendererState:jP,resetSceneState:qP,restoreRendererAndSceneState:XP,restoreRendererState:GP,restoreSceneState:HP,saveRendererAndSceneState:$P,saveRendererState:FP,saveSceneState:WP}),vY=new WeakMap,bY=JN(({depthTexture:e,shadowCoord:t,depthLayer:i})=>{let r=JD(e,t.xy).setName("t_basic");return e.isArrayTexture&&(r=r.depth(i)),r.compare(t.z)}),xY=JN(({depthTexture:e,shadowCoord:t,shadow:i,depthLayer:r})=>{let s=(t,i)=>{let s=JD(e,t);return e.isArrayTexture&&(s=s.depth(r)),s.compare(i)},a=JL("mapSize","vec2",i).setGroup(OO),n=JL("radius","float",i).setGroup(OO),o=PE(1).div(a),l=n.mul(o.x),h=Uq(fI.xy).mul(6.28318530718);return GO(s(t.xy.add(Fq(0,5,h).mul(l)),t.z),s(t.xy.add(Fq(1,5,h).mul(l)),t.z),s(t.xy.add(Fq(2,5,h).mul(l)),t.z),s(t.xy.add(Fq(3,5,h).mul(l)),t.z),s(t.xy.add(Fq(4,5,h).mul(l)),t.z)).mul(.2)}),wY=JN(({depthTexture:e,shadowCoord:t,shadow:i,depthLayer:r})=>{let s=JL("mapSize","vec2",i).setGroup(OO),a=PE(1).div(s),n=t.xy,o=VB(n.mul(s).add(.5)).toConst();n.subAssign(o.sub(.5).mul(a));let l=i=>{let s=JD(e,n).offset(i).gather();return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)},h=l(RE(-1,1)).toConst(),u=l(RE(1,1)).toConst(),d=l(RE(-1,-1)).toConst(),c=l(RE(1,-1)).toConst();return GO(MV(h.x,u.y,o.x).add(h.y).add(u.x).mul(o.y),MV(h.w,u.z,o.x).add(h.z).add(u.w),MV(d.x,c.y,o.x).add(d.y).add(c.x),MV(d.w,c.z,o.x).add(d.z).add(c.w).mul(o.y.oneMinus())).mul(1/9)}),_Y=JN(({depthTexture:e,shadowCoord:t,depthLayer:i},r)=>{let s=JD(e).sample(t.xy);e.isArrayTexture&&(s=s.depth(i)),s=s.rg;let a=s.x,n=lV(1e-7,s.y.mul(s.y)),o=r.renderer.reversedDepthBuffer?hV(a,t.z):hV(t.z,a),l=TE(1).toVar();return _E(o.notEqual(1),()=>{let e=t.z.sub(a),i=n.div(n.add(e.mul(e)));i=TV(WO(i,.3).div(.65)),l.assign(lV(o,i))}),l}),SY=e=>{let t=vY.get(e);return void 0===t&&(t=new UU,t.colorNode=LE(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=He,t.fog=!1,vY.set(e,t)),t},MY=e=>{let t=vY.get(e);void 0!==t&&(t.dispose(),vY.delete(e))},TY=new EG,CY=[],AY=(e,t,i,r)=>{CY[0]=e,CY[1]=t;let s=TY.get(CY);return(void 0===s||s.shadowType!==i||s.useVelocity!==r)&&(s=(s,a,n,o,l,h,u,d,c)=>{(!0===s.castShadow||s.receiveShadow&&i===je)&&(r&&(HN(s).useVelocity=!0),s.onBeforeShadow(e,s,n,t.camera,o,a.overrideMaterial,h),e.renderObject(s,a,n,o,l,h,u,d,c),s.onAfterShadow(e,s,n,t.camera,o,a.overrideMaterial,h))},s.shadowType=i,s.useVelocity=r,TY.set(CY,s)),CY[0]=null,CY[1]=null,s},NY=JN(({samples:e,radius:t,size:i,shadowPass:r,depthLayer:s})=>{let a=TE(0).toVar("meanVertical"),n=TE(0).toVar("squareMeanVertical"),o=e.lessThanEqual(TE(1)).select(TE(0),TE(2).div(e.sub(1))),l=e.lessThanEqual(TE(1)).select(TE(0),TE(-1));Jk({start:CE(0),end:CE(e),type:"int",condition:"<"},({i:e})=>{let h=l.add(TE(e).mul(o)),u=r.sample(GO(fI.xy,PE(0,h).mul(t)).div(i));r.value.isArrayTexture&&(u=u.depth(s)),u=u.x,a.addAssign(u),n.addAssign(u.mul(u))}),a.divAssign(e),n.divAssign(e);let h=PB(n.sub(a.mul(a)).max(0));return PE(a,h)}),PY=JN(({samples:e,radius:t,size:i,shadowPass:r,depthLayer:s})=>{let a=TE(0).toVar("meanHorizontal"),n=TE(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(TE(1)).select(TE(0),TE(2).div(e.sub(1))),l=e.lessThanEqual(TE(1)).select(TE(0),TE(-1));Jk({start:CE(0),end:CE(e),type:"int",condition:"<"},({i:e})=>{let h=l.add(TE(e).mul(o)),u=r.sample(GO(fI.xy,PE(h,0).mul(t)).div(i));r.value.isArrayTexture&&(u=u.depth(s)),a.addAssign(u.x),n.addAssign(GO(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),n.divAssign(e);let h=PB(n.sub(a.mul(a)).max(0));return PE(a,h)}),RY=[bY,xY,wY,_Y],OY=new Oq,BY=class extends gY{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:i,shadowCoord:r,shadow:s,depthLayer:a}){let n=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),o=t({depthTexture:i,shadowCoord:r,shadow:s,depthLayer:a});return n.select(o,TE(1))}setupShadowCoord(e,t){let i,{shadow:r}=this,{renderer:s}=e,a=r.biasNode||JL("bias","float",r).setGroup(OO),n=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)n=n.xyz.div(n.w),i=n.z;else{let e=n.w;n=n.xy.div(e);let t=JL("near","float",r.camera).setGroup(OO),s=JL("far","float",r.camera).setGroup(OO);i=TU(e.negate(),t,s)}return n=BE(n.x,n.y.oneMinus(),s.reversedDepthBuffer?i.sub(a):i.add(a)),n}getShadowFilterFn(e){return RY[e]}setupRenderTarget(e,t){let i=new Do(e.mapSize.width,e.mapSize.height);i.name="ShadowDepthTexture",i.compareFunction=t.renderer.reversedDepthBuffer?zr:Dr;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name="ShadowMap",r.texture.type=e.mapType,r.depthTexture=i,{shadowMap:r,depthTexture:i}}setupShadow(e){let{renderer:t,camera:i}=e,{light:r,shadow:s}=this,{depthTexture:a,shadowMap:n}=this.setupRenderTarget(s,e),o=t.shadowMap.type,l=t.hasCompatibility(qr.TEXTURE_COMPARE);if(o!==Ue&&o!==Fe||!l?(a.minFilter=jt,a.magFilter=jt):(a.minFilter=qt,a.magFilter=qt),s.camera.coordinateSystem=i.coordinateSystem,s.camera.updateProjectionMatrix(),o===je&&!0!==s.isPointLightShadow){a.compareFunction=null,n.depth>1?(n._vsmShadowMapVertical||(n._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:gi,type:ii,depth:n.depth,depthBuffer:!1}),n._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=n._vsmShadowMapVertical,n._vsmShadowMapHorizontal||(n._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:gi,type:ii,depth:n.depth,depthBuffer:!1}),n._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=n._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:gi,type:ii,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:gi,type:ii,depthBuffer:!1}));let t=JD(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let i=JD(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(i=i.depth(this.depthLayer));let r=JL("blurSamples","float",s).setGroup(OO),o=JL("radius","float",s).setGroup(OO),l=JL("mapSize","vec2",s).setGroup(OO),h=this.vsmMaterialVertical||(this.vsmMaterialVertical=new UU);h.fragmentNode=NY({samples:r,radius:o,size:l,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),h.name="VSMVertical",h=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new UU),h.fragmentNode=PY({samples:r,radius:o,size:l,shadowPass:i,depthLayer:this.depthLayer}).context(e.getSharedContext()),h.name="VSMHorizontal"}let h,u=JL("intensity","float",s).setGroup(OO),d=JL("normalBias","float",s).setGroup(OO),c=IP(r),p=EL.mul(d);h=!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?c.mul(fY.add(p)):DO("mat4").onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(c.value,e.matrixWorld)).mul(gL).add(c.mul(LE(p,0)));let m=this.setupShadowCoord(e,h),g=t.shadowFilterHook,f=g&&g(s,this.light)||s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===f)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");let y,v,b=o===je&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:a,x=this.setupShadowFilter(e,{filterFn:f,shadowTexture:n.texture,depthTexture:b,shadowCoord:m,shadow:s,depthLayer:this.depthLayer});!0===t.shadowMap.transmitted&&(n.texture.isCubeTexture?y=YL(n.texture,m.xyz):(y=JD(n.texture,m),a.isArrayTexture&&(y=y.depth(this.depthLayer)))),v=y?MV(1,x.rgb.mix(y,1),u.mul(y.a)).toVar():MV(1,x,u).toVar(),this.shadowMap=n,this.shadow.map=n;let w=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return y&&v.toInspector(`${w} / Color`,()=>this.shadowMap.texture.isCubeTexture?YL(this.shadowMap.texture,sF()):JD(this.shadowMap.texture)),v.toInspector(`${w} / Depth`,()=>{let e,t,i=JL("near","float",this.shadow.camera),r=JL("far","float",this.shadow.camera);return e=this.shadowMap.texture.isCubeTexture?YL(this.shadowMap.depthTexture,sF()).r:JD(this.shadowMap.depthTexture).r,t=this.shadow.camera.isPerspectiveCamera?MU(e,i,r):wU(e,i,r),t=bU(t,i,r),t.oneMinus()})}setup(e){if(!1!==e.renderer.shadowMap.enabled)return JN(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let i=this._node;return this.setupShadowPosition(e),null===i&&(this._node=i=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(i=e.material.receivedShadowNode(i)),i})()}renderShadow(e){let{shadow:t,shadowMap:i,light:r}=this,{renderer:s,scene:a}=e;t.updateMatrices(r),i.setSize(t.mapSize.width,t.mapSize.height,i.depth);let n=a.name;a.name=`Shadow Map [ ${r.name||"ID: "+r.id} ]`,s.render(a,t.camera),a.name=n}updateShadow(e){let{shadowMap:t,light:i,shadow:r}=this,{renderer:s,scene:a,camera:n}=e,o=s.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;let h=r.camera.layers.mask;!(4294967294&r.camera.layers.mask)&&(r.camera.layers.mask=n.layers.mask);let u=s.getRenderObjectFunction(),d=s.getMRT(),c=!!d&&d.has("velocity");EY=YP(s,a,EY),a.overrideMaterial=SY(i),s.setRenderObjectFunction(AY(s,r,o,c)),s.setClearColor(0,0),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(u),o===je&&!0!==r.isPointLightShadow&&this.vsmPass(s),r.camera.layers.mask=h,XP(s,a,EY)}vsmPass(e){let{shadow:t}=this,i=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,i),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,i),e.setRenderTarget(this.vsmShadowMapVertical),OY.material=this.vsmMaterialVertical,OY.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),OY.material=this.vsmMaterialHorizontal,OY.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,MY(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){let{shadow:t}=this,i=t.needsUpdate||t.autoUpdate;i&&(this._cameraFrameId[e.camera]===e.frameId&&(i=!1),this._cameraFrameId[e.camera]=e.frameId),i&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},VY=(e,t)=>new BY(e,t),DY=new aa,IY=new As,LY=new ns,zY=new ns,kY=[new ns(1,0,0),new ns(-1,0,0),new ns(0,-1,0),new ns(0,1,0),new ns(0,0,1),new ns(0,0,-1)],UY=[new ns(0,-1,0),new ns(0,-1,0),new ns(0,0,-1),new ns(0,0,1),new ns(0,-1,0),new ns(0,-1,0)],FY=[new ns(1,0,0),new ns(-1,0,0),new ns(0,1,0),new ns(0,-1,0),new ns(0,0,1),new ns(0,0,-1)],jY=[new ns(0,-1,0),new ns(0,-1,0),new ns(0,0,1),new ns(0,0,-1),new ns(0,-1,0),new ns(0,-1,0)],GY=JN(({depthTexture:e,bd3D:t,dp:i})=>YL(e,t).compare(i)),WY=JN(({depthTexture:e,bd3D:t,dp:i,shadow:r})=>{let s=JL("radius","float",r).setGroup(OO),a=JL("mapSize","vec2",r).setGroup(OO),n=s.div(a.x),o=$B(t),l=BB(mV(t,o.x.greaterThan(o.z).select(BE(0,1,0),BE(1,0,0)))),h=mV(t,l),u=Uq(fI.xy).mul(6.28318530718),d=Fq(0,5,u),c=Fq(1,5,u),p=Fq(2,5,u),m=Fq(3,5,u),g=Fq(4,5,u);return YL(e,t.add(l.mul(d.x).add(h.mul(d.y)).mul(n))).compare(i).add(YL(e,t.add(l.mul(c.x).add(h.mul(c.y)).mul(n))).compare(i)).add(YL(e,t.add(l.mul(p.x).add(h.mul(p.y)).mul(n))).compare(i)).add(YL(e,t.add(l.mul(m.x).add(h.mul(m.y)).mul(n))).compare(i)).add(YL(e,t.add(l.mul(g.x).add(h.mul(g.y)).mul(n))).compare(i)).mul(.2)}),qY=JN(({filterFn:e,depthTexture:t,shadowCoord:i,shadow:r},s)=>{let a=i.xyz.toConst(),n=a.abs().toConst(),o=n.x.max(n.y).max(n.z),l=DO("float").setGroup(OO).onRenderUpdate(()=>r.camera.near),h=DO("float").setGroup(OO).onRenderUpdate(()=>r.camera.far),u=JL("bias","float",r).setGroup(OO),d=TE(1).toVar();return _E(o.sub(h).lessThanEqual(0).and(o.sub(l).greaterThanEqual(0)),()=>{let i;s.renderer.reversedDepthBuffer?(i=SU(o.negate(),l,h),i.subAssign(u)):s.renderer.logarithmicDepthBuffer?(i=TU(o.negate(),l,h),i.addAssign(u)):(i=_U(o.negate(),l,h),i.addAssign(u));let n=a.normalize();d.assign(e({depthTexture:t,bd3D:n,dp:i,shadow:r}))}),d}),HY=class extends BY{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===ke?GY:WY}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:i,shadowCoord:r,shadow:s}){return qY({filterFn:t,depthTexture:i,shadowCoord:r,shadow:s})}setupRenderTarget(e,t){let i=new Io(e.mapSize.width);i.name="PointShadowDepthTexture",i.compareFunction=t.renderer.reversedDepthBuffer?zr:Dr;let r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name="PointShadowMap",r.depthTexture=i,{shadowMap:r,depthTexture:i}}renderShadow(e){let{shadow:t,shadowMap:i,light:r}=this,{renderer:s,scene:a}=e,n=t.camera,o=t.matrix,l=s.coordinateSystem===Gr,h=l?kY:FY,u=l?UY:jY;i.setSize(t.mapSize.width,t.mapSize.width);let d=s.autoClear,c=s.getClearColor(DY),p=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){s.setRenderTarget(i,e),s.clear();let l=r.distance||n.far;l!==n.far&&(n.far=l,n.updateProjectionMatrix()),LY.setFromMatrixPosition(r.matrixWorld),n.position.copy(LY),zY.copy(n.position),zY.add(h[e]),n.up.copy(u[e]),n.lookAt(zY),n.updateMatrixWorld(),o.makeTranslation(-LY.x,-LY.y,-LY.z),IY.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),t._frustum.setFromProjectionMatrix(IY,n.coordinateSystem,n.reversedDepth);let d=a.name;a.name=`Point Light Shadow [ ${r.name||"ID: "+r.id} ] - Face ${e+1}`,s.render(a,n),a.name=d}s.autoClear=d,s.setClearColor(c,p)}},$Y=(e,t)=>new HY(e,t),YY=class extends nU{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new aa,this.colorNode=e&&e.colorNode||DO(this.color).setGroup(OO),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=mR.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){void 0!==this._spParkedShadowNode&&null!==this._spParkedShadowNode&&(this._spParkedShadowNode.dispose(),this._spParkedShadowNode=null,this._spParkedShadowColorNode=null),null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,null!==this.baseColorNode&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return UP(this.light).sub(e.context.positionView||bL)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return VY(this.light)}setupShadow(e){let{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let i=this.shadowColorNode;if(null===i){let e=this.light.shadow.shadowNode;if(void 0!==this._spParkedShadowNode&&null!==this._spParkedShadowNode&&void 0===e)this.shadowNode=this._spParkedShadowNode,this.shadowColorNode=i=this._spParkedShadowColorNode,this._spParkedShadowNode=null,this._spParkedShadowColorNode=null;else{let t;t=void 0!==e?uE(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=i=this.colorNode.mul(t),this.baseColorNode=this.colorNode}}e.context.getShadow&&(i=e.context.getShadow(this,e)),this.colorNode=i}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this._spParkedShadowNode=this.shadowNode,this._spParkedShadowColorNode=this.shadowColorNode,this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),i=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),i&&e.lightsNode.setupDirectRectAreaLight(e,this,i)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},XY=JN(({lightDistance:e,cutoffDistance:t,decayExponent:i})=>{let r=e.pow(i).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),KY=({color:e,lightVector:t,cutoffDistance:i,decayExponent:r})=>{let s=t.normalize(),a=t.length(),n=XY({lightDistance:a,cutoffDistance:i,decayExponent:r});return{lightDirection:s,lightColor:e.mul(n)}},ZY=class extends YY{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=DO(0).setGroup(OO),this.decayExponentNode=DO(2).setGroup(OO)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return $Y(this.light)}setupDirect(e){return KY({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}},JY=JN(([e=qD()])=>{let t=e.mul(2),i=t.x.floor(),r=t.y.floor();return i.add(r).mod(2).sign()}),QY=JN(([e=qD()],{renderer:t,material:i})=>{let r,s=SV(e.mul(2).sub(1));if(i.alphaToCoverage&&t.currentSamples>0){let e=TE(s.fwidth()).toVar();r=NV(e.oneMinus(),e.add(1),s).oneMinus()}else r=IV(s.greaterThan(1),0,1);return r}),eX=JN(([e,t,i])=>{let r=TE(i).toVar(),s=TE(t).toVar(),a=NE(e).toVar();return IV(a,s,r).uniformFlow()}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),tX=JN(([e,t])=>{let i=NE(t).toVar(),r=TE(e).toVar();return IV(i,r.negate(),r).uniformFlow()}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),iX=JN(([e])=>{let t=TE(e).toVar();return CE(EB(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),rX=JN(([e,t])=>{let i=TE(e).toVar();return t.assign(iX(i)),i.sub(TE(t))}),sX=JN(([e,t,i,r,s,a])=>{let n=TE(a).toVar(),o=TE(s).toVar(),l=TE(r).toVar(),h=TE(i).toVar(),u=TE(t).toVar(),d=TE(e).toVar(),c=TE(WO(1,o)).toVar();return WO(1,n).mul(d.mul(c).add(u.mul(o))).add(n.mul(h.mul(c).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),aX=JN(([e,t,i,r,s,a])=>{let n=TE(a).toVar(),o=TE(s).toVar(),l=BE(r).toVar(),h=BE(i).toVar(),u=BE(t).toVar(),d=BE(e).toVar(),c=TE(WO(1,o)).toVar();return WO(1,n).mul(d.mul(c).add(u.mul(o))).add(n.mul(h.mul(c).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),nX=JW([sX,aX]),oX=JN(([e,t,i,r,s,a,n,o,l,h,u])=>{let d=TE(u).toVar(),c=TE(h).toVar(),p=TE(l).toVar(),m=TE(o).toVar(),g=TE(n).toVar(),f=TE(a).toVar(),y=TE(s).toVar(),v=TE(r).toVar(),b=TE(i).toVar(),x=TE(t).toVar(),w=TE(e).toVar(),_=TE(WO(1,p)).toVar(),S=TE(WO(1,c)).toVar();return TE(WO(1,d)).toVar().mul(S.mul(w.mul(_).add(x.mul(p))).add(c.mul(b.mul(_).add(v.mul(p))))).add(d.mul(S.mul(y.mul(_).add(f.mul(p))).add(c.mul(g.mul(_).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),lX=JN(([e,t,i,r,s,a,n,o,l,h,u])=>{let d=TE(u).toVar(),c=TE(h).toVar(),p=TE(l).toVar(),m=BE(o).toVar(),g=BE(n).toVar(),f=BE(a).toVar(),y=BE(s).toVar(),v=BE(r).toVar(),b=BE(i).toVar(),x=BE(t).toVar(),w=BE(e).toVar(),_=TE(WO(1,p)).toVar(),S=TE(WO(1,c)).toVar();return TE(WO(1,d)).toVar().mul(S.mul(w.mul(_).add(x.mul(p))).add(c.mul(b.mul(_).add(v.mul(p))))).add(d.mul(S.mul(y.mul(_).add(f.mul(p))).add(c.mul(g.mul(_).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),hX=JW([oX,lX]),uX=JN(([e,t,i])=>{let r=TE(i).toVar(),s=TE(t).toVar(),a=AE(e).toVar(),n=AE(a.bitAnd(AE(7))).toVar(),o=TE(eX(n.lessThan(AE(4)),s,r)).toVar(),l=TE(qO(2,eX(n.lessThan(AE(4)),r,s))).toVar();return tX(o,NE(n.bitAnd(AE(1)))).add(tX(l,NE(n.bitAnd(AE(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),dX=JN(([e,t,i,r])=>{let s=TE(r).toVar(),a=TE(i).toVar(),n=TE(t).toVar(),o=AE(e).toVar(),l=AE(o.bitAnd(AE(15))).toVar(),h=TE(eX(l.lessThan(AE(8)),n,a)).toVar(),u=TE(eX(l.lessThan(AE(4)),a,eX(l.equal(AE(12)).or(l.equal(AE(14))),n,s))).toVar();return tX(h,NE(l.bitAnd(AE(1)))).add(tX(u,NE(l.bitAnd(AE(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),cX=JW([uX,dX]),pX=JN(([e,t,i])=>{let r=TE(i).toVar(),s=TE(t).toVar(),a=DE(e).toVar();return BE(cX(a.x,s,r),cX(a.y,s,r),cX(a.z,s,r))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),mX=JN(([e,t,i,r])=>{let s=TE(r).toVar(),a=TE(i).toVar(),n=TE(t).toVar(),o=DE(e).toVar();return BE(cX(o.x,n,a,s),cX(o.y,n,a,s),cX(o.z,n,a,s))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),gX=JW([pX,mX]),fX=JN(([e])=>{let t=TE(e).toVar();return qO(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),yX=JN(([e])=>{let t=TE(e).toVar();return qO(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),vX=JN(([e])=>{let t=BE(e).toVar();return qO(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),bX=JW([fX,vX]),xX=JN(([e])=>{let t=BE(e).toVar();return qO(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),wX=JW([yX,xX]),_X=JN(([e,t])=>{let i=CE(t).toVar(),r=AE(e).toVar();return r.shiftLeft(i).bitOr(r.shiftRight(CE(32).sub(i)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),SX=JN(([e,t,i])=>{e.subAssign(i),e.bitXorAssign(_X(i,CE(4))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(_X(e,CE(6))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(_X(t,CE(8))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(_X(i,CE(16))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(_X(e,CE(19))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(_X(t,CE(4))),t.addAssign(e)}),MX=JN(([e,t,i])=>{let r=AE(i).toVar(),s=AE(t).toVar(),a=AE(e).toVar();return r.bitXorAssign(s),r.subAssign(_X(s,CE(14))),a.bitXorAssign(r),a.subAssign(_X(r,CE(11))),s.bitXorAssign(a),s.subAssign(_X(a,CE(25))),r.bitXorAssign(s),r.subAssign(_X(s,CE(16))),a.bitXorAssign(r),a.subAssign(_X(r,CE(4))),s.bitXorAssign(a),s.subAssign(_X(a,CE(14))),r.bitXorAssign(s),r.subAssign(_X(s,CE(24))),r}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),TX=JN(([e])=>{let t=AE(e).toVar();return TE(t).div(TE(AE(CE(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),CX=JN(([e])=>{let t=TE(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AX=JN(([e])=>{let t=CE(e).toVar(),i=AE(AE(1)).toVar(),r=AE(AE(CE(3735928559)).add(i.shiftLeft(AE(2))).add(AE(13))).toVar();return MX(r.add(AE(t)),r,r)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),NX=JN(([e,t])=>{let i=CE(t).toVar(),r=CE(e).toVar(),s=AE(AE(2)).toVar(),a=AE().toVar(),n=AE().toVar(),o=AE().toVar();return a.assign(n.assign(o.assign(AE(CE(3735928559)).add(s.shiftLeft(AE(2))).add(AE(13))))),a.addAssign(AE(r)),n.addAssign(AE(i)),MX(a,n,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),PX=JN(([e,t,i])=>{let r=CE(i).toVar(),s=CE(t).toVar(),a=CE(e).toVar(),n=AE(AE(3)).toVar(),o=AE().toVar(),l=AE().toVar(),h=AE().toVar();return o.assign(l.assign(h.assign(AE(CE(3735928559)).add(n.shiftLeft(AE(2))).add(AE(13))))),o.addAssign(AE(a)),l.addAssign(AE(s)),h.addAssign(AE(r)),MX(o,l,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),RX=JN(([e,t,i,r])=>{let s=CE(r).toVar(),a=CE(i).toVar(),n=CE(t).toVar(),o=CE(e).toVar(),l=AE(AE(4)).toVar(),h=AE().toVar(),u=AE().toVar(),d=AE().toVar();return h.assign(u.assign(d.assign(AE(CE(3735928559)).add(l.shiftLeft(AE(2))).add(AE(13))))),h.addAssign(AE(o)),u.addAssign(AE(n)),d.addAssign(AE(a)),SX(h,u,d),h.addAssign(AE(s)),MX(h,u,d)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),EX=JN(([e,t,i,r,s])=>{let a=CE(s).toVar(),n=CE(r).toVar(),o=CE(i).toVar(),l=CE(t).toVar(),h=CE(e).toVar(),u=AE(AE(5)).toVar(),d=AE().toVar(),c=AE().toVar(),p=AE().toVar();return d.assign(c.assign(p.assign(AE(CE(3735928559)).add(u.shiftLeft(AE(2))).add(AE(13))))),d.addAssign(AE(h)),c.addAssign(AE(l)),p.addAssign(AE(o)),SX(d,c,p),d.addAssign(AE(n)),c.addAssign(AE(a)),MX(d,c,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),OX=JW([AX,NX,PX,RX,EX]),BX=JN(([e,t])=>{let i=CE(t).toVar(),r=CE(e).toVar(),s=AE(OX(r,i)).toVar(),a=DE().toVar();return a.x.assign(s.bitAnd(CE(255))),a.y.assign(s.shiftRight(CE(8)).bitAnd(CE(255))),a.z.assign(s.shiftRight(CE(16)).bitAnd(CE(255))),a}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),VX=JN(([e,t,i])=>{let r=CE(i).toVar(),s=CE(t).toVar(),a=CE(e).toVar(),n=AE(OX(a,s,r)).toVar(),o=DE().toVar();return o.x.assign(n.bitAnd(CE(255))),o.y.assign(n.shiftRight(CE(8)).bitAnd(CE(255))),o.z.assign(n.shiftRight(CE(16)).bitAnd(CE(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),DX=JW([BX,VX]),IX=JN(([e])=>{let t=PE(e).toVar(),i=CE().toVar(),r=CE().toVar(),s=TE(rX(t.x,i)).toVar(),a=TE(rX(t.y,r)).toVar(),n=TE(CX(s)).toVar(),o=TE(CX(a)).toVar(),l=TE(nX(cX(OX(i,r),s,a),cX(OX(i.add(CE(1)),r),s.sub(1),a),cX(OX(i,r.add(CE(1))),s,a.sub(1)),cX(OX(i.add(CE(1)),r.add(CE(1))),s.sub(1),a.sub(1)),n,o)).toVar();return bX(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),LX=JN(([e])=>{let t=BE(e).toVar(),i=CE().toVar(),r=CE().toVar(),s=CE().toVar(),a=TE(rX(t.x,i)).toVar(),n=TE(rX(t.y,r)).toVar(),o=TE(rX(t.z,s)).toVar(),l=TE(CX(a)).toVar(),h=TE(CX(n)).toVar(),u=TE(CX(o)).toVar(),d=TE(hX(cX(OX(i,r,s),a,n,o),cX(OX(i.add(CE(1)),r,s),a.sub(1),n,o),cX(OX(i,r.add(CE(1)),s),a,n.sub(1),o),cX(OX(i.add(CE(1)),r.add(CE(1)),s),a.sub(1),n.sub(1),o),cX(OX(i,r,s.add(CE(1))),a,n,o.sub(1)),cX(OX(i.add(CE(1)),r,s.add(CE(1))),a.sub(1),n,o.sub(1)),cX(OX(i,r.add(CE(1)),s.add(CE(1))),a,n.sub(1),o.sub(1)),cX(OX(i.add(CE(1)),r.add(CE(1)),s.add(CE(1))),a.sub(1),n.sub(1),o.sub(1)),l,h,u)).toVar();return wX(d)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),zX=JW([IX,LX]),kX=JN(([e])=>{let t=PE(e).toVar(),i=CE().toVar(),r=CE().toVar(),s=TE(rX(t.x,i)).toVar(),a=TE(rX(t.y,r)).toVar(),n=TE(CX(s)).toVar(),o=TE(CX(a)).toVar(),l=BE(nX(gX(DX(i,r),s,a),gX(DX(i.add(CE(1)),r),s.sub(1),a),gX(DX(i,r.add(CE(1))),s,a.sub(1)),gX(DX(i.add(CE(1)),r.add(CE(1))),s.sub(1),a.sub(1)),n,o)).toVar();return bX(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),UX=JN(([e])=>{let t=BE(e).toVar(),i=CE().toVar(),r=CE().toVar(),s=CE().toVar(),a=TE(rX(t.x,i)).toVar(),n=TE(rX(t.y,r)).toVar(),o=TE(rX(t.z,s)).toVar(),l=TE(CX(a)).toVar(),h=TE(CX(n)).toVar(),u=TE(CX(o)).toVar(),d=BE(hX(gX(DX(i,r,s),a,n,o),gX(DX(i.add(CE(1)),r,s),a.sub(1),n,o),gX(DX(i,r.add(CE(1)),s),a,n.sub(1),o),gX(DX(i.add(CE(1)),r.add(CE(1)),s),a.sub(1),n.sub(1),o),gX(DX(i,r,s.add(CE(1))),a,n,o.sub(1)),gX(DX(i.add(CE(1)),r,s.add(CE(1))),a.sub(1),n,o.sub(1)),gX(DX(i,r.add(CE(1)),s.add(CE(1))),a,n.sub(1),o.sub(1)),gX(DX(i.add(CE(1)),r.add(CE(1)),s.add(CE(1))),a.sub(1),n.sub(1),o.sub(1)),l,h,u)).toVar();return wX(d)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),FX=JW([kX,UX]),jX=JN(([e])=>{let t=TE(e).toVar(),i=CE(iX(t)).toVar();return TX(OX(i))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),GX=JN(([e])=>{let t=PE(e).toVar(),i=CE(iX(t.x)).toVar(),r=CE(iX(t.y)).toVar();return TX(OX(i,r))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),WX=JN(([e])=>{let t=BE(e).toVar(),i=CE(iX(t.x)).toVar(),r=CE(iX(t.y)).toVar(),s=CE(iX(t.z)).toVar();return TX(OX(i,r,s))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),qX=JN(([e])=>{let t=LE(e).toVar(),i=CE(iX(t.x)).toVar(),r=CE(iX(t.y)).toVar(),s=CE(iX(t.z)).toVar(),a=CE(iX(t.w)).toVar();return TX(OX(i,r,s,a))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),HX=JW([jX,GX,WX,qX]),$X=JN(([e])=>{let t=TE(e).toVar(),i=CE(iX(t)).toVar();return BE(TX(OX(i,CE(0))),TX(OX(i,CE(1))),TX(OX(i,CE(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),YX=JN(([e])=>{let t=PE(e).toVar(),i=CE(iX(t.x)).toVar(),r=CE(iX(t.y)).toVar();return BE(TX(OX(i,r,CE(0))),TX(OX(i,r,CE(1))),TX(OX(i,r,CE(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),XX=JN(([e])=>{let t=BE(e).toVar(),i=CE(iX(t.x)).toVar(),r=CE(iX(t.y)).toVar(),s=CE(iX(t.z)).toVar();return BE(TX(OX(i,r,s,CE(0))),TX(OX(i,r,s,CE(1))),TX(OX(i,r,s,CE(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),KX=JN(([e])=>{let t=LE(e).toVar(),i=CE(iX(t.x)).toVar(),r=CE(iX(t.y)).toVar(),s=CE(iX(t.z)).toVar(),a=CE(iX(t.w)).toVar();return BE(TX(OX(i,r,s,a,CE(0))),TX(OX(i,r,s,a,CE(1))),TX(OX(i,r,s,a,CE(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),ZX=JW([$X,YX,XX,KX]),JX=JN(([e,t,i,r])=>{let s=TE(r).toVar(),a=TE(i).toVar(),n=CE(t).toVar(),o=BE(e).toVar(),l=TE(0).toVar(),h=TE(1).toVar();return Jk(n,()=>{l.addAssign(h.mul(zX(o))),h.mulAssign(s),o.mulAssign(a)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),QX=JN(([e,t,i,r])=>{let s=TE(r).toVar(),a=TE(i).toVar(),n=CE(t).toVar(),o=BE(e).toVar(),l=BE(0).toVar(),h=TE(1).toVar();return Jk(n,()=>{l.addAssign(h.mul(FX(o))),h.mulAssign(s),o.mulAssign(a)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),eK=JN(([e,t,i,r])=>{let s=TE(r).toVar(),a=TE(i).toVar(),n=CE(t).toVar(),o=BE(e).toVar();return PE(JX(o,n,a,s),JX(o.add(BE(CE(19),CE(193),CE(17))),n,a,s))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),tK=JN(([e,t,i,r])=>{let s=TE(r).toVar(),a=TE(i).toVar(),n=CE(t).toVar(),o=BE(e).toVar(),l=BE(QX(o,n,a,s)).toVar(),h=TE(JX(o.add(BE(CE(19),CE(193),CE(17))),n,a,s)).toVar();return LE(l,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),iK=JN(([e,t,i,r,s,a,n])=>{let o=CE(n).toVar(),l=TE(a).toVar(),h=CE(s).toVar(),u=CE(r).toVar(),d=CE(i).toVar(),c=CE(t).toVar(),p=PE(e).toVar(),m=BE(ZX(PE(c.add(u),d.add(h)))).toVar(),g=PE(m.x,m.y).toVar();g.subAssign(.5),g.mulAssign(l),g.addAssign(.5);let f=PE(PE(TE(c),TE(d)).add(g)).toVar(),y=PE(f.sub(p)).toVar();return _E(o.equal(CE(2)),()=>$B(y.x).add($B(y.y))),_E(o.equal(CE(3)),()=>lV($B(y.x),$B(y.y))),pV(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),rK=JN(([e,t,i,r,s,a,n,o,l])=>{let h=CE(l).toVar(),u=TE(o).toVar(),d=CE(n).toVar(),c=CE(a).toVar(),p=CE(s).toVar(),m=CE(r).toVar(),g=CE(i).toVar(),f=CE(t).toVar(),y=BE(e).toVar(),v=BE(ZX(BE(f.add(p),g.add(c),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let b=BE(BE(TE(f),TE(g),TE(m)).add(v)).toVar(),x=BE(b.sub(y)).toVar();return _E(h.equal(CE(2)),()=>$B(x.x).add($B(x.y)).add($B(x.z))),_E(h.equal(CE(3)),()=>lV($B(x.x),$B(x.y),$B(x.z))),pV(x,x)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),sK=JW([iK,rK]),aK=JN(([e,t,i])=>{let r=CE(i).toVar(),s=TE(t).toVar(),a=PE(e).toVar(),n=CE().toVar(),o=CE().toVar(),l=PE(rX(a.x,n),rX(a.y,o)).toVar(),h=TE(1e6).toVar();return Jk({start:-1,end:CE(1),name:"x",condition:"<="},({x:e})=>{Jk({start:-1,end:CE(1),name:"y",condition:"<="},({y:t})=>{let i=TE(sK(l,e,t,n,o,s,r)).toVar();h.assign(oV(h,i))})}),_E(r.equal(CE(0)),()=>{h.assign(PB(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nK=JN(([e,t,i])=>{let r=CE(i).toVar(),s=TE(t).toVar(),a=PE(e).toVar(),n=CE().toVar(),o=CE().toVar(),l=PE(rX(a.x,n),rX(a.y,o)).toVar(),h=PE(1e6,1e6).toVar();return Jk({start:-1,end:CE(1),name:"x",condition:"<="},({x:e})=>{Jk({start:-1,end:CE(1),name:"y",condition:"<="},({y:t})=>{let i=TE(sK(l,e,t,n,o,s,r)).toVar();_E(i.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(i)}).ElseIf(i.lessThan(h.y),()=>{h.y.assign(i)})})}),_E(r.equal(CE(0)),()=>{h.assign(PB(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),oK=JN(([e,t,i])=>{let r=CE(i).toVar(),s=TE(t).toVar(),a=PE(e).toVar(),n=CE().toVar(),o=CE().toVar(),l=PE(rX(a.x,n),rX(a.y,o)).toVar(),h=BE(1e6,1e6,1e6).toVar();return Jk({start:-1,end:CE(1),name:"x",condition:"<="},({x:e})=>{Jk({start:-1,end:CE(1),name:"y",condition:"<="},({y:t})=>{let i=TE(sK(l,e,t,n,o,s,r)).toVar();_E(i.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(i)}).ElseIf(i.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(i)}).ElseIf(i.lessThan(h.z),()=>{h.z.assign(i)})})}),_E(r.equal(CE(0)),()=>{h.assign(PB(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),lK=JN(([e,t,i])=>{let r=CE(i).toVar(),s=TE(t).toVar(),a=BE(e).toVar(),n=CE().toVar(),o=CE().toVar(),l=CE().toVar(),h=BE(rX(a.x,n),rX(a.y,o),rX(a.z,l)).toVar(),u=TE(1e6).toVar();return Jk({start:-1,end:CE(1),name:"x",condition:"<="},({x:e})=>{Jk({start:-1,end:CE(1),name:"y",condition:"<="},({y:t})=>{Jk({start:-1,end:CE(1),name:"z",condition:"<="},({z:i})=>{let a=TE(sK(h,e,t,i,n,o,l,s,r)).toVar();u.assign(oV(u,a))})})}),_E(r.equal(CE(0)),()=>{u.assign(PB(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),hK=JW([aK,lK]),uK=JN(([e,t,i])=>{let r=CE(i).toVar(),s=TE(t).toVar(),a=BE(e).toVar(),n=CE().toVar(),o=CE().toVar(),l=CE().toVar(),h=BE(rX(a.x,n),rX(a.y,o),rX(a.z,l)).toVar(),u=PE(1e6,1e6).toVar();return Jk({start:-1,end:CE(1),name:"x",condition:"<="},({x:e})=>{Jk({start:-1,end:CE(1),name:"y",condition:"<="},({y:t})=>{Jk({start:-1,end:CE(1),name:"z",condition:"<="},({z:i})=>{let a=TE(sK(h,e,t,i,n,o,l,s,r)).toVar();_E(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),_E(r.equal(CE(0)),()=>{u.assign(PB(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),dK=JW([nK,uK]),cK=JN(([e,t,i])=>{let r=CE(i).toVar(),s=TE(t).toVar(),a=BE(e).toVar(),n=CE().toVar(),o=CE().toVar(),l=CE().toVar(),h=BE(rX(a.x,n),rX(a.y,o),rX(a.z,l)).toVar(),u=BE(1e6,1e6,1e6).toVar();return Jk({start:-1,end:CE(1),name:"x",condition:"<="},({x:e})=>{Jk({start:-1,end:CE(1),name:"y",condition:"<="},({y:t})=>{Jk({start:-1,end:CE(1),name:"z",condition:"<="},({z:i})=>{let a=TE(sK(h,e,t,i,n,o,l,s,r)).toVar();_E(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),_E(r.equal(CE(0)),()=>{u.assign(PB(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),pK=JW([oK,cK]),mK=JN(([e,t,i,r,s,a,n,o,l,h,u])=>{let d=CE(e).toVar(),c=PE(t).toVar(),p=PE(i).toVar(),m=PE(r).toVar(),g=TE(s).toVar(),f=TE(a).toVar(),y=TE(n).toVar(),v=NE(o).toVar(),b=CE(l).toVar(),x=TE(h).toVar(),w=TE(u).toVar(),_=c.mul(p).add(m),S=TE(0).toVar();return _E(d.equal(CE(0)),()=>{S.assign(FX(_))}),_E(d.equal(CE(1)),()=>{S.assign(ZX(_))}),_E(d.equal(CE(2)),()=>{S.assign(pK(_,g,CE(0)))}),_E(d.equal(CE(3)),()=>{S.assign(QX(BE(_,0),b,x,w))}),S.assign(S.mul(y.sub(f)).add(f)),_E(v,()=>{S.assign(TV(S,f,y))}),S}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gK=JN(([e,t,i,r,s,a,n,o,l,h,u])=>{let d=CE(e).toVar(),c=BE(t).toVar(),p=BE(i).toVar(),m=BE(r).toVar(),g=TE(s).toVar(),f=TE(a).toVar(),y=TE(n).toVar(),v=NE(o).toVar(),b=CE(l).toVar(),x=TE(h).toVar(),w=TE(u).toVar(),_=c.mul(p).add(m),S=TE(0).toVar();return _E(d.equal(CE(0)),()=>{S.assign(FX(_))}),_E(d.equal(CE(1)),()=>{S.assign(ZX(_))}),_E(d.equal(CE(2)),()=>{S.assign(pK(_,g,CE(0)))}),_E(d.equal(CE(3)),()=>{S.assign(QX(_,b,x,w))}),S.assign(S.mul(y.sub(f)).add(f)),_E(v,()=>{S.assign(TV(S,f,y))}),S}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),fK=JN(([e])=>{let t=e.y,i=e.z,r=BE().toVar();return _E(t.lessThan(1e-4),()=>{r.assign(BE(i,i,i))}).Else(()=>{let s=e.x;s=s.sub(EB(s)).mul(6).toVar();let a=CE(iV(s)),n=s.sub(TE(a)),o=i.mul(t.oneMinus()),l=i.mul(t.mul(n).oneMinus()),h=i.mul(t.mul(n.oneMinus()).oneMinus());_E(a.equal(CE(0)),()=>{r.assign(BE(i,h,o))}).ElseIf(a.equal(CE(1)),()=>{r.assign(BE(l,i,o))}).ElseIf(a.equal(CE(2)),()=>{r.assign(BE(o,i,h))}).ElseIf(a.equal(CE(3)),()=>{r.assign(BE(o,l,i))}).ElseIf(a.equal(CE(4)),()=>{r.assign(BE(h,o,i))}).Else(()=>{r.assign(BE(i,o,l))})}),r}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),yK=JN(([e])=>{let t=BE(e).toVar(),i=TE(t.x).toVar(),r=TE(t.y).toVar(),s=TE(t.z).toVar(),a=TE(oV(i,oV(r,s))).toVar(),n=TE(lV(i,lV(r,s))).toVar(),o=TE(n.sub(a)).toVar(),l=TE().toVar(),h=TE().toVar(),u=TE().toVar();return u.assign(n),_E(n.greaterThan(0),()=>{h.assign(o.div(n))}).Else(()=>{h.assign(0)}),_E(h.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{_E(i.greaterThanEqual(n),()=>{l.assign(r.sub(s).div(o))}).ElseIf(r.greaterThanEqual(n),()=>{l.assign(GO(2,s.sub(i).div(o)))}).Else(()=>{l.assign(GO(4,i.sub(r).div(o)))}),l.mulAssign(1/6),_E(l.lessThan(0),()=>{l.addAssign(1)})}),BE(l,h,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),vK=JN(([e])=>{let t=BE(e).toVar(),i=IE(ZO(t,BE(.04045))).toVar(),r=BE(t.div(12.92)).toVar(),s=BE(gV(lV(t.add(BE(.055)),BE(0)).div(1.055),BE(2.4))).toVar();return MV(r,s,i)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),bK=(e,t)=>{e=TE(e),t=TE(t);let i=PE(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return NV(e.sub(i),e.add(i),t)},xK=(e,t,i,r)=>MV(e,t,i[r].clamp()),wK=(e,t,i=qD())=>xK(e,t,i,"x"),_K=(e,t,i=qD())=>xK(e,t,i,"y"),SK=(e,t,i,r,s=qD())=>{let a=s.x.clamp(),n=s.y.clamp(),o=MV(e,t,a),l=MV(i,r,a);return MV(o,l,n)},MK=(e,t,i,r,s)=>MV(e,t,bK(i,r[s])),TK=(e,t,i,r=qD())=>MK(e,t,i,r,"x"),CK=(e,t,i,r=qD())=>MK(e,t,i,r,"y"),AK=(e=1,t=0,i=qD())=>i.mul(e).add(t),NK=(e,t=1)=>(e=TE(e)).abs().pow(t).mul(e.sign()),PK=(e,t=1,i=.5)=>TE(e).sub(i).mul(t).add(i),RK=(e=qD(),t=1,i=0)=>zX(e.convert("vec2|vec3")).mul(t).add(i),EK=(e=qD(),t=1,i=0)=>FX(e.convert("vec2|vec3")).mul(t).add(i),OK=(e=qD(),t=1,i=0)=>(e=e.convert("vec2|vec3"),LE(FX(e),zX(e.add(PE(19,73)))).mul(t).add(i)),BK=(e,t=qD(),i=PE(1,1),r=PE(0,0),s=1,a=0,n=1,o=!1,l=1,h=2,u=.5)=>mK(e,t.convert("vec2|vec3"),i,r,s,a,n,o,l,h,u),VK=(e,t=qD(),i=PE(1,1),r=PE(0,0),s=1,a=0,n=1,o=!1,l=1,h=2,u=.5)=>gK(e,t.convert("vec2|vec3"),i,r,s,a,n,o,l,h,u),DK=(e=qD(),t=1)=>hK(e.convert("vec2|vec3"),t,CE(1)),IK=(e=qD(),t=1)=>dK(e.convert("vec2|vec3"),t,CE(1)),LK=(e=qD(),t=1)=>pK(e.convert("vec2|vec3"),t,CE(1)),zK=(e=qD())=>HX(e.convert("vec2|vec3")),kK=(e=qD(),t=3,i=2,r=.5,s=1)=>JX(e,CE(t),i,r).mul(s),UK=(e=qD(),t=3,i=2,r=.5,s=1)=>eK(e,CE(t),i,r).mul(s),FK=(e=qD(),t=3,i=2,r=.5,s=1)=>QX(e,CE(t),i,r).mul(s),jK=(e=qD(),t=3,i=2,r=.5,s=1)=>tK(e,CE(t),i,r).mul(s),GK=(e,t=TE(0))=>GO(e,t),WK=(e,t=TE(0))=>WO(e,t),qK=(e,t=TE(1))=>qO(e,t),HK=(e,t=TE(1))=>HO(e,t),$K=(e,t=TE(1))=>$O(e,t),YK=(e,t=TE(1))=>gV(e,t),XK=(e=TE(0),t=TE(1))=>qB(e,t),KK=()=>QW,ZK=()=>tq,JK=(e,t=TE(1))=>WO(t,e),QK=(e,t,i,r)=>e.greaterThan(t).mix(i,r),eZ=(e,t,i,r)=>e.greaterThanEqual(t).mix(i,r),tZ=(e,t,i,r)=>e.equal(t).mix(i,r),iZ=(e,t=null)=>{if("string"==typeof t){let i={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},r=t.replace(/^out/,"").toLowerCase();if(void 0!==i[r])return e.element(i[r])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){let i={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==i[t])return e.element(i[t])}return e},rZ=(e,t=PE(.5,.5),i=PE(1,1),r=TE(0),s=PE(0,0))=>{let a=e;if(t&&(a=a.sub(t)),i&&(a=a.mul(i)),r){let e=r.mul(Math.PI/180),t=e.cos(),i=e.sin();a=PE(a.x.mul(t).sub(a.y.mul(i)),a.x.mul(i).add(a.y.mul(t)))}return t&&(a=a.add(t)),s&&(a=a.add(s)),a},sZ=(e,t)=>{e=PE(e);let i=(t=TE(t)).mul(Math.PI/180);return xG(e,i)},aZ=(e,t,i)=>{e=BE(e),t=TE(t),i=BE(i);let r=t.mul(Math.PI/180),s=i.normalize(),a=r.cos(),n=r.sin(),o=TE(1).sub(a);return e.mul(a).add(s.cross(e).mul(n)).add(s.mul(s.dot(e)).mul(o))},nZ=(e,t)=>(e=BE(e),t=TE(t),Lz(e,t)),oZ=JN(([e,t,i])=>{let r=BB(e).toVar(),s=WO(TE(.5).mul(t.sub(i)),yL).div(r).toVar(),a=WO(TE(-.5).mul(t.sub(i)),yL).div(r).toVar(),n=BE().toVar();n.x=r.x.greaterThan(TE(0)).select(s.x,a.x),n.y=r.y.greaterThan(TE(0)).select(s.y,a.y),n.z=r.z.greaterThan(TE(0)).select(s.z,a.z);let o=oV(n.x,n.y,n.z).toVar();return yL.add(r.mul(o)).toVar().sub(i)}),lZ=JN(([e,t])=>{let i=e.x,r=e.y,s=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(1.023328).mul(r)),a=a.add(t.element(2).mul(1.023328).mul(s)),a=a.add(t.element(3).mul(1.023328).mul(i)),a=a.add(t.element(4).mul(.858086).mul(i).mul(r)),a=a.add(t.element(5).mul(.858086).mul(r).mul(s)),a=a.add(t.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(.858086).mul(i).mul(s)),a=a.add(t.element(8).mul(.429043).mul(qO(i,i).sub(qO(r,r)))),a}),hZ=Object.freeze({__proto__:null,BRDF_GGX:EF,BRDF_Lambert:gF,BasicPointShadowFilter:GY,BasicShadowFilter:bY,Break:eU,Const:WV,Continue:Qk,DFGLUT:VF,D_GGX:NF,Discard:BD,EPSILON:gB,F_Schlick:mF,Fn:JN,HALF_PI:xB,INFINITY:fB,If:_E,Loop:Jk,NodeAccess:fR,NodeShaderStage:pR,NodeType:gR,NodeUpdateType:mR,OnBeforeFrameUpdate:Ok,OnBeforeMaterialUpdate:Ek,OnBeforeObjectUpdate:Rk,OnFrameUpdate:Pk,OnMaterialUpdate:Nk,OnObjectUpdate:Ak,PCFShadowFilter:xY,PCFSoftShadowFilter:wY,PI:yB,PI2:vB,PointShadowFilter:WY,Return:VD,Schlick_to_F0:LF,ShaderNode:ZN,Stack:QN,Switch:SE,TBNViewMatrix:Tz,TWO_PI:bB,VSMShadowFilter:_Y,V_GGX_SmithCorrelated:CF,Var:GV,VarIntent:qV,abs:$B,acesFilmicToneMapping:zH,acos:GB,acosh:WB,add:GO,addMethodChaining:$N,addNodeElement:lP,agxToneMapping:jH,all:wB,alphaT:hO,ambientOcclusion:AO,and:eB,anisotropy:uO,anisotropyB:cO,anisotropyT:dO,any:_B,append:$E,array:LO,asin:FB,asinh:jB,assign:zO,atan:qB,atanh:HB,atomicAdd:T$,atomicAnd:P$,atomicFunc:_$,atomicLoad:S$,atomicMax:A$,atomicMin:N$,atomicOr:R$,atomicStore:M$,atomicSub:C$,atomicXor:E$,attenuationColor:TO,attenuationDistance:MO,attribute:WD,attributeArray:Hq,backgroundBlurriness:Kq,backgroundIntensity:Zq,backgroundRotation:Jq,batch:Hk,batchColor:qk,bentNormalView:Nz,billboarding:lq,bitAnd:sB,bitNot:aB,bitOr:nB,bitXor:oB,bitangentGeometry:wz,bitangentLocal:_z,bitangentView:Sz,bitangentWorld:Mz,bitcast:TW,blendBurn:dH,blendColor:gH,blendDodge:cH,blendOverlay:mH,blendScreen:pH,blur:zj,bool:NE,buffer:aI,bufferAttribute:pD,builtin:hI,builtinAOContext:tP,builtinShadowContext:eP,bumpMap:Lz,bvec2:OE,bvec3:IE,bvec4:UE,bypass:PD,cache:aP,call:UO,cameraFar:zI,cameraIndex:II,cameraNear:LI,cameraNormalMatrix:GI,cameraPosition:WI,cameraProjectionMatrix:kI,cameraProjectionMatrixInverse:UI,cameraViewMatrix:FI,cameraViewport:qI,cameraWorldMatrix:jI,cbrt:_V,cdl:wH,ceil:OB,checker:JY,cineonToneMapping:IH,clamp:TV,clearcoat:iO,clearcoatNormalView:OL,clearcoatRoughness:rO,clipSpace:pL,code:qH,color:ME,colorSpaceToWorking:tD,colorToDirection:Bz,compute:CD,computeKernel:TD,computeSkinning:Kk,context:zV,convert:qE,convertColorSpace:iD,convertToTexture:Iq,cos:LB,cosh:zB,countLeadingZeros:BW,countOneBits:VW,countTrailingZeros:OW,cross:mV,cubeTexture:YL,cubeTextureBase:$L,dFdx:JB,dFdy:QB,dashSize:vO,debug:UD,decrement:pB,decrementBefore:dB,defaultBuildStages:vR,defaultShaderStages:yR,defined:KN,degrees:MB,deltaTime:eq,densityFogFactor:e$,depth:NU,depthPass:EH,determinant:aV,difference:cV,diffuseColor:ZE,diffuseContribution:JE,directPointLight:KY,directionToColor:Oz,directionToFaceDirection:ML,dispersion:CO,disposeShadowMaterial:MY,distance:dV,div:HO,dot:pV,drawIndex:SD,dynamicBufferAttribute:mD,element:WE,emissive:QE,equal:YO,equirectDirection:sF,equirectUV:rF,exp:TB,exp2:CB,exponentialHeightFogFactor:t$,expression:OD,faceDirection:_L,faceForward:PV,faceforward:VV,float:TE,floatBitsToInt:CW,floatBitsToUint:AW,floor:EB,fog:i$,fract:VB,frameGroup:EO,frameId:tq,frontFacing:wL,fwidth:rV,gain:LW,gapSize:bO,getConstNodeType:hE,getCurrentStack:wE,getDirection:Vj,getDistanceAttenuation:XY,getGeometryRoughness:MF,getNormalFromDepth:kq,getParallaxCorrectNormal:oZ,getRoughness:TF,getScreenPosition:zq,getShIrradianceAt:lZ,getShadowMaterial:SY,getShadowRenderObjectFunction:AY,getTextureIndex:RP,getViewPosition:Lq,ggxConvolution:jj,globalId:u$,glsl:YH,glslFn:ZH,grayscale:fH,greaterThan:ZO,greaterThanEqual:QO,hash:DW,highpModelNormalViewMatrix:cL,highpModelViewMatrix:dL,hue:bH,increment:cB,incrementBefore:uB,inspector:oP,instance:Fk,instanceColor:Uk,instanceIndex:bD,instancedArray:$q,instancedBufferAttribute:gD,instancedDynamicBufferAttribute:fD,instancedMesh:jk,int:CE,intBitsToFloat:NW,interleavedGradientNoise:Uq,inverse:nV,inverseSqrt:RB,inversesqrt:DV,invocationLocalIndex:_D,invocationSubgroupIndex:wD,ior:wO,iridescence:nO,iridescenceIOR:oO,iridescenceThickness:lO,isolate:ND,ivec2:RE,ivec3:VE,ivec4:zE,js:HH,label:iP,length:XB,lengthSq:SV,lessThan:KO,lessThanEqual:JO,lightPosition:zP,lightProjectionUV:LP,lightShadowMatrix:IP,lightTargetDirection:aY,lightTargetPosition:kP,lightViewPosition:UP,lightingContext:lU,lights:mY,linearDepth:PU,linearToneMapping:VH,localId:d$,log:AB,log2:NB,logarithmicDepthToViewZ:CU,luminance:xH,mat2:FE,mat3:jE,mat4:GE,matcapUV:yG,materialAO:_k,materialAlphaTest:Uz,materialAnisotropy:ak,materialAnisotropyVector:Sk,materialAttenuationColor:pk,materialAttenuationDistance:ck,materialClearcoat:Qz,materialClearcoatNormal:tk,materialClearcoatRoughness:ek,materialColor:Fz,materialDispersion:xk,materialEmissive:Gz,materialEnvIntensity:UL,materialEnvRotation:FL,materialIOR:dk,materialIridescence:nk,materialIridescenceIOR:ok,materialIridescenceThickness:lk,materialLightMap:wk,materialLineDashOffset:vk,materialLineDashSize:gk,materialLineGapSize:fk,materialLineScale:mk,materialLineWidth:yk,materialMetalness:Zz,materialNormal:Jz,materialOpacity:Wz,materialPointSize:bk,materialReference:tz,materialReflectivity:Xz,materialRefractionRatio:kL,materialRotation:ik,materialRoughness:Kz,materialSheen:rk,materialSheenRoughness:sk,materialShininess:jz,materialSpecular:qz,materialSpecularColor:$z,materialSpecularIntensity:Hz,materialSpecularStrength:Yz,materialThickness:uk,materialTransmission:hk,max:lV,maxMipLevel:$D,mediumpModelViewMatrix:uL,metalness:tO,min:oV,mix:MV,mixElement:EV,mod:$O,modelDirection:tL,modelNormalMatrix:oL,modelPosition:rL,modelRadius:nL,modelScale:sL,modelViewMatrix:hL,modelViewPosition:aL,modelViewProjection:Mk,modelWorldMatrix:iL,modelWorldMatrixInverse:lL,morphReference:aU,mrt:SW,mul:qO,mx_aastep:bK,mx_add:GK,mx_atan2:XK,mx_cell_noise_float:zK,mx_contrast:PK,mx_divide:HK,mx_fractal_noise_float:kK,mx_fractal_noise_vec2:UK,mx_fractal_noise_vec3:FK,mx_fractal_noise_vec4:jK,mx_frame:ZK,mx_heighttonormal:nZ,mx_hsvtorgb:fK,mx_ifequal:tZ,mx_ifgreater:QK,mx_ifgreatereq:eZ,mx_invert:JK,mx_modulo:$K,mx_multiply:qK,mx_noise_float:RK,mx_noise_vec3:EK,mx_noise_vec4:OK,mx_place2d:rZ,mx_power:YK,mx_ramp4:SK,mx_ramplr:wK,mx_ramptb:_K,mx_rgbtohsv:yK,mx_rotate2d:sZ,mx_rotate3d:aZ,mx_safepower:NK,mx_separate:iZ,mx_splitlr:TK,mx_splittb:CK,mx_srgb_texture_to_lin_rec709:vK,mx_subtract:WK,mx_timer:KK,mx_transform_uv:AK,mx_unifiednoise2d:BK,mx_unifiednoise3d:VK,mx_worley_noise_float:DK,mx_worley_noise_vec2:IK,mx_worley_noise_vec3:LK,negate:KB,negateOnBackSide:SL,neutralToneMapping:GH,nodeArray:pE,nodeImmutable:gE,nodeObject:uE,nodeObjectIntent:dE,nodeObjects:cE,nodeProxy:mE,nodeProxyConstructor:yE,nodeProxyIntent:fE,normalFlat:AL,normalGeometry:TL,normalLocal:CL,normalMap:Vz,normalView:RL,normalViewGeometry:NL,normalWorld:EL,normalWorldGeometry:PL,normalize:BB,not:iB,notEqual:XO,numWorkgroups:l$,objectDirection:YI,objectGroup:BO,objectPosition:KI,objectRadius:QI,objectScale:ZI,objectViewPosition:JI,objectWorldMatrix:XI,oneMinus:ZB,or:tB,orthographicDepthToViewZ:wU,oscSawtooth:aq,oscSine:iq,oscSquare:rq,oscTriangle:sq,output:yO,outputStruct:vW,overloadingFn:JW,overrideNode:NP,overrideNodes:PP,packHalf2x16:GW,packNormalToRGB:Pz,packSnorm2x16:FW,packUnorm2x16:jW,parabola:IW,parallaxDirection:Cz,parallaxUV:Az,parameter:cW,pass:PH,passTexture:RH,pcurve:zW,perspectiveDepthToViewZ:MU,pmremTexture:sG,pointShadow:$Y,pointUV:Yq,pointWidth:xO,positionGeometry:mL,positionLocal:gL,positionPrevious:fL,positionView:bL,positionViewDirection:xL,positionWorld:yL,positionWorldDirection:vL,posterize:_H,pow:gV,pow2:fV,pow3:yV,pow4:vV,premultiplyAlpha:DD,property:XE,quadBroadcast:rY,quadSwapDiagonal:Z$,quadSwapX:X$,quadSwapY:K$,radians:SB,rand:RV,range:a$,rangeFogFactor:QH,reciprocal:tV,reference:JL,referenceBuffer:QL,reflect:uV,reflectVector:WL,reflectView:jL,reflector:Pq,refract:AV,refractVector:qL,refractView:GL,reinhardToneMapping:DH,remap:RD,remapClamp:nP,renderGroup:OO,renderOutput:zD,rendererReference:oD,replaceDefaultUV:EP,rotate:xG,rotateUV:nq,roughness:eO,round:eV,rtt:Dq,sRGBTransferEOTF:KV,sRGBTransferOETF:ZV,sample:Gq,sampler:iI,samplerComparison:rI,saturate:CV,saturation:yH,screenCoordinate:fI,screenDPR:pI,screenSize:gI,screenUV:mI,select:IV,setCurrentStack:xE,setName:UV,shaderStages:bR,shadow:VY,shadowPositionWorld:fY,shapeCircle:QY,sharedUniformGroup:RO,sheen:sO,sheenRoughness:aO,shiftLeft:lB,shiftRight:hB,shininess:fO,sign:YB,sin:DB,sinc:kW,sinh:IB,skinning:Xk,smoothstep:NV,smoothstepElement:OV,specularColor:pO,specularColorBlended:mO,specularF90:gO,spherizeUV:oq,split:HE,spritesheetUV:uq,sqrt:PB,stack:pW,step:hV,stepElement:BV,storage:Ik,storageBarrier:g$,storageTexture:eH,storageTexture3D:iH,struct:fW,sub:WO,subBuild:$V,subgroupAdd:D$,subgroupAll:H$,subgroupAnd:F$,subgroupAny:$$,subgroupBallot:V$,subgroupBroadcast:J$,subgroupBroadcastFirst:Y$,subgroupElect:B$,subgroupExclusiveAdd:L$,subgroupExclusiveMul:U$,subgroupInclusiveAdd:I$,subgroupInclusiveMul:k$,subgroupIndex:xD,subgroupMax:q$,subgroupMin:W$,subgroupMul:z$,subgroupOr:j$,subgroupShuffle:Q$,subgroupShuffleDown:iY,subgroupShuffleUp:tY,subgroupShuffleXor:eY,subgroupSize:c$,subgroupXor:G$,tan:kB,tangentGeometry:fz,tangentLocal:yz,tangentView:vz,tangentWorld:bz,tanh:UB,texture:JD,texture3D:sH,texture3DLevel:nH,texture3DLoad:aH,textureBarrier:f$,textureBicubic:ij,textureBicubicLevel:tj,textureCubeUV:Dj,textureLevel:tI,textureLoad:eI,textureSize:HD,textureStore:tH,thickness:SO,time:QW,toneMapping:hD,toneMappingExposure:uD,toonOutlinePass:BH,transformDirection:bV,transformNormal:BL,transformNormalByInverseViewMatrix:wV,transformNormalByViewMatrix:xV,transformNormalToView:VL,transformedClearcoatNormalView:LL,transformedNormalView:DL,transformedNormalWorld:IL,transmission:_O,transpose:sV,triNoise3D:KW,triplanarTexture:cq,triplanarTextures:dq,trunc:iV,uint:AE,uintBitsToFloat:PW,uniform:DO,uniformArray:lI,uniformCubeTexture:XL,uniformFlow:kV,uniformGroup:PO,uniformTexture:QD,unpackHalf2x16:$W,unpackNormal:Ez,unpackRGBToNormal:Rz,unpackSnorm2x16:qW,unpackUnorm2x16:HW,unpremultiplyAlpha:ID,userData:lH,uv:qD,uvec2:EE,uvec3:DE,uvec4:kE,varying:YV,varyingProperty:KE,vec2:PE,vec3:BE,vec4:LE,vectorComponents:xR,velocity:uH,vertexColor:kU,vertexIndex:vD,vertexStage:XV,vibrance:vH,viewZToLogarithmicDepth:TU,viewZToOrthographicDepth:bU,viewZToPerspectiveDepth:_U,viewZToReversedOrthographicDepth:xU,viewZToReversedPerspectiveDepth:SU,viewport:yI,viewportCoordinate:bI,viewportDepthTexture:yU,viewportLinearDepth:RU,viewportMipTexture:pU,viewportOpaqueMipTexture:gU,viewportResolution:wI,viewportSafeUV:hq,viewportSharedTexture:MH,viewportSize:vI,viewportTexture:cU,viewportUV:xI,vogelDiskSample:Fq,wgsl:$H,wgslFn:JH,workgroupArray:b$,workgroupBarrier:m$,workgroupId:h$,workingToColorSpace:eD,xor:rB}),uZ=new hW,dZ=class extends UG{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,i){let r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(null===s)r._clearColor.getRGB(uZ),uZ.a=r._clearColor.a;else if(!0===s.isColor)s.getRGB(uZ),uZ.a=1,a=!0;else if(!0===s.isNode){let i=this.get(e),a=s;uZ.copy(r._clearColor);let n=i.backgroundMesh;if(void 0===n){let e=function(){s.removeEventListener("dispose",e),n.material.dispose(),n.geometry.dispose()},t=LE(a).mul(Zq).context({getUV:()=>Jq.mul(PL),getTextureLevel:()=>Kq}),r=kI.element(3).element(3).equal(1),o=HO(1,kI.element(1).element(1)).mul(3),l=r.select(gL.mul(o),gL),h=hL.mul(LE(l,0)),u=kI.mul(LE(h.xyz,1));u=u.setZ(u.w);let d=new UU;d.name="Background.material",d.side=We,d.depthTest=!1,d.depthWrite=!1,d.allowOverride=!1,d.fog=!1,d.lights=!1,d.vertexNode=u,d.colorNode=t,i.backgroundMeshNode=t,i.backgroundMesh=n=new Hn(new pl(1,32,32),d),n.frustumCulled=!1,n.name="Background.mesh",s.addEventListener("dispose",e)}let o=a.getCacheKey();i.backgroundCacheKey!==o&&(i.backgroundMeshNode.node=LE(a).mul(Zq),i.backgroundMeshNode.needsUpdate=!0,n.material.needsUpdate=!0,i.backgroundCacheKey=o),t.unshift(n,n.geometry,n.material,0,0,null,null)}else y("Renderer: Unsupported background configuration.",s);let n=r.xr.getEnvironmentBlendMode();if("additive"===n?uZ.set(0,0,0,1):"alpha-blend"===n&&uZ.set(0,0,0,0),!0===r.autoClear||!0===a){let e=i.clearColorValue;e.r=uZ.r,e.g=uZ.g,e.b=uZ.b,e.a=uZ.a,(!0===r.backend.isWebGLBackend||!0===r.alpha)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),i.depthClearValue=r.getClearDepth(),i.stencilClearValue=r.getClearStencil(),i.clearColor=!0===r.autoClearColor,i.clearDepth=!0===r.autoClearDepth,i.clearStencil=!0===r.autoClearStencil}else i.clearColor=!1,i.clearDepth=!1,i.clearStencil=!1}},cZ=0,pZ=class{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=cZ++}},mZ=class{constructor(e,t,i,r,s,a,n,o,l,h,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=i,this.transforms=u,this.nodeAttributes=r,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=n,this.updateAfterNodes=o,this.observer=l,this.hardwareClipping=h,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(!0!==t.bindings[0].groupNode.shared){let i=new pZ(t.name,[]);e.push(i);for(let e of t.bindings)i.bindings.push(e.clone())}else e.push(t);return e}},gZ=class{constructor(e,t,i=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=i}},fZ=class{constructor(e,t,i){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=i}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},yZ=class{constructor(e,t,i=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=i,this.count=r}},vZ=class extends yZ{constructor(e,t,i=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=i,this.interpolationSampling=r}},bZ=class{constructor(e,t,i=""){this.name=e,this.type=t,this.code=i,Object.defineProperty(this,"isNodeCode",{value:!0})}},xZ=0,wZ=class{constructor(e=null){this.id=xZ++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},_Z=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},SZ=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}},MZ=class extends SZ{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},TZ=class extends SZ{constructor(e,t=new rs){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},CZ=class extends SZ{constructor(e,t=new ns){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},AZ=class extends SZ{constructor(e,t=new Ss){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},NZ=class extends SZ{constructor(e,t=new aa){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},PZ=class extends SZ{constructor(e,t=new Gh){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},RZ=class extends SZ{constructor(e,t=new us){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},EZ=class extends SZ{constructor(e,t=new As){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},OZ=class extends MZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},BZ=class extends TZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},VZ=class extends CZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},DZ=class extends AZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},IZ=class extends NZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},LZ=class extends PZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},zZ=class extends RZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},kZ=class extends EZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},UZ=0,FZ=new WeakMap,jZ=new WeakMap,GZ=new WeakMap,WZ=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),qZ=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0"),HZ=e=>{if(e.writeUsageCount>0)return!0;if(void 0!==e.subBuildsCache)for(let t in e.subBuildsCache)if(HZ(e.subBuildsCache[t]))return!0;return!1},$Z=class{constructor(e,t,i){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=i,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=pW(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new wZ,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:UZ++})}isFlatShading(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}isOpaque(){let e=this.material;return!1===e.transparent&&e.blending===$e&&!1===e.alphaToCoverage}createRenderTarget(e,t,i){return new Ms(e,t,i)}createCubeRenderTarget(e,t){return new aF(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t="vec4",i=this.renderer.getRenderTarget();if(null!==i){let r=i.textures[e].type,s=i.textures[e].format,a="vec";r===Qt?a="ivec":r===ei&&(a="uvec"),t=s===pi||s===mi?r===Qt?"int":r===ei?"uint":"float":s===gi||s===fi?`${a}2`:s===hi||s===yi?`${a}3`:`${a}4`}return t}getOutputStructName(){}_getBindGroup(e,t){let i,r=t[0].groupNode,s=r.shared;if(s)for(let e=1;e<t.length;e++)r!==t[e].groupNode&&(s=!1);if(s){let r="";for(let e of t)if(e.isNodeUniformsGroup){e.uniforms.sort((e,t)=>e.nodeUniform.node.id-t.nodeUniform.node.id);for(let t of e.uniforms)r+=t.nodeUniform.node.id}else r+=e.nodeUniform.id;let s=this.renderer._currentRenderContext||this.renderer,a=FZ.get(s);void 0===a&&(a=new Map,FZ.set(s,a));let n=lR(r);i=a.get(n),void 0===i&&(i=new pZ(e,t),a.set(n,i))}else i=new pZ(e,t);return i}getBindGroupArray(e,t){let i=this.bindings[t],r=i[e];return void 0===r&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),i[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(null===e){let t={},i=this.bindings;for(let e of bR)for(let r in i[e]){let s=i[e][r],a=t[r]||(t[r]=[]);for(let e of s)!1===a.includes(e)&&a.push(e)}e=[];for(let i in t){let r=t[i],s=this._getBindGroup(i,r);e.push(s)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let i=e[t];this.bindingsIndexes[i.name].group=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){!1===this.nodes.has(e)&&(this.nodes.add(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){let t=e.getUpdateBeforeType(),i=e.getUpdateAfterType();(t!==mR.NONE||i!==mR.NONE)&&this.sequentialNodes.add(e)}buildUpdateNodes(){for(let e of this.nodes)e.getUpdateType()!==mR.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),i=e.getUpdateAfterType();t!==mR.NONE&&this.updateBeforeNodes.push(e),i!==mR.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===qt||e.magFilter===Ht||e.magFilter===Wt||e.magFilter===$t||e.minFilter===qt||e.minFilter===Ht||e.minFilter===Wt||e.minFilter===$t}getUniformBufferLimit(){return this.renderer.backend.capabilities.getUniformBufferLimit()}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("THREE.NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){let t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){let e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){let i=this.getDataFromNode(e);return void 0===i.cache&&(i.cache=new wZ(t?this.getCache():null)),i.cache}isAvailable(){return!1}getVertexIndex(){f("Abstract function.")}getInstanceIndex(){f("Abstract function.")}getDrawIndex(){f("Abstract function.")}getFrontFacing(){f("Abstract function.")}getFragCoord(){f("Abstract function.")}isFlipY(){return!1}isContextAssign(){return!0===this.context.assign}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=void 0===t.usageCount?1:t.usageCount+1,this.isContextAssign()?t.writeUsageCount=void 0===t.writeUsageCount?1:t.writeUsageCount+1:t.readUsageCount=void 0===t.readUsageCount?1:t.readUsageCount+1,t.usageCount}hasWriteUsage(e){let t=e.getShared(this),i=(t.isGlobal(this)?this.globalCache:this.cache).getData(t);if(void 0!==i)for(let e in i)if(HZ(i[e]))return!0;return!1}generateTexture(){f("Abstract function.")}generateTextureLod(){f("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,i=null){let r=this.generateArrayDeclaration(e,t)+"( ";for(let s=0;s<t;s++){let a=i?i[s]:null;r+=null!==a?a.build(this,e):this.generateConst(e),s<t-1&&(r+=", ")}return r+=" )",r}generateStruct(e,t,i=null){let r=[];for(let e of t){let{name:t,type:s}=e;i&&i[t]&&i[t].isNode?r.push(i[t].build(this,s)):r.push(this.generateConst(s))}return e+"( "+r.join(", ")+" )"}generateConst(e,t=null){if(null===t&&("float"===e||"int"===e||"uint"===e?t=0:"bool"===e?t=!1:"color"===e?t=new aa:"vec2"===e||"uvec2"===e||"ivec2"===e?t=new rs:"vec3"===e||"uvec3"===e||"ivec3"===e?t=new ns:("vec4"===e||"uvec4"===e||"ivec4"===e)&&(t=new Ss)),"float"===e)return qZ(t);if("int"===e)return`${Math.round(t)}`;if("uint"===e)return t>=0?`${Math.round(t)}u`:"0u";if("bool"===e)return t?"true":"false";if("color"===e)return`${this.getType("vec3")}( ${qZ(t.r)}, ${qZ(t.g)}, ${qZ(t.b)} )`;let i=this.getTypeLength(e),r=this.getComponentType(e),s=e=>this.generateConst(r,e);if(2===i)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(3===i)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(4===i&&"mat2"!==e)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(i>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(i>4)return`${this.getType(e)}()`;throw new Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){let i=this.attributes;for(let t of i)if(t.name===e)return t;let r=new gZ(e,t);return this.registerDeclaration(r),i.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;return!0===e.isDepthTexture?"float":t===Qt?"int":t===ei?"uint":"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let i=kN(e),r="float"===t?"":t[0];return!0===/mat2/.test(t)&&(i=i.replace("vec","mat")),r+i}getTypeFromArray(e){return WZ.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let i,r=t.array,s=e.itemSize,a=e.normalized;return!(e instanceof qa)&&!0!==a&&(i=this.getTypeFromArray(r)),this.getTypeFromLength(s,i)}getTypeLength(e){let t=this.getVectorType(e),i=/vec([2-4])/.exec(t);return null!==i?Number(i[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]!==e)throw new Error("THREE.NodeBuilder: Invalid active stack removal.");this.activeStacks.pop()}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=pW(this.stack);let e=wE();return this.stacks.push(e),xE(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes)this.getDataFromNode(t).stack=e;return this.stack=e.parent,xE(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,i=null){let r=(i=null===i?e.isGlobal(this)?this.globalCache:this.cache:i).getData(e);void 0===r&&(r={},i.setData(e,r)),void 0===r[t]&&(r[t]={});let s=r[t];if(0===this.subBuildLayers.length)return s;let a=r.any?r.any.subBuilds:null,n=this.getClosestSubBuild(a);return n&&(void 0===s.subBuildsCache&&(s.subBuildsCache={}),s=s.subBuildsCache[n]||(s.subBuildsCache[n]={}),s.subBuilds=a),s}getNodeProperties(e,t="any"){let i=this.getDataFromNode(e,t);return i.properties||(i.properties={outputNode:null})}getBufferAttributeFromNode(e,t,i=null){let r=this.getDataFromNode(e,"vertex"),s=r.bufferAttribute;if(void 0===s){let a=this.uniforms.index++;null===i&&(i="nodeAttribute"+a),s=new gZ(i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,i=null,r=this.shaderStage){let s=this.getDataFromNode(e,r,this.globalCache),a=s.structType;if(void 0===a){let n=this.structs.index++;null===i&&(i="StructType"+n),a=new _Z(i,t),this.structs[r].push(a),this.types[r][i]=e,s.structType=a}return a}getOutputStructTypeFromNode(e,t){let i=this.getStructTypeFromNode(e,t,"OutputType","fragment");return i.output=!0,i}getUniformFromNode(e,t,i=this.shaderStage,r=null){let s=this.getDataFromNode(e,i,this.globalCache),a=s.uniform;if(void 0===a){let n=this.uniforms.index++;a=new fZ(r||"nodeUniform"+n,t,e),this.uniforms[i].push(a),this.registerDeclaration(a),s.uniform=a}return a}getVarFromNode(e,t=null,i=e.getNodeType(this),r=this.shaderStage,s=!1){let a=this.getDataFromNode(e,r),n=this.getSubBuildProperty("variable",a.subBuilds),o=a[n];if(void 0===o){let l=s?"_const":"_var",h=this.vars[r]||(this.vars[r]=[]),u=this.vars[l]||(this.vars[l]=0);null===t&&(t=(s?"nodeConst":"nodeVar")+u,this.vars[l]++),"variable"!==n&&(t=this.getSubBuildProperty(t,a.subBuilds));let d=e.getArrayCount(this);o=new yZ(t,i,s,d),s||h.push(o),this.registerDeclaration(o),a[n]=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(let t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,i=e.getNodeType(this),r=null,s=null){let a=this.getDataFromNode(e,"any"),n=this.getSubBuildProperty("varying",a.subBuilds),o=a[n];if(void 0===o){let e=this.varyings,l=e.length;null===t&&(t="nodeVarying"+l),"varying"!==n&&(t=this.getSubBuildProperty(t,a.subBuilds)),o=new vZ(t,i,r,s),e.push(o),this.registerDeclaration(o),a[n]=o}return o}registerDeclaration(e){let t=this.shaderStage,i=this.declarations[t]||(this.declarations[t]={}),r=e.name,s=r,a=this.getPropertyName(e),n=1;for(;void 0!==i[a];)s=r+"_"+n++,e.name=s,a=this.getPropertyName(e);s!==r&&f(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${s}'.`),i[a]=e}getCodeFromNode(e,t,i=this.shaderStage){let r=this.getDataFromNode(e),s=r.code;if(void 0===s){let e=this.codes[i]||(this.codes[i]=[]),a=e.length;s=new bZ("nodeCode"+a,t),e.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){let{flowCodes:i,flowCodeBlock:r}=this.getDataFromNode(e),s=!0,a=t;for(;a;){if(!0===r.get(a)){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(let e of i)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,i){let r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(i,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),i=this.flowChildNode(e,t);return this.flowsData.set(e,i),i}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=this.renderer.backend,i=jZ.get(t);void 0===i&&(i=new WeakMap,jZ.set(t,i));let r=i.get(e);if(void 0===r){r=new XH;let t=this.currentFunctionNode;this.currentFunctionNode=r,r.code=this.buildFunctionCode(e),this.currentFunctionNode=t,i.set(e,r)}return r}flowShaderNode(e){let t=e.layout,i={[Symbol.iterator](){let e=0,t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(let e of t.inputs)i[e.name]=new dW(e.type,e.name);e.layout=null;let r=e.call(i),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowBuildStage(e,t,i=null){let r=this.getBuildStage();this.setBuildStage(t);let s=e.build(this,i);return this.setBuildStage(r),s}flowStagesNode(e,t=null){let i=this.flow,r=this.vars,s=this.declarations,a=this.cache,n=this.buildStage,o=this.stack,l={code:""};this.flow=l,this.vars={},this.declarations={},this.cache=new wZ,this.stack=pW();for(let i of vR)this.setBuildStage(i),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=i,this.vars=r,this.declarations=s,this.cache=a,this.stack=o,this.setBuildStage(n),l}getFunctionOperator(){return null}buildFunctionCode(){f("Abstract function.")}flowChildNode(e,t=null){let i=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=i,r}flowNodeFromShaderStage(e,t,i=null,r=null){let s=this.tab,a=this.cache,n=this.shaderStage,o=this.context;this.setShaderStage(e);let l={...this.context};delete l.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=l;let h=null;if("generate"===this.buildStage){let s=this.flowChildNode(t,i);null!==r&&(s.code+=`${this.tab+r} = ${s.result};\n`),this.flowCode[e]=this.flowCode[e]+s.code,h=s}else h=t.build(this);return this.setShaderStage(n),this.cache=a,this.tab=s,this.context=o,h}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){f("Abstract function.")}getVaryings(){f("Abstract function.")}getVar(e,t,i=null){return`${null!==i?this.generateArrayDeclaration(e,i):this.getType(e)} ${t}`}getVars(e,t=!1){let i=[],r=this.vars[e];if(void 0!==r)for(let e of r)i.push(`${this.getVar(e.type,e.name,e.count)};`);return i.join(t?"\n":"\n\t")}getUniforms(){f("Abstract function.")}getCodes(e){let t=this.codes[e],i="";if(void 0!==t)for(let e of t)i+=e.code+"\n";return i}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){f("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:e instanceof Set?[...e]:e,!t)return null;let i=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){let r=t[e];if(i.includes(r))return r}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let i,r;return i=null!==t?this.getClosestSubBuild(t):this.subBuildFn,r=i?e?i+"_"+e:i:e,r}prebuild(){let{object:e,renderer:t,material:i}=this;if(!0===t.contextNode.isContextNode?this.context={...this.context,...t.contextNode.getFlowContextData()}:y('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),i&&i.contextNode&&(!0===i.contextNode.isContextNode?this.context={...this.context,...i.contextNode.getFlowContextData()}:y('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),null!==i){let e=t.library.fromMaterial(i);null===e&&(y(`NodeBuilder: Material "${i.type}" is not compatible.`),e=new UU),e.build(this)}else this.addFlow("compute",e)}build(){return this.buildStep(1/0),this}buildStep(e){let t=this._buildStepState;if(null==t&&(this.prebuild(),t=this._buildStepState={stage:0,shader:0,node:0,positionFlowed:!1},performance.now()>=e))return!1;for(;t.stage<vR.length;){let i=vR[t.stage];if(this.setBuildStage(i),!1===t.positionFlowed&&(this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position),t.positionFlowed=!0,performance.now()>=e))return!1;for(;t.shader<bR.length;){let r=bR[t.shader];this.setShaderStage(r);let s=this.flowNodes[r];for(;t.node<s.length;){let r=s[t.node];if(t.node++,"generate"===i?this.flowNode(r):r.build(this),performance.now()>=e)return!1}t.node=0,t.shader++}t.shader=0,t.positionFlowed=!1,t.stage++}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this._buildStepState=null,!0}getSharedDataFromNode(e){let t=GZ.get(e);return void 0===t&&(t={}),t}getNodeUniform(e,t){let i=this.getSharedDataFromNode(e),r=i.cache;if(void 0===r){if("float"===t||"int"===t||"uint"===t)r=new OZ(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)r=new BZ(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)r=new VZ(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)r=new DZ(e);else if("color"===t)r=new IZ(e);else if("mat2"===t)r=new LZ(e);else if("mat3"===t)r=new zZ(e);else{if("mat4"!==t)throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);r=new kZ(e)}i.cache=r}return r}format(e,t,i){if((t=this.getVectorType(t))===(i=this.getVectorType(i))||null===i||this.isReference(i))return e;let r=this.getTypeLength(t),s=this.getTypeLength(i);return 16===r&&9===s?`${this.getType(i)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===r&&4===s?`${this.getType(i)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||s>4||0===s?e:r===s?`${this.getType(i)}( ${e} )`:r>s?(e="bool"===i?`all( ${e} )`:`${e}.${"xyz".slice(0,s)}`,this.format(e,this.getTypeFromLength(s,this.getComponentType(t)),i)):4===s&&r>1?`${this.getType(i)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===r?`${this.getType(i)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===r&&s>1&&t!==this.getComponentType(i)&&(e=`${this.getType(this.getComponentType(i))}( ${e} )`),`${this.getType(i)}( ${e} )`)}getSignature(){return`// Three.js r${Le} - Node System\n`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has("velocity")||!0===HN(this.object).useVelocity}},YZ=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let i=e.get(t);return void 0===i&&(i={renderId:0,frameId:0},e.set(t,i)),i}updateBeforeNode(e){let t=e.getUpdateBeforeType(),i=e.updateReference(this);if(t===mR.FRAME){let t=this._getMaps(this.updateBeforeMap,i);if(t.frameId!==this.frameId){let i=t.frameId;t.frameId=this.frameId,!1===e.updateBefore(this)&&(t.frameId=i)}}else if(t===mR.RENDER){let t=this._getMaps(this.updateBeforeMap,i);if(t.renderId!==this.renderId){let i=t.renderId;t.renderId=this.renderId,!1===e.updateBefore(this)&&(t.renderId=i)}}else t===mR.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),i=e.updateReference(this);if(t===mR.FRAME){let t=this._getMaps(this.updateAfterMap,i);t.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(t.frameId=this.frameId)}else if(t===mR.RENDER){let t=this._getMaps(this.updateAfterMap,i);t.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(t.renderId=this.renderId)}else t===mR.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),i=e.updateReference(this);if(t===mR.FRAME){let t=this._getMaps(this.updateMap,i);t.frameId!==this.frameId&&!1!==e.update(this)&&(t.frameId=this.frameId)}else if(t===mR.RENDER){let t=this._getMaps(this.updateMap,i);t.renderId!==this.renderId&&!1!==e.update(this)&&(t.renderId=this.renderId)}else t===mR.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},(XZ=class{constructor(e,t,i=null,r="",s=!1){this.type=e,this.name=t,this.count=i,this.qualifier=r,this.isConst=s}}).isNodeFunctionInput=!0,KZ=class extends YY{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},ZZ=class extends YY{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:aY(this.light),lightColor:e}}},JZ=class extends YY{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=zP(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=DO(new aa).setGroup(OO)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:i,lightDirectionNode:r}=this,s=EL.dot(r).mul(.5).add(.5),a=MV(i,t,s);e.context.irradiance.addAssign(a)}},QZ=class extends YY{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=DO(0).setGroup(OO),this.penumbraCosNode=DO(0).setGroup(OO),this.cutoffDistanceNode=DO(0).setGroup(OO),this.decayExponentNode=DO(0).setGroup(OO),this.colorNode=DO(this.color).setGroup(OO)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:i,penumbraCosNode:r}=this;return NV(i,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),i=t.projectionUV;return void 0===i&&(i=LP(this.light,e.context.positionWorld),t.projectionUV=i),i}setupDirect(e){let t,i,{colorNode:r,cutoffDistanceNode:s,decayExponentNode:a,light:n}=this,o=this.getLightVector(e),l=o.normalize(),h=l.dot(aY(n)),u=this.getSpotAttenuation(e,h),d=o.length(),c=XY({lightDistance:d,cutoffDistance:s,decayExponent:a}),p=r.mul(u).mul(c);return n.colorNode?(i=this.getLightCoord(e),t=n.colorNode(i)):n.map&&(i=this.getLightCoord(e),t=JD(n.map,i.xy).onRenderUpdate(()=>n.map)),t&&(p=i.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(t),p)),{lightColor:p,lightDirection:l}}},eJ=class extends QZ{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){let i=this.light.iesMap,r=null;if(i&&!0===i.isTexture){let e=t.acos().mul(1/Math.PI);this._iesTextureNode=JD(i,PE(e,0),0),r=this._iesTextureNode.r}else r=super.getSpotAttenuation(e,t);return r}update(e){super.update(e),null!==this._iesTextureNode&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}},tJ=class extends YY{static get type(){return"LightProbeNode"}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new ns);this.lightProbe=lI(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=lZ(EL,this.lightProbe);e.context.irradiance.addAssign(t)}},iJ=JN(([e,t])=>{let i=e.abs().sub(t);return XB(lV(i,0)).add(oV(lV(i.x,i.y),0))}),rJ=class extends QZ{static get type(){return"ProjectorLightNode"}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=TE(0),i=this.penumbraCosNode,r=IP(this.light).mul(e.context.positionWorld||yL);return _E(r.w.greaterThan(0),()=>{let e=r.xyz.div(r.w),s=iJ(e.xy.sub(PE(.5)),PE(.5)),a=HO(-1,WO(1,GB(i)).sub(1));t.assign(CV(s.mul(-2).mul(a)))}),t}},sJ=new As,aJ=new As,nJ=null,oJ=class extends YY{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=DO(new ns).setGroup(OO),this.halfWidth=DO(new ns).setGroup(OO),this.updateType=mR.RENDER}update(e){super.update(e);let{light:t}=this,i=e.camera.matrixWorldInverse;aJ.identity(),sJ.copy(t.matrixWorld),sJ.premultiply(i),aJ.extractRotation(sJ),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(aJ),this.halfHeight.value.applyMatrix4(aJ)}setupDirectRectArea(e){let t,i;e.isAvailable("float32Filterable")?(t=JD(nJ.LTC_FLOAT_1),i=JD(nJ.LTC_FLOAT_2)):(t=JD(nJ.LTC_HALF_1),i=JD(nJ.LTC_HALF_2));let{colorNode:r,light:s}=this;return{lightColor:r,lightPosition:UP(s),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:i}}static setLTC(e){nJ=e}},lJ=class{parseFunction(){f("Abstract function.")}},(hJ=class{constructor(e,t,i="",r=""){this.type=e,this.inputs=t,this.name=i,this.precision=r}getCode(){f("Abstract function.")}}).isNodeFunction=!0,uJ=[],dJ=[],cJ=DO(0,"int").setGroup(OO),pJ=class extends UG{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new YZ,this.nodeBuilderCache=new Map,this.callHashCache=new EG,this.groupsData=new EG,this.cacheLib={}}updateGroup(e){let t=e.groupNode;if(t.updateType===mR.OBJECT)return!0;uJ[0]=t,uJ[1]=e;let i=this.groupsData.get(uJ);return void 0===i&&this.groupsData.set(uJ,i={}),uJ[0]=null,uJ[1]=null,i.version!==t.version&&(i.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}_createNodeBuilder(e,t){let i=this.backend.createNodeBuilder(e.object,this.renderer);return i.scene=e.scene,i.material=t,i.camera=e.camera,i.context.material=t,i.lightsNode=e.lightsNode,i.environmentNode=this.getEnvironmentNode(e.scene),i.fogNode=this.getFogNode(e.scene),i.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&i.enableMultiview(),i}getForRender(e){let t=this.get(e),i=t.nodeBuilderState;if(void 0===i){let{nodeBuilderCache:r}=this,s=this.getForRenderCacheKey(e);if(i=r.get(s),void 0===i&&(i=this._spResurrectRetired(s)),void 0===i){let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(i){t=this._createNodeBuilder(e,new UU),t.build();let r=i.stackTrace;!r&&i.stack&&(r=new oR(i.stack)),y("TSL: "+i,r)}i=this.adoptNodeBuilder(s,t)}i.usedTimes++,t.nodeBuilderState=i,t.cacheKey=s}return i}adoptNodeBuilder(e,t){let i=this.nodeBuilderCache.get(e);return void 0===i&&(i=this._createNodeBuilderState(t),this.nodeBuilderCache.set(e,i)),i}_spResurrectRetired(e){if(void 0===this._spRetiredNodeStates)return;let t=this._spRetiredNodeStates.get(e);return void 0!==t&&(this._spRetiredNodeStates.delete(e),this.nodeBuilderCache.set(e,t),this._spResurrections=(this._spResurrections||0)+1),t}releaseBuilderState(e,t){if(t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.get(e)===t){this.nodeBuilderCache.delete(e);let i=this._spRetiredNodeStates||(this._spRetiredNodeStates=new Map);i.delete(e),i.set(e,t),i.size>256&&i.delete(i.keys().next().value)}}delete(e){if(e.isRenderObject){let t=this.get(e),i=t.nodeBuilderState;if(null!=i){let r=void 0!==t.cacheKey?t.cacheKey:this.getForRenderCacheKey(e);this.releaseBuilderState(r,i)}}return super.delete(e)}getForCompute(e){let t=this.get(e),i=t.nodeBuilderState;if(void 0===i||t.version!==e.version){let r=this.backend.createNodeBuilder(e,this.renderer);r.build(),i=this._createNodeBuilderState(r),t.nodeBuilderState=i,t.version=e.version}return i}_createNodeBuilderState(e){return new mZ(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(!1===this.renderer.lighting.enabled)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let i=this.get(e);i.environmentNode&&(t=i.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let i=this.get(e);i.backgroundNode&&(t=i.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){uJ[0]=e,uJ[1]=t;let i=this.renderer.info.calls,r=this.callHashCache.get(uJ)||{};if(r.callId!==i){if(dJ.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),dJ.push(this.renderer.lighting.enabled?1:0),this.renderer.lighting.enabled){dJ.push(t.getCacheKey(!0)),dJ.push(this.renderer.shadowMap.enabled?1:0),dJ.push(this.renderer.shadowMap.type);let i=this.getEnvironmentNode(e);i&&dJ.push(i.getCacheKey())}let s=this.getFogNode(e);s&&dJ.push(s.getCacheKey()),r.callId=i,r.cacheKey=hR(dJ),this.callHashCache.set(uJ,r),dJ.length=0}return uJ[0]=null,uJ[1]=null,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),i=e.background;if(i){let r=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==i||r){let s=this.getCacheNode("background",i,()=>{if(!0===i.isCubeTexture||i.mapping===It||i.mapping===Lt||i.mapping===zt){if(e.backgroundBlurriness>0||i.mapping===zt)return sG(i);{let e;return e=!0===i.isCubeTexture?YL(i):JD(i),oF(e)}}if(!0===i.isTexture)return JD(i,mI.flipY()).setUpdateMatrix(!0);!0!==i.isColor&&y("WebGPUNodes: Unsupported background configuration.",i)},r);t.backgroundNode=s,t.background=i,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,i,r=!1){let s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),a=s.get(t);return(void 0===a||r)&&(a=i(),s.set(t,a)),a}updateFog(e){let t=this.get(e),i=e.fog;if(i){if(t.fog!==i){let e=this.getCacheNode("fog",i,()=>{if(i.isFogExp2){let e=JL("color","color",i).setGroup(OO),t=JL("density","float",i).setGroup(OO);return i$(e,e$(t))}if(i.isFog){let e=JL("color","color",i).setGroup(OO),t=JL("near","float",i).setGroup(OO),r=JL("far","float",i).setGroup(OO);return i$(e,QH(t,r))}y("Renderer: Unsupported fog configuration.",i)});t.fogNode=e,t.fog=i}}else delete t.fogNode,delete t.fog}updateEnvironment(e){let t=this.get(e),i=e.environment;if(i){if(t.environment!==i){let e=this.getCacheNode("environment",i,()=>!0===i.isCubeTexture?YL(i):!0===i.isTexture?JD(i):void y("Nodes: Unsupported environment configuration.",i));t.environmentNode=e,t.environment=i}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,i=null,r=null,s=null){let a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=i,a.camera=r,a.material=s,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){let t,i=this.renderer;return t=e.isArrayTexture?this.backend.isWebGLBackend?JD(e,mI).depth(hI("gl_ViewID_OVR")).renderOutput(i.toneMapping,i.currentColorSpace):JD(e,mI).depth(cJ).renderOutput(i.toneMapping,i.currentColorSpace):JD(e,mI).renderOutput(i.toneMapping,i.currentColorSpace),t}setOutputLayerIndex(e){cJ.value=e}updateBefore(e){let t=e.getNodeBuilderState();for(let i of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(i)}updateAfter(e){let t=e.getNodeBuilderState();for(let i of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(i)}updateForCompute(e){let t=this.getNodeFrame(),i=this.getForCompute(e);for(let e of i.updateNodes)t.updateNode(e)}updateForRender(e){let t=this.getNodeFrameForRender(e),i=e.getNodeBuilderState();for(let e of i.updateNodes)t.updateNode(e)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new YZ,this.nodeBuilderCache=new Map,this._spRetiredNodeStates=void 0,this.cacheLib={}}},mJ=new uo,gJ=class{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new As,this.viewNormalMatrix=new us,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,i){let r=e.length;for(let s=0;s<r;s++){mJ.copy(e[s]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let r=t[i+s],a=mJ.normal;r.x=-a.x,r.y=-a.y,r.z=-a.z,r.w=mJ.constant}}updateGlobal(e,t){this.shadowPass=null!==e.overrideMaterial&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix.copy(t.matrixWorldInverse),this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let i=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);let r,s,a=t.clippingPlanes,n=a.length;if(this.clipIntersection?(r=this.intersectionPlanes,s=e.intersectionPlanes.length):(r=this.unionPlanes,s=e.unionPlanes.length),r.length!==s+n){r.length=s+n;for(let e=0;e<n;e++)r[s+e]=new Ss;i=!0}this.projectPlanes(a,r,s),i&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return void 0===t&&(t=new gJ(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}},fJ=class{constructor(e,t,i){this.bundleGroup=e,this.camera=t,this.renderContext=i}},yJ=[],vJ=class{constructor(){this.bundles=new EG}get(e,t,i){let r=this.bundles;yJ[0]=e,yJ[1]=t,yJ[2]=i;let s=r.get(yJ);return void 0===s&&(s=new fJ(e,t,i),r.set(yJ,s)),yJ[0]=null,yJ[1]=null,yJ[2]=null,s}dispose(){this.bundles=new EG}},bJ=class{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,i=this.getMaterialNodeClass(e.type);if(null!==i){t=new i;for(let i in e)t[i]=e[i]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,i){if(i.has(t))f(`Redefinition of node ${t}`);else{if("function"!=typeof e)throw new Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if("function"==typeof t||"object"==typeof t)throw new Error(`THREE.NodeLibrary: Base class ${t} is not a class.`);i.set(t,e)}}addClass(e,t,i){if(i.has(t))f(`Redefinition of node ${t.name}`);else{if("function"!=typeof e)throw new Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if("function"!=typeof t)throw new Error(`THREE.NodeLibrary: Base class ${t.name} is not a class.`);i.set(t,e)}}},xJ=new pY,wJ=new WeakMap,_J=class{constructor(){this.enabled=!0,this._cache=[]}createNode(e=[]){return(new pY).setLights(e)}getNode(e){if(!0!==e.isScene&&!0!==e.isGroup)return xJ;let t=wJ.get(e);return void 0===t&&(t=this.createNode(),wJ.set(e,t)),t}beginRender(e){this._cache.push(this.getNode(e).getLights())}finishRender(e){this.getNode(e).setLights(this._cache.pop())}},SJ=class extends Kr{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new Ss(0,0,this._width,this._height),this._scissor=new Ss(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new Oo,this.depthTexture=new Do}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,i){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=i,this.domElement.width=Math.floor(e*i),this.domElement.height=Math.floor(t*i),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,i=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===i&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._dispatchResize())}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,i,r){let s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,i,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,i,r,s=0,a=1){let n=this._viewport;e.isVector4?n.copy(e):n.set(e,t,i,r),n.minDepth=s,n.maxDepth=a}_dispatchResize(){this.dispatchEvent({type:"resize"})}dispose(){this.dispatchEvent({type:"dispose"})}},MJ=new la,TJ=new rs,CJ=new Ss,AJ=new go,NJ=new yo,PJ=new As,RJ=new Ss,EJ={[Ge]:We,[We]:Ge,[qe]:qe},OJ=class{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:i=!1,reversedDepthBuffer:r=!1,alpha:s=!0,depth:a=!0,stencil:n=!1,antialias:o=!1,samples:l=0,getFallback:h=null,outputBufferType:u=ii,multiview:d=!1,asyncCompilation:c=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=s,this.logarithmicDepthBuffer=i,this.reversedDepthBuffer=r,this.outputColorSpace=hr,this.toneMapping=Ct,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=a,this.stencil=n,this.info=new qG,this.contextNode=zV(),this.library=new bJ,this.lighting=new _J,this._samples=l||!0===o?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new SJ(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new FD,this._inspector.setRenderer(this),this._getFallback=h,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quadCache=new Map,this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTargets=new Map;let p=!0===this.alpha?0:1;this._clearColor=new hW(0,0,0,p),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this.onError=this._onError,this._outputBufferType=u,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._asyncCompilation=!0===c,this._compilationBurst=!1,this._compilation=null,this.onBackgroundWorkReady=null,this._compilationPromises=null,this._currentSourceMaterial=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:Ue},this.xr={enabled:!1,isPresenting:!1,cameraAutoUpdate:!0,updateCamera(){},getCamera:()=>null,getEnvironmentBlendMode:()=>null,getSession:()=>null,async setSession(){throw new Error("WebXR is not supported by the Spline runtime")},getController:()=>null,getControllerGrip:()=>null,getHand:()=>null,addEventListener(){},removeEventListener(){},hasEventListener:()=>!1,dispatchEvent(){},dispose(){}},this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,i)=>{await this.compileAsync(i,t,e);let r=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,s=this._renderLists.get(e,t),a=this._renderContexts.get(r,this._mrt),n=e.overrideMaterial||i.material,o=this._objects.get(i,n,e,t,s.lightsNode,a,a.clippingContext),{fragmentShader:l,vertexShader:h}=o.getNodeBuilderState();return{fragmentShader:l,vertexShader:h}}}}async init(){return null!==this._initPromise||(this._initPromise=new Promise(async(e,t)=>{let i=this.backend;try{await i.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=i=this._getFallback(e),await i.init(this)}catch(e){return void t(e)}}this._nodes=new pJ(this,i),this._animation=new RG(this,this._nodes,this.info),this._attributes=new GG(i,this.info),this._background=new dZ(this,this._nodes),this._geometries=new WG(this._attributes,this.info),this._textures=new lW(this,i,this.info),this._pipelines=new ZG(i,this._nodes,this.info),this._bindings=new JG(i,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new kG(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new rW(this.lighting,this._objects),this._bundles=new vJ,this._renderContexts=new nW(this),this._compilation=new IG(this),this._compilation.burst=this._compilationBurst,this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}setAsyncCompilation(e){!0==(e=!0===e)&&!1===this._asyncCompilation&&null!==this._objects&&this._objects.resetClassifications(),this._asyncCompilation=e}setCompilationBurst(e){e=!0===e,this._compilationBurst=e,null!==this._compilation&&(this._compilation.burst=e)}async compileAsync(e,t,i=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();let r=this._nodes.nodeFrame,s=r.renderId,a=this._currentRenderContext,n=this._currentRenderObjectFunction,o=this._handleObjectFunction,l=this._compilationPromises;null===i&&(i=e);let h=!0===e.isScene?e:!0===i.isScene?i:MJ,u=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,d=this._renderContexts.get(u,this._mrt),c=this._activeMipmapLevel;d.renderTarget=u,d.activeCubeFace=this._activeCubeFace,d.activeMipmapLevel=c;let p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,r.renderId++,r.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new gJ),d.clippingContext.updateGlobal(h,t),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t=this._updateCamera(t),h.onBeforeRender(this,e,t,u);let m=t.isArrayCamera?NJ:AJ;t.isArrayCamera?m.setFromArrayCamera(t):(PJ.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),m.setFromProjectionMatrix(PJ,t.coordinateSystem,t.reversedDepth));let g=this._renderLists.get(h,t);if(g.begin(),this._projectObject(e,t,0,g,d.clippingContext),i!==e&&i.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&g.pushLight(e)}),g.finish(),null!==u){this._textures.updateRenderTarget(u,c);let e=this._textures.get(u);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;i!==e?this._background.update(i,g,d):this._background.update(h,g,d);let f=g.opaque,y=g.transparent,v=g.transparentDoublePass,b=g.lightsNode;!0===this.opaque&&f.length>0&&this._renderObjects(f,t,h,b),!0===this.transparent&&y.length>0&&this._renderTransparents(y,v,t,h,b),r.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=n,this._handleObjectFunction=o,this._compilationPromises=l,await Promise.all(p)}async renderAsync(e,t){v('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){y("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){null!==this._inspector&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;!0===e?(t.modelViewMatrix=dL,t.modelNormalViewMatrix=cL):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===dL&&e.modelNormalViewMatrix===cL}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return v('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),y(t),this._isDeviceLost=!0,null!==this._compilation&&this._compilation.clear("cancelled")}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),y(t)}_bundleNeedsUpdate(e,t){return void 0===t.bundleGPU||e.version!==t.version}_renderBundle(e,t,i){let{bundleGroup:r,camera:s,renderList:a}=e,n=this._currentRenderContext,o=this._bundles.get(r,s,n),l=this.backend.get(o),h=this._bundleNeedsUpdate(r,l);if(void 0===this._bundleDebug&&(this._bundleDebug={records:0,replays:0}),h){this._bundleDebug.records++,l.incompleteRecord=!1,this.backend.beginBundle(n),this._currentRenderBundle=o;let{transparentDoublePass:e,transparent:h,opaque:u}=a;!0===this.opaque&&u.length>0&&this._renderObjects(u,s,t,i),!0===this.transparent&&h.length>0&&this._renderTransparents(h,e,s,t,i),this._currentRenderBundle=null,this.backend.finishBundle(n,o),!0===l.incompleteRecord?this._bundleDebug.incompleteRecords=(this._bundleDebug.incompleteRecords||0)+1:l.version=r.version}else{this._bundleDebug.replays++;let{renderObjects:e}=l;for(let t=0,i=e.length;t<i;t++){let i=e[t];this._nodes.updateBefore(i),this._geometries.updateForRender(i),this._nodes.updateForRender(i),this._bindings.updateForRender(i),this._nodes.updateAfter(i)}}this.backend.addBundle(n,o)}render(e,t){if(!1===this._initialized)throw new Error('THREE.Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(e,t),null!==this._compilation&&-1===this._callDepth&&this._compilation.update()}get initialized(){return this._initialized}_renderOutputLayers(e,t){if(!0!==t.texture.isArrayTexture||t.texture.image.depth<=1)return void this._renderScene(e,e.camera,!1);let i=this._activeCubeFace;try{for(let i=0;i<t.texture.image.depth;i++)this._nodes.setOutputLayerIndex(i),this._activeCubeFace=i,this._renderScene(e,e.camera,!1)}finally{this._nodes.setOutputLayerIndex(0),this._activeCubeFace=i}}_getFrameBufferTarget(){let{currentToneMapping:e,currentColorSpace:t}=this,i=e!==Ct,r=t!==ms.workingColorSpace;if(!1===i&&!1===r)return null;let{width:s,height:a}=this.getDrawingBufferSize(TJ),{depth:n,stencil:o}=this,l=this._outputRenderTarget||this._canvasTarget,h=this._frameBufferTargets.get(l);if(void 0===h){h=new Ms(s,a,{depthBuffer:n,stencilBuffer:o,type:this._outputBufferType,format:ui,colorSpace:ms.workingColorSpace,generateMipmaps:!1,minFilter:qt,magFilter:qt,samples:this.samples}),h.isPostProcessingRenderTarget=!0;let e=()=>{l.removeEventListener("dispose",e),h.dispose(),this._frameBufferTargets.delete(l)};l.addEventListener("dispose",e),this._frameBufferTargets.set(l,h)}let u=this.getOutputRenderTarget();h.depthBuffer=n,h.stencilBuffer=o,null!==u?h.setSize(u.width,u.height,u.depth):h.setSize(s,a,1);let d=this._outputRenderTarget?this._outputRenderTarget.viewport:l._viewport,c=this._outputRenderTarget?this._outputRenderTarget.scissor:l._scissor,p=this._outputRenderTarget?1:l._pixelRatio,m=this._outputRenderTarget?this._outputRenderTarget.scissorTest:l._scissorTest;return h.viewport.copy(d),h.scissor.copy(c),h.viewport.multiplyScalar(p),h.scissor.multiplyScalar(p),h.scissorTest=m,h.multiview=null!==u&&u.multiview,h.useArrayDepthTexture=null!==u&&u.useArrayDepthTexture,h.resolveDepthBuffer=null===u||u.resolveDepthBuffer,h._autoAllocateDepthBuffer=null!==u&&u._autoAllocateDepthBuffer,h}_renderScene(e,t,i=!0){if(!0===this._isDeviceLost)return;null!==this._compilation&&-1===this._callDepth&&this._compilation.applyPromotions();let r=i?this._getFrameBufferTarget():null,s=this._nodes.nodeFrame,a=s.renderId,n=this._currentRenderContext,o=this._currentRenderObjectFunction,l=this._handleObjectFunction,h=this._currentRenderBundle;this._currentRenderBundle=null,this.lighting.beginRender(e),this._callDepth++;let u,d=!0===e.isScene?e:MJ,c=this._renderTarget||this._outputRenderTarget,p=this._activeCubeFace,m=this._activeMipmapLevel;if(null!==r?(u=r,this.setRenderTarget(u)):u=c,null!==u&&!0===u.depthBuffer){let e=this._textures.get(u);!0!==e.depthInitialized&&((!1===this.autoClear||!0===this.autoClear&&!1===this.autoClearDepth)&&this.clearDepth(),e.depthInitialized=!0)}let g=this._renderContexts.get(u,this._mrt,this._callDepth);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,s.renderId=this.info.calls,this.backend.updateTimeStampUID(g),this.inspector.beginRender(this.backend.getTimestampUID(g),e,t,u),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t=this._updateCamera(t);let f=this._canvasTarget,y=f._viewport,v=f._scissor,b=f._pixelRatio;null!==u&&(y=u.viewport,v=u.scissor,b=1),this.getDrawingBufferSize(TJ),CJ.set(0,0,TJ.width,TJ.height);let x=void 0===y.minDepth?0:y.minDepth,w=void 0===y.maxDepth?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(b).floor(),g.viewportValue.width>>=m,g.viewportValue.height>>=m,g.viewportValue.minDepth=x,g.viewportValue.maxDepth=w,g.viewport=!1===g.viewportValue.equals(CJ),g.scissorValue.copy(v).multiplyScalar(b).floor(),g.scissor=f._scissorTest&&!1===g.scissorValue.equals(CJ),g.scissorValue.width>>=m,g.scissorValue.height>>=m,g.clippingContext||(g.clippingContext=new gJ),g.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,u);let _=t.isArrayCamera?NJ:AJ;t.isArrayCamera?_.setFromArrayCamera(t):(PJ.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(PJ,t.coordinateSystem,t.reversedDepth));let S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,g.clippingContext),S.finish(),!0===this.sortObjects&&S.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),null!==u){this._textures.updateRenderTarget(u,m);let e=this._textures.get(u);g.textures=e.textures,g.depthTexture=e.depthTexture,g.width=e.width,g.height=e.height,g.renderTarget=u,g.depth=u.depthBuffer,g.stencil=u.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=TJ.width,g.height=TJ.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=m,g.height>>=m,g.activeCubeFace=p,g.activeMipmapLevel=m,g.occlusionQueryCount=S.occlusionQueryCount,g.scissorValue.max(RJ.set(0,0,0,0)),g.scissorValue.x+g.scissorValue.width>g.width&&(g.scissorValue.width=Math.max(g.width-g.scissorValue.x,0)),g.scissorValue.y+g.scissorValue.height>g.height&&(g.scissorValue.height=Math.max(g.height-g.scissorValue.y,0)),this._background.update(d,S,g),g.camera=t,this.backend.beginRender(g);let{bundles:M,lightsNode:T,transparentDoublePass:C,transparent:A,opaque:N}=S;return M.length>0&&this._renderBundles(M,d,T),!0===this.opaque&&N.length>0&&this._renderObjects(N,t,d,T),!0===this.transparent&&A.length>0&&this._renderTransparents(A,C,t,d,T),this.backend.finishRender(g),s.renderId=a,this._currentRenderContext=n,this._currentRenderObjectFunction=o,this._handleObjectFunction=l,this._currentRenderBundle=h,this.lighting.finishRender(e),this._callDepth--,null!==r&&(this.setRenderTarget(c,p,m),this._renderOutput(u)),d.onAfterRender(this,e,t,u),this.inspector.finishRender(this.backend.getTimestampUID(g)),g}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t,i=this._nodes.getOutputCacheKey(),r=this._quadCache.get(e.texture);if(void 0===r){t=new Oq(new UU),t.name="Output Color Transform",t.material.name="outputColorTransform",t.material.fragmentNode=this._nodes.getOutputNode(e.texture),r={quad:t,cacheKey:i},this._quadCache.set(e.texture,r);let s=()=>{t.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",s)};e.texture.addEventListener("dispose",s)}else t=r.quad,r.cacheKey!==i&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0,r.cacheKey=i);let s=this.autoClear,a=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(t,e),this.autoClear=s,this.xr.enabled=a}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,i=0,r=-1){if(null!==t&&t.isReadbackBuffer&&!1===this.info.memoryMap.has(t)){this.info.createReadbackBuffer(t);let e=()=>{t.removeEventListener("dispose",e),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",e)}if(i%4!=0||r>0&&r%4!=0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,i,r)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,i){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,i)}setSize(e,t,i=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,i)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,i,r){this._canvasTarget.setScissor(e,t,i,r)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,i,r,s=0,a=1){this._canvasTarget.setViewport(e,t,i,r,s,a)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return!0===this.reversedDepthBuffer?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,i=!0){if(!1===this._initialized)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');let r=this._renderTarget||this._getFrameBufferTarget(),s=null;if(null!==r){this._textures.updateRenderTarget(r);let e=this._textures.get(r);s=this._renderContexts.get(r,null,-1),s.textures=e.textures,s.depthTexture=e.depthTexture,s.width=e.width,s.height=e.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer;let t=this.backend.getClearColor();s.clearColorValue.r=t.r,s.clearColorValue.g=t.g,s.clearColorValue.b=t.b,s.clearColorValue.a=t.a,s.clearDepthValue=this.getClearDepth(),s.clearStencilValue=this.getClearStencil(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel(),!0===r.depthBuffer&&(e.depthInitialized=!0)}this.backend.clear(e,t,i,s),null!==r&&null===this._renderTarget&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,i=!0){v('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,i)}async clearColorAsync(){v('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){v('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){v('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==Ct,t=this.currentColorSpace!==ms.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return null!==this._renderTarget?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:Ct}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ms.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){if(!0===this._initialized){this.info.dispose(),this.backend.dispose(),this._compilation.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(let e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{null!==e&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,i=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=i}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(let e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return f("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);let i=this._nodes.nodeFrame,r=i.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let s=this.backend,a=this._pipelines,n=this._bindings,o=this._nodes,l=Array.isArray(e)?e:[e];if(void 0===l[0]||!0!==l[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(let i of l){if(!1===a.has(i)){let e=()=>{i.removeEventListener("dispose",e),a.delete(i),n.deleteForCompute(i),o.delete(i)};i.addEventListener("dispose",e);let t=i.onInitFunction;null!==t&&t.call(i,{renderer:this})}o.updateForCompute(i),n.updateForCompute(i);let r=n.getForCompute(i),l=a.getForCompute(i,r);s.compute(e,i,r,l,t)}s.finishCompute(e),i.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){!1===this._initialized&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return v('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){v('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);let t=this._textures.get(e),i=this._renderContexts.get(e);i.textures=t.textures,i.depthTexture=t.depthTexture,i.width=t.width,i.height=t.height,i.renderTarget=e,i.depth=e.depthBuffer,i.stencil=e.stencilBuffer,this.backend.initRenderTarget(i)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=RJ.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void y("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=RJ.copy(t).floor()}else t=RJ.set(0,0,e.image.width,e.image.height);let i,r=this._currentRenderContext;null!==r?i=r.renderTarget:(i=this._renderTarget||this._getFrameBufferTarget(),null!==i&&(this._textures.updateRenderTarget(i),r=this._textures.get(i))),this._textures.updateTexture(e,{renderTarget:i}),this.backend.copyFramebufferToTexture(e,r,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,i=null,r=null,s=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,i,r,s,a),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,i,r,s,a=0,n=0){return this.backend.copyTextureToBuffer(e.textures[a],t,i,r,s,n)}_projectObject(e,t,i,r,s){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)i=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){let a=t.isArrayCamera?NJ:AJ;if(!e.frustumCulled||a.intersectsSprite(e)){!0===this.sortObjects&&RJ.setFromMatrixPosition(e.matrixWorld).applyMatrix4(PJ);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,i,RJ.z,null,s)}}else if(e.isLineLoop)y("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&!0!==e.isDrawSuppressed){let a=t.isArrayCamera?NJ:AJ;if(!e.frustumCulled||a.intersectsObject(e)){let{geometry:t,material:a}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),RJ.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(PJ)),Array.isArray(a)){let n=t.groups;for(let o=0,l=n.length;o<l;o++){let l=n[o],h=a[l.materialIndex];h&&h.visible&&r.push(e,t,h,i,RJ.z,l,s)}}else a.visible&&r.push(e,t,a,i,RJ.z,null,s)}}if(!0===e.isBundleGroup&&void 0!==this.backend.beginBundle){let a=r;r=this._renderLists.get(e,t);let n=this._bundles.get(e,t,this._currentRenderContext),o=this.backend.get(n);if(this._bundleNeedsUpdate(e,o)){r.begin(),void 0===o.renderObjects?o.renderObjects=[]:o.renderObjects.length=0;let a=e.children;for(let e=0,n=a.length;e<n;e++)this._projectObject(a[e],t,i,r,s);r.finish()}let l=r.lightsArray;for(let e=0,t=l.length;e<t;e++)a.pushLight(l[e]);return void a.pushBundle({bundleGroup:e,camera:t,renderList:r})}let a=e.children;for(let e=0,n=a.length;e<n;e++)this._projectObject(a[e],t,i,r,s)}_renderBundles(e,t,i){for(let r of e)this._renderBundle(r,t,i)}_renderTransparents(e,t,i,r,s){if(t.length>0){for(let{material:e}of t)e.side=We;this._renderObjects(t,i,r,s,"backSide");for(let{material:e}of t)e.side=Ge;this._renderObjects(e,i,r,s);for(let{material:e}of t)e.side=qe}else this._renderObjects(e,i,r,s)}_renderObjects(e,t,i,r,s=null){for(let a=0,n=e.length;a<n;a++){let{object:n,geometry:o,material:l,group:h,clippingContext:u}=e[a];this._currentRenderObjectFunction(n,i,t,o,l,h,r,u,s)}}_getShadowNodes(e){let t=e.version,i=this._cacheShadowNodes.get(e);if(void 0===i||i.version!==t){let r=e.castShadowNode&&e.castShadowNode.isNode,s=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode,a=e.alphaTest>0||!0===this.shadowMap.transmitted||r||s,n=a&&e.map&&e.map.isTexture,o=a&&e.colorNode&&e.colorNode.isNode,l=null,h=null,u=null;if(n||o||r||s){let t,i;if(r?(t=e.castShadowNode.rgb,i=e.castShadowNode.a,!0!==this.shadowMap.transmitted&&v("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(t=BE(0),i=TE(1)),n&&(i=i.mul(JL("map","texture",e).a)),o&&(i=i.mul(e.colorNode.a)),h=LE(t,i),s){let t=e.maskShadowNode||e.maskNode;h=JN(([e])=>(t.not().discard(),e))(h)}}e.depthNode&&e.depthNode.isNode&&(u=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?l=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(l=e.positionNode),i={version:t,colorNode:h,depthNode:u,positionNode:l},this._cacheShadowNodes.set(e,i)}return i}_updateCamera(e){let t=this.xr;if(!1===t.isPresenting){let t=!1;if(!0===this.reversedDepthBuffer&&!0!==e.reversedDepth){if(e._reversedDepth=!0,e.isArrayCamera)for(let t of e.cameras)t._reversedDepth=!0;t=!0}let i=this.coordinateSystem;if(e.coordinateSystem!==i){if(e.coordinateSystem=i,e.isArrayCamera)for(let t of e.cameras)t.coordinateSystem=i;t=!0}if(!0===t&&(e.updateProjectionMatrix(),e.isArrayCamera))for(let t of e.cameras)t.updateProjectionMatrix()}return null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===t.enabled&&!0===t.isPresenting&&(!0===t.cameraAutoUpdate&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,i,r,s,a,n,o=null,l=null){let h,u,d,c,p,m,g,f=!1,y=this._currentSourceMaterial;if(e.onBeforeRender(this,t,i,r,s,a),!0===s.allowOverride&&null!==t.overrideMaterial){this._currentSourceMaterial=s;let e=t.overrideMaterial;if(f=!0,h=e.isNodeMaterial?e.colorNode:null,u=e.isNodeMaterial?e.depthNode:null,d=e.isNodeMaterial?e.positionNode:null,c=t.overrideMaterial.side,p=e.displacementMap,m=e.displacementScale,g=e.displacementBias,s.positionNode&&s.positionNode.isNode&&(e.positionNode=s.positionNode),e.alphaTest=s.alphaTest,e.alphaMap=s.alphaMap,e.displacementMap=s.displacementMap,e.displacementScale=s.displacementScale,e.displacementBias=s.displacementBias,e.transparent=s.transparent||s.transmission>0||s.transmissionNode&&s.transmissionNode.isNode||s.backdropNode&&s.backdropNode.isNode,e.isShadowPassMaterial){let{colorNode:t,depthNode:i,positionNode:r}=this._getShadowNodes(s);this.shadowMap.type===je?e.side=null!==s.shadowSide?s.shadowSide:s.side:e.side=null!==s.shadowSide?s.shadowSide:EJ[s.side],null!==t&&(e.colorNode=t),null!==i&&(e.depthNode=i),null!==r&&(e.positionNode=r)}s=e}!0===s.transparent&&s.side===qe&&!1===s.forceSinglePass?(s.side=We,this._handleObjectFunction(e,s,t,i,n,a,o,"backSide"),s.side=Ge,this._handleObjectFunction(e,s,t,i,n,a,o,l),s.side=qe):this._handleObjectFunction(e,s,t,i,n,a,o,l),f&&(t.overrideMaterial.colorNode=h,t.overrideMaterial.depthNode=u,t.overrideMaterial.positionNode=d,t.overrideMaterial.side=c,t.overrideMaterial.displacementMap=p,t.overrideMaterial.displacementScale=m,t.overrideMaterial.displacementBias=g),this._currentSourceMaterial=y,e.onAfterRender(this,t,i,r,s,a)}hasCompatibility(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,i,r,s,a,n,o){let l=this._objects.get(e,t,i,r,s,this._currentRenderContext,n,o);l.drawRange=e.geometry.drawRange,l.group=a,null!==this._currentRenderBundle&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup);let h=!0===this._asyncCompilation&&!1===this._compilation._updating&&!0!==e.isQuadMesh;if(!0===h){if(!0===this._pipelines.isReady(l)){let e=this.backend.detectAttachmentMismatch(l);if((!0===this.backend.detectStructuralChange(l)||!0===e)&&this._objects.requestPending(l,l.getCacheKey(),!0,o),!0===e)return void this._spNoteSkippedAsyncDraw()}if(!1===this._pipelines.isReady(l))return void this._spNoteSkippedAsyncDraw()}let u=this._nodes.needsRefresh(l)||!0===l._spBindingsFresh;u&&(l._spBindingsFresh=!1,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),!1!==h||(this._pipelines.updateForRender(l),!1!==this._pipelines.isReady(l))?(this.backend.draw(l,this.info),u&&this._nodes.updateAfter(l)):this._spNoteSkippedAsyncDraw()}_spNoteSkippedAsyncDraw(){this._skippedAsyncDraws=(this._skippedAsyncDraws||0)+1,null!==this._currentRenderBundle&&(this.backend.get(this._currentRenderBundle).incompleteRecord=!0)}_createObjectPipeline(e,t,i,r,s,a,n,o){let l=this._objects.get(e,t,i,r,s,this._currentRenderContext,n,o);l.drawRange=e.geometry.drawRange,l.group=a;let h=this._compilation.request(l,o);null!==h&&null!==this._compilationPromises&&this._compilationPromises.push(new Promise(e=>h.onSettled(e)))}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}},BJ=class{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}},VJ=class extends BJ{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return KP(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}},DJ=class extends VJ{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},IJ=0,LJ=class extends DJ{constructor(e,t){super("UniformBuffer_"+IJ++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return KP(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}},zJ=class extends DJ{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){let t=e.index;if(this._addedIndices.has(t))return;let i=this._updateRangeCache.get(t);void 0===i&&(i={start:0,count:0},this._updateRangeCache.set(t,i)),i.start=e.offset,i.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(i)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}clone(){let e=super.clone();return e._buffer=null,e._values=null,e._updateRanges=[],e._updateRangeCache=new Map,e._addedIndices=new Set,e}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let i=0,r=this.uniforms.length;i<r;i++){let r=this.uniforms[i],s=r.boundary,a=r.itemSize*e,n=t%jG,o=n%s,l=n+o;t+=o,0!==l&&jG-l<a&&(t+=jG-l),r.offset=t/e,r.index=i,t+=a}return Math.ceil(t/jG)*jG}update(){let e=!1;for(let t of this.uniforms)!0===this.updateByType(t)&&(e=!0);return e}release(){super.release(),this._values=null}updateByType(e){return e.isNumberUniform?this.updateNumber(e):e.isVector2Uniform?this.updateVector2(e):e.isVector3Uniform?this.updateVector3(e):e.isVector4Uniform?this.updateVector4(e):e.isColorUniform?this.updateColor(e):e.isMatrix3Uniform?this.updateMatrix3(e):e.isMatrix4Uniform?this.updateMatrix4(e):void y("WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset,a=e.getType();return i[s]!==r&&(this._getBufferForType(a)[s]=i[s]=r,t=!0,this.addUniformUpdateRange(e)),t}updateVector2(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset,a=e.getType();if(i[s+0]!==r.x||i[s+1]!==r.y){let n=this._getBufferForType(a);n[s+0]=i[s+0]=r.x,n[s+1]=i[s+1]=r.y,t=!0,this.addUniformUpdateRange(e)}return t}updateVector3(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset,a=e.getType();if(i[s+0]!==r.x||i[s+1]!==r.y||i[s+2]!==r.z){let n=this._getBufferForType(a);n[s+0]=i[s+0]=r.x,n[s+1]=i[s+1]=r.y,n[s+2]=i[s+2]=r.z,t=!0,this.addUniformUpdateRange(e)}return t}updateVector4(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset,a=e.getType();if(i[s+0]!==r.x||i[s+1]!==r.y||i[s+2]!==r.z||i[s+3]!==r.w){let n=this._getBufferForType(a);n[s+0]=i[s+0]=r.x,n[s+1]=i[s+1]=r.y,n[s+2]=i[s+2]=r.z,n[s+3]=i[s+3]=r.w,t=!0,this.addUniformUpdateRange(e)}return t}updateColor(e){let t=!1,i=this.values,r=e.getValue(),s=e.offset;if(i[s+0]!==r.r||i[s+1]!==r.g||i[s+2]!==r.b){let a=this.buffer;a[s+0]=i[s+0]=r.r,a[s+1]=i[s+1]=r.g,a[s+2]=i[s+2]=r.b,t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix3(e){let t=!1,i=this.values,r=e.getValue().elements,s=e.offset;if(i[s+0]!==r[0]||i[s+1]!==r[1]||i[s+2]!==r[2]||i[s+4]!==r[3]||i[s+5]!==r[4]||i[s+6]!==r[5]||i[s+8]!==r[6]||i[s+9]!==r[7]||i[s+10]!==r[8]){let a=this.buffer;a[s+0]=i[s+0]=r[0],a[s+1]=i[s+1]=r[1],a[s+2]=i[s+2]=r[2],a[s+4]=i[s+4]=r[3],a[s+5]=i[s+5]=r[4],a[s+6]=i[s+6]=r[5],a[s+8]=i[s+8]=r[6],a[s+9]=i[s+9]=r[7],a[s+10]=i[s+10]=r[8],t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix4(e){let t=!1,i=this.values,r=e.getValue().elements,s=e.offset;return!1===function(e,t,i){for(let r=0,s=t.length;r<s;r++)if(e[i+r]!==t[r])return!1;return!0}(i,r,s)&&(this.buffer.set(r,s),function(e,t,i){for(let r=0,s=t.length;r<s;r++)e[i+r]=t[r]}(i,r,s),t=!0,this.addUniformUpdateRange(e)),t}_getBufferForType(e){return"int"===e||"ivec2"===e||"ivec3"===e||"ivec4"===e?new Int32Array(this.buffer.buffer):"uint"===e||"uvec2"===e||"uvec3"===e||"uvec4"===e?new Uint32Array(this.buffer.buffer):this.buffer}},kJ=0,UJ=class extends zJ{constructor(e,t){super(e),this.id=kJ++,this.groupNode=t,this.isNodeUniformsGroup=!0}},FJ=class extends BJ{constructor(e,t){super(e),this._texture=t,this.version=-1,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture=e,this.reset())}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}reset(){this.generation=null,this.version=-1}release(){this._texture=null}},jJ=0,GJ=class extends FJ{constructor(e,t){super(e,t),this.id=jJ++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}},WJ=null,qJ=class extends GJ{constructor(e,t,i,r=null){super(e,(t?t.value:null)||ZP()),this.textureNode=t,this.groupNode=i,this.access=r}update(){let{textureNode:e}=this,t=e.value;if(null==t){if(null!==this.texture&&void 0!==this.texture)return!1;t=ZP()}return this.texture!==t?(this.texture=t,!0):super.update()}},HJ=class extends qJ{constructor(e,t,i,r=null){super(e,t,i,r),this.isSampledCubeTexture=!0}},$J=class extends qJ{constructor(e,t,i,r=null){super(e,t,i,r),this.isSampledTexture3D=!0}},new WH("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),new WH("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }"),new WH("\nvec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset, bool flipY ) {\n\tif ( flipY ) offset.y = - offset.y;\n\tvec2 size = vec2( textureSize( map, 0 ) );\n\tvec2 st = floor( coord * size + vec2( offset ) - 0.5 );\n\tvec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;\n\tvec4 ret = vec4(\n\t\ttextureLod( map, ij.xw, 0.0 )[ comp ],\n\t\ttextureLod( map, ij.zw, 0.0 )[ comp ],\n\t\ttextureLod( map, ij.zy, 0.0 )[ comp ],\n\t\ttextureLod( map, ij.xy, 0.0 )[ comp ]\n\t);\n\treturn flipY ? ret.wzyx : ret;\n}\n"),new WH("\nvec4 tsl_textureGather_array( const int comp, sampler2DArray map, vec3 coord, ivec2 offset, bool flipY ) {\n\tif ( flipY ) offset.y = - offset.y;\n\tvec2 size = vec2( textureSize( map, 0 ).xy );\n\tvec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );\n\tvec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;\n\tvec4 ret = vec4(\n\t\ttextureLod( map, vec3( ij.xw, coord.z ), 0.0 )[ comp ],\n\t\ttextureLod( map, vec3( ij.zw, coord.z ), 0.0 )[ comp ],\n\t\ttextureLod( map, vec3( ij.zy, coord.z ), 0.0 )[ comp ],\n\t\ttextureLod( map, vec3( ij.xy, coord.z ), 0.0 )[ comp ]\n\t);\n\treturn flipY ? ret.wzyx : ret;\n}\n"),new WH("\nvec4 tsl_textureGatherCompare( sampler2DShadow map, vec2 coord, ivec2 offset, float ref, bool flipY ) {\n\tif ( flipY ) offset.y = - offset.y;\n\tvec2 size = vec2( textureSize( map, 0 ) );\n\tvec2 st = floor( coord * size + vec2( offset ) - 0.5 );\n\tvec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;\n\tvec4 ret = vec4(\n\t\ttextureLod( map, vec3( ij.xw, ref ), 0.0 ),\n\t\ttextureLod( map, vec3( ij.zw, ref ), 0.0 ),\n\t\ttextureLod( map, vec3( ij.zy, ref ), 0.0 ),\n\t\ttextureLod( map, vec3( ij.xy, ref ), 0.0 )\n\t);\n\treturn flipY ? ret.wzyx : ret;\n}\n"),new WH("\nvec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2 offset, float ref, bool flipY ) {\n\tif ( flipY ) offset.y = - offset.y;\n\tvec2 size = vec2( textureSize( map, 0 ).xy );\n\tvec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );\n\tvec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;\n\tvec4 ret = vec4(\n\t\ttexture( map, vec4( ij.xw, coord.z, ref ) ),\n\t\ttexture( map, vec4( ij.zw, coord.z, ref ) ),\n\t\ttexture( map, vec4( ij.zy, coord.z, ref ) ),\n\t\ttexture( map, vec4( ij.xy, coord.z, ref ) )\n\t);\n\treturn flipY ? ret.wzyx : ret;\n}\n"),YJ=null,XJ=null,KJ=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Wr.RENDER]:null,[Wr.COMPUTE]:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}syncRenderUpdateState(){}detectStructuralChange(){return!1}getAttachmentStateKey(){return""}detectAttachmentMismatch(e){let t=this.get(e).compiledAttachmentKey;return void 0!==t&&t!==this.getAttachmentStateKey(e)}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t,i=this.get(e),r=this.renderer.info.frame;t=!0===e.isComputeNode?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls,i.timestampUID=t+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith("c:")?Wr.COMPUTE:Wr.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void v("WebGPURenderer: Timestamp tracking is disabled.");let t=this.timestampQueryPool[e];if(!t)return;let i=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=i,i}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return YJ=YJ||new rs,this.renderer.getDrawingBufferSize(YJ)}setScissorTest(){}getClearColor(){let e=this.renderer;return XJ=XJ||new hW,e.getClearColor(XJ),XJ.getRGB(XJ),XJ}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:function(){let e=p("canvas");return e.style.display="block",e}(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Le} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}},ZJ=class{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return void 0===t&&(f(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestampQuery(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}},JJ={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list"},QJ=typeof self<"u"&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},eQ={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},tQ={Store:"store"},iQ={Load:"load",Clear:"clear"},rQ={CCW:"ccw",CW:"cw"},sQ={None:"none",Back:"back"},aQ={Uint16:"uint16",Uint32:"uint32"},nQ={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R16Unorm:"r16unorm",R16Snorm:"r16snorm",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RG16Unorm:"rg16unorm",RG16Snorm:"rg16snorm",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA16Unorm:"rgba16unorm",RGBA16Snorm:"rgba16snorm",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},oQ={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},lQ={Linear:"linear",Nearest:"nearest"},hQ={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},uQ={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},dQ={None:0,All:15},cQ={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},pQ={Storage:"storage",ReadOnlyStorage:"read-only-storage"},mQ={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},gQ={NonFiltering:"non-filtering",Comparison:"comparison"},fQ={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},yQ={TwoD:"2d",ThreeD:"3d"},vQ={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},bQ={All:"all"},xQ={Vertex:"vertex",Instance:"instance"},wQ={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},_Q={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"},SQ=class extends FJ{constructor(e,t,i){super(e,(t?t.value:null)||ZP()),this.textureNode=t,this.groupNode=i}update(){let{textureNode:e}=this,t=e.value;if(null==t){if(null!==this.texture&&void 0!==this.texture)return!1;t=ZP()}return this.texture!==t?(this.texture=t,!0):super.update()}},MQ=class extends VJ{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}},TQ=0,CQ=class extends MQ{constructor(e,t){super("StorageBuffer_"+TQ++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:fR.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}},AQ=[null],NQ=class{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=null!==e.depthTexture?this.getTextureFormatGPU(e.depthTexture):e.stencil?!0===this.backend.renderer.reversedDepthBuffer?nQ.Depth32FloatStencil8:nQ.Depth24PlusStencil8:!0===this.backend.renderer.reversedDepthBuffer?nQ.Depth32Float:nQ.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,i=e.getRenderTarget();t=i?i.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);let i=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:i?1:t,isMSAA:i}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return null!==e.textures?e.textures.map(e=>this.getTextureFormatGPU(e)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?JJ.PointList:e.isLineSegments||e.isMesh&&!0===t.wireframe?JJ.LineList:e.isLine?JJ.LineStrip:e.isMesh?JJ.TriangleList:void 0}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(void 0===e)return null===this._preferredCanvasFormat&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(e===Xt)return nQ.BGRA8Unorm;if(e===ii)return nQ.RGBA16Float;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}},PQ=class{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}},RQ=class{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}},EQ=class{constructor(){this.label=""}reset(){this.label=""}},OQ=class{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}},BQ=class{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}},VQ=class{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}},DQ=class{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new IQ,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}},IQ=class{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}},LQ=class{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}},zQ=class{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}},kQ=class{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=void 0}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle=void 0}},UQ=new PQ,FQ=new RQ,jQ=new EQ,GQ=new OQ,WQ=new VQ,qQ=new DQ,HQ=new BQ,$Q=new LQ,YQ=new zQ,XQ=new kQ,KQ=class extends UG{constructor(e){super(),this.device=e,this.mipmapSampler=e.createSampler({minFilter:lQ.Linear}),this.flipYSampler=e.createSampler({minFilter:lQ.Nearest}),FQ.size=4,FQ.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(FQ),FQ.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),FQ.size=4,FQ.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(FQ),FQ.reset(),this.transferPipelines={},$Q.label="mipmap",$Q.code="\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4f,\n\t@location( 0 ) vTex : vec2f,\n\t@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,\n};\n\n@group( 0 ) @binding ( 2 )\nvar<uniform> flipY: u32;\n\n@vertex\nfn mainVS(\n\t\t@builtin( vertex_index ) vertexIndex : u32,\n\t\t@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array(\n\t\tvec2f( -1, -1 ),\n\t\tvec2f( -1, 3 ),\n\t\tvec2f( 3, -1 ),\n\t);\n\n\tlet p = pos[ vertexIndex ];\n\tlet mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );\n\tVarys.vTex = p * mult + vec2f( 0.5 );\n\tVarys.Position = vec4f( p, 0, 1 );\n\tVarys.vBaseArrayLayer = instanceIndex;\n\n\treturn Varys;\n\n}\n\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img2d : texture_2d<f32>;\n\n@fragment\nfn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {\n\n\treturn textureSample( img2d, imgSampler, Varys.vTex );\n\n}\n\n@group( 0 ) @binding( 1 )\nvar img2dArray : texture_2d_array<f32>;\n\n@fragment\nfn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {\n\n\treturn textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );\n\n}\n\nconst faceMat = array(\n mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), \n mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), \n mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), \n mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), \n mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), \n mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), \n);\n\n@group( 0 ) @binding( 1 )\nvar imgCube : texture_cube<f32>;\n\n@fragment\nfn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {\n\n\treturn textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );\n\n}\n",this.mipmapShaderModule=e.createShaderModule($Q),$Q.reset()}getTransferPipeline(e,t){let i=`${e}-${t=t||"2d-array"}`,r=this.transferPipelines[i];return void 0===r&&(qQ.label=`mipmap-${e}-${t}`,qQ.vertex={module:this.mipmapShaderModule},qQ.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},qQ.layout="auto",r=this.device.createRenderPipeline(qQ),qQ.reset(),this.transferPipelines[i]=r),r}flipY(e,t,i=0){let r=t.format,{width:s,height:a}=t.size;YQ.size.width=s,YQ.size.height=a,YQ.format=r,YQ.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;let n=this.device.createTexture(YQ);YQ.reset();let o=this.getTransferPipeline(r,e.textureBindingViewDimension),l=this.getTransferPipeline(r,n.textureBindingViewDimension),h=this.device.createCommandEncoder(jQ),u=(e,t,i,r,s,a)=>{let n=e.getBindGroupLayout(0);XQ.dimension=t.textureBindingViewDimension||"2d-array",XQ.mipLevelCount=1;let o=t.createView(XQ);XQ.reset(),UQ.layout=n,UQ.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:o},{binding:2,resource:{buffer:a?this.flipUniformBuffer:this.noFlipUniformBuffer}});let l=this.device.createBindGroup(UQ);UQ.reset(),XQ.dimension="2d",XQ.mipLevelCount=1,XQ.baseArrayLayer=s,XQ.arrayLayerCount=1;let u=r.createView(XQ);XQ.reset(),HQ.view=u,HQ.loadOp=iQ.Clear,HQ.storeOp=tQ.Store,WQ.colorAttachments.push(HQ);let d=h.beginRenderPass(WQ);WQ.reset(),HQ.reset(),d.setPipeline(e),d.setBindGroup(0,l),d.draw(3,1,0,i),d.end()};u(o,e,i,n,0,!1),u(l,n,0,e,i,!0),JP(this.device,h.finish()),n.destroy()}generateMipmaps(e,t=null){let i=this.get(e),r=i.layers||this._mipmapCreateBundles(e),s=t;null===s&&(jQ.label="mipmapEncoder",s=this.device.createCommandEncoder(jQ),jQ.reset()),this._mipmapRunBundles(s,r),null===t&&JP(this.device,s.finish()),i.layers=r}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||"2d-array",i=this.getTransferPipeline(e.format,t),r=i.getBindGroupLayout(0),s=[];for(let a=1;a<e.mipLevelCount;a++)for(let n=0;n<e.depthOrArrayLayers;n++){XQ.dimension=t,XQ.baseMipLevel=a-1,XQ.mipLevelCount=1;let o=e.createView(XQ);XQ.reset(),UQ.layout=r,UQ.entries.push({binding:0,resource:this.mipmapSampler},{binding:1,resource:o},{binding:2,resource:{buffer:this.noFlipUniformBuffer}});let l=this.device.createBindGroup(UQ);UQ.reset(),XQ.dimension="2d",XQ.baseMipLevel=a,XQ.mipLevelCount=1,XQ.baseArrayLayer=n,XQ.arrayLayerCount=1;let h=e.createView(XQ);XQ.reset();let u=new BQ;u.view=h,u.loadOp=iQ.Clear,u.storeOp=tQ.Store;let d=new VQ;d.colorAttachments.push(u),GQ.colorFormats=[e.format];let c=this.device.createRenderBundleEncoder(GQ);GQ.reset(),c.setPipeline(i),c.setBindGroup(0,l),c.draw(3,1,0,n),s.push({renderBundles:[c.finish()],passDescriptor:d})}return s}_mipmapRunBundles(e,t){let i=t.length;for(let r=0;r<i;r++){let i=t[r],s=e.beginRenderPass(i.passDescriptor);s.executeBundles(i.renderBundles),s.end()}}},ZQ=class{constructor(){this.label="",this.addressModeU="clamp-to-edge",this.addressModeV="clamp-to-edge",this.addressModeW="clamp-to-edge",this.magFilter="nearest",this.minFilter="nearest",this.mipmapFilter="nearest",this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}reset(){this.label="",this.addressModeU="clamp-to-edge",this.addressModeV="clamp-to-edge",this.addressModeW="clamp-to-edge",this.magFilter="nearest",this.minFilter="nearest",this.mipmapFilter="nearest",this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}},JQ=class{constructor(){this.texture=null,this.mipLevel=0,this.origin={x:0,y:0,z:0},this.aspect="all"}reset(){this.texture=null,this.mipLevel=0,this.origin.x=0,this.origin.y=0,this.origin.z=0,this.aspect="all"}},QQ=class{constructor(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}},e0=class{constructor(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}},t0=class{constructor(){this.source=null,this.origin={x:0,y:0},this.flipY=!1}reset(){this.source=null,this.origin.x=0,this.origin.y=0,this.flipY=!1}},i0=class extends JQ{constructor(){super(),this.colorSpace="srgb",this.premultipliedAlpha=!1}reset(){super.reset(),this.colorSpace="srgb",this.premultipliedAlpha=!1}},r0=class{constructor(){this.width=0,this.height=1,this.depthOrArrayLayers=1}reset(){this.width=0,this.height=1,this.depthOrArrayLayers=1}},s0=new RQ,a0=new EQ,n0=new ZQ,o0=new JQ,l0=new QQ,h0=new e0,u0=new t0,d0=new i0,c0=new zQ,p0=new r0,m0={[Or]:"never",[Br]:"less",[Vr]:"equal",[Dr]:"less-equal",[Ir]:"greater",[zr]:"greater-equal",[kr]:"always",[Lr]:"not-equal"},g0=[0,1,3,2,4,5],f0=class{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){let t=this.backend,i=e.texture;null==i&&(i=e.textureNode&&e.textureNode.value||ZP(),e.texture=i),e.textureNode;let r=i.minFilter+"-"+i.magFilter+"-"+i.wrapS+"-"+i.wrapT+"-"+(i.wrapR||"0")+"-"+i.anisotropy+"-"+(!0===i.isDepthTexture?1:0)+"-"+(null!==i.compareFunction?i.compareFunction:0),s=this._samplerCache.get(r);if(void 0===s){n0.addressModeU=this._convertAddressMode(i.wrapS),n0.addressModeV=this._convertAddressMode(i.wrapT),n0.addressModeW=this._convertAddressMode(i.wrapR),n0.magFilter=this._convertFilterMode(i.magFilter),n0.minFilter=this._convertFilterMode(i.minFilter),n0.mipmapFilter=this._convertMipmapFilterMode(i.minFilter),i.isDepthTexture&&null===i.compareFunction&&(n0.magFilter=lQ.Nearest,n0.minFilter=lQ.Nearest,n0.mipmapFilter=lQ.Nearest),n0.magFilter===lQ.Linear&&n0.minFilter===lQ.Linear&&n0.mipmapFilter===lQ.Linear&&(n0.maxAnisotropy=i.anisotropy),i.isDepthTexture&&null!==i.compareFunction&&t.hasCompatibility(qr.TEXTURE_COMPARE)&&(n0.compare=m0[i.compareFunction]);let e=t.device.createSampler(n0);n0.reset(),s={sampler:e,usedTimes:0},this._samplerCache.set(r,s)}let a=t.get(e);return a.sampler!==s.sampler&&(this._releaseSampler(a),a.samplerKey=r,a.sampler=s.sampler,s.usedTimes++),r}destroySampler(e){this._releaseSampler(this.backend.get(e))}_releaseSampler(e){if(void 0!==e.sampler){let t=this._samplerCache.get(e.samplerKey);t.usedTimes--,0===t.usedTimes&&this._samplerCache.delete(e.samplerKey),e.sampler=void 0,e.samplerKey=void 0}}createDefaultTexture(e){let t,i=eR(e,this.backend.device);t=e.isCubeTexture?this._getDefaultCubeTextureGPU(i):this._getDefaultTextureGPU(i),this.backend.get(e).texture=t}createTexture(e,t={}){let i=this.backend,r=i.get(e);if(r.initialized){if(!0===r.externalTexture)return;throw new Error("THREE.WebGPUTextureUtils: Texture already initialized.")}if(e.isExternalTexture)return r.texture=e.sourceTexture,void(r.initialized=!0);void 0===t.needsMipmaps&&(t.needsMipmaps=!1),void 0===t.levels&&(t.levels=1),void 0===t.depth&&(t.depth=1);let{width:s,height:a,depth:n,levels:o}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());let l=this._getDimension(e),h=e.internalFormat||t.format||eR(e,i.device);r.format=h;let{samples:u,primarySamples:d,isMSAA:c}=i.utils.getTextureSampleData(e),p=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;!0===e.isStorageTexture&&(p|=GPUTextureUsage.STORAGE_BINDING),!0!==e.isCompressedTexture&&!0!==e.isCompressedArrayTexture&&h!==nQ.RGB9E5UFloat&&!0!==e.is3DTexture&&!0!==e.isData3DTexture&&(p|=GPUTextureUsage.RENDER_ATTACHMENT);let m=new zQ;if(m.label=e.name,m.size.width=s,m.size.height=a,m.size.depthOrArrayLayers=n,m.mipLevelCount=o,m.sampleCount=d,m.dimension=l,m.format=h,m.usage=p,void 0===h)return f("WebGPURenderer: Texture format not supported."),void this.createDefaultTexture(e);e.isCubeTexture&&(m.textureBindingViewDimension=vQ.Cube);try{r.texture=i.device.createTexture(m)}catch{return f("WebGPURenderer: Failed to create texture with descriptor:",m),void this.createDefaultTexture(e)}if(c){let e=Object.assign({},m);e.label=e.label+"-msaa",e.sampleCount=u,e.mipLevelCount=1,r.msaaTexture=i.device.createTexture(e)}r.initialized=!0,r.textureDescriptorGPU=m}destroyTexture(e,t=!1){let i=this.backend,r=i.get(e);void 0!==r.texture&&!1===t&&!0!==e.isExternalTexture&&r.texture.destroy(),void 0!==r.msaaTexture&&r.msaaTexture.destroy(),i.delete(e)}generateMipmaps(e,t=null){let i=this.backend.get(e);this._generateMipmaps(i.texture,t)}getColorBuffer(){let e=this.backend,t=e.renderer.getCanvasTarget(),{width:i,height:r}=e.getDrawingBufferSize(),s=e.renderer.currentSamples,a=t.colorTexture,n=e.get(a);if(a.width===i&&a.height===r&&a.samples===s)return n.texture;let o=n.texture;return o&&o.destroy(),c0.label="colorBuffer",c0.size.width=i,c0.size.height=r,c0.sampleCount=e.utils.getSampleCount(e.renderer.currentSamples),c0.format=e.utils.getPreferredCanvasFormat(),c0.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,o=e.device.createTexture(c0),c0.reset(),a.source.width=i,a.source.height=r,a.samples=s,n.texture=o,o}getDepthBuffer(e=!0,t=!1){let i=this.backend,r=i.renderer.getCanvasTarget(),{width:s,height:a}=i.getDrawingBufferSize(),n=i.renderer.currentSamples,o=r.depthTexture;if(o.width===s&&o.height===a&&o.samples===n&&o.depth===e&&o.stencil===t)return i.get(o).texture;let l,h,u=i.get(o).texture;if(t?(l=ci,h=!0===i.renderer.reversedDepthBuffer?ti:ai):e&&(l=di,h=!0===i.renderer.reversedDepthBuffer?ti:ei),void 0!==u){if(o.image.width===s&&o.image.height===a&&o.format===l&&o.type===h&&o.samples===n)return u;this.destroyTexture(o)}return o.name="depthBuffer",o.format=l,o.type=h,o.image.width=s,o.image.height=a,o.samples=n,this.createTexture(o,{width:s,height:a}),i.get(o).texture}updateTexture(e,t){let i=this.backend.get(e),r=e.mipmaps,{textureDescriptorGPU:s}=i;if(!e.isRenderTargetTexture&&void 0!==s){if(e.isDataTexture)if(r.length>0)for(let t=0,a=r.length;t<a;t++){let a=r[t];this._copyBufferToTexture(a,i.texture,s,0,e.flipY,0,t)}else this._copyBufferToTexture(t.image,i.texture,s,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)if(e.layerUpdates&&e.layerUpdates.size>0){for(let r of e.layerUpdates)this._copyBufferToTexture(t.image,i.texture,s,r,e.flipY,r);e.clearLayerUpdates()}else for(let r=0;r<t.image.depth;r++)this._copyBufferToTexture(t.image,i.texture,s,r,e.flipY,r);else if(e.isCompressedTexture||e.isCompressedArrayTexture)e.isCompressedArrayTexture&&e.layerUpdates.size>0?(this._copyCompressedBufferToTexture(e.mipmaps,i.texture,s,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,i.texture,s);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,i.texture,s);else if(e.isHTMLTexture){let t=this.backend.device,r=this.backend.renderer.domElement,a=e.image;if("function"!=typeof t.queue.copyElementImageToTexture)return;if(!i.hasPaintCallback)return i.hasPaintCallback=!0,void r.requestPaint();let n=s.size.width,o=s.size.height;2===t.queue.copyElementImageToTexture.length?t.queue.copyElementImageToTexture({source:a},{destination:{texture:i.texture},width:n,height:o}):t.queue.copyElementImageToTexture(a,n,o,{texture:i.texture}),e.flipY&&this._flipY(i.texture,s)}else if(r.length>0)for(let t=0,a=r.length;t<a;t++){let a=r[t];this._copyImageToTexture(a,i.texture,s,0,e.flipY,e.premultiplyAlpha,t)}else this._copyImageToTexture(t.image,i.texture,s,0,e.flipY,e.premultiplyAlpha);i.version=e.version}}async copyTextureToBuffer(e,t,i,r,s,a){let n=this.backend.device,o=this.backend.get(e),l=o.texture,h=o.textureDescriptorGPU.format,u=this._getBytesPerTexel(h),d=r*u;d=256*Math.ceil(d/256),s0.size=(s-1)*d+r*u,s0.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let c=n.createBuffer(s0);s0.reset();let p=n.createCommandEncoder(a0);o0.texture=l,o0.origin.x=t,o0.origin.y=i,o0.origin.z=a,l0.buffer=c,l0.bytesPerRow=d,p0.width=r,p0.height=s,p.copyTextureToBuffer(o0,l0,p0),o0.reset(),l0.reset(),p0.reset();let m=this._getTypedArrayType(h);JP(n,p.finish()),await c.mapAsync(GPUMapMode.READ);let g=c.getMappedRange().slice();return c.destroy(),new m(g)}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(void 0===t){let i=new ws;i.minFilter=jt,i.magFilter=jt,this.createTexture(i,{width:1,height:1,format:e}),this.defaultTexture[e]=t=i}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(void 0===t){let i=new Bo;i.minFilter=jt,i.magFilter=jt,this.createTexture(i,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=i}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,i){let r=e.images,s=e.mipmaps;for(let a=0;a<6;a++){let n=r[a],o=!0===e.flipY?g0[a]:a;n.isDataTexture?this._copyBufferToTexture(n.image,t,i,o,e.flipY):this._copyImageToTexture(n,t,i,o,e.flipY,e.premultiplyAlpha);for(let r=0;r<s.length;r++){let n=s[r].images[a];n.isDataTexture?this._copyBufferToTexture(n.image,t,i,o,e.flipY,0,r+1):this._copyImageToTexture(n,t,i,o,e.flipY,e.premultiplyAlpha,r+1)}}}_copyImageToTexture(e,t,i,r,s,a,n=0){let o=this.backend.device,l=n>0?e.width:i.size.width,h=n>0?e.height:i.size.height;u0.source=e,u0.flipY=s,d0.texture=t,d0.mipLevel=n,d0.origin.z=r,d0.premultipliedAlpha=a,p0.width=l,p0.height=h;try{o.queue.copyExternalImageToTexture(u0,d0,p0)}catch{}finally{u0.reset(),d0.reset(),p0.reset()}}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new KQ(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,i=0){this._getPassUtils().flipY(e,t,i)}_copyBufferToTexture(e,t,i,r,s,a=0,n=0){let o=this.backend.device,l=e.data,h=this._getBytesPerTexel(i.format),u=e.width*h;o0.texture=t,o0.mipLevel=n,o0.origin.z=r,h0.offset=e.width*e.height*h*a,h0.bytesPerRow=u,p0.width=e.width,p0.height=e.height,o.queue.writeTexture(o0,l,h0,p0),o0.reset(),h0.reset(),p0.reset(),!0===s&&this._flipY(t,i,r)}_copyCompressedBufferToTexture(e,t,i,r=null){let s=this.backend.device,a=this._getBlockData(i.format),n=i.size.depthOrArrayLayers>1,o=r&&r.size>0?r:null;for(let r=0;r<e.length;r++){let l=e[r],h=l.width,u=l.height,d=n?i.size.depthOrArrayLayers:1,c=Math.ceil(h/a.width)*a.byteLength,p=Math.ceil(u/a.height),m=c*p,g=Math.ceil(h/a.width)*a.width,f=p*a.height;if(null!==o)for(let e of o)QP(s,t,r,e,l,m,c,p,g,f);else for(let e=0;e<d;e++)QP(s,t,r,e,l,m,c,p,g,f)}}_getBlockData(e){return e===nQ.BC1RGBAUnorm||e===nQ.BC1RGBAUnormSRGB?{byteLength:8,width:4,height:4}:e===nQ.BC2RGBAUnorm||e===nQ.BC2RGBAUnormSRGB||e===nQ.BC3RGBAUnorm||e===nQ.BC3RGBAUnormSRGB?{byteLength:16,width:4,height:4}:e===nQ.BC4RUnorm||e===nQ.BC4RSnorm?{byteLength:8,width:4,height:4}:e===nQ.BC5RGUnorm||e===nQ.BC5RGSnorm||e===nQ.BC6HRGBUFloat||e===nQ.BC6HRGBFloat||e===nQ.BC7RGBAUnorm||e===nQ.BC7RGBAUnormSRGB?{byteLength:16,width:4,height:4}:e===nQ.ETC2RGB8Unorm||e===nQ.ETC2RGB8UnormSRGB||e===nQ.ETC2RGB8A1Unorm||e===nQ.ETC2RGB8A1UnormSRGB?{byteLength:8,width:4,height:4}:e===nQ.ETC2RGBA8Unorm||e===nQ.ETC2RGBA8UnormSRGB?{byteLength:16,width:4,height:4}:e===nQ.EACR11Unorm||e===nQ.EACR11Snorm?{byteLength:8,width:4,height:4}:e===nQ.EACRG11Unorm||e===nQ.EACRG11Snorm||e===nQ.ASTC4x4Unorm||e===nQ.ASTC4x4UnormSRGB?{byteLength:16,width:4,height:4}:e===nQ.ASTC5x4Unorm||e===nQ.ASTC5x4UnormSRGB?{byteLength:16,width:5,height:4}:e===nQ.ASTC5x5Unorm||e===nQ.ASTC5x5UnormSRGB?{byteLength:16,width:5,height:5}:e===nQ.ASTC6x5Unorm||e===nQ.ASTC6x5UnormSRGB?{byteLength:16,width:6,height:5}:e===nQ.ASTC6x6Unorm||e===nQ.ASTC6x6UnormSRGB?{byteLength:16,width:6,height:6}:e===nQ.ASTC8x5Unorm||e===nQ.ASTC8x5UnormSRGB?{byteLength:16,width:8,height:5}:e===nQ.ASTC8x6Unorm||e===nQ.ASTC8x6UnormSRGB?{byteLength:16,width:8,height:6}:e===nQ.ASTC8x8Unorm||e===nQ.ASTC8x8UnormSRGB?{byteLength:16,width:8,height:8}:e===nQ.ASTC10x5Unorm||e===nQ.ASTC10x5UnormSRGB?{byteLength:16,width:10,height:5}:e===nQ.ASTC10x6Unorm||e===nQ.ASTC10x6UnormSRGB?{byteLength:16,width:10,height:6}:e===nQ.ASTC10x8Unorm||e===nQ.ASTC10x8UnormSRGB?{byteLength:16,width:10,height:8}:e===nQ.ASTC10x10Unorm||e===nQ.ASTC10x10UnormSRGB?{byteLength:16,width:10,height:10}:e===nQ.ASTC12x10Unorm||e===nQ.ASTC12x10UnormSRGB?{byteLength:16,width:12,height:10}:e===nQ.ASTC12x12Unorm||e===nQ.ASTC12x12UnormSRGB?{byteLength:16,width:12,height:12}:void 0}_convertAddressMode(e){let t=oQ.ClampToEdge;return e===kt?t=oQ.Repeat:e===Ft&&(t=oQ.MirrorRepeat),t}_convertFilterMode(e){let t=lQ.Linear;return(e===jt||e===Gt||e===Wt)&&(t=lQ.Nearest),t}_convertMipmapFilterMode(e){return e===Wt||e===$t?lQ.Linear:lQ.Nearest}_getBytesPerTexel(e){return e===nQ.R8Unorm||e===nQ.R8Snorm||e===nQ.R8Uint||e===nQ.R8Sint?1:e===nQ.R16Uint||e===nQ.R16Sint||e===nQ.R16Float||e===nQ.RG8Unorm||e===nQ.RG8Snorm||e===nQ.RG8Uint||e===nQ.RG8Sint||e===nQ.R16Unorm||e===nQ.R16Snorm?2:e===nQ.R32Uint||e===nQ.R32Sint||e===nQ.R32Float||e===nQ.RG16Uint||e===nQ.RG16Sint||e===nQ.RG16Float||e===nQ.RGBA8Unorm||e===nQ.RGBA8UnormSRGB||e===nQ.RGBA8Snorm||e===nQ.RGBA8Uint||e===nQ.RGBA8Sint||e===nQ.BGRA8Unorm||e===nQ.BGRA8UnormSRGB||e===nQ.RG16Unorm||e===nQ.RG16Snorm||e===nQ.RGB9E5UFloat||e===nQ.RGB10A2Unorm||e===nQ.RG11B10UFloat||e===nQ.Depth32Float||e===nQ.Depth24Plus||e===nQ.Depth24PlusStencil8||e===nQ.Depth32FloatStencil8?4:e===nQ.RG32Uint||e===nQ.RG32Sint||e===nQ.RG32Float||e===nQ.RGBA16Uint||e===nQ.RGBA16Sint||e===nQ.RGBA16Float||e===nQ.RGBA16Unorm||e===nQ.RGBA16Snorm?8:e===nQ.RGBA32Uint||e===nQ.RGBA32Sint||e===nQ.RGBA32Float?16:void 0}_getTypedArrayType(e){return e===nQ.R8Uint?Uint8Array:e===nQ.R8Sint?Int8Array:e===nQ.R8Unorm?Uint8Array:e===nQ.R8Snorm?Int8Array:e===nQ.RG8Uint?Uint8Array:e===nQ.RG8Sint?Int8Array:e===nQ.RG8Unorm?Uint8Array:e===nQ.RG8Snorm?Int8Array:e===nQ.RGBA8Uint?Uint8Array:e===nQ.RGBA8Sint?Int8Array:e===nQ.RGBA8Unorm||e===nQ.RGBA8UnormSRGB?Uint8Array:e===nQ.RGBA8Snorm?Int8Array:e===nQ.R16Uint?Uint16Array:e===nQ.R16Sint?Int16Array:e===nQ.RG16Uint?Uint16Array:e===nQ.RG16Sint?Int16Array:e===nQ.RGBA16Uint?Uint16Array:e===nQ.RGBA16Sint?Int16Array:e===nQ.R16Float||e===nQ.RG16Float||e===nQ.RGBA16Float||e===nQ.R16Unorm?Uint16Array:e===nQ.R16Snorm?Int16Array:e===nQ.RG16Unorm?Uint16Array:e===nQ.RG16Snorm?Int16Array:e===nQ.RGBA16Unorm?Uint16Array:e===nQ.RGBA16Snorm?Int16Array:e===nQ.R32Uint?Uint32Array:e===nQ.R32Sint?Int32Array:e===nQ.R32Float?Float32Array:e===nQ.RG32Uint?Uint32Array:e===nQ.RG32Sint?Int32Array:e===nQ.RG32Float?Float32Array:e===nQ.RGBA32Uint?Uint32Array:e===nQ.RGBA32Sint?Int32Array:e===nQ.RGBA32Float?Float32Array:e===nQ.BGRA8Unorm||e===nQ.BGRA8UnormSRGB?Uint8Array:e===nQ.RGB10A2Unorm||e===nQ.RGB9E5UFloat||e===nQ.RG11B10UFloat?Uint32Array:e===nQ.Depth32Float?Float32Array:e===nQ.Depth24Plus||e===nQ.Depth24PlusStencil8?Uint32Array:e===nQ.Depth32FloatStencil8?Float32Array:void 0}_getDimension(e){let t;return t=e.is3DTexture||e.isData3DTexture?yQ.ThreeD:yQ.TwoD,t}},y0=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,v0=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,b0={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},x0=e=>{let t=(e=e.trim()).match(y0);if(null!==t&&4===t.length){let i=t[2],r=[],s=null;for(;null!==(s=v0.exec(i));)r.push({name:s[1],type:s[2]});let a=[];for(let e=0;e<r.length;e++){let{name:t,type:i}=r[e],s=i;s.startsWith("ptr")?s="pointer":(s.startsWith("texture")&&(s=i.split("<")[0]),s=b0[s]),a.push(new XZ(s,t))}let n=e.substring(t[0].length),o=t[3]||"void",l=void 0!==t[1]?t[1]:"";return{type:b0[o]||o,inputs:a,name:l,inputsCode:i,blockCode:n,outputType:o}}throw new Error("THREE.WGSLNodeFunction: Function is not a WGSL code.")},w0=class extends hJ{constructor(e){let{type:t,inputs:i,name:r,inputsCode:s,blockCode:a,outputType:n}=x0(e);super(t,i,r),this.inputsCode=s,this.blockCode=a,this.outputType=n}getCode(e=this.name){let t="void"!==this.outputType?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},_0=class extends lJ{parseFunction(e){return new w0(e)}},S0={[fR.READ_ONLY]:"read",[fR.WRITE_ONLY]:"write",[fR.READ_WRITE]:"read_write"},M0={[kt]:"repeat",[Ut]:"clamp",[Ft]:"mirror"},T0={vertex:QJ.VERTEX,fragment:QJ.FRAGMENT,compute:QJ.COMPUTE},C0={instance:!0,swizzleAssign:!1,storageBuffer:!0},A0={"^^":"tsl_xor"},N0={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},P0={},R0={tsl_xor:new WH("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new WH("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new WH("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new WH("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new WH("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new WH("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new WH("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new WH("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new WH("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new WH("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new WH("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new WH("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),inverse_mat2:new WH("\nfn tsl_inverse_mat2( m : mat2x2<f32> ) -> mat2x2<f32> {\n\n\tlet det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ];\n\n\treturn mat2x2<f32>(\n\t\tm[ 1 ][ 1 ], - m[ 0 ][ 1 ],\n\t\t- m[ 1 ][ 0 ], m[ 0 ][ 0 ]\n\t) * ( 1.0 / det );\n\n}\n"),inverse_mat3:new WH("\nfn tsl_inverse_mat3( m : mat3x3<f32> ) -> mat3x3<f32> {\n\n\tlet a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ];\n\tlet a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ];\n\tlet a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ];\n\n\tlet b01 = a22 * a11 - a12 * a21;\n\tlet b11 = - a22 * a10 + a12 * a20;\n\tlet b21 = a21 * a10 - a11 * a20;\n\n\tlet det = a00 * b01 + a01 * b11 + a02 * b21;\n\n\treturn mat3x3<f32>(\n\t\tb01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ),\n\t\tb11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ),\n\t\tb21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 )\n\t) * ( 1.0 / det );\n\n}\n"),inverse_mat4:new WH("\nfn tsl_inverse_mat4( m : mat4x4<f32> ) -> mat4x4<f32> {\n\n\tlet a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ];\n\tlet a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ];\n\tlet a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ];\n\tlet a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ];\n\n\tlet b00 = a00 * a11 - a01 * a10;\n\tlet b01 = a00 * a12 - a02 * a10;\n\tlet b02 = a00 * a13 - a03 * a10;\n\tlet b03 = a01 * a12 - a02 * a11;\n\tlet b04 = a01 * a13 - a03 * a11;\n\tlet b05 = a02 * a13 - a03 * a12;\n\tlet b06 = a20 * a31 - a21 * a30;\n\tlet b07 = a20 * a32 - a22 * a30;\n\tlet b08 = a20 * a33 - a23 * a30;\n\tlet b09 = a21 * a32 - a22 * a31;\n\tlet b10 = a21 * a33 - a23 * a31;\n\tlet b11 = a22 * a33 - a23 * a32;\n\n\tlet det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n\treturn mat4x4<f32>(\n\t\ta11 * b11 - a12 * b10 + a13 * b09,\n\t\ta02 * b10 - a01 * b11 - a03 * b09,\n\t\ta31 * b05 - a32 * b04 + a33 * b03,\n\t\ta22 * b04 - a21 * b05 - a23 * b03,\n\t\ta12 * b08 - a10 * b11 - a13 * b07,\n\t\ta00 * b11 - a02 * b08 + a03 * b07,\n\t\ta32 * b02 - a30 * b05 - a33 * b01,\n\t\ta20 * b05 - a22 * b02 + a23 * b01,\n\t\ta10 * b10 - a11 * b08 + a13 * b06,\n\t\ta01 * b08 - a00 * b10 - a03 * b06,\n\t\ta30 * b04 - a31 * b02 + a33 * b00,\n\t\ta21 * b02 - a20 * b04 - a23 * b00,\n\t\ta11 * b07 - a10 * b09 - a12 * b06,\n\t\ta00 * b09 - a01 * b07 + a02 * b06,\n\t\ta31 * b01 - a30 * b03 - a32 * b00,\n\t\ta20 * b03 - a21 * b01 + a22 * b00\n\t) * ( 1.0 / det );\n\n}\n"),biquadraticTexture:new WH("\nfn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n"),biquadraticTextureArray:new WH("\nfn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},E0={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inverse_mat2:"tsl_inverse_mat2",inverse_mat3:"tsl_inverse_mat3",inverse_mat4:"tsl_inverse_mat4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"},O0="",!0!==(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))&&(O0+="diagnostic( off, derivative_uniformity );\n"),B0=class extends $Z{constructor(e,t){super(e,t,new _0),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,i,r,s,a=this.shaderStage){return"fragment"===a?r?s?`textureSample( ${t}, ${t}_sampler, ${i}, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${i}, ${r} )`:s?`textureSample( ${t}, ${t}_sampler, ${i}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${i} )`:this.generateTextureSampleLevel(e,t,i,"0",r)}generateTextureSampleLevel(e,t,i,r,s,a){return!1===this.isUnfilterable(e)?s?a?`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,i,a,r,s):this.generateTextureLod(e,t,i,s,a,r)}generateWrapFunction(e){let t=`tsl_coord_${M0[e.wrapS]}S_${M0[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`,i=P0[t];if(void 0===i){let r=[],s=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f",a=`fn ${t}( coord : ${s} ) -> ${s} {\n\n\treturn ${s}(\n`,n=(e,t)=>{e===kt?(r.push(R0.repeatWrapping_float),a+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===Ut?(r.push(R0.clampWrapping_float),a+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===Ft?(r.push(R0.mirrorWrapping_float),a+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(a+=`\t\tcoord.${t}`,f(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};n(e.wrapS,"x"),a+=",\n",n(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(a+=",\n",n(e.wrapR,"z")),a+="\n\t);\n\n}\n",P0[t]=i=new WH(a,r)}return i.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,i){let r=this.getDataFromNode(e,this.shaderStage,this.cache);void 0===r.dimensionsSnippet&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[i];if(void 0===r.dimensionsSnippet[i]){let a,n,{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),l=o>1;n=e.is3DTexture||e.isData3DTexture?"vec3<u32>":"vec2<u32>",a=l||e.isStorageTexture?t:`${t}${i?`, u32( ${i} )`:""}`,s=new FV(new ED(`textureDimensions( ${a} )`,n)),r.dimensionsSnippet[i]=s,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new FV(new ED(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new FV(new ED("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,i,r,s="0u",a){let n=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,s);return r&&(i=`${i} + vec2<f32>(${r}) / ${o}`),a?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${n}( ${i} ), ${o}, u32( ${a} ), u32( ${s} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${n}( ${i} ), ${o}, u32( ${s} ) )`)}generateTextureLod(e,t,i,r,s,a="0u"){if(!0===e.isCubeTexture)return s&&(i=`${i} + vec3<f32>(${s})`),`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${e.isDepthTexture?"u32":"f32"}( ${a} ) )`;let n=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,a),l=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";return s&&(i=`${i} + ${l}<f32>(${s}) / ${l}<f32>( ${o} )`),i=`${l}<u32>( clamp( floor( ${n}( ${i} ) * ${l}<f32>( ${o} ) ), ${l}<f32>( 0 ), ${l}<f32>( ${o} - ${"vec3"===l?"vec3<u32>( 1, 1, 1 )":"vec2<u32>( 1, 1 )"} ) ) )`,this.generateTextureLoad(e,t,i,a,r,null)}generateStorageTextureLoad(e,t,i,r,s,a){let n;return a&&(i=`${i} + ${a}`),n=s?`textureLoad( ${t}, ${i}, ${s} )`:`textureLoad( ${t}, ${i} )`,n}generateTextureLoad(e,t,i,r,s,a){let n;return null===r&&(r="0u"),a&&(i=`${i} + ${a}`),s?n=`textureLoad( ${t}, ${i}, ${s}, u32( ${r} ) )`:(n=`textureLoad( ${t}, ${i}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,i,r,s){let a;return a=r?`textureStore( ${t}, ${i}, ${r}, ${s} )`:`textureStore( ${t}, ${i}, ${s} )`,a}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction&&this.renderer.hasCompatibility(qr.TEXTURE_COMPARE)}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&e.type===ti||!1===this.isSampleCompare(e)&&e.minFilter===jt&&e.magFilter===jt||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,i,r,s,a=this.shaderStage){let n=null;return n=this.isUnfilterable(e)?this.generateTextureLod(e,t,i,r,s,"0",a):this._generateTextureSample(e,t,i,r,s,a),n}generateTextureGrad(e,t,i,r,s,a,n=this.shaderStage){if("fragment"===n)return s?a?`textureSampleGrad( ${t}, ${t}_sampler, ${i}, ${s}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${i}, ${s}, ${r[0]}, ${r[1]} )`:a?`textureSampleGrad( ${t}, ${t}_sampler, ${i}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${i}, ${r[0]}, ${r[1]} )`;y(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,i,r,s,a,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?a?`textureSampleCompareLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${a} )`:`textureSampleCompareLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r} )`:a?`textureSampleCompareLevel( ${t}, ${t}_sampler, ${i}, ${r}, ${a} )`:`textureSampleCompareLevel( ${t}, ${t}_sampler, ${i}, ${r} )`;y(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureGather(e,t,i,r,s,a){let n=!0===e.isDepthTexture?"":`${r}, `;return s?a?`textureGather( ${n}${t}, ${t}_sampler, ${i}, ${s}, ${a} )`:`textureGather( ${n}${t}, ${t}_sampler, ${i}, ${s} )`:a?`textureGather( ${n}${t}, ${t}_sampler, ${i}, ${a} )`:`textureGather( ${n}${t}, ${t}_sampler, ${i})`}generateTextureGatherCompare(e,t,i,r,s,a){return s?a?`textureGatherCompare( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${i}, ${s}, ${r})`:a?`textureGatherCompare( ${t}, ${t}_sampler, ${i}, ${r}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${i}, ${r})`}generateTextureLevel(e,t,i,r,s,a){return!1===this.isUnfilterable(e)?s?a?`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${s}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${i}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,i,a,r,s):this.generateTextureLod(e,t,i,s,a,r)}generateTextureBias(e,t,i,r,s,a,n=this.shaderStage){if("fragment"===n)return s?a?`textureSampleBias( ${t}, ${t}_sampler, ${i}, ${s}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${i}, ${s}, ${r} )`:a?`textureSampleBias( ${t}, ${t}_sampler, ${i}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${i}, ${r} )`;y(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){let t=e.name,i=e.type;return"texture"===i||"cubeTexture"===i||"cubeDepthTexture"===i||"storageTexture"===i||"texture3D"===i?t:"buffer"===i||"storageBuffer"===i||"indirectStorageBuffer"===i?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){let t=A0[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?(f("WebGPURenderer: Atomic operations are only supported in compute shaders."),fR.READ_WRITE):fR.READ_ONLY:e.access}getStorageAccess(e,t){return S0[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,i,r=null){let s=super.getUniformFromNode(e,t,i,r),a=this.getDataFromNode(e,i,this.globalCache);if(void 0===a.uniformGPU){let n,o=e.groupNode,l=o.name,h=this.getBindGroupArray(l,i);if("texture"===t||"cubeTexture"===t||"cubeDepthTexture"===t||"storageTexture"===t||"texture3D"===t){let r=null,a=this.getNodeAccess(e,i);if("texture"===t||"storageTexture"===t?r=!0===e.value.is3DTexture?new $J(s.name,s.node,o,a):new qJ(s.name,s.node,o,a):"cubeTexture"===t||"cubeDepthTexture"===t?r=new HJ(s.name,s.node,o,a):"texture3D"===t&&(r=new $J(s.name,s.node,o,a)),r.store=!0===e.isStorageTextureNode,r.mipLevel=r.store?e.mipLevel:0,r.setVisibility(T0[i]),!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===r.store||null!==e.gatherNode){let e=new SQ(`${s.name}_sampler`,s.node,o);e.setVisibility(T0[i]),h.push(e,r),n=[e,r]}else h.push(r),n=[r]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){let a=this.getSharedDataFromNode(e),l=a.buffer;void 0===l&&(l=new("buffer"===t?LJ:CQ)(e,o),a.buffer=l),l.setVisibility(l.getVisibility()|T0[i]),h.push(l),n=l,s.name=r||"NodeBuffer_"+s.id}else{let e=this.uniformGroups[l];void 0===e&&(e=new UJ(l,o),e.setVisibility(QJ.VERTEX|QJ.FRAGMENT|QJ.COMPUTE),this.uniformGroups[l]=e),-1===h.indexOf(e)&&h.push(e),n=this.getNodeUniform(s,t);let i=n.name;e.uniforms.some(e=>e.name===i)||e.addUniform(n)}a.uniformGPU=n}return s}getBuiltin(e,t,i,r=this.shaderStage){let s=this.builtins[r]||(this.builtins[r]=new Map);return!1===s.has(e)&&s.set(e,{name:e,property:t,type:i}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){let t=e.layout,i=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(e.name+" : "+this.getType(e.type));let s=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} {\n${i.vars}\n${i.code}\n`;return i.result&&(s+=`\treturn ${i.result};\n`),s+="\n}\n",s}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){let t=[],i=this.directives[e];if(void 0!==i)for(let e of i)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){let t=[],i=this.builtins[e];if(void 0!==i)for(let{name:e,property:r,type:s}of i.values())t.push(`@builtin( ${e} ) ${r} : ${s}`);return t.join(",\n\t")}getScopedArray(e,t,i,r){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:i,bufferCount:r}),e}getScopedArrays(e){if("compute"!==e)return;let t=[];for(let{name:e,scope:i,bufferType:r,bufferCount:s}of this.scopedArrays.values()){let a=this.getType(r);t.push(`var<${i}> ${e}: array< ${a}, ${s} >;`)}return t.join("\n")}getAttributes(e){let t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){let e=this.getBuiltins("attribute");e&&t.push(e);let i=this.getAttributesArray();for(let e=0,r=i.length;e<r;e++){let r=i[e],s=r.name,a=this.getType(r.type);t.push(`@location( ${e} ) ${s} : ${a}`)}}return t.join(",\n\t")}getStructMembers(e){let t=[];for(let i of e.members){let r=e.output?"@location( "+i.index+" ) ":"",s=this.getType(i.type);i.atomic&&(s="atomic< "+s+" >"),t.push(`\t${r+i.name} : ${s}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="",i=this.structs[e];if(i.length>0){let e=[];for(let t of i){let i=`struct ${t.name} {\n`;i+=this.getStructMembers(t),i+="\n};",e.push(i)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,i=null,r=""){let s=`var${r} ${t} : `;return s+=null!==i?this.generateArrayDeclaration(e,i):this.getType(e),s}getVars(e,t=!1){let i="";t&&(i="<private>");let r=[],s=this.vars[e];if(void 0!==s)for(let e of s)r.push(`${this.getVar(e.type,e.name,e.count,i)};`);return t?r.join("\n"):`\n\t${r.join("\n\t")}\n`}getVaryings(e){let t=[];if("vertex"===e&&this.getBuiltin("position","builtinClipSpace","vec4<f32>","vertex"),"vertex"===e||"fragment"===e){let i=this.varyings,r=this.vars[e],s=0;for(let a=0;a<i.length;a++){let n=i[a];if(n.needsInterpolation){let e=`@location( ${s++} )`;if(n.interpolationType){let t=null!==n.interpolationSampling?`, ${n.interpolationSampling} )`:" )";e+=` @interpolate( ${n.interpolationType}${t}`}else/^(int|uint|ivec|uvec)/.test(n.type)&&(e+=" @interpolate(flat, either)");t.push(`${e} ${n.name} : ${this.getType(n.type)}`)}else"vertex"===e&&!1===r.includes(n)&&r.push(n)}}let i=this.getBuiltins(e);i&&t.push(i);let r=t.join(",\n\t");return"vertex"===e?this._getWGSLStruct("VaryingsStruct","\t"+r):r}isCustomStruct(e){let t=e.value,i=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&null!==i.structTypeNode,s=i.value&&i.value.array&&"number"==typeof i.value.itemSize&&i.value.array.length>i.value.itemSize;return r&&!s}getUniforms(e){let t=this.renderer.backend,i=this.uniforms[e],r=[],s=[],a=[],n={};for(let a of i){let i=a.groupNode.name,o=this.bindingsIndexes[i];if("texture"===a.type||"cubeTexture"===a.type||"cubeDepthTexture"===a.type||"storageTexture"===a.type||"texture3D"===a.type){let i=a.node,s=i.value;(!0===s.isCubeTexture||!1===this.isUnfilterable(s)&&!0!==i.isStorageTextureNode||null!==i.gatherNode)&&(this.isSampleCompare(s)?r.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${a.name}_sampler : sampler_comparison;`):r.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${a.name}_sampler : sampler;`));let n,l="",{primarySamples:h}=t.utils.getTextureSampleData(s);if(h>1&&(l="_multisampled"),!0===s.isCubeTexture&&!0===s.isDepthTexture)n="texture_depth_cube";else if(!0===s.isCubeTexture)n="texture_cube<f32>";else if(!0===s.isDepthTexture)n=t.compatibilityMode&&null===s.compareFunction?`texture${l}_2d<f32>`:`texture_depth${l}_2d${!0===s.isArrayTexture?"_array":""}`;else if(!0===a.node.isStorageTextureNode){let i=eR(s,t.device),r=this.getStorageAccess(a.node,e),o=a.node.value.is3DTexture,l=a.node.value.isArrayTexture;n=`texture_storage_${o?"3d":"2d"+(l?"_array":"")}<${i}, ${r}>`}else n=!0===s.isArrayTexture||!0===s.isDataArrayTexture||!0===s.isCompressedArrayTexture?"texture_2d_array<f32>":!0===s.is3DTexture||!0===s.isData3DTexture?"texture_3d<f32>":`texture${l}_2d<${this.getComponentTypeFromTexture(s).charAt(0)}32>`;r.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${a.name} : ${n};`)}else if("buffer"===a.type||"storageBuffer"===a.type||"indirectStorageBuffer"===a.type){let t=a.node,i=this.getType(t.getNodeType(this)),r=t.bufferCount,n=r>0&&"buffer"===a.type?", "+r:"",l=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(a))s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var<${l}> ${a.name} : ${i};`);else{let e=`\tvalue : array< ${t.isAtomic?`atomic<${i}>`:`${i}`}${n} >`;s.push(this._getWGSLStructBinding(a.name,e,l,o.binding++,o.group))}}else{let e=a.groupNode.name;if(void 0===n[e]){let t=this.uniformGroups[e];if(void 0!==t){let i=[];for(let e of t.uniforms){let t=e.getType(),r=this.getType(this.getVectorType(t));i.push(`\t${e.name} : ${r}`)}let r=this.uniformGroupsBindings[e];void 0===r&&(r={index:o.binding++,id:o.group},this.uniformGroupsBindings[e]=r),n[e]={index:r.index,id:r.id,snippets:i}}}}}for(let e in n){let t=n[e];a.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}return[...r,...s,...a].join("\n")}buildCode(){let e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(let t in e){this.shaderStage=t;let i=this.allowGlobalVariables,r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t,i),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];let a=this.flowNodes[t],n=a[a.length-1],o=n.outputNode,l=void 0!==o&&!0===o.isOutputStructNode;for(let e of a){let i=this.getFlowData(e),a=e.name;if(a&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${a}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.builtinClipSpace = ${i.result};`;else if("fragment"===t)if(l)r.returnType=o.getNodeType(this),r.structs+="var<private> output : "+r.returnType+";",s+=`return ${i.result};`;else{let e=`\t@location( 0 ) color: ${this.getType(this.getOutputType())}`,t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar<private> output : OutputStruct;",s+=`output.color = ${this.format(i.result,n.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}r.flow=s}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let i;return null!==t&&(i=this._getWGSLMethod(e+"_"+t)),void 0===i&&(i=this._getWGSLMethod(e)),i||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,i){return`select( ${i}, ${t}, ${e} )`}getType(e){return N0[e]||e}isAvailable(e){let t=C0[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),C0[e]=t),t}_getWGSLMethod(e){return void 0!==R0[e]&&this._include(e),E0[e]}_include(e){let t=R0[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar<private> varyings : VaryingsStruct;\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${O0}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){let[i,r,s]=t;return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar<private> instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${this.allowGlobalVariables?e.vars:""}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${i}, ${r}, ${s} )\nfn main( ${e.attributes} ) {\n\n\t// local vars\n\t${this.allowGlobalVariables?"":e.vars}\n\n\t// system\n\tinstanceIndex = globalId.x\n\t\t+ globalId.y * ( ${i} * numWorkgroups.x )\n\t\t+ globalId.z * ( ${i} * numWorkgroups.x ) * ( ${r} * numWorkgroups.y );\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,i,r=0,s=0){let a=e+"Struct";return`${this._getWGSLStruct(a,t)}\n@binding( ${r} ) @group( ${s} )\nvar<${i}> ${e} : ${a};`}},V0=new RQ,D0=new EQ,I0=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),typeof Float16Array<"u"&&I0.set(Float16Array,["float16"]),L0=new Map([[qa,["float16"]]]),z0=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]),k0=class{constructor(e){this.backend=e}createAttribute(e,t){let i=this._getBufferAttribute(e),r=this.backend,s=r.get(i),a=s.buffer;if(void 0===a){let n,o=r.device,l=i.array;if(!1===e.normalized)if(l.constructor===Int16Array||l.constructor===Int8Array)l=new Int32Array(l);else if((l.constructor===Uint16Array||l.constructor===Uint8Array)&&(l=new Uint32Array(l),t&GPUBufferUsage.INDEX))for(let e=0;e<l.length;e++)65535===l[e]&&(l[e]=4294967295);if(i.array=l,(i.isStorageBufferAttribute||i.isStorageInstancedBufferAttribute)&&3===i.itemSize)n=4;else if(i.itemSize>1&&i.itemSize*l.BYTES_PER_ELEMENT%4!=0){let e=i.itemSize*l.BYTES_PER_ELEMENT;n=4*Math.floor((e+3)/4)/l.BYTES_PER_ELEMENT}if(void 0!==n){let e=i.itemSize,t=new l.constructor(i.count*n);for(let r=0;r<i.count;r++)t.set(l.subarray(r*e,r*e+e),r*n);(i.isStorageBufferAttribute||i.isStorageInstancedBufferAttribute)&&(i.itemSize=n,i.array=t),l=t,s._itemSize=e,s._paddedItemSize=n}let h=l.byteLength,u=h+(4-h%4)%4;V0.label=i.name,V0.size=u,V0.usage=t,V0.mappedAtCreation=!0,a=o.createBuffer(V0),V0.reset(),new l.constructor(a.getMappedRange()).set(l),a.unmap(),s.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),i=this.backend,r=i.device,s=i.get(t),a=i.get(t).buffer,n=t.array,o=s._itemSize,l=s._paddedItemSize;if(void 0!==l){n=new n.constructor(t.count*l);for(let e=0;e<t.count;e++)n.set(t.array.subarray(e*o,e*o+o),e*l);(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(t.array=n)}let h=t.updateRanges;if(0===h.length)r.queue.writeBuffer(a,0,n,0);else{let e=c(n),i=e?1:n.BYTES_PER_ELEMENT;for(let t=0,s=h.length;t<s;t++){let s,u,d=h[t];if(void 0!==l){let e=Math.floor(d.start/o);s=e*l*i,u=(Math.ceil((d.start+d.count)/o)-e)*l*i}else s=d.start*i,u=d.count*i;let c=s*(e?n.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,c,n,s,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),i=new Map;for(let e=0;e<t.length;e++){let r=t[e],s=this._getUploadedArrayType(r).BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),n=i.get(a);if(void 0===n){let e,t;!0===r.isInterleavedBufferAttribute?(e=r.data.stride*s,t=r.data.isInstancedInterleavedBuffer?xQ.Instance:xQ.Vertex):(e=r.itemSize*s,t=r.isInstancedBufferAttribute?xQ.Instance:xQ.Vertex,r.itemSize>1&&e%4!=0&&(e=4*Math.floor((e+3)/4))),n={arrayStride:e,attributes:[],stepMode:t},i.set(a,n)}let o=this._getVertexFormat(r),l=!0===r.isInterleavedBufferAttribute?r.offset*s:0;n.attributes.push({shaderLocation:e,offset:l,format:o})}return Array.from(i.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,i=0,r=-1){let s,a=this.backend,n=a.device,o=a.get(this._getBufferAttribute(e)).buffer,l=-1===r?o.size-i:r;if(null!==t&&t.isReadbackBuffer){let e=a.get(t);if(!0===t._mapped)throw new Error("THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.");if(t._mapped=!0,void 0===e.readBufferGPU){V0.label=`${t.name}_readback`,V0.size=t.maxByteLength,V0.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,s=n.createBuffer(V0),V0.reset();let i=()=>{t.buffer=null,t._mapped=!1,s.unmap()},r=()=>{t.buffer=null,t._mapped=!1,s.destroy(),a.delete(t),t.removeEventListener("release",i),t.removeEventListener("dispose",r)};t.addEventListener("release",i),t.addEventListener("dispose",r),e.readBufferGPU=s}else s=e.readBufferGPU}else V0.label=`${e.name}_readback`,V0.size=l,V0.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,s=n.createBuffer(V0),V0.reset();D0.label=`readback_encoder_${e.name}`;let h=n.createCommandEncoder(D0);if(D0.reset(),h.copyBufferToBuffer(o,i,s,0,l),JP(n,h.finish()),await s.mapAsync(GPUMapMode.READ,0,l),null===t){let e=s.getMappedRange(0,l).slice();return s.destroy(),e}if(t.isReadbackBuffer)return t.buffer=s.getMappedRange(0,l),t;{let e=s.getMappedRange(0,l);return new Uint8Array(t).set(new Uint8Array(e)),s.destroy(),t}}_getVertexFormat(e){let t,{itemSize:i,normalized:r}=e,s=this._getUploadedArrayType(e),a=e.constructor;if(1===i)t=z0.get(s);else{let e=(L0.get(a)||I0.get(s))[r?1:0];if(e){let r=s.BYTES_PER_ELEMENT*i,a=4*Math.floor((r+3)/4)/s.BYTES_PER_ELEMENT;if(a%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");t=`${e}x${a}`}}return t||y("WebGPUAttributeUtils: Vertex format not supported yet."),t}_getUploadedArrayType(e){let t=e.array.constructor;if(!1===e.normalized&&!0!==e.isFloat16BufferAttribute){if(t===Int16Array||t===Int8Array)return Int32Array;if(t===Uint16Array||t===Uint8Array)return Uint32Array}return t}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},U0=new PQ,F0=new RQ,j0=new kQ,G0=class{constructor(e){this.layoutGPU=e,this.usedTimes=0}},W0=class{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,i=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;let s=this._createLayoutEntries(e),a=lR(JSON.stringify(s)),n=this._bindGroupLayoutCache.get(a);return void 0===n&&(n=new G0(i.createBindGroupLayout({entries:s})),this._bindGroupLayoutCache.set(a,n)),n.usedTimes++,r.layout=n,r.layoutKey=a,n.layoutGPU}createBindings(e,t,i,r=0){let s,{backend:a}=this,n=a.get(e),o=this.createBindingsLayout(e);0!==i&&(void 0===n.groups&&(n.groups=[],n.versions=[]),n.versions[i]===r&&(s=n.groups[i])),void 0===s&&(s=this.createBindGroup(e,o),0!==i&&(n.groups[i]=s,n.versions[i]=r)),n.group=s}updateBinding(e){let t=this.backend,i=t.device,r=e.buffer,s=t.get(e).buffer,a=e.updateRanges;if(0===a.length)i.queue.writeBuffer(s,0,r,0);else{let e=c(r),t=e?1:r.BYTES_PER_ELEMENT,n=a[0].start;for(let o=0,l=a.length;o<l;o++){let l=a[o],h=a[o+1],u=l.start+l.count;if(void 0!==h&&h.start===u)continue;let d=n*t,c=(u-n)*t,p=d*(e?r.BYTES_PER_ELEMENT:1);i.queue.writeBuffer(s,p,r,d,c),void 0!==h&&(n=h.start)}}}createBindGroupIndex(e,t){let i=this.backend.device,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=e[0];F0.label="bindingCameraIndex_"+s,F0.size=16,F0.usage=r;let a=i.createBuffer(F0);F0.reset(),i.queue.writeBuffer(a,0,e,0),U0.reset(),U0.label="bindGroupCameraIndex_"+s,U0.layout=t,U0.entries.push({binding:0,resource:{buffer:a}});let n=i.createBindGroup(U0);return U0.reset(),n}createBindGroup(e,t){let i=this.backend,r=i.device,s=0;U0.reset(),U0.label="bindGroup_"+e.name,U0.layout=t;for(let t of e.bindings){if(t.isUniformBuffer){let e=i.get(t);U0.entries.push({binding:s,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=i.get(t.attribute).buffer;U0.entries.push({binding:s,resource:{buffer:e}})}else if(t.isSampledTexture){let e,a=i.get(t.texture);if(void 0!==a.externalTexture)e=r.importExternalTexture({source:a.externalTexture});else{let i=t.store?1:a.texture.mipLevelCount,r=t.store?t.mipLevel:0,s=`view-${a.texture.width}-${a.texture.height}`;if(a.texture.depthOrArrayLayers>1&&(s+=`-${a.texture.depthOrArrayLayers}`),s+=`-${i}-${r}`,e=a[s],void 0===e){let n,o=bQ.All;n=t.isSampledCubeTexture?vQ.Cube:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vQ.TwoDArray:t.isSampledTexture3D||t.texture.is3DTexture?vQ.ThreeD:vQ.TwoD,j0.aspect=o,j0.dimension=n,j0.mipLevelCount=i,j0.baseMipLevel=r,e=a[s]=a.texture.createView(j0),j0.reset()}}U0.entries.push({binding:s,resource:e})}else if(t.isSampler){let e=i.get(t);U0.entries.push({binding:s,resource:e.sampler})}s++}let a=r.createBindGroup(U0);return U0.reset(),a}_createLayoutEntries(e){let t=[],i=0;for(let r of e.bindings){let e=this.backend,s={binding:i,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){let e={};r.isStorageBuffer&&(r.visibility&QJ.COMPUTE&&(r.access===fR.READ_WRITE||r.access===fR.WRITE_ONLY)?e.type=pQ.Storage:e.type=pQ.ReadOnlyStorage),s.buffer=e}else if(r.isSampledTexture&&r.store){let e={};e.format=this.backend.get(r.texture).texture.format;let t=r.access;e.access=t===fR.READ_WRITE?mQ.ReadWrite:t===fR.WRITE_ONLY?mQ.WriteOnly:mQ.ReadOnly,r.texture.isArrayTexture?e.viewDimension=vQ.TwoDArray:r.texture.is3DTexture&&(e.viewDimension=vQ.ThreeD),s.storageTexture=e}else if(r.isSampledTexture){let t={},{primarySamples:i}=e.utils.getTextureSampleData(r.texture);if(i>1&&(t.multisampled=!0,r.texture.isDepthTexture||(t.sampleType=fQ.UnfilterableFloat)),r.texture.isDepthTexture)e.compatibilityMode&&null===r.texture.compareFunction?t.sampleType=fQ.UnfilterableFloat:t.sampleType=fQ.Depth;else{let e=r.texture.type;e===Qt?t.sampleType=fQ.SInt:e===ei?t.sampleType=fQ.UInt:e===ti&&(this.backend.hasFeature("float32-filterable")?t.sampleType=fQ.Float:t.sampleType=fQ.UnfilterableFloat)}r.isSampledCubeTexture?t.viewDimension=vQ.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?t.viewDimension=vQ.TwoDArray:r.isSampledTexture3D&&(t.viewDimension=vQ.ThreeD),s.texture=t}else if(r.isSampler){let t={};r.texture.isDepthTexture&&(null!==r.texture.compareFunction&&e.hasCompatibility(qr.TEXTURE_COMPARE)?t.type=gQ.Comparison:t.type=gQ.NonFiltering),s.sampler=t}else y(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(s),i++}return t}deleteBindGroupData(e){let{backend:t}=this,i=t.get(e);i.layout&&(i.layout.usedTimes--,0===i.layout.usedTimes&&this._bindGroupLayoutCache.delete(i.layoutKey),i.layout=void 0,i.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}},q0=class{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}},H0=class{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}},$0=class{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}},Y0=new H0,X0=new $0,K0=new OQ,Z0=new DQ,J0=class{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:i,geometry:r,pipeline:s}=e,a=e.drawMaterial,{vertexProgram:n,fragmentProgram:o}=s,l=this.backend,h=l.device,u=l.utils,d=l.get(s),c=[];for(let t of e.getBindings()){let e=l.get(t),{layoutGPU:i}=e.layout;c.push(i)}let p,m=l.attributeUtils.createShaderVertexBuffers(e);a.blending!==He&&(a.blending!==$e||!1!==a.transparent)&&(p=this._getBlending(a));let g={};!0===a.stencilWrite&&(g={compare:this._getStencilCompare(a),failOp:this._getStencilOperation(a.stencilFail),depthFailOp:this._getStencilOperation(a.stencilZFail),passOp:this._getStencilOperation(a.stencilZPass)});let f=this._getColorWriteMask(a),b=[];if(null!==e.context.textures){let t=e.context.textures,i=e.context.mrt;for(let e=0;e<t.length;e++){let r,s=t[e],a=u.getTextureFormatGPU(s);if(null!==i)if(!0!==this.backend.compatibilityMode){let e=i.getBlendMode(s.name);e.blending===Je?r=p:e.blending!==He&&(r=this._getBlending(e))}else v("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets."),r=p;else r=p;b.push({format:a,blend:r,writeMask:f})}}else{let t=u.getCurrentColorFormat(e.context);b.push({format:t,blend:p,writeMask:f})}let x=l.get(n).module,w=l.get(o).module,_=this._getPrimitiveState(i,r,a),S=this._getDepthCompare(a),M=u.getCurrentDepthStencilFormat(e.context),T=this._getSampleCount(e.context);X0.bindGroupLayouts=c;let C=h.createPipelineLayout(X0);X0.reset(),Z0.label=`renderPipeline_${a.name||a.type}_${a.id}`,Z0.vertex=Object.assign({},x,{buffers:m}),Z0.fragment=Object.assign({},w,{targets:b}),Z0.primitive=_,Z0.multisample.count=T,Z0.multisample.alphaToCoverageEnabled=a.alphaToCoverage&&T>1,Z0.layout=C;let A={},N=e.context.depth,P=e.context.stencil;(!0===N||!0===P)&&(!0===N&&(A.format=M,A.depthWriteEnabled=a.depthWrite,A.depthCompare=S),!0===P&&(A.stencilFront=g,A.stencilBack=g,A.stencilReadMask=a.stencilFuncMask,A.stencilWriteMask=a.stencilWriteMask),!0===a.polygonOffset&&_.topology===JJ.TriangleList&&(A.depthBias=a.polygonOffsetUnits,A.depthBiasSlopeScale=a.polygonOffsetFactor,A.depthBiasClamp=0),Z0.depthStencil=A),h.pushErrorScope("validation");let R=[{program:n,module:x.module},{program:o,module:w.module}],E=Z0.label;if(null===t)d.pipeline=h.createRenderPipeline(Z0),Z0.reset(),h.popErrorScope().then(e=>{null!==e&&(d.error=!0,y(`WebGPURenderer: Render pipeline creation failed (${E}): ${e.message}`),this._reportShaderDiagnostics(R,E))});else{let e=h.createRenderPipelineAsync(Z0),i=h.popErrorScope();Z0.reset();let r=new Promise(async t=>{try{let t=null;try{d.pipeline=await e}catch(e){t=e}let r=await i;if(null!==r||null!==t){d.error=!0;let e=r&&r.message||t&&t.message||"unknown";y(`WebGPURenderer: Async render pipeline creation failed (${E}): ${e}`),await this._reportShaderDiagnostics(R,E)}}finally{t()}});t.push(r)}}createBundleEncoder(e,t="renderBundleEncoder"){let i=this.backend,{utils:r,device:s}=i,a=r.getCurrentDepthStencilFormat(e),n=r.getCurrentColorFormats(e),o=this._getSampleCount(e);K0.label=t,K0.colorFormats=n,K0.depthStencilFormat=a,K0.sampleCount=o;let l=s.createRenderBundleEncoder(K0);return K0.reset(),l}createComputePipeline(e,t){let i=this.backend,r=i.device,s=i.get(e.computeProgram).module,a=i.get(e),n=[];for(let e of t){let t=i.get(e),{layoutGPU:r}=t.layout;n.push(r)}let o=e.computeProgram,l=`computePipeline_${o.stage}${o.name?`_${o.name}`:""}`;r.pushErrorScope("validation"),X0.bindGroupLayouts=n;let h=r.createPipelineLayout(X0);X0.reset(),Y0.label=l,Y0.compute=s,Y0.layout=h,a.pipeline=r.createComputePipeline(Y0),Y0.reset(),r.popErrorScope().then(e=>{null!==e&&(a.error=!0,y(`WebGPURenderer: Compute pipeline creation failed (${l}): ${e.message}`),this._reportShaderDiagnostics([{program:o,module:s.module}],l))})}async _reportShaderDiagnostics(e,t){for(let{program:i,module:r}of e){let e=await r.getCompilationInfo();if(0===e.messages.length)continue;let s=i.code.split("\n");for(let r of e.messages){let e=r.lineNum>0?` at line ${r.lineNum}${r.linePos>0?`:${r.linePos}`:""}`:"",a=`WebGPURenderer [${t} / ${i.stage} ${r.type}]${e}: ${r.message}`,n="";r.lineNum>0&&r.lineNum<=s.length&&(n=`\n ${s[r.lineNum-1]}`,r.linePos>0&&(n+=`\n ${" ".repeat(r.linePos-1)}^`)),("error"===r.type?y:f)(a+n)}}}_getBlending(e){let t,i,r=e.blending,s=e.blendSrc,a=e.blendDst,n=e.blendEquation;if(r===Ze){let r=null!==e.blendSrcAlpha?e.blendSrcAlpha:s,o=null!==e.blendDstAlpha?e.blendDstAlpha:a,l=null!==e.blendEquationAlpha?e.blendEquationAlpha:n;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(n)},i={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(l)}}else{let s=(e,r,s,a)=>{t={srcFactor:e,dstFactor:r,operation:uQ.Add},i={srcFactor:s,dstFactor:a,operation:uQ.Add}};if(e.premultipliedAlpha)switch(r){case $e:s(hQ.One,hQ.OneMinusSrcAlpha,hQ.One,hQ.OneMinusSrcAlpha);break;case Ye:s(hQ.One,hQ.One,hQ.One,hQ.One);break;case Xe:s(hQ.Zero,hQ.OneMinusSrc,hQ.Zero,hQ.One);break;case Ke:s(hQ.Dst,hQ.OneMinusSrcAlpha,hQ.Zero,hQ.One)}else switch(r){case $e:s(hQ.SrcAlpha,hQ.OneMinusSrcAlpha,hQ.One,hQ.OneMinusSrcAlpha);break;case Ye:s(hQ.SrcAlpha,hQ.One,hQ.One,hQ.One);break;case Xe:y(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case Ke:y(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(void 0!==t&&void 0!==i)return{color:t,alpha:i};y("WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case st:t=hQ.Zero;break;case at:t=hQ.One;break;case nt:t=hQ.Src;break;case ot:t=hQ.OneMinusSrc;break;case lt:t=hQ.SrcAlpha;break;case ht:t=hQ.OneMinusSrcAlpha;break;case ct:t=hQ.Dst;break;case pt:t=hQ.OneMinusDst;break;case ut:t=hQ.DstAlpha;break;case dt:t=hQ.OneMinusDstAlpha;break;case mt:t=hQ.SrcAlphaSaturated;break;case 211:t=hQ.Constant;break;case 212:t=hQ.OneMinusConstant;break;default:y("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t,i=e.stencilFunc;switch(i){case Mr:t=eQ.Never;break;case Er:t=eQ.Always;break;case Tr:t=eQ.Less;break;case Ar:t=eQ.LessEqual;break;case Cr:t=eQ.Equal;break;case Rr:t=eQ.GreaterEqual;break;case Nr:t=eQ.Greater;break;case Pr:t=eQ.NotEqual;break;default:y("WebGPURenderer: Invalid stencil function.",i)}return t}_getStencilOperation(e){let t;switch(e){case yr:t=cQ.Keep;break;case fr:t=cQ.Zero;break;case vr:t=cQ.Replace;break;case Sr:t=cQ.Invert;break;case br:t=cQ.IncrementClamp;break;case xr:t=cQ.DecrementClamp;break;case wr:t=cQ.IncrementWrap;break;case _r:t=cQ.DecrementWrap;break;default:y("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Qe:t=uQ.Add;break;case et:t=uQ.Subtract;break;case tt:t=uQ.ReverseSubtract;break;case it:t=uQ.Min;break;case rt:t=uQ.Max;break;default:y("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,i){let r={},s=this.backend.utils;r.topology=s.getPrimitiveTopology(e,i),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(r.stripIndexFormat=aQ.Uint32);let a=i.side===We;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(a=!a),r.frontFace=!0===a?rQ.CW:rQ.CCW,r.cullMode=i.side===qe?sQ.None:sQ.Back,r}_getColorWriteMask(e){return!0===e.colorWrite?dQ.All:dQ.None}_getDepthCompare(e){let t;if(!1===e.depthTest)t=eQ.Always;else{let i=this.backend.parameters.reversedDepthBuffer?Xr[e.depthFunc]:e.depthFunc;switch(i){case gt:t=eQ.Never;break;case ft:t=eQ.Always;break;case yt:t=eQ.Less;break;case vt:t=eQ.LessEqual;break;case bt:t=eQ.Equal;break;case xt:t=eQ.GreaterEqual;break;case wt:t=eQ.Greater;break;case _t:t=eQ.NotEqual;break;default:y("WebGPUPipelineUtils: Invalid depth function.",i)}}return t}},Q0=class{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}},e1=new RQ,t1=new EQ,i1=new Q0,r1=class extends ZJ{constructor(e,t,i=2048){super(i),this.device=e,this.type=t,i1.label=`queryset_global_timestamp_${t}`,i1.type="timestamp",i1.count=this.maxQueries,this.querySet=this.device.createQuerySet(i1),i1.reset();let r=8*this.maxQueries;e1.label=`buffer_timestamp_resolve_${t}`,e1.size=r,e1.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(e1),e1.reset(),e1.label=`buffer_timestamp_result_${t}`,e1.size=r,e1.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(e1),e1.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return v(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,i=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder(t1);r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,i);let s=r.finish();if(JP(this.device,s),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,i),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,i)),n={},o=[];for(let[t,i]of e){let e=t.match(/^(.*):f(\d+)$/),r=parseInt(e[2]);!1===o.includes(r)&&o.push(r),void 0===n[r]&&(n[r]=0);let s=a[i],l=a[i+1],h=Number(l-s)/1e6;this.timestamps.set(t,h),n[r]+=h}let l=n[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=o,l}catch(e){return y("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){y("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){y("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},s1=class{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}},a1=class{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}},n1=class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},o1={r:0,g:0,b:0,a:1},l1=new RQ,h1=new EQ,u1=new s1,d1=new Q0,c1=new LQ,p1=new n1,m1=new JQ,g1=new JQ,f1=new kQ,y1=new r0,v1=class extends KJ{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new NQ(this),this.attributeUtils=new k0(this),this.bindingUtils=new W0(this),this.capabilities=new q0(this),this.pipelineUtils=new J0(this),this.textureUtils=new f0(this),this.occludedResolveCache=new Map;let t=typeof navigator>"u"||!1===/Android/.test(navigator.userAgent);this._compatibility={[qr.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t,i=this.parameters;if(void 0===i.device){let r={powerPreference:i.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},s=typeof navigator<"u"?await navigator.gpu.requestAdapter(r):null;if(null===s)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");let a=Object.values(wQ),n=[];for(let e of a)s.features.has(e)&&n.push(e);let o={requiredFeatures:n,requiredLimits:i.requiredLimits};this.adapter=s,t=await s.requestDevice(o)}else t=i.device;this.compatibilityMode=!t.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),t.lost.then(t=>{if("destroyed"===t.reason)return;let i={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(i)}),t.onuncapturederror=t=>{let i=t.error,r=i&&i.constructor?i.constructor.name:"GPUError",s=i&&i.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:r,message:s,originalEvent:t})},this.device=t,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(wQ.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,i=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:i,initialized:!0})}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),i=t.context;if(void 0===i){let r=this.parameters;i=!0===e.isDefaultCanvasTarget&&void 0!==r.context?r.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${Le} webgpu`);let s=r.alpha?"premultiplied":"opaque",a=r.outputType===ii?"extended":"standard";i.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,colorSpace:r.canvasColorSpace||"srgb",toneMapping:{mode:a}}),t.context=i}return i}get coordinateSystem(){return Gr}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,i=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,i,r)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),i=this.get(t),r=e.currentSamples,s=i.descriptor;if(void 0===s||i.samples!==r){if(s=new VQ,s.colorAttachments.push(new BQ),!0===e.depth||!0===e.stencil){let t=new a1;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),s.depthStencilAttachment=t}let t=s.colorAttachments[0];r>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,i.descriptor=s,i.samples=r}let a=s.colorAttachments[0];return r>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),s}_isRenderCameraDepthArray(e){let t=e.camera;return e.depthTexture&&!0===e.depthTexture.isArrayTexture&&null!==t&&!0===t.isArrayCamera}_hasExternalTexture(e){let t=e.textures;if(null===t)return!1;for(let e=0;e<t.length;e++)if(!0===this.get(t[e]).externalTexture)return!0;return!1}_createExternalTextureViews(e,t){let i=[],r=e.camera;if(t.xrViewDescriptors&&null!==r&&!0===r.isArrayCamera)for(let e=0;e<t.xrViewDescriptors.length;e++)i.push({view:t.texture.createView(t.xrViewDescriptors[e]),resolveTarget:void 0,depthSlice:void 0});else i.push({view:t.texture.createView({dimension:vQ.TwoD,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1}),resolveTarget:void 0,depthSlice:void 0});return i}_getRenderPassDescriptor(e,t={}){let i=e.renderTarget,r=this.get(i),s=this._hasExternalTexture(e),a=r.descriptors;(void 0===a||r.width!==i.width||r.height!==i.height||r.samples!==i.samples||s)&&(a={},r.descriptors=a);let n=e.getCacheKey(),o=a[n];if(void 0===o||s){let t,s=e.textures,l=[],h=this._isRenderCameraDepthArray(e);for(let r=0;r<s.length;r++){let a=this.get(s[r]);if(!0!==a.externalTexture){if(f1.label=`colorAttachment_${r}`,f1.baseMipLevel=e.activeMipmapLevel,f1.mipLevelCount=1,f1.baseArrayLayer=e.activeCubeFace,f1.arrayLayerCount=1,f1.dimension=vQ.TwoD,i.isRenderTarget3D)t=e.activeCubeFace,f1.baseArrayLayer=0,f1.dimension=vQ.ThreeD;else if(i.isRenderTarget&&s[r].image.depth>1)if(!0===h){let t=e.camera.cameras;for(let e=0;e<t.length;e++){f1.baseArrayLayer=e,f1.arrayLayerCount=1,f1.dimension=vQ.TwoD;let t=a.texture.createView(f1);l.push({view:t,resolveTarget:void 0,depthSlice:void 0})}}else f1.dimension=vQ.TwoDArray;if(!0!==h){let e,i,r=a.texture.createView(f1);void 0!==a.msaaTexture?(e=a.msaaTexture.createView(),i=r):(e=r,i=void 0),l.push({view:e,resolveTarget:i,depthSlice:t})}f1.reset()}else l.push(...this._createExternalTextureViews(e,a))}let u=[];for(let e=0;e<l.length;e++){let t=l[e],i=new BQ;i.view=t.view,i.depthSlice=t.depthSlice,i.resolveTarget=t.resolveTarget,u.push(i)}if(o={textureViews:l,colorAttachments:u,descriptor:new VQ},e.depth){let t=this.get(e.depthTexture);(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(f1.dimension=vQ.TwoD,f1.arrayLayerCount=1,f1.baseArrayLayer=e.activeCubeFace);let i=new a1;i.view=t.texture.createView(f1),o.depthStencilAttachment=i,f1.reset()}a[n]=o,r.width=i.width,r.height=i.height,r.samples=i.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace}let l=o.descriptor;l.reset();for(let e=0;e<o.colorAttachments.length;e++){let i=o.colorAttachments[e],r={r:0,g:0,b:0,a:1};0===e&&t.clearValue&&(r=t.clearValue),i.loadOp=t.loadOp||iQ.Load,i.storeOp=t.storeOp||tQ.Store,i.clearValue=r,l.colorAttachments.push(i)}return o.depthStencilAttachment&&(l.depthStencilAttachment=o.depthStencilAttachment),l}beginRender(e){let t,i,r=this.get(e),s=this.device,a=e.occlusionQueryCount;a>0&&(r.currentOcclusionQuerySet&&r.currentOcclusionQuerySet.destroy(),r.currentOcclusionQueryBuffer&&r.currentOcclusionQueryBuffer.destroy(),r.currentOcclusionQuerySet=r.occlusionQuerySet,r.currentOcclusionQueryBuffer=r.occlusionQueryBuffer,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,d1.label=`occlusionQuerySet_${e.id}`,d1.type="occlusion",d1.count=a,t=s.createQuerySet(d1),d1.reset(),r.occlusionQuerySet=t,r.occlusionQueryIndex=0,r.occlusionQueryObjects=new Array(a),r.lastOcclusionObject=null),i=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:iQ.Load}),this.initTimestampQuery(Wr.RENDER,this.getTimestampUID(e),i),i.occlusionQuerySet=t;let n=i.depthStencilAttachment;if(null!==e.textures){let t=i.colorAttachments;for(let i=0;i<t.length;i++){let r=t[i];e.clearColor?(0===i?r.clearValue=e.clearColorValue:(o1.r=0,o1.g=0,o1.b=0,o1.a=1,r.clearValue=o1),r.loadOp=iQ.Clear):r.loadOp=iQ.Load,r.storeOp=tQ.Store}}else{let t=i.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=iQ.Clear):t.loadOp=iQ.Load,t.storeOp=tQ.Store}e.depth&&(e.clearDepth?(n.depthClearValue=e.clearDepthValue,n.depthLoadOp=iQ.Clear):n.depthLoadOp=iQ.Load,n.depthStoreOp=tQ.Store),e.stencil&&(e.clearStencil?(n.stencilClearValue=e.clearStencilValue,n.stencilLoadOp=iQ.Clear):n.stencilLoadOp=iQ.Load,n.stencilStoreOp=tQ.Store),h1.label="renderContext_"+e.id;let o=s.createCommandEncoder(h1);if(h1.reset(),!0===this._isRenderCameraDepthArray(e)){let t=e.camera.cameras;r.layerDescriptors&&r.layerDescriptors.length===t.length?this._updateArrayCameraLayerDescriptors(e,r,t):this._createArrayCameraLayerDescriptors(e,r,i,t),r.bundleEncoders=[],r.bundleSets=[];for(let i=0;i<t.length;i++){let t=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+i),s={attributes:{},bindingGroups:[],pipeline:null,index:null};r.bundleEncoders.push(t),r.bundleSets.push(s)}r.currentPass=null}else{let t=o.beginRenderPass(i);r.currentPass=t,e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e)}r.descriptor=i,r.encoder=o,r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},r.renderBundles=[]}_createArrayCameraLayerDescriptors(e,t,i,r){let s=i.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||(a.viewCache=[]);for(let n=0;n<r.length;n++){let r=i.colorAttachments[0],o=new BQ;o.view=i.colorAttachments[n].view,o.depthSlice=r.depthSlice,o.resolveTarget=r.resolveTarget,o.loadOp=r.loadOp,o.storeOp=r.storeOp,o.clearValue=r.clearValue;let l=new VQ;if(l.label=i.label,l.occlusionQuerySet=i.occlusionQuerySet,l.timestampWrites=i.timestampWrites,l.colorAttachments.push(o),i.depthStencilAttachment){let t=n;a.viewCache[t]||(f1.dimension=vQ.TwoD,f1.baseArrayLayer=n,f1.arrayLayerCount=1,a.viewCache[t]=a.texture.createView(f1),f1.reset());let i=new a1;i.view=a.viewCache[t],i.depthLoadOp=s.depthLoadOp||iQ.Clear,i.depthStoreOp=s.depthStoreOp||tQ.Store,i.depthClearValue=s.depthClearValue||1,e.stencil&&(i.stencilLoadOp=s.stencilLoadOp,i.stencilStoreOp=s.stencilStoreOp,i.stencilClearValue=s.stencilClearValue),l.depthStencilAttachment=i}else{let e=new a1;e.view=s.view,e.depthLoadOp=s.depthLoadOp,e.depthStoreOp=s.depthStoreOp,e.depthClearValue=s.depthClearValue,e.depthReadOnly=s.depthReadOnly,e.stencilLoadOp=s.stencilLoadOp,e.stencilStoreOp=s.stencilStoreOp,e.stencilClearValue=s.stencilClearValue,e.stencilReadOnly=s.stencilReadOnly,l.depthStencilAttachment=e}t.layerDescriptors.push(l)}}_updateArrayCameraLayerDescriptors(e,t,i){for(let r=0;r<i.length;r++){let i=t.layerDescriptors[r];if(i.depthStencilAttachment){let t=i.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=iQ.Clear):t.depthLoadOp=iQ.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=iQ.Clear):t.stencilLoadOp=iQ.Load)}}}finishRender(e){let t=this.get(e),i=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),i>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){let i=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];i.push(r.finish())}for(let s=0;s<t.layerDescriptors.length;s++)if(s<i.length){let a=t.layerDescriptors[s],n=r.beginRenderPass(a);if(e.viewport){let{x:t,y:i,width:r,height:s,minDepth:a,maxDepth:o}=e.viewportValue;n.setViewport(t,i,r,s,a,o)}if(e.scissor){let{x:t,y:i,width:r,height:s}=e.scissorValue;n.setScissorRect(t,i,r,s)}n.executeBundles([i[s]]),n.end()}}else t.currentPass&&t.currentPass.end();if(i>0){let r=8*i,s=this.occludedResolveCache.get(r);void 0===s&&(l1.size=r,l1.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,s=this.device.createBuffer(l1),l1.reset(),this.occludedResolveCache.set(r,s)),l1.size=r,l1.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer(l1);l1.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,i,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(JP(this.device,t.encoder.finish()),null!==e.textures){let t=e.textures;for(let e=0;e<t.length;e++){let i=t[e];!0===i.generateMipmaps&&this.textureUtils.generateMipmaps(i)}}}isOccluded(e,t){let i=this.get(e);return i.occluded&&i.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:i,currentOcclusionQueryObjects:r}=t;if(i&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await i.mapAsync(GPUMapMode.READ);let s=i.getMappedRange(),a=new BigUint64Array(s);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);i.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:i,y:r,width:s,height:a,minDepth:n,maxDepth:o}=e.viewportValue;t.setViewport(i,r,s,a,n,o)}updateScissor(e){let{currentPass:t}=this.get(e),{x:i,y:r,width:s,height:a}=e.scissorValue;t.setScissorRect(i,r,s,a)}getClearColor(){let e=super.getClearColor();return!0===this.renderer.alpha&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,i,r=null){let s,a,n,o=this.device,l=this.renderer,h=[];if(e){let e=this.getClearColor();o1.r=e.r,o1.g=e.g,o1.b=e.b,o1.a=e.a}if(null===r){a=l.depth,n=l.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){h=t.colorAttachments;let e=h[0];e.clearValue=o1,e.loadOp=iQ.Clear,e.storeOp=tQ.Store}(a||n)&&(s=t.depthStencilAttachment)}else{a=r.depth,n=r.stencil;let o={loadOp:e?iQ.Clear:iQ.Load,clearValue:e?o1:void 0};a&&(o.depthLoadOp=t?iQ.Clear:iQ.Load,o.depthClearValue=t?l.getClearDepth():void 0,o.depthStoreOp=tQ.Store),n&&(o.stencilLoadOp=i?iQ.Clear:iQ.Load,o.stencilClearValue=i?l.getClearStencil():void 0,o.stencilStoreOp=tQ.Store);let u=this._getRenderPassDescriptor(r,o);h=u.colorAttachments,s=u.depthStencilAttachment}a&&s&&(t?(s.depthLoadOp=iQ.Clear,s.depthClearValue=l.getClearDepth(),s.depthStoreOp=tQ.Store):(s.depthLoadOp=iQ.Load,s.depthStoreOp=tQ.Store)),n&&s&&(i?(s.stencilLoadOp=iQ.Clear,s.stencilClearValue=l.getClearStencil(),s.stencilStoreOp=tQ.Store):(s.stencilLoadOp=iQ.Load,s.stencilStoreOp=tQ.Store)),h1.label="clear";let u=o.createCommandEncoder(h1);h1.reset(),u.beginRenderPass({colorAttachments:h,depthStencilAttachment:s}).end(),JP(o,u.finish())}beginCompute(e){let t=this.get(e),i="computeGroup_"+e.id;u1.label=i,h1.label=i,this.initTimestampQuery(Wr.COMPUTE,this.getTimestampUID(e),u1),t.cmdEncoderGPU=this.device.createCommandEncoder(h1),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(u1),t.currentPipeline=null,h1.reset(),u1.reset()}compute(e,t,i,r,s=null){let a=this.get(t),n=this.get(e),{passEncoderGPU:o}=n,l=this.get(r).pipeline;n.currentPipeline!==l&&(o.setPipeline(l),n.currentPipeline=l);for(let e=0,t=i.length;e<t;e++){let t=i[e],r=this.get(t);o.setBindGroup(e,r.group)}if(null===s&&(s=t.dispatchSize||t.count),s&&s.isIndirectStorageBufferAttribute){let e=this.get(s).buffer;return void o.dispatchWorkgroupsIndirect(e,0)}if("number"==typeof s){let e=s;if(void 0===a.dispatchSize||a.count!==e){a.dispatchSize=[0,1,1],a.count=e;let i=t.workgroupSize,r=i[0];for(let e=1;e<i.length;e++)r*=i[e];let n=Math.ceil(e/r),o=this.device.limits.maxComputeWorkgroupsPerDimension;s=[n,1,1],n>o&&(s[0]=Math.min(n,o),s[1]=Math.ceil(n/o)),a.dispatchSize=s}s=a.dispatchSize}o.dispatchWorkgroups(s[0],s[1]||1,s[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),JP(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,i,r,s,a,n,o,l){let{object:h,context:u}=e,d=e.drawMaterial,c=e.getIndex(),p=null!==c;l.pipeline!==r&&(o.setPipeline(r),l.pipeline=r);let m=l.bindingGroups;for(let e=0,t=s.length;e<t;e++){let t=s[e];if(m[e]!==t.id){let i=this.get(t);o.setBindGroup(e,i.group),m[e]=t.id}}if(!0===p&&l.index!==c){let e=this.get(c).buffer,t=c.array instanceof Uint16Array?aQ.Uint16:aQ.Uint32;o.setIndexBuffer(e,t),l.index=c}for(let e=0,t=a.length;e<t;e++){let t=a[e];if(l.attributes[e]!==t){let i=this.get(t).buffer;o.setVertexBuffer(e,i),l.attributes[e]=t}}if(!0===u.stencil&&!0===d.stencilWrite&&i.currentStencilRef!==d.stencilRef&&(o.setStencilReference(d.stencilRef),i.currentStencilRef=d.stencilRef),!0===h.isBatchedMesh){let e=h._multiDrawStarts,i=h._multiDrawCounts,r=h._multiDrawCount,s=!0===p?c.array.BYTES_PER_ELEMENT:1;d.wireframe&&(s=h.geometry.attributes.position.count>65535?4:2);for(let a=0;a<r;a++)!0===p?o.drawIndexed(i[a],1,e[a]/s,0,a):o.draw(i[a],1,e[a],a),t.update(h,i[a],1)}else if(!0===p){let{vertexCount:i,instanceCount:r,firstVertex:s}=n,a=e.getIndirect();if(null!==a){let t=this.get(a).buffer,i=e.getIndirectOffset(),r=Array.isArray(i)?i:[i];for(let e=0;e<r.length;e++)o.drawIndexedIndirect(t,r[e])}else o.drawIndexed(i,r,s,0,0);t.update(h,i,r)}else{let{vertexCount:i,instanceCount:r,firstVertex:s}=n,a=e.getIndirect();if(null!==a){let t=this.get(a).buffer,i=e.getIndirectOffset(),r=Array.isArray(i)?i:[i];for(let e=0;e<r.length;e++)o.drawIndirect(t,r[e])}else o.draw(i,r,s,0);t.update(h,i,r)}}draw(e,t){let{object:i,context:r,pipeline:s}=e,a=this.get(r),n=this.get(s),o=n.pipeline;if(!0===n.error)return;let l=e.getDrawParameters();if(null===l)return;let h=e.getBindings(),u=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let s=this.get(e.camera),n=e.camera.cameras,d=e.getBindingGroup("cameraIndex");if(void 0===s.indexesGPU||s.indexesGPU.length!==n.length){let e=this.get(d),t=[],i=new Uint32Array([0,0,0,0]);for(let r=0,s=n.length;r<s;r++){i[0]=r;let{layoutGPU:s}=e.layout,a=this.bindingUtils.createBindGroupIndex(i,s);t.push(a)}s.indexesGPU=t}let c=this.renderer.getPixelRatio();for(let p=0,m=n.length;p<m;p++){let m=n[p];if(i.layers.test(m.layers)){let i=m.viewport,n=a.currentPass,g=a.currentSets,f=void 0!==a.bundleEncoders;if(f&&(n=a.bundleEncoders[p],g=a.bundleSets[p]),i&&!f&&n.setViewport(Math.floor(i.x*c),Math.floor(i.y*c),Math.floor(i.width*c),Math.floor(i.height*c),r.viewportValue.minDepth,r.viewportValue.maxDepth),d&&s.indexesGPU){let e=h.indexOf(d);n.setBindGroup(e,s.indexesGPU[p]),g.bindingGroups[e]=d.id}this._draw(e,t,a,o,h,u,l,n,g)}}}else if(a.currentPass){if(void 0!==a.occlusionQuerySet){let e=a.lastOcclusionObject;e!==i&&(null!==e&&!0===e.occlusionTest&&(a.currentPass.endOcclusionQuery(),a.occlusionQueryIndex++),!0===i.occlusionTest&&(a.currentPass.beginOcclusionQuery(a.occlusionQueryIndex),a.occlusionQueryObjects[a.occlusionQueryIndex]=i),a.lastOcclusionObject=i)}this._draw(e,t,a,o,h,u,l,a.currentPass,a.currentSets)}}needsRenderUpdate(e){let t=this.get(e),i=e.material,r=!1;return(t.material!==i||t.materialVersion!==i.version)&&(t.material=i,t.materialVersion=i.version,r=!0),this._syncStructuralState(t,e,i)||r}_syncStructuralState(e,t,i){let{object:r}=t,s=this.utils,a=s.getSampleCountRenderContext(t.context),n=s.getCurrentColorSpace(t.context),o=s.getCurrentColorFormat(t.context),l=s.getCurrentDepthStencilFormat(t.context),h=s.getPrimitiveTopology(r,i),u=r.isMesh&&r.matrixWorld.determinantAffine()<0,d=!1;return(e.transparent!==i.transparent||e.blending!==i.blending||e.premultipliedAlpha!==i.premultipliedAlpha||e.blendSrc!==i.blendSrc||e.blendDst!==i.blendDst||e.blendEquation!==i.blendEquation||e.blendSrcAlpha!==i.blendSrcAlpha||e.blendDstAlpha!==i.blendDstAlpha||e.blendEquationAlpha!==i.blendEquationAlpha||e.colorWrite!==i.colorWrite||e.depthWrite!==i.depthWrite||e.depthTest!==i.depthTest||e.depthFunc!==i.depthFunc||e.stencilWrite!==i.stencilWrite||e.stencilFunc!==i.stencilFunc||e.stencilFail!==i.stencilFail||e.stencilZFail!==i.stencilZFail||e.stencilZPass!==i.stencilZPass||e.stencilFuncMask!==i.stencilFuncMask||e.stencilWriteMask!==i.stencilWriteMask||e.side!==i.side||e.alphaToCoverage!==i.alphaToCoverage||e.polygonOffset!==i.polygonOffset||e.polygonOffsetFactor!==i.polygonOffsetFactor||e.polygonOffsetUnits!==i.polygonOffsetUnits||e.sampleCount!==a||e.colorSpace!==n||e.colorFormat!==o||e.depthStencilFormat!==l||e.primitiveTopology!==h||e.frontFaceCW!==u||e.clippingContextCacheKey!==t.clippingContextCacheKey)&&(e.transparent=i.transparent,e.blending=i.blending,e.premultipliedAlpha=i.premultipliedAlpha,e.blendSrc=i.blendSrc,e.blendDst=i.blendDst,e.blendEquation=i.blendEquation,e.blendSrcAlpha=i.blendSrcAlpha,e.blendDstAlpha=i.blendDstAlpha,e.blendEquationAlpha=i.blendEquationAlpha,e.colorWrite=i.colorWrite,e.depthWrite=i.depthWrite,e.depthTest=i.depthTest,e.depthFunc=i.depthFunc,e.stencilWrite=i.stencilWrite,e.stencilFunc=i.stencilFunc,e.stencilFail=i.stencilFail,e.stencilZFail=i.stencilZFail,e.stencilZPass=i.stencilZPass,e.stencilFuncMask=i.stencilFuncMask,e.stencilWriteMask=i.stencilWriteMask,e.side=i.side,e.alphaToCoverage=i.alphaToCoverage,e.polygonOffset=i.polygonOffset,e.polygonOffsetFactor=i.polygonOffsetFactor,e.polygonOffsetUnits=i.polygonOffsetUnits,e.sampleCount=a,e.colorSpace=n,e.colorFormat=o,e.depthStencilFormat=l,e.primitiveTopology=h,e.frontFaceCW=u,e.clippingContextCacheKey=t.clippingContextCacheKey,d=!0),d}detectStructuralChange(e){return this._syncStructuralState(this.get(e),e,e.material)}getAttachmentStateKey(e){let t=this.utils,i=e.context;return t.getSampleCountRenderContext(i)+","+t.getCurrentColorSpace(i)+","+t.getCurrentColorFormat(i)+","+t.getCurrentDepthStencilFormat(i)}syncRenderUpdateState(e,t){let i=this.get(e);i.material=e.material,i.materialVersion=e.material.version,this._syncStructuralState(i,e,t)}getVertexLayoutCacheKey(e){let{object:t,geometry:i}=e,r="";for(let t of this.attributeUtils.createShaderVertexBuffers(e)){r+=t.stepMode+":"+t.arrayStride+":";for(let e of t.attributes)r+=e.shaderLocation+"-"+e.offset+"-"+e.format+",";r+=";"}return null!==i.index&&!0===t.isLine&&!0!==t.isLineSegments&&(r+=i.index.array instanceof Uint16Array?"index-u16":"index-u32"),r}getRenderCacheKey(e){let{object:t}=e,i=e.drawMaterial,r=this.utils,s=e.context,a=t.isMesh&&t.matrixWorld.determinantAffine()<0,n=r.getSampleCountRenderContext(s),o=i.blending!==He&&(i.blending!==$e||!1!==i.transparent),l=o&&i.blending===Ze,h=!0===s.depth,u=!0===s.stencil,d=u&&!0===i.stencilWrite,c=r.getPrimitiveTopology(t,i),p=(h||u)&&!0===i.polygonOffset&&c===JJ.TriangleList;return[o?i.blending:-1,o&&!1===l?i.premultipliedAlpha:-1,l?i.blendSrc:-1,l?i.blendDst:-1,l?i.blendEquation:-1,l?null!==i.blendSrcAlpha?i.blendSrcAlpha:i.blendSrc:-1,l?null!==i.blendDstAlpha?i.blendDstAlpha:i.blendDst:-1,l?null!==i.blendEquationAlpha?i.blendEquationAlpha:i.blendEquation:-1,i.colorWrite,h?i.depthWrite:-1,h&&!0===i.depthTest?i.depthFunc:-1,d?i.stencilFunc:-1,d?i.stencilFail:-1,d?i.stencilZFail:-1,d?i.stencilZPass:-1,u?i.stencilFuncMask:-1,u?i.stencilWriteMask:-1,p?i.polygonOffsetUnits:0,p?i.polygonOffsetFactor:0,!0===i.alphaToCoverage&&n>1,i.side,a,n,r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),c,this.getVertexLayoutCacheKey(e),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,i,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,i,r,s,a)}initTimestampQuery(e,t,i){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new r1(this.device,e,2048));let r=this.timestampQueryPool[e],s=r.allocateQueriesForContext(t);p1.querySet=r.querySet,p1.beginningOfPassWriteIndex=s,p1.endOfPassWriteIndex=s+1,i.timestampWrites=p1}createNodeBuilder(e,t){return new B0(e,t)}createProgram(e){let t=this.get(e);c1.label=e.stage+(""!==e.name?`_${e.name}`:""),c1.code=e.code,t.module={module:this.device.createShaderModule(c1),entryPoint:"main"},c1.reset()}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let i=this.get(e),r=i.currentPass.finish();this.get(t).bundleGPU=r,i.currentSets=i._currentSets,i.currentPass=i._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createUniformBuffer(e){let t=this.get(e);if(void 0===t.buffer){let i=e.byteLength,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=[];e.visibility&QJ.VERTEX&&s.push("vertex"),e.visibility&QJ.FRAGMENT&&s.push("fragment"),e.visibility&QJ.COMPUTE&&s.push("compute");let a=`(${s.join(",")})`;l1.label=`bindingBuffer${e.id}_${e.name}_${a}`,l1.size=i,l1.usage=r;let n=this.device.createBuffer(l1);l1.reset(),t.buffer=n}}destroyUniformBuffer(e){this.get(e).buffer.destroy(),this.delete(e)}createBindings(e,t,i,r){this.bindingUtils.createBindings(e,t,i,r)}updateBindings(e,t,i,r){this.bindingUtils.createBindings(e,t,i,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}hasFeature(e){return void 0!==_Q[e]&&(e=_Q[e]),this.device.features.has(e)}copyTextureToTexture(e,t,i=null,r=null,s=0,a=0){let n=0,o=0,l=0,h=0,u=0,d=0,c=e.image.width,p=e.image.height,m=1;null!==i&&(!0===i.isBox3?(h=i.min.x,u=i.min.y,d=i.min.z,c=i.max.x-i.min.x,p=i.max.y-i.min.y,m=i.max.z-i.min.z):(h=i.min.x,u=i.min.y,c=i.max.x-i.min.x,p=i.max.y-i.min.y,m=1)),null!==r&&(n=r.x,o=r.y,l=r.z||0),h1.label="copyTextureToTexture_"+e.id+"_"+t.id;let g=this.device.createCommandEncoder(h1);h1.reset();let f=this.get(e).texture,y=this.get(t).texture;m1.texture=f,m1.mipLevel=s,m1.origin.x=h,m1.origin.y=u,m1.origin.z=d,g1.texture=y,g1.mipLevel=a,g1.origin.x=n,g1.origin.y=o,g1.origin.z=l,y1.width=c,y1.height=p,y1.depthOrArrayLayers=m,g.copyTextureToTexture(m1,g1,y1),m1.reset(),g1.reset(),y1.reset(),JP(this.device,g.finish()),0===a&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,i){let r=this.get(t),s=null;s=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a,n=this.get(e).texture;if(s.format===n.format)if(r.currentPass?(r.currentPass.end(),a=r.encoder):(h1.label="copyFramebufferToTexture_"+e.id,a=this.device.createCommandEncoder(h1),h1.reset()),m1.texture=s,m1.origin.x=i.x,m1.origin.y=i.y,g1.texture=n,y1.width=i.z,y1.height=i.w,a.copyTextureToTexture(m1,g1,y1),m1.reset(),g1.reset(),y1.reset(),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,a),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=iQ.Load;t.depth&&(e.depthStencilAttachment.depthLoadOp=iQ.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=iQ.Load),r.currentPass=a.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else JP(this.device,a.finish());else y("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,n.format)}hasCompatibility(e){return void 0!==this._compatibility[e]?this._compatibility[e]:super.hasCompatibility(e)}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(let e of Object.values(this.timestampQueryPool))null!==e&&e.dispose();void 0===this.parameters.device&&null!==this.device&&this.device.destroy()}},b1=class extends oh{constructor(e,t,i,r,s,a){super(e,t,i,r,s,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},x1=class extends oh{constructor(e,t,i,r,s,a){super(e,t,i,r,s,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},w1=class extends bJ{constructor(){super(),this.addMaterial(SF,"MeshPhongMaterial"),this.addMaterial(uG,"MeshStandardMaterial"),this.addMaterial(cG,"MeshPhysicalMaterial"),this.addMaterial(fG,"MeshToonMaterial"),this.addMaterial(pF,"MeshBasicMaterial"),this.addMaterial(wF,"MeshLambertMaterial"),this.addMaterial(iF,"MeshNormalMaterial"),this.addMaterial(bG,"MeshMatcapMaterial"),this.addMaterial(jU,"LineBasicMaterial"),this.addMaterial(WU,"LineDashedMaterial"),this.addMaterial(TG,"PointsMaterial"),this.addMaterial(_G,"SpriteMaterial"),this.addMaterial(PG,"ShadowMaterial"),this.addLight(ZY,hh),this.addLight(ZZ,ch),this.addLight(oJ,mh),this.addLight(QZ,oh),this.addLight(KZ,ph),this.addLight(JZ,$l),this.addLight(tJ,fh),this.addLight(eJ,b1),this.addLight(rJ,x1),this.addToneMapping(VH,At),this.addToneMapping(DH,Nt),this.addToneMapping(IH,Pt),this.addToneMapping(zH,Rt),this.addToneMapping(jH,Et),this.addToneMapping(GH,Ot)}},_1=class extends OJ{constructor(e={}){if(e.forceWebGL)throw new Error("WebGPURenderer: forceWebGL is not supported in this WebGPU-only build.");let t=v1;e.getFallback=e=>{throw new Error("WebGPURenderer: WebGPU is not available, and this WebGPU-only build has no WebGL2 fallback. "+(e&&e.message?e.message:e))},super(new t(e),e),this.library=new w1,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},S1=class{constructor(e,t=LE(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;let i=new UU;i.name="RenderPipeline",this._quadMesh=new Oq(i),this._quadMesh.name="Render Pipeline",this._context=null,this._toneMapping=e.toneMapping,this._outputColorSpace=e.outputColorSpace}render(){let e=this.renderer;this._update(),null!==this._context.onBeforeRenderPipeline&&this._context.onBeforeRenderPipeline();let t=e.toneMapping,i=e.outputColorSpace;e.toneMapping=Ct,e.outputColorSpace=ms.workingColorSpace;let r=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=r,e.toneMapping=t,e.outputColorSpace=i,null!==this._context.onAfterRenderPipeline&&this._context.onAfterRenderPipeline()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),!0===this.needsUpdate){let e=this._toneMapping,t=this._outputColorSpace,i={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null},r=this.outputNode;!0===this.outputColorTransform?(r=r.context(i),r=zD(r,e,t)):(i.toneMapping=e,i.outputColorSpace=t,r=r.context(i)),this._context=i,this._quadMesh.material.fragmentNode=r,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){v('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}}}),b5=n(()=>{v5(),hZ.BRDF_GGX,hZ.BRDF_Lambert,hZ.BasicPointShadowFilter,hZ.BasicShadowFilter,M1=hZ.Break,hZ.Const,hZ.Continue,hZ.DFGLUT,hZ.D_GGX,T1=hZ.Discard,hZ.EPSILON,hZ.F_Schlick,C1=hZ.Fn,hZ.INFINITY,A1=hZ.If,N1=hZ.Loop,hZ.NodeAccess,hZ.NodeShaderStage,hZ.NodeType,P1=hZ.NodeUpdateType,hZ.PCFShadowFilter,hZ.PCFSoftShadowFilter,R1=hZ.PI,hZ.PI2,hZ.TWO_PI,hZ.HALF_PI,E1=hZ.PointShadowFilter,hZ.Return,hZ.Schlick_to_F0,hZ.ShaderNode,hZ.Stack,hZ.Switch,hZ.TBNViewMatrix,hZ.VSMShadowFilter,hZ.V_GGX_SmithCorrelated,hZ.Var,hZ.VarIntent,O1=hZ.abs,hZ.acesFilmicToneMapping,B1=hZ.acos,hZ.acosh,hZ.add,hZ.addMethodChaining,hZ.addNodeElement,hZ.agxToneMapping,hZ.all,hZ.alphaT,hZ.ambientOcclusion,hZ.and,hZ.anisotropy,hZ.anisotropyB,hZ.anisotropyT,V1=hZ.any,hZ.append,hZ.array,D1=hZ.asin,hZ.asinh,hZ.assign,I1=hZ.atan,hZ.atanh,hZ.atomicAdd,hZ.atomicAnd,hZ.atomicFunc,hZ.atomicLoad,hZ.atomicMax,hZ.atomicMin,hZ.atomicOr,hZ.atomicStore,hZ.atomicSub,hZ.atomicXor,hZ.attenuationColor,hZ.attenuationDistance,L1=hZ.attribute,hZ.attributeArray,hZ.backgroundBlurriness,hZ.backgroundIntensity,hZ.backgroundRotation,hZ.batch,hZ.bentNormalView,hZ.billboarding,hZ.bitAnd,hZ.bitNot,hZ.bitOr,hZ.bitXor,hZ.bitangentGeometry,hZ.bitangentLocal,hZ.bitangentView,hZ.bitangentWorld,z1=hZ.bitcast,hZ.blendBurn,hZ.blendColor,hZ.blendDodge,hZ.blendOverlay,hZ.blendScreen,hZ.blur,k1=hZ.bool,U1=hZ.buffer,hZ.bufferAttribute,hZ.bumpMap,hZ.builtin,hZ.builtinAOContext,hZ.builtinShadowContext,hZ.bvec2,hZ.bvec3,hZ.bvec4,hZ.bypass,hZ.cache,hZ.call,hZ.cameraFar,hZ.cameraIndex,F1=hZ.cameraNear,hZ.cameraNormalMatrix,j1=hZ.cameraPosition,G1=hZ.cameraProjectionMatrix,W1=hZ.cameraProjectionMatrixInverse,q1=hZ.cameraViewMatrix,hZ.cameraViewport,H1=hZ.cameraWorldMatrix,hZ.cbrt,hZ.cdl,hZ.ceil,hZ.checker,hZ.cineonToneMapping,$1=hZ.clamp,Y1=hZ.clearcoat,X1=hZ.clearcoatNormalView,K1=hZ.clearcoatRoughness,hZ.clipSpace,hZ.code,Z1=hZ.color,hZ.colorSpaceToWorking,hZ.colorToDirection,hZ.compute,hZ.computeKernel,hZ.computeSkinning,hZ.context,hZ.convert,hZ.convertColorSpace,J1=hZ.convertToTexture,hZ.countLeadingZeros,hZ.countOneBits,hZ.countTrailingZeros,Q1=hZ.cos,hZ.cosh,e2=hZ.cross,t2=hZ.cubeTexture,hZ.cubeTextureBase,i2=hZ.dFdx,r2=hZ.dFdy,hZ.dashSize,hZ.debug,hZ.decrement,hZ.decrementBefore,hZ.defaultBuildStages,hZ.defaultShaderStages,hZ.defined,hZ.degrees,hZ.deltaTime,hZ.densityFog,hZ.densityFogFactor,s2=hZ.depth,hZ.depthPass,hZ.determinant,hZ.difference,a2=hZ.diffuseColor,hZ.directPointLight,hZ.directionToColor,hZ.directionToFaceDirection,hZ.dispersion,n2=hZ.distance,hZ.div,o2=hZ.dot,hZ.drawIndex,hZ.dynamicBufferAttribute,hZ.element,l2=hZ.emissive,hZ.equal,hZ.equirectDirection,hZ.equirectUV,h2=hZ.exp,u2=hZ.exp2,hZ.exponentialHeightFogFactor,hZ.expression,d2=hZ.faceDirection,hZ.faceForward,hZ.faceforward,c2=hZ.float,hZ.floatBitsToInt,hZ.floatBitsToUint,p2=hZ.floor,m2=hZ.fog,g2=hZ.fract,hZ.frameGroup,hZ.frameId,f2=hZ.frontFacing,y2=hZ.fwidth,hZ.gain,hZ.gapSize,hZ.getConstNodeType,hZ.getCurrentStack,hZ.getDirection,hZ.getDistanceAttenuation,hZ.getGeometryRoughness,hZ.getNormalFromDepth,v2=hZ.interleavedGradientNoise,b2=hZ.vogelDiskSample,hZ.getParallaxCorrectNormal,hZ.getRoughness,hZ.getScreenPosition,hZ.getShIrradianceAt,hZ.getShadowMaterial,hZ.getShadowRenderObjectFunction,hZ.getTextureIndex,x2=hZ.getViewPosition,hZ.globalId,hZ.glsl,hZ.glslFn,hZ.grayscale,hZ.greaterThan,hZ.greaterThanEqual,hZ.hash,hZ.highpModelNormalViewMatrix,hZ.highpModelViewMatrix,w2=hZ.hue,hZ.increment,hZ.incrementBefore,hZ.instance,_2=hZ.instanceIndex,hZ.instancedArray,S2=hZ.instancedBufferAttribute,M2=hZ.instancedDynamicBufferAttribute,hZ.instancedMesh,T2=hZ.int,hZ.intBitsToFloat,hZ.inverse,C2=hZ.inverseSqrt,hZ.inversesqrt,hZ.invocationLocalIndex,hZ.invocationSubgroupIndex,A2=hZ.ior,N2=hZ.iridescence,P2=hZ.iridescenceIOR,R2=hZ.iridescenceThickness,E2=hZ.ivec2,O2=hZ.ivec3,hZ.ivec4,hZ.js,hZ.label,B2=hZ.length,hZ.lengthSq,hZ.lessThan,hZ.lessThanEqual,hZ.lightPosition,hZ.lightProjectionUV,hZ.lightShadowMatrix,V2=hZ.lightTargetDirection,hZ.lightTargetPosition,hZ.lightViewPosition,D2=hZ.lightingContext,hZ.lights,hZ.linearDepth,hZ.linearToneMapping,hZ.localId,hZ.log,I2=hZ.log2,hZ.logarithmicDepthToViewZ,L2=hZ.luminance,hZ.mat2,z2=hZ.mat3,k2=hZ.mat4,hZ.matcapUV,hZ.materialAO,hZ.materialAlphaTest,hZ.materialAnisotropy,hZ.materialAnisotropyVector,hZ.materialAttenuationColor,hZ.materialAttenuationDistance,hZ.materialClearcoat,hZ.materialClearcoatNormal,hZ.materialClearcoatRoughness,U2=hZ.materialColor,hZ.materialDispersion,hZ.materialEmissive,F2=hZ.materialEnvIntensity,hZ.materialEnvRotation,hZ.materialIOR,hZ.materialIridescence,hZ.materialIridescenceIOR,hZ.materialIridescenceThickness,hZ.materialLightMap,hZ.materialLineDashOffset,hZ.materialLineDashSize,hZ.materialLineGapSize,hZ.materialLineScale,hZ.materialLineWidth,hZ.materialMetalness,hZ.materialNormal,hZ.materialOpacity,hZ.materialPointSize,hZ.materialReference,hZ.materialReflectivity,hZ.materialRefractionRatio,hZ.materialRotation,hZ.materialRoughness,hZ.materialSheen,hZ.materialSheenRoughness,hZ.materialShininess,hZ.materialSpecular,hZ.materialSpecularColor,hZ.materialSpecularIntensity,hZ.materialSpecularStrength,hZ.materialThickness,hZ.materialTransmission,j2=hZ.max,hZ.maxMipLevel,hZ.mediumpModelViewMatrix,G2=hZ.metalness,W2=hZ.min,q2=hZ.mix,hZ.mixElement,H2=hZ.mod,hZ.modelDirection,$2=hZ.modelNormalMatrix,hZ.modelPosition,hZ.modelRadius,Y2=hZ.modelScale,hZ.modelViewMatrix,hZ.modelViewPosition,X2=hZ.modelViewProjection,K2=hZ.modelWorldMatrix,Z2=hZ.modelWorldMatrixInverse,hZ.morphReference,J2=hZ.mrt,Q2=hZ.mul,hZ.mx_aastep,hZ.mx_add,hZ.mx_atan2,hZ.mx_cell_noise_float,hZ.mx_contrast,hZ.mx_divide,hZ.mx_fractal_noise_float,hZ.mx_fractal_noise_vec2,hZ.mx_fractal_noise_vec3,hZ.mx_fractal_noise_vec4,hZ.mx_frame,hZ.mx_heighttonormal,hZ.mx_hsvtorgb,hZ.mx_ifequal,hZ.mx_ifgreater,hZ.mx_ifgreatereq,hZ.mx_invert,hZ.mx_modulo,hZ.mx_multiply,hZ.mx_noise_float,hZ.mx_noise_vec3,hZ.mx_noise_vec4,hZ.mx_place2d,hZ.mx_power,hZ.mx_ramp4,hZ.mx_ramplr,hZ.mx_ramptb,hZ.mx_rgbtohsv,hZ.mx_rotate2d,hZ.mx_rotate3d,hZ.mx_safepower,hZ.mx_separate,hZ.mx_splitlr,hZ.mx_splittb,hZ.mx_srgb_texture_to_lin_rec709,hZ.mx_subtract,hZ.mx_timer,hZ.mx_transform_uv,hZ.mx_unifiednoise2d,hZ.mx_unifiednoise3d,hZ.mx_worley_noise_float,hZ.mx_worley_noise_vec2,hZ.mx_worley_noise_vec3,hZ.negate,e3=hZ.negateOnBackSide,hZ.neutralToneMapping,hZ.nodeArray,hZ.nodeImmutable,t3=hZ.nodeObject,hZ.nodeObjectIntent,hZ.nodeObjects,hZ.nodeProxy,hZ.nodeProxyIntent,hZ.normalFlat,i3=hZ.normalGeometry,r3=hZ.normalLocal,hZ.normalMap,s3=hZ.normalView,hZ.normalViewGeometry,a3=hZ.normalWorld,hZ.normalWorldGeometry,n3=hZ.normalize,hZ.not,o3=hZ.notEqual,hZ.numWorkgroups,hZ.objectDirection,hZ.objectGroup,hZ.objectPosition,hZ.objectRadius,hZ.objectScale,hZ.objectViewPosition,hZ.objectWorldMatrix,hZ.OnBeforeObjectUpdate,hZ.OnBeforeMaterialUpdate,hZ.OnObjectUpdate,hZ.OnMaterialUpdate,l3=hZ.oneMinus,hZ.or,h3=hZ.orthographicDepthToViewZ,hZ.oscSawtooth,hZ.oscSine,hZ.oscSquare,hZ.oscTriangle,u3=hZ.output,d3=hZ.outputStruct,hZ.overloadingFn,hZ.overrideNode,hZ.overrideNodes,hZ.packHalf2x16,hZ.packSnorm2x16,hZ.packUnorm2x16,c3=hZ.packNormalToRGB,hZ.parabola,hZ.parallaxDirection,hZ.parallaxUV,hZ.parameter,p3=hZ.pass,m3=hZ.passTexture,hZ.pcurve,g3=hZ.perspectiveDepthToViewZ,f3=hZ.pmremTexture,hZ.pointShadow,hZ.pointUV,hZ.pointWidth,y3=hZ.positionGeometry,v3=hZ.positionLocal,b3=hZ.positionPrevious,x3=hZ.positionView,w3=hZ.positionViewDirection,_3=hZ.positionWorld,hZ.positionWorldDirection,hZ.posterize,S3=hZ.pow,M3=hZ.pow2,hZ.pow3,T3=hZ.pow4,C3=hZ.premultiplyAlpha,A3=hZ.property,hZ.radians,N3=hZ.rand,hZ.range,hZ.rangeFog,P3=hZ.rangeFogFactor,hZ.reciprocal,hZ.reference,hZ.referenceBuffer,R3=hZ.reflect,hZ.reflectVector,hZ.reflectView,hZ.reflector,E3=hZ.refract,hZ.refractVector,hZ.refractView,hZ.reinhardToneMapping,hZ.remap,hZ.remapClamp,O3=hZ.renderGroup,hZ.renderOutput,hZ.rendererReference,hZ.replaceDefaultUV,hZ.rotate,hZ.rotateUV,B3=hZ.roughness,V3=hZ.round,hZ.rtt,hZ.sRGBTransferEOTF,hZ.sRGBTransferOETF,hZ.sample,hZ.sampler,hZ.samplerComparison,D3=hZ.saturate,I3=hZ.saturation,hZ.screen,L3=hZ.screenCoordinate,hZ.screenDPR,hZ.screenSize,z3=hZ.screenUV,k3=hZ.select,hZ.setCurrentStack,hZ.setName,hZ.shaderStages,hZ.shadow,hZ.shadowPositionWorld,hZ.shapeCircle,hZ.sharedUniformGroup,U3=hZ.sheen,F3=hZ.sheenRoughness,hZ.shiftLeft,hZ.shiftRight,j3=hZ.shininess,G3=hZ.sign,W3=hZ.sin,hZ.sinh,hZ.sinc,hZ.skinning,q3=hZ.smoothstep,hZ.smoothstepElement,H3=hZ.specularColor,$3=hZ.specularF90,hZ.spherizeUV,hZ.split,hZ.spritesheetUV,Y3=hZ.sqrt,hZ.stack,X3=hZ.step,hZ.stepElement,K3=hZ.storage,hZ.storageBarrier,hZ.storageTexture,hZ.storageTexture3D,hZ.struct,Z3=hZ.sub,hZ.subgroupAdd,hZ.subgroupAll,hZ.subgroupAnd,hZ.subgroupAny,hZ.subgroupBallot,hZ.subgroupBroadcast,hZ.subgroupBroadcastFirst,J3=hZ.subBuild,hZ.subgroupElect,hZ.subgroupExclusiveAdd,hZ.subgroupExclusiveMul,hZ.subgroupInclusiveAdd,hZ.subgroupInclusiveMul,hZ.subgroupIndex,hZ.subgroupMax,hZ.subgroupMin,hZ.subgroupMul,hZ.subgroupOr,hZ.subgroupShuffle,hZ.subgroupShuffleDown,hZ.subgroupShuffleUp,hZ.subgroupShuffleXor,hZ.subgroupSize,hZ.subgroupXor,Q3=hZ.tan,hZ.tanh,hZ.tangentGeometry,hZ.tangentLocal,hZ.tangentView,hZ.tangentWorld,e5=hZ.texture,hZ.texture3D,hZ.textureBarrier,hZ.textureBicubic,hZ.textureBicubicLevel,hZ.textureCubeUV,hZ.textureLoad,t5=hZ.textureSize,hZ.textureLevel,hZ.textureStore,hZ.thickness,i5=hZ.time,hZ.toneMapping,hZ.toneMappingExposure,hZ.toonOutlinePass,r5=hZ.transformDirection,hZ.transformNormal,hZ.transformNormalByInverseViewMatrix,hZ.transformNormalByViewMatrix,s5=hZ.transformNormalToView,hZ.transformedClearcoatNormalView,hZ.transformedNormalView,hZ.transformedNormalWorld,hZ.transmission,hZ.transpose,hZ.triNoise3D,hZ.triplanarTexture,hZ.triplanarTextures,hZ.trunc,a5=hZ.uint,hZ.uintBitsToFloat,n5=hZ.uniform,o5=hZ.uniformArray,hZ.uniformCubeTexture,hZ.uniformGroup,hZ.uniformFlow,hZ.uniformTexture,hZ.unpackHalf2x16,hZ.unpackSnorm2x16,hZ.unpackUnorm2x16,hZ.unpackRGBToNormal,l5=hZ.unpremultiplyAlpha,h5=hZ.userData,u5=hZ.uv,hZ.uvec2,d5=hZ.uvec3,hZ.uvec4,hZ.varying,c5=hZ.varyingProperty,p5=hZ.vec2,m5=hZ.vec3,g5=hZ.vec4,hZ.vectorComponents,f5=hZ.velocity,y5=hZ.vertexColor,hZ.vertexIndex,hZ.vertexStage,hZ.vibrance,hZ.viewZToLogarithmicDepth,hZ.viewZToOrthographicDepth,hZ.viewZToPerspectiveDepth,hZ.viewZToReversedOrthographicDepth,hZ.viewZToReversedPerspectiveDepth,hZ.viewport,hZ.viewportCoordinate,hZ.viewportDepthTexture,hZ.viewportLinearDepth,hZ.viewportMipTexture,hZ.viewportOpaqueMipTexture,hZ.viewportResolution,hZ.viewportSafeUV,hZ.viewportSharedTexture,hZ.viewportSize,hZ.viewportTexture,hZ.viewportUV,hZ.wgsl,hZ.wgslFn,hZ.workgroupArray,hZ.workgroupBarrier,hZ.workgroupId,hZ.workingToColorSpace,hZ.xor});function x5(){try{return"0"!==new URLSearchParams(window.location.search).get("dbgsrgb8")}catch{return!0}}var w5,_5,S5,M5,T5,C5,A5,N5,P5=n(()=>{Mu(),b5(),w5=8,_5=new ws,S5=(()=>{let e=new Yn(new Uint8Array([0,0,0,255]),1,1);return e.minFilter=qt,e.magFilter=qt,e.needsUpdate=!0,e})(),M5=(()=>{let e=new Yn(new Uint8Array([0,0,0,255]),1,1);return e.minFilter=qt,e.magFilter=qt,e.needsUpdate=!0,e})(),T5=(()=>{let e=new Yn(new Uint8Array([255,255,255,255]),1,1);return e.minFilter=qt,e.magFilter=qt,e.needsUpdate=!0,e})(),C5=(()=>{let e=new Yn(new Uint8Array([0,0,0,0]),1,1);return e.minFilter=qt,e.magFilter=qt,e.needsUpdate=!0,e})(),A5={chainBuilds:0,lastChainBuildReason:"",taaResolves:0,taaJitterIndex:0,taaJitterApplies:0,taaHistoryValid:!1,taaResolveSize:"",helperOverlayMode:"",deviceLost:"",outputInterpositions:0,bundleChecks:0,bundleRebuilds:0,bundleDisabled:!1,bundleResourceRebuilds:0,bundleIncompleteRecords:0,bundleRecords:0,bundleReplays:0,instancingGroups:0,instancedDrawsSaved:0,instancingRegroups:0,instancingParks:0,instancingIneligible:{},skippedAsyncDraws:0,stalledSkipFrames:0,compilationBurst:!1,pcssLights:0,pcssInstalled:0,pcssForeignFilter:0,pcssPyramidBuilds:0,pcssPyramidActive:0,shadowMaskResolves:0,shadowMaskActive:0,pcssHookServes:0,pcssRadius0:0,pcssPenumbra0:0,nodeResurrections:0,shadowTypeSoft:!0},typeof window<"u"&&(window.__SPLINE_WEBGPU_STATS=A5),N5={resolution:n5(new rs(1,1)),pixelRatio:n5(1),frameIndex:n5(0),aspectRatio:n5(new rs(1,1)),transmissionRenderTarget:e5(_5),normalRenderTarget:e5(_5),normalRenderTargetDepth:e5(_5),normalViewRenderTarget:e5(_5),aoRenderTarget:e5(_5),reflectionRenderTarget:e5(S5),reflectionDepthPyramid:e5(S5),reflectionDepthSize:n5(new rs(1,1)),reflectionDepthLevels:n5(1,"int"),reflectionEnvMap:e5(S5),reflectionEnvEnabled:n5(0),reflectionPlanarTarget:e5(S5),reflectionPlanarEnabled:n5(0),reflectionMissColor:n5(new ns(0,0,0)),reflectionResolveTarget:e5(M5),reflectionResolveEnabled:n5(0),shadowMaskTexture:e5(T5),shadowMaskGBuffer:e5(C5),shadowMaskEnabled:n5(0),shadowMaskResolution:n5(new rs(1,1)),shadowMaskFullResolution:n5(new rs(1,1)),transmissionSamplerSize:n5(new rs(2048,2048)),transmissionActualSize:n5(new rs(1,1)),orthographicUniform:n5(0),unjitteredProjection:n5(new As),aoEnabledUniform:n5(0),pcssHalton:n5(new rs(0,-.333334)),tapAngle:n5(0),tapAngle2:n5(0),cameraJitterPx:n5(new rs(0,0)),toonLightData:o5(Array.from({length:w5},()=>new Ss),"vec4"),toonLightCount:n5(0,"int"),taaEnabled:{value:!1},aoEnabled:{value:!1},transmissionLod:{value:2}}});function R5(e,t){return new D5(e,t)}var E5,O5,B5,V5,D5,I5,L5,z5,k5,U5,F5,j5,G5,W5=n(()=>{Mu(),v5(),b5(),P5(),E5=new Oq,O5=new rs,B5=[[0,0],[0,1,1],[0,1,1,2],[0,1,2,2,3],[0,1,2,3,4,4,5],[0,1,2,3,4,5,7,8,9,10]],V5=[.2126729,.7151522,.072175],D5=class extends CR{constructor(e,t){super("vec4"),this._width=0,this._height=0,this._materials=[],this._input=e,this._opts=t,this._rtL=this._makeRT(1,1,"SplineBloom.L"),this._rtA=this._makeRT(1,1,"SplineBloom.A"),this._rtB=this._makeRT(1,1,"SplineBloom.B"),this._outputTexNode=e5(this._rtL.texture),this._buildMaterials()}static get type(){return"SplineBloomNode"}_makeRT(e,t,i){let r=new Ms(e,t,{minFilter:qt,magFilter:qt,depthBuffer:!1});return x5()&&(r.texture.internalFormat="rgba8unorm-srgb"),r.texture.name=i,r}_buildMaterials(){for(let e of this._materials)e.dispose();this._materials=[];let e=(e,t)=>{let i=new UU;return i.name=e,i.colorNode=t,i.depthTest=!1,i.depthWrite=!1,i.blending=He,i.needsUpdate=!0,i},t=this._opts.luminanceThreshold,i=Math.max(this._opts.luminanceSmoothing,1e-4),r=this._input,s=C1(()=>{let e=r.sample(u5()),s=q3(c2(t),c2(t+i),o2(e.rgb,m5(V5[0],V5[1],V5[2])));return g5(e.rgb.mul(s),s)});this._materials.push(e("SplineBloom.luminance",s()));let a=B5[this._opts.kernelSize]??B5[3],n=1/Math.max(1,this._width),o=1/Math.max(1,this._height),l=this._passSequence(a.length);for(let t=0;t<a.length;t++){let i=n*(a[t]+.5)*this._opts.blurScale,r=o*(a[t]+.5)*this._opts.blurScale,s=e5(l[t].from.texture),h=C1(()=>{let e=u5();return s.sample(e.add(p5(-i,r))).add(s.sample(e.add(p5(i,r)))).add(s.sample(e.add(p5(i,-r)))).add(s.sample(e.add(p5(-i,-r)))).mul(.25)});this._materials.push(e(`SplineBloom.blur${t}`,h()))}}_passSequence(e){let t=[],i=this._rtL;for(let r=0;r<e-1;r++){let e=1&r?this._rtB:this._rtA;t.push({from:i,to:e}),i=e}return t.push({from:i,to:this._rtL}),t}renderBloom(e){e.getDrawingBufferSize(O5);let t=Math.max(1,Math.round(.5*O5.x)),i=Math.max(1,Math.round(.5*O5.y));(t!==this._width||i!==this._height)&&(this._width=t,this._height=i,this._rtL.dispose(),this._rtA.dispose(),this._rtB.dispose(),this._rtL=this._makeRT(t,i,"SplineBloom.L"),this._rtA=this._makeRT(t,i,"SplineBloom.A"),this._rtB=this._makeRT(t,i,"SplineBloom.B"),this._outputTexNode.value=this._rtL.texture,this._buildMaterials());let r=B5[this._opts.kernelSize]??B5[3],s=this._passSequence(r.length),a=e.getRenderTarget(),n=e.getMRT();e.setMRT(null),e.setRenderTarget(this._rtL),E5.material=this._materials[0],E5.name="SplineBloom.luminance",E5.render(e);for(let t=0;t<s.length;t++)e.setRenderTarget(s[t].to),E5.material=this._materials[t+1],E5.name=`SplineBloom.blur${t}`,E5.render(e);e.setRenderTarget(a),e.setMRT(n)}setup(){return this._outputTexNode}dispose(){for(let e of this._materials)e.dispose();this._materials=[],this._rtL.dispose(),this._rtA.dispose(),this._rtB.dispose()}}}),q5={},H5=n(()=>{LN(),W5(),ON("bloom",R5)}),$5=n(()=>{v5(),b5(),I5=new Oq,z5=class extends CR{static get type(){return"GaussianBlurNode"}constructor(e,t=null,i=4,r={}){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=i,this._invSize=n5(new rs),this._passDirection=n5(new rs),this._horizontalRT=new Ms(1,1,{depthBuffer:!1}),this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new Ms(1,1,{depthBuffer:!1}),this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=m3(this,this._verticalRT.texture),this._textureNode.uvNode=e.uvNode,this._material=null,this.updateBeforeType=mR.FRAME,this.resolutionScale=r.resolutionScale||1,this.premultipliedAlpha=r.premultipliedAlpha||!1,this.isGaussianBlurNode=!0}setSize(e,t){e=Math.max(Math.round(e*this.resolutionScale),1),t=Math.max(Math.round(t*this.resolutionScale),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){let{renderer:t}=e;L5=yY.resetRendererState(t,L5);let i=this.textureNode,r=i.value,s=i.value;I5.material=this._material,this.setSize(r.image.width,r.image.height);let a=r.type;this._horizontalRT.texture.type=a,this._verticalRT.texture.type=a,t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),I5.name="Gaussian Blur [ Horizontal Pass ]",I5.render(t),i.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),I5.name="Gaussian Blur [ Vertical Pass ]",I5.render(t),i.value=s,yY.restoreRendererState(t,L5)}getTextureNode(){return this._textureNode}setup(e){let t,i,r=this.textureNode,s=u5(),a=p5(this.directionNode||1);this.premultipliedAlpha?(t=e=>C3(r.sample(e)),i=e=>l5(e)):(t=e=>r.sample(e),i=e=>e);let n=C1(()=>{let e=3+2*this.sigma,r=this._getCoefficients(e),n=this._invSize,o=a.mul(this._passDirection),l=g5(t(s).mul(r[0])).toVar();for(let i=1;i<e;i++){let e=c2(i),a=c2(r[i]),h=p5(o.mul(n.mul(e))).toVar(),u=t(s.add(h)),d=t(s.sub(h));l.addAssign(u.add(d).mul(a))}return i(l)}),o=this._material||(this._material=new UU);return o.fragmentNode=n().context(e.getSharedContext()),o.name="Gaussian_blur",o.needsUpdate=!0,e.getNodeProperties(this).textureNode=r,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose(),null!==this._material&&this._material.dispose()}_getCoefficients(e){let t=[],i=e/3;for(let r=0;r<e;r++)t.push(.39894*Math.exp(-.5*r*r/(i*i))/i);return t}get resolution(){return console.warn('THREE.GaussianBlurNode: The "resolution" property has been renamed to "resolutionScale" and is now of type `number`.'),new rs(this.resolutionScale,this.resolutionScale)}set resolution(e){console.warn('THREE.GaussianBlurNode: The "resolution" property has been renamed to "resolutionScale" and is now of type `number`.'),this.resolutionScale=e.x}},k5=(e,t,i,r={})=>new z5(J1(e),t,i,r)}),Y5=n(()=>{v5(),b5(),$5(),U5=new Oq,j5=class extends CR{static get type(){return"DepthOfFieldNode"}constructor(e,t,i,r,s){super("vec4"),this.textureNode=e,this.viewZNode=t,this.focusDistanceNode=i,this.focalLengthNode=r,this.bokehScaleNode=s,this._invSize=n5(new rs),this._CoCRT=new Ms(1,1,{depthBuffer:!1,type:ii,format:pi,count:2}),this._CoCRT.textures[0].name="DepthOfField.NearField",this._CoCRT.textures[1].name="DepthOfField.FarField",this._CoCBlurredRT=new Ms(1,1,{depthBuffer:!1,type:ii,format:pi}),this._CoCBlurredRT.texture.name="DepthOfField.NearFieldBlurred",this._blur64RT=new Ms(1,1,{depthBuffer:!1,type:ii}),this._blur64RT.texture.name="DepthOfField.Blur64",this._blur16NearRT=new Ms(1,1,{depthBuffer:!1,type:ii}),this._blur16NearRT.texture.name="DepthOfField.Blur16Near",this._blur16FarRT=new Ms(1,1,{depthBuffer:!1,type:ii}),this._blur16FarRT.texture.name="DepthOfField.Blur16Far",this._compositeRT=new Ms(1,1,{depthBuffer:!1,type:ii}),this._compositeRT.texture.name="DepthOfField.Composite",this._CoCMaterial=new UU,this._CoCBlurredMaterial=new UU,this._blur64Material=new UU,this._blur16Material=new UU,this._compositeMaterial=new UU,this._textureNode=e5(this._compositeRT.texture),this._CoCTextureNode=e5(this._CoCRT.texture),this._blur64TextureNode=e5(this._blur64RT.texture),this._blur16NearTextureNode=e5(this._blur16NearRT.texture),this._blur16FarTextureNode=e5(this._blur16FarRT.texture),this.updateBeforeType=mR.FRAME}setSize(e,t){this._invSize.value.set(1/e,1/t),this._CoCRT.setSize(e,t),this._compositeRT.setSize(e,t);let i=Math.round(e/2),r=Math.round(t/2);this._CoCBlurredRT.setSize(i,r),this._blur64RT.setSize(i,r),this._blur16NearRT.setSize(i,r),this._blur16FarRT.setSize(i,r)}getTextureNode(){return this._textureNode}updateBefore(e){let{renderer:t}=e,i=this.textureNode.value;this.setSize(i.image.width,i.image.height),F5=yY.resetRendererState(t,F5),t.setClearColor(0,0),U5.material=this._CoCMaterial,t.setRenderTarget(this._CoCRT),U5.name="DoF [ CoC ]",U5.render(t),this._CoCTextureNode.value=this._CoCRT.textures[0],U5.material=this._CoCBlurredMaterial,t.setRenderTarget(this._CoCBlurredRT),U5.name="DoF [ CoC Blur ]",U5.render(t),this._CoCTextureNode.value=this._CoCBlurredRT.texture,U5.material=this._blur64Material,t.setRenderTarget(this._blur64RT),U5.name="DoF [ Blur64 Near ]",U5.render(t),U5.material=this._blur16Material,t.setRenderTarget(this._blur16NearRT),U5.name="DoF [ Blur16 Near ]",U5.render(t),this._CoCTextureNode.value=this._CoCRT.textures[1],U5.material=this._blur64Material,t.setRenderTarget(this._blur64RT),U5.name="DoF [ Blur64 Far ]",U5.render(t),U5.material=this._blur16Material,t.setRenderTarget(this._blur16FarRT),U5.name="DoF [ Blur16 Far ]",U5.render(t),U5.material=this._compositeMaterial,t.setRenderTarget(this._compositeRT),U5.name="DoF [ Composite ]",U5.render(t),yY.restoreRendererState(t,F5)}setup(e){let t=this._generateKernels(),i=A3("float"),r=A3("float"),s=d3(i,r),a=C1(()=>{let e=this.viewZNode.negate().sub(this.focusDistanceNode),t=q3(0,this.focalLengthNode,e.abs());return i.assign(X3(e,0).mul(t)),r.assign(X3(0,e).mul(t)),c2(0)});this._CoCMaterial.colorNode=a().context(e.getSharedContext()),this._CoCMaterial.outputNode=s,this._CoCMaterial.needsUpdate=!0,this._CoCBlurredMaterial.colorNode=k5(this._CoCTextureNode,1,2),this._CoCBlurredMaterial.needsUpdate=!0;let n=o5(t.points64),o=C1(()=>{let e=m5(),t=u5(),i=this._CoCTextureNode.sample(t).r,r=this._invSize.mul(this.bokehScaleNode).mul(i);return N1(64,({i:i})=>{let s=t.add(r.mul(n.element(i))),a=this.textureNode.sample(s);e.addAssign(a.rgb)}),e.divAssign(64),g5(e,i)});this._blur64Material.fragmentNode=o().context(e.getSharedContext()),this._blur64Material.needsUpdate=!0;let l=o5(t.points16),h=C1(()=>{let e=u5(),t=this._blur64TextureNode.sample(e).toVar(),i=t.rgb,r=t.a,s=this._invSize.mul(this.bokehScaleNode).mul(r);return N1(16,({i:t})=>{let r=e.add(s.mul(l.element(t))),a=this._blur64TextureNode.sample(r);i.assign(j2(a.rgb,i))}),g5(i,r)});this._blur16Material.fragmentNode=h().context(e.getSharedContext()),this._blur16Material.needsUpdate=!0;let u=C1(()=>{let e=u5(),t=this._blur16NearTextureNode.sample(e),i=this._blur16FarTextureNode.sample(e),r=this.textureNode.sample(e),s=W2(t.a,.5).mul(2),a=W2(i.a,.5).mul(2),n=g5(0,0,0,1).toVar();return n.rgb=q2(r.rgb,i.rgb,a),n.rgb=q2(n.rgb,t.rgb,s),n});return this._compositeMaterial.fragmentNode=u().context(e.getSharedContext()),this._compositeMaterial.needsUpdate=!0,this._textureNode}_generateKernels(){let e=[],t=[],i=0,r=0;for(let s=0;s<80;s++){let a=2.39996323*s,n=Math.sqrt(s)/Math.sqrt(80),o=new rs(n*Math.cos(a),n*Math.sin(a));s%5==0?(t[r]=o,r++):(e[i]=o,i++)}return{points16:t,points64:e}}dispose(){this._CoCRT.dispose(),this._CoCBlurredRT.dispose(),this._blur64RT.dispose(),this._blur16NearRT.dispose(),this._blur16FarRT.dispose(),this._compositeRT.dispose(),this._CoCMaterial.dispose(),this._CoCBlurredMaterial.dispose(),this._blur64Material.dispose(),this._blur16Material.dispose(),this._compositeMaterial.dispose()}},G5=(e,t,i=1,r=1,s=1)=>new j5(J1(e),t3(t),t3(i),t3(r),t3(s))}),X5={},K5=n(()=>{Y5(),LN(),ON("depthOfField",G5)}),Z5=o((e,t)=>{t.exports=function(e,t){for(var i=e.split("."),r=t.split("."),s=0;s<3;s++){var a=Number(i[s]),n=Number(r[s]);if(a>n)return 1;if(n>a)return-1;if(!isNaN(a)&&isNaN(n))return 1;if(isNaN(a)&&!isNaN(n))return-1}return 0}}),J5={};l(J5,{Perfs:()=>Q5});var Q5,e4,t4=n(()=>{Q5=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}}}),i4=n(()=>{e4=[[.478712,.875764],[-.337956,-.793959],[-.955259,-.028164],[.864527,.325689],[.209342,-.395657],[-.106779,.672585],[.156213,.235113],[-.413644,-.082856],[-.415667,.323909],[.141896,-.93998],[.954932,-.182516],[-.766184,.410799],[-.434912,-.458845],[.415242,-.078724],[.728335,-.491777],[-.058086,-.066401],[.20299,.686837],[-.808362,-.556402],[.507386,-.640839],[-.723494,-.22924],[.48974,.317826],[-.622663,.765301],[-.01064,.929347],[.663146,.647618],[-.096674,-.413835],[.525945,-.321063],[-.122533,.366019],[.195235,-.687983],[-.563203,.098748],[.418563,.561335],[-.378595,.800367],[.826922,.001024],[-.085372,-.766651],[-.92192,.183673],[-.590008,-.721799],[.167751,-.164393],[.032961,-.56253],[.6329,-.107059],[-.46408,.569669],[-.173676,-.958758],[-.242648,-.234303],[-.275362,.157163],[.382295,-.795131],[.562955,.115562],[.190586,.470121],[.770764,-.297576],[.237281,.93105],[-.666642,-.455871],[-.905649,-.298379],[.33952,.157829],[.701438,-.7041],[-.062758,.160346],[-.220674,.957141],[.642692,.432706],[-.77339,-.015272],[-.671467,.24688],[.158051,.062859],[.806009,.527232],[-.05762,-.247071],[.333436,-.51671],[-.550658,-.315773],[-.652078,.589846],[.008818,.530556],[-.210004,.519896]]});function r4(e){let{fog:t,backupFog:i}=e,r=[e,e.scene!==e?e.scene:void 0];if(null!=t&&void 0!==i){for(let e of r)e&&(e.fogNode=d4);s4.value.copy(i.color),a4.value=i.near,n4.value=i.far,o4.value=Xg.getModeIndex({mode:e.fogMode}),l4.value.set(e.fogDensity??Xg.getDensity({}),e.fogHeightFalloff??Xg.getHeightFalloff({}),e.fogHeightBase??Xg.getHeightBase({}))}else if(null===t)for(let e of r)e?.fogNode&&(e.fogNode=null)}var s4,a4,n4,o4,l4,h4,u4,d4,c4,p4,m4,g4,f4,y4,v4,b4=n(()=>{Mu(),Bv(),b5(),s4=n5(new aa(1,1,1)).setGroup(O3),a4=n5(.1).setGroup(O3),n4=n5(2e3).setGroup(O3),o4=n5(0).setGroup(O3),l4=n5(new ns(.005,.01,0)).setGroup(O3),h4=C1(([e,t,i,r])=>{let s=r.x,a=r.y,n=i.y.sub(r.z),o=s.mul(a.mul(n).negate().clamp(-60,60).exp()),l=a.mul(e.y).clamp(-60,60).toVar(),h=k3(l.greaterThanEqual(0),c2(1),c2(-1)).mul(l.abs().max(1e-4));return o.mul(t).mul(c2(1).sub(h.negate().exp())).div(h).max(0).negate().exp().oneMinus()}),u4=C1(()=>{let e=_3.sub(j1).toVar(),t=e.length().max(1e-6);return h4(e,t,j1,l4)}),d4=(()=>{let e=c2(1).sub(X3(.5,o4)).add(X3(1.5,o4)),t=X3(.5,o4),i=c2(1).sub(c2(1).sub(P3(a4,n4).mul(e)).mul(c2(1).sub(u4().mul(t))));return m2(s4,i)})()}),x4=n(()=>{Mu(),v5(),b5(),i4(),b4(),c4=e=>e,p4=e=>e,m4=e=>e,g4=(e,t,i)=>p2(e.add(.5).mul(t)).add(.5).div(i),f4=new Oq,y4=new aa,v4=class{constructor(){this._gBuffer=null,this._aoBuffer=null,this._hbaoMaterial=null,this._resolveMaterial=null,this._boundBlueNoise=null,this._frameIndex=0,this._projectionMatrixInverse=n5(new As),this._isOrtho=n5(0),this._resolution=n5(new rs(1,1)),this._fullResolution=n5(new rs(1,1)),this._radiusOfInfluence=n5(128),this._radiusInScreenSpace=n5(1),this._exponent=n5(1),this._aoColor=n5(new aa(0,0,0)),this._bias=n5(.5),this._frame=n5(0),this._fogEnabled=n5(0),this._fogNear=n5(1),this._fogFar=n5(1e3),this._fogMode=n5(0),this._fogHeightParams=n5(new ns(.005,.01,0)),this._cameraWorldMatrix=n5(new As);let e=new UU;e.name="SplineHBAO.gbuffer",e.side=qe,e.fragmentNode=g5(s3.mul(d2),1),e.lights=!1,e.blending=He,e.needsUpdate=!0,this._normalMaterial=e}_ensureTarget(e,t,i,r){return e&&e.width===t&&e.height===i?{target:e,changed:!1}:(e?.dispose(),{target:r(),changed:!0})}_buildHBAOMaterial(e,t){let i=e5(this._gBuffer.depthTexture),r=e5(this._gBuffer.texture),s=e5(t),a=this._projectionMatrixInverse,n=this._isOrtho,o=this._resolution,l=this._fullResolution,h=this._radiusOfInfluence,u=this._radiusInScreenSpace,d=this._exponent,c=this._aoColor,p=this._bias,m=this._frame,g=this._fogEnabled,f=this._fogNear,y=this._fogFar,v=this._fogMode,b=this._fogHeightParams,x=this._cameraWorldMatrix,w=!0===e.reversedDepthBuffer,_=e=>i.sample(e),S=(e,t)=>x2(e,t,a),M=e=>S(e,_(e)),T=C1(()=>{let e=u5().toVar(),t=o,i=l,a=p2(e.mul(t)).toVar(),T=i.div(t).toVar(),C=g4(a,T,i).toVar(),A=_(C).toVar(),N=S(C,A).toVar(),P=n3(r.sample(C).xyz).toVar(),R=j2(u.div(q2(N.z.negate(),c2(1),n)),c2(5)).toVar(),E=E2(T2(L3.xy.x).bitAnd(T2(127)),T2(L3.xy.y).bitAnd(T2(127))),O=s.load(E).xyz.x,B=g2(O.add(c2(.61803398875).mul(m))).mul(6.283),V=Q1(B).toVar(),D=W3(B).toVar(),I=R.div(5).toVar(),L=c2(0).toVar();for(let e=0;e<4;e++){let t=I.add(1).toVar();for(let r=0;r<4;r++){let[s,n]=e4[4*e+r],o=p5(V.mul(s).sub(D.mul(n)),D.mul(s).add(V.mul(n))),l=p4(a.add(V3(o.mul(t)))).toVar(),u=m4(M(g4(l,T,i))).toVar();t.addAssign(I);let d=m4(u.sub(N)).toVar(),c=c4(d.dot(d)).toVar(),m=Y3(c),g=c4(P.dot(d)).div(j2(m,c2(1e-4))),f=c.mul(c2(-1).div(h.mul(h))).add(1);L.addAssign($1(g.sub(p),0,1).mul($1(f,0,1)))}}let z=c2(1).div(c2(1).sub(p));L.mulAssign(z.div(16));let k=$1(c2(1).sub(L.mul(2)),0,1),U=S3(k,d).toVar(),F=w?A.lessThanEqual(0):A.greaterThanEqual(1);U.assign(F.select(c2(1),U));let j=m5(q2(c,m5(1),U)).toVar(),G=q3(f,y,N.z.negate()),W=x.mul(g5(N,1)).xyz,q=x.mul(g5(0,0,0,1)).xyz,H=W.sub(q).toVar(),$=h4(H,H.length().max(1e-6),q,b),Y=v,X=c2(1).sub(X3(.5,Y)).add(X3(1.5,Y)),K=X3(.5,Y),Z=c2(1).sub(c2(1).sub(G.mul(X)).mul(c2(1).sub($.mul(K)))).mul(g);return j.assign(q2(j,m5(1),Z)),g5(j,1)}),C=new UU;return C.name="SplineHBAO.hbao",C.colorNode=T(),C.depthTest=!1,C.depthWrite=!1,C.blending=He,C.needsUpdate=!0,C}_buildResolveMaterial(){let e=e5(this._aoBuffer.texture),t=e5(this._gBuffer.depthTexture),i=this._resolution,r=this._fullResolution,s=C1(()=>{let s=u5().toVar(),a=i,n=r,o=p5(c2(1).div(a.x),c2(1).div(a.y)).toVar(),l=s.sub(o.mul(.5)).toVar(),h=l.add(p5(o.x,0)).toVar(),u=l.add(p5(0,o.y)).toVar(),d=l.add(o).toVar(),c=t.sample(s).toVar(),p=n.div(a).toVar(),m=e=>t.sample(g4(e,p,n)),g=p2(l.mul(a)).toVar(),f=c.sub(m(g)).abs().toVar(),y=c.sub(m(g.add(p5(1,0)))).abs().toVar(),v=c.sub(m(g.add(p5(0,1)))).abs().toVar(),b=c.sub(m(g.add(p5(1,1)))).abs().toVar(),x=f.min(y).min(v).min(b).toVar(),w=d.toVar();return w.assign(x.equal(v).select(u,w)),w.assign(x.equal(y).select(h,w)),w.assign(x.equal(f).select(l,w)),e.sample(w)}),a=new UU;return a.name="SplineHBAO.resolve",a.colorNode=s(),a.depthTest=!1,a.depthWrite=!1,a.blending=He,a.needsUpdate=!0,a}render(e,t,i,r,s,a){let n=a.width,o=a.height,l=!0!==r.aoFullRes,h=l?.5:1,u=Math.max(1,Math.round(n*h)),d=Math.max(1,Math.round(o*h)),c=null===this._hbaoMaterial,p=this._ensureTarget(this._gBuffer,n,o,()=>new Ms(n,o,{type:ii,depthTexture:new Do(n,o),minFilter:qt,magFilter:qt}));if(this._gBuffer=p.target,c=c||p.changed,l){let e=this._ensureTarget(this._aoBuffer,u,d,()=>new Ms(u,d,{minFilter:qt,magFilter:qt,depthBuffer:!1}));this._aoBuffer=e.target,c=c||e.changed}c=c||this._boundBlueNoise!==s;let m=l;(c||m&&null===this._resolveMaterial)&&(this._hbaoMaterial?.dispose(),this._resolveMaterial?.dispose(),this._hbaoMaterial=this._buildHBAOMaterial(e,s),this._resolveMaterial=m?this._buildResolveMaterial():null,this._boundBlueNoise=s);let g=i,f=g.projectionMatrix.elements,y=0===f[11];if(this._projectionMatrixInverse.value.copy(g.projectionMatrixInverse),this._isOrtho.value=y?1:0,this._resolution.value.set(u,d),this._fullResolution.value.set(n,o),this._radiusOfInfluence.value=r.radius,y){let e=2/f[5];this._radiusInScreenSpace.value=r.radius*(d/e*.5)}else{let e=d*f[5]/2;this._radiusInScreenSpace.value=.5*r.radius*e}this._bias.value=r.bias,this._aoColor.value.setRGB(r.aoColor.r,r.aoColor.g,r.aoColor.b),this._fogEnabled.value=r.fogEnabled?1:0,this._fogNear.value=r.fogNear,this._fogFar.value=r.fogFar,this._fogMode.value=r.fogMode,this._fogHeightParams.value.set(r.fogDensity,r.fogHeightFalloff,r.fogHeightBase),this._cameraWorldMatrix.value.copy(i.matrixWorld),this._frame.value=this._frameIndex,this._frameIndex++;let v=e,b=t,x=b.overrideMaterial,w=v.getRenderTarget(),_=v.getMRT(),S=v.getClearColor(y4),M=v.getClearAlpha(),T=i.layers.mask;i.layers.set(5),b.overrideMaterial=this._normalMaterial,v.setMRT(null),v.setClearColor(0,0),v.setRenderTarget(this._gBuffer),v.render(t,i),b.overrideMaterial=x,i.layers.mask=T,f4.material=this._hbaoMaterial,f4.name="SplineHBAO.hbao",v.setRenderTarget(l?this._aoBuffer:a),f4.render(e),l&&(f4.material=this._resolveMaterial,f4.name="SplineHBAO.resolve",v.setRenderTarget(a),f4.render(e)),v.setRenderTarget(w),v.setMRT(_),v.setClearColor(S,M)}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._aoBuffer?.dispose(),this._aoBuffer=null,this._normalMaterial.dispose(),this._hbaoMaterial?.dispose(),this._hbaoMaterial=null,this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._boundBlueNoise=null}}});function w4(){return M4}var _4,S4,M4,T4=n(()=>{_4=null,S4=null,M4=null});function C4(e){let t=P4.texture,i=e.lights&&"physical"===e.category&&null!==t&&("full"===P4.quality||!1!==e.envReflectiveInLow?.()),r=e.envNode instanceof O4;i?(!r||e.envNode.sourceTexture!==t)&&(e.envNode=new O4(t),e.needsUpdate=!0):r&&(e.envNode=null,e.needsUpdate=!0)}function A4(e,t){let i=null;return{getUV:()=>{if(null===i){let r=N4(w3.negate().reflect(t));r=T3(e).mix(N4(r),t),r=N4(r).normalize(),i=N4(r).transformDirection(H1)}return i},getTextureLevel:()=>e}}var N4,P4,R4,E4,O4,B4,V4,D4=n(()=>{Mu(),v5(),b5(),N4=e=>e,P4={texture:null,version:0,rotation:new Ls,quality:"full"},R4=new Set,E4=new WeakMap,O4=class extends nG{constructor(e){super(null),this.sourceTexture=e}static get type(){return"SplineEnvironmentNode"}setup(e){let t=function(e){let t=E4.get(e);return void 0===t&&(t=f3(e),E4.set(e,t)),t}(this.sourceTexture),i=e.context,r=t.context(A4(B3,s3)).mul(F2);i.radiance.addAssign(r);let s=t.context({getUV:()=>a3,getTextureLevel:()=>c2(1)}).mul(Math.PI).mul(F2);i.iblIrradiance.addAssign(s);let a=i.lightingModel?.clearcoatRadiance;if(a){let e=t.context(A4(K1,X1)).mul(F2);a.addAssign(e)}return null}},B4=class extends $l{},V4=class extends JZ{static get type(){return"SplineSkyHemisphereLightNode"}setup(e){return e.material?.envNode instanceof O4?null:super.setup(e)}}});function I4(){return z4}var L4,z4,k4,U4,F4,j4,G4,W4,q4,H4,$4,Y4,X4,K4,Z4,J4,Q4,e6=n(()=>{L4=null,z4=null}),t6=n(()=>{sA()}),i6=n(()=>{k4=new Set}),r6=n(()=>{b5(),P5(),U4=e=>e,F4=e=>e,j4=e=>e,G4=e=>e,W4=.25,q4=256/(2*Math.PI),H4=.075,$4=(e,t,i,r,s)=>{let a=m5(0).toVar();return A1(r.lessThan(.5),()=>{a.assign(e.sample(t).level(s).rgb)}).Else(()=>{let r=m5(0).toVar(),n=c2(0).toVar();for(let a=0;a<12;a++){let o=Math.sqrt((a+.5)/12),l=2.399963229728653*a,h=o*Math.cos(l),u=o*Math.sin(l),d=Math.exp(-2.5*o*o),c=j4(G4(e.sample(p5(U4(t.x).add(i.mul(h)),U4(t.y).add(i.mul(u)))).level(s)).rgb);r.addAssign(c.mul(d)),n.addAssign(c2(d))}a.assign(r.div(n))}),a},Y4=(e,t,i,r)=>{let s=g5(t.mul(2).sub(1),c2(1).sub(i).mul(2).sub(1),r,1),a=e.mul(s).toVar();return a.xyz.div(a.w)},X4=(e,t,i,r)=>{let s=N5.reflectionEnvEnabled,a=N5.reflectionMissColor,n=i.greaterThan(.05),o=r??k3(n,c2(.6),c2(1)),l=I1(t.z,t.x).div(2*Math.PI).add(.5),h=D1($1(t.y,c2(-1),c2(1))).div(Math.PI).add(.5),u=W2(I2(i.mul(o).mul(W4*q4).add(1)),c2(8)),d=e.sample(p5(l,h)).level(u).rgb;return k3(s.greaterThan(.5),d,a)},K4=e=>{let{dials:t,surface:i,camera:r,resources:s}=e,{blur:a,thickness:n,steps:o,stepSize:l,tracingMode:h}=t,{colorMap:u,depthPyramid:d,depthPyramidNode:c,envMap:p}=s,m=e.usePlanar,g=N5.reflectionDepthSize,f=N5.reflectionDepthLevels,y=(e,t)=>d.load(e).level(t).r.add(1e-6),v=N5.orthographicUniform.greaterThan(.5),b=k3(v,m5(0,0,-1),n3(i.originView)).toVar(),x=i.normalV.toVar(),w=R3(b,x).toVar(),_=$1(a.mul(.1),c2(0),c2(1)).toVar(),S=N5.resolution,M=_.greaterThan(.05),T=e.singleRay?c2(1):k3(M,c2(.6),c2(1)),C=(e,t,s,a)=>{let o=n3(r5(e,r.worldMatrix)).toVar(),d=c2(1).sub(q3(c2(.85),c2(.99),e.z)).toVar(),b=i.originView.toVar(),w=b.z.negate().max(r.near).toVar(),M=c2(w.mul(10)).toVar();A1(e.z.greaterThan(1e-5),()=>{let t=r.near.negate().sub(b.z).div(e.z);M.assign(W2(M,t.mul(.95).max(1e-4)))});let C,A=b.add(e.mul(M)).toVar(),N=m5(i.screenUv,i.fragWindowZ).toVar(),P=(e=>{let t=r.projectionMatrix.mul(g5(e,1)).toVar(),i=t.xyz.div(t.w);return m5(i.x.mul(.5).add(.5),i.y.mul(-.5).add(.5),i.z)})(A).toVar(),R=_.mul(S.y).mul(H4).toVar();if(a){let e=R.mul(g.y.div(S.y)).toVar(),t=W2(c2(.8),c2(12).div(e.max(.001))).toVar();a.assign(e.mul(t)),C=c2(1).sub(t.mul(t)).max(0).sqrt().toVar()}let E=P.sub(N).toVar(),O=j2(E.xy.length(),c2(1e-5)).toVar(),B=c2(0).toVar(),V=m5(0).toVar(),D=()=>{let e=f.sub(1).toVar(),i=T2(1).toVar(),r=T2(0).toVar(),s=(e,t)=>W2(e,t),a=E,o=a.div(a.z).toVar(),l=m5(N).toVar(),h=p5(k3(a.x.greaterThanEqual(0),c2(1),c2(-1)),k3(a.y.greaterThanEqual(0),c2(1),c2(-1))).toVar(),u=h.mul(1e-5).toVar();h.assign($1(h,p5(0),p5(1)));let d=e=>p5(t5(c,e)),p=(e,t)=>e.mul(t).floor(),m=(e,t,i)=>{let r=p5(1).div(i),s=t.div(i).add(r.mul(h)).sub(e.xy).div(a.xy).toVar(),n=e.add(a.mul(W2(s.x,s.y))).toVar();return n.xy.addAssign(k3(s.x.lessThan(s.y),p5(u.x,0),p5(0,u.y))),n},v=d(i),b=p(l.xy,v);l.assign(m(l,b,v)),N1(256,()=>{A1(i.lessThan(T2(0)).or(r.greaterThanEqual(t)),()=>{M1()});let h=d(i).toVar(),u=p(l.xy,h).toVar(),c=y(E2(T2(u.x),T2(u.y)),i).toVar(),g=m5(l).toVar();A1(a.z.greaterThan(0),()=>{let t=c.sub(l.z).toVar();A1(t.greaterThan(0),()=>{g.assign(l.add(o.mul(t)))});let r=p(g.xy,h).toVar();A1(((e,t)=>T2(e.x).notEqual(T2(t.x)).or(T2(e.y).notEqual(T2(t.y))))(u,r),()=>{g.assign(m(l,u,h)),i.assign(s(e,i.add(T2(2))))}).Else(()=>{A1(i.equal(T2(1)).and(t.abs().greaterThan(n)),()=>{g.assign(m(l,u,h)),i.assign(T2(2))})})}).Else(()=>{A1(l.z.lessThan(c),()=>{g.assign(m(l,u,h)),i.assign(s(e,i.add(T2(2))))})}),l.assign(g),i.subAssign(T2(1)),r.addAssign(T2(1))});let x=l.x.greaterThan(0).and(l.x.lessThan(1)).and(l.y.greaterThan(0)).and(l.y.lessThan(1)).and(l.z.greaterThan(0)).and(l.z.lessThan(1));A1(i.lessThan(T2(0)).and(r.lessThan(t)).and(x),()=>{B.assign(1),V.assign(l);let e=l.xy.sub(N.xy).length().div(O).clamp(0,1),t=e.sub(c2(2).div(g.y).div(O)).max(0),i=m5(N.add(E.mul(t))).toVar(),r=m5(N.add(E.mul(e))).toVar(),s=m5(r).toVar();for(let e=0;e<4;e++){s.assign(q2(i,r,.5));let e=U4(y(E2(F4(s.xy).mul(g)),T2(0)));A1(s.z.sub(e).greaterThan(0),()=>{r.assign(s)}).Else(()=>{i.assign(s)})}V.assign(s)})},I=()=>{let e=j2(l,c2(1e-4)),i=c2(e).toVar(),r=m5(N).toVar(),s=m5(N).toVar(),a=c2(-1).toVar();N1(256,({i:o})=>{A1(o.greaterThanEqual(t),()=>{M1()});let l=c2(o).mul(i).div(O).toVar();A1(l.greaterThan(1),()=>{M1()}),s.assign(E.mul(l).add(N));let h=s.x.lessThan(0).or(s.x.greaterThan(1)).or(s.y.lessThan(0)).or(s.y.greaterThan(1)).or(s.z.lessThan(0)).or(s.z.greaterThan(1));A1(h,()=>{M1()});let u=y(E2(s.xy.mul(g)),T2(0)).toVar(),d=s.z.sub(u).toVar();A1(a.lessThanEqual(0).and(d.greaterThan(0)),()=>{let e=m5(r).toVar(),t=m5(s).toVar(),i=m5(s).toVar(),a=c2(d).toVar();for(let r=0;r<4;r++){i.assign(q2(e,t,.5));let r=U4(y(E2(F4(i.xy).mul(g)),T2(0)));a.assign(i.z.sub(r)),A1(a.greaterThan(0),()=>{t.assign(i)}).Else(()=>{e.assign(i)})}A1(a.abs().lessThan(n),()=>{B.assign(1),V.assign(i),M1()})}),a.assign(d),r.assign(s),i.addAssign(e.div(2))})};A1(d.greaterThan(0).and(m.not()),()=>{"number"==typeof h?1===h?D():I():A1(h.greaterThan(.5),()=>{D()}).Else(()=>{I()})});let L=X4(p,o,_,C).toVar(),z=m5(L).toVar();return A1(B.greaterThan(.5),()=>{let t=V.xy.sub(N.xy).length().div(O).clamp(0,1).toVar(),i=b.z.negate().max(1e-4).toVar(),n=A.z.negate().max(1e-4).toVar(),o=q2(c2(1).div(i),c2(1).div(n),t).toVar(),l=q2(b.div(i),A.div(n),t).div(o),h=q2(b,A,t),c=k3(v,h,l).toVar(),p=c.sub(b).length().toVar(),m=r.projectionMatrix.element(1).y.mul(S.y).mul(.5),M=k3(v,c2(1),c.z.abs().max(1e-4)),C=_.mul(T).mul(W4).mul(p).mul(m).div(M),P=j2(C,R).toVar(),E=P.mul(g.y.div(S.y)).toVar(),B=E.toVar(),D=P.toVar();if(a){let e=W2(c2(.8),c2(12).div(E.max(.001))).toVar();a.assign(E.mul(e)),B.assign(E.mul(c2(1).sub(e.mul(e)).max(0).sqrt())),D.assign(B.mul(S.y.div(g.y)))}let I=c2(f.sub(1)),k=W2(I2(B.add(1)),I),U=s?$4(u,V.xy,D.mul(.75).div(S.y),B.mul(.75),k.sub(1).max(0).floor()).toVar():u.sample(V.xy).level(k).rgb.toVar(),F=e=>q3(c2(0),c2(.07),e).mul(q3(c2(0),c2(.07),c2(1).sub(e))),j=F(V.x).mul(F(V.y)),G=V.xy.mul(g),W=y(E2(G),T2(0)),q=Y4(r.projectionMatrixInverse,V.x,V.y,W).toVar(),H=o2(q.sub(b),x),$=q3(w.mul(-.05),w.mul(-.005),H),Y=c2(1).div(g.x),X=c2(1).div(g.y),K=y(E2(G.sub(p5(1,0))),T2(0)),Z=y(E2(G.add(p5(1,0))),T2(0)),J=y(E2(G.sub(p5(0,1))),T2(0)),Q=y(E2(G.add(p5(0,1))),T2(0)),ee=Y4(r.projectionMatrixInverse,V.x.sub(Y),V.y,K),te=Y4(r.projectionMatrixInverse,V.x.add(Y),V.y,Z),ie=Y4(r.projectionMatrixInverse,V.x,V.y.sub(X),J),re=Y4(r.projectionMatrixInverse,V.x,V.y.add(X),Q),se=n3(e2(te.sub(ee),re.sub(ie))).toVar(),ae=k3(se.z.lessThan(0),se.negate(),se),ne=q3(c2(.02),c2(.12),o2(ae,e).negate()),oe=d.mul(j).mul($).mul(ne);z.assign(q2(L,U,oe))}),z};if(e.singleRay)return C(w,o,!0,e.singleRay.footprintOut).toVar();let A=e.noisePixel,N=g2(c2(52.9829189).mul(g2(A.x.mul(.06711056).add(A.y.mul(.00583715))))).mul(2*Math.PI).toVar(),P=k3(w.y.abs().greaterThan(.99),m5(1,0,0),m5(0,1,0)),R=n3(e2(P,w)).toVar(),E=e2(w,R).toVar(),O=(e,t=4)=>{let i=_.mul(W4*Math.sqrt((e+.5)/t)),r=N.add(2.399963229728653*e);return n3(w.mul(Q1(i)).add(R.mul(Q1(r)).add(E.mul(W3(r))).mul(W3(i)))).toVar()},B=M.and(m.not()),V=k3(B,O(0),w).toVar(),D=m5(0).toVar();D.addAssign(C(V,o,!0));let I=c2(1).toVar();return A1(B,()=>{D.addAssign(C(O(2),o,!1)),I.assign(2),A1(_.greaterThan(.35),()=>{D.addAssign(C(O(1),o,!1)),D.addAssign(C(O(3),o,!1)),I.assign(4)})}),D.div(I).toVar()}}),s6=n(()=>{Mu(),b5(),Bv(),P5(),Z4=new rs,(Q4=J4=class extends Kr{constructor(e){super(),this.postprocessingState=vf.defaultData,this.sceneTransitionPass={uniforms:{mixRatio:n5(0),uDPR:{value:1},uResolution:{value:new rs}}},this.sceneTransitionFromTexture=null,this.watermarkTexture=null,this.uiCanvasTexture=null,this.uiOverlayEnabled=!1,this._isUIOverlayEnabled=!1,this._helpersEnabled=!0,this._renderToScreen=!0,this._rt=null,this._effectChain=null,this._effectChainDirty=!1,this.blueNoiseTexture=new Yn,this._rebuildCount=0,this._rebuildLogAt=0,this._chainUiTexture=null,this._chainWatermark=null,this._chainTransitionTexture=null,this._chainCamera=null,this._chainHdr=!1,this.lastOutputTarget=null,this._renderer=e}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){this._renderToScreen=e}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}get isUIOverlayEnabled(){return this._isUIOverlayEnabled}enableUIOverlay(){this._isUIOverlayEnabled=!0}disableUIOverlay(){this._isUIOverlayEnabled=!1}enableHelpers(){this._helpersEnabled=!0}disableHelpers(){this._helpersEnabled=!1}get helpersEnabled(){return this._helpersEnabled}setWatermark(e){this.watermarkTexture=e,this._effectChainDirty=!0}updateBlueNoiseTexture(e){this.blueNoiseTexture.dispose();let t=new Yn(e,128,128);t.wrapS=kt,t.wrapT=kt,t.minFilter=jt,t.magFilter=jt,t.needsUpdate=!0,this.blueNoiseTexture=t}static _topologyJSON(e){let t=e,i={};for(let e of Object.keys(t)){let r=t[e],s=J4.UNIFORM_BACKED_FIELDS[e];if(s&&r&&"object"==typeof r){let t={...r};for(let e of s)delete t[e];i[e]=t}else i[e]=r}return JSON.stringify(i)}updatePostprocessing(e){this.postprocessingState=e;let t=J4._topologyJSON(e);this._postprocessingJSON!==t&&(this._postprocessingJSON=t,this._effectChainDirty=!0)}_needsEffectChain(){if(this._renderer.temporalAAEnabled||this.uiOverlayEnabled&&this.uiCanvasTexture||this.watermarkTexture||this.sceneTransitionFromTexture)return!0;if(!0!==this.postprocessingState.enabled)return!1;let e=this.postprocessingState;for(let t of Object.keys(e)){let i=e[t];if(i&&"object"==typeof i&&!0===i.enabled)return!0}return!1}render(){let{scene:e,camera:t}=this;if(!e||!t)return;let i=this._renderer;if(i.warmupInFlight)return;let r=!1;if(!this._renderToScreen&&null===i.getRenderTarget()){i.getDrawingBufferSize(Z4);let e=Math.max(1,Math.round(Z4.x)),t=Math.max(1,Math.round(Z4.y));null===this._rt?this._rt=new Ms(e,t,{depthBuffer:!0}):(this._rt.width!==e||this._rt.height!==t)&&(this._rt.dispose(),this._rt=new Ms(e,t,{depthBuffer:!0})),i.setRenderTarget(this._rt),r=!0}this.lastOutputTarget=r?this._rt:i.getRenderTarget();try{this._renderFrame(e,t)}finally{r&&i.setRenderTarget(null)}}_renderFrame(e,t){let i=this._renderer;i.renderStarted=!0,i.normalizeCameraCoordinateSystem(t);let r=this._needsEffectChain(),s=null;this._effectChainDirty?s="postprocessing/watermark":r!==(null!==this._effectChain)?s="chain presence":null!==this._effectChain&&(this._chainUiTexture!==(this.uiOverlayEnabled?this.uiCanvasTexture:null)?s="ui overlay texture":this._chainWatermark!==this.watermarkTexture?s="watermark texture":this._chainTransitionTexture!==this.sceneTransitionFromTexture?s="transition texture":this._chainCamera!==t?s="camera identity":this._chainHdr!==i.hdrChainActive&&(s="grading pipeline"));let a=null!==s;if(a&&null!==this._effectChain){this._rebuildCount++;let e=Date.now();e-this._rebuildLogAt>1e3&&(this._rebuildLogAt=e,this._rebuildCount=0)}if(a&&(this._effectChain,this._effectChain?.dispose(),this._effectChain=null,this._effectChainDirty=!1,r&&(this._effectChain=i.createEffectChain(),A5.chainBuilds++,A5.lastChainBuildReason=s??"initial",this._chainUiTexture=this.uiOverlayEnabled?this.uiCanvasTexture:null,this._chainWatermark=this.watermarkTexture,this._chainTransitionTexture=this.sceneTransitionFromTexture,this._chainCamera=t,this._chainHdr=i.hdrChainActive)),this._effectChain){this._effectChain.syncValues(this.postprocessingState,i);let e=i.temporalAAEnabled?i.taaHistory:null;e&&(i.getDrawingBufferSize(Z4),e.beginJitter(t,Z4.x,Z4.y)),this._effectChain.renderTAAResolve?.(i),this._effectChain.renderBloomPasses?.(i),this._effectChain.render(),e?.endJitter()}else i.renderScenePass(e,t);this._helpersEnabled&&(this.sceneHelpers||this.sceneHelpersOnTop)&&i.renderHelperOverlay(this.sceneHelpers,this.sceneHelpersOnTop,t,this._effectChain?this._effectChain.sceneDepthTexture():null)}resize(e,t,i){this._effectChain?.resize()}setViewport(e,t,i,r){e instanceof Ss?this._renderer.setViewport(e.x,e.y,e.z,e.w):this._renderer.setViewport(e,t,i,r)}setScissor(e,t,i,r){e instanceof Ss?this._renderer.setScissor(e.x,e.y,e.z,e.w):this._renderer.setScissor(e,t,i,r)}setScissorTest(e){this._renderer.setScissorTest(e)}dispose(){this._effectChain?.dispose(),this._effectChain=null,this._rt?.dispose(),this._rt=null,this.blueNoiseTexture.dispose()}}).UNIFORM_BACKED_FIELDS={bloom:["intensity","opacity"],chromaticAberration:["offset","opacity"],vignette:["offset","darkness","opacity"],noise:["opacity"],hueSaturation:["hue","saturation","opacity"],brightnessContrast:["brightness","contrast","opacity"],depthOfField:["focusDistance","focalLength","bokehScale","opacity"],pixelation:["granularity","opacity"]}});function a6(e,t,i){l6.push({t:Math.round(performance.now()),frame:u6(),kind:e,label:t||"(unlabeled)",size:i,stack:((new Error).stack??"").split("\n").slice(2,9).join("\n")}),l6.length>o6&&l6.shift()}var n6,o6,l6,h6,u6,d6,c6,p6=n(()=>{n6=(()=>{try{return"1"===new URLSearchParams(window.location.search).get("dbgdestroys")}catch{return!1}})(),o6=32,l6=[],h6=6,u6=()=>-1,d6=!1,c6=null});function m6(e,t){let i=new Ms(e,t,{depthBuffer:!1,type:ti,format:gi});return i.texture.generateMipmaps=!1,i.texture.minFilter=jt,i.texture.magFilter=jt,i}function g6(){return null===A6&&((A6=m6(x6*w6,x6)).texture.name="SplinePCSSPyramidAtlas"),A6.texture}function f6(e,t,i,r,s,a){let n=new UU,o=e5(t),l=C1(()=>{let e=L3,t=0!==a?S6(e.x).sub(a):S6(e.x),n=T2(t).mul(i).toVar(),l=T2(e.y).mul(i).toVar(),h=c2(1e9).toVar(),u=c2(-1e9).toVar();return N1(T6("ly",i),T6("lx",i),e=>{let{lx:t,ly:i}=e,a=M6(C6(n.add(t),T2(0),T2(r))),d=M6(C6(l.add(i),T2(0),T2(r))),c=o.load(E2(a,d));h.assign(W2(h,S6(c.x))),u.assign(j2(u,S6(s?c.y:c.x)))}),g5(h,u,0,1)})();return n.fragmentNode=l,n.name=e,n.lights=!1,n.blending=He,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,n}function y6(e){let t=e;return t.__spePcssPyramid||(t.__spePcssPyramid={fresh:!1,slot:-1,passKey:"",mid:null,small:null,toMid:null,toSmall:null},N6.add(new WeakRef(t.__spePcssPyramid))),t.__spePcssPyramid}function v6(e){return!0===e.__spePcssPyramid?.fresh}function b6(e){return e.__spePcssPyramid?.slot??-1}var x6,w6,_6,S6,M6,T6,C6,A6,N6,P6,R6,E6,O6=n(()=>{Mu(),v5(),b5(),P5(),x6=8,w6=8,_6=64,S6=e=>e,M6=e=>e,T6=(e,t)=>({start:T2(0),end:T2(t),type:"int",condition:"<",name:e}),C6=$1,A6=null,N6=new Set,P6=new Array(w6).fill(null),R6=!1,E6=new ns});function B6(e){let t=e;return t.__spePcssKnobs||(t.__spePcssKnobs={mapSize:n5(2048),radius:n5(1),penumbraSize:n5(.5),depthEps:n5(1e-4),penumbraFrameScale:n5(1),penumbraFrameOffset:n5(0),pyramidEnabled:n5(0),pyramidSlot:n5(0),maskChannel:n5(new Ss(0,0,0,0)),planeNormalMat:n5((new us).set(0,0,0,0,0,0,0,0,0))}),t.__spePcssKnobs}function V6(e,t){B6(e).maskChannel.value.set(0===t?1:0,1===t?1:0,2===t?1:0,3===t?1:0)}function D6(e,t,i){let r=e,s=B6(e);s.mapSize.value=r.mapSize?.x??2048,s.radius.value=r.radius??1,s.penumbraSize.value=t??r.penumbraSize??.5,r.camera?.isOrthographicCamera&&r.matrix?s.planeNormalMat.value.getNormalMatrix(r.matrix):s.planeNormalMat.value.set(0,0,0,0,0,0,0,0,0);let a="number"==typeof r.camera?.far&&"number"==typeof r.camera?.near?r.camera.far-r.camera.near:0;s.depthEps.value=a>.001?a8/a:1e-4;let n=e.__speRangeEnvelope,o=n?n.far-n.near:0;n&&o>.001&&a>.001&&r.camera?(s.penumbraFrameScale.value=a/o,s.penumbraFrameOffset.value=(r.camera.near-n.near)/o):(s.penumbraFrameScale.value=1,s.penumbraFrameOffset.value=0);let l=0;if(i&&i.fresh&&i.slot>=0&&K6()){let e=s.mapSize.value;t8/1024+(2*s.radius.value+2)/Math.max(1,e)<=1/x6&&(l=1)}return s.pyramidEnabled.value=n8??l,s.pyramidSlot.value=Math.max(0,i?.slot??0),1===s.pyramidEnabled.value}function I6(e,t){let i=G6(e.planeNormalMat.mul(t)).toVar(),r=F6(i.z),s=F6(G3(r).add(X3(O1(r),c2(0))).mul(j2(O1(r),c2(1e-4))));return j6(p5(F6(i.x).negate().div(s),F6(i.y).div(s))).toVar()}function L6(e,t,i,r,s,a,n){let o=r8(),l=s8(),h=X6(),u=B6(t),d=F6(u.mapSize),c=j6(p5(d,d)),p=F6(u.radius),m=F6(u.penumbraSize),g=e5(e),f=e=>F6(g.load(E2($1(e,p5(0),p5(1)).mul(c))).x),y=c2(1).div(c.x).toVar(),v=c2(t8).div(y.mul(1024)).toVar(),b=F6(u.depthEps),x=I6(u,n),w=()=>{let t=c2(0).toVar(),n=c2(0).toVar();for(let e=0;e<l;e++){let a=j6(b2(T2(e),T2(l),s)).mul(y).mul(v),o=f(j6(i.add(a))).toVar();A1(o.lessThan(r.add(o8(x,a)).add(b)),()=>{t.addAssign(o),n.addAssign(1)})}let d=c2(0).toVar();A1(n.greaterThan(0),()=>{let e=t.div(n).toVar(),i=F6(u.penumbraFrameScale),s=F6(u.penumbraFrameOffset),a=r.sub(e).mul(i).div(e.mul(i).add(s)).toVar();d.assign($1(a.mul(a).mul(200).mul(m),c2(0),c2(1)))});let c=c2(0).toVar();for(let t=0;t<o;t++){let a=j6(b2(T2(t),T2(o),s)).mul(y),n=j6(a.mul(p.mul(2)).add(a.mul(d.mul(v)))),l=F6(r.add(o8(x,n)));h?c.addAssign(F6(e5(e,j6(i.add(n))).compare(l))):c.addAssign(X3(l,f(j6(i.add(n)))))}a.assign(c.div(o))};if(K6()){let e=e5(g6()),t=F6(u.pyramidEnabled),s=F6(u.pyramidSlot),n=c2(x6),o=c2(0).toVar();A1(t.greaterThan(.5),()=>{let t=j6($1(i,p5(0),p5(1))),a=F6(t.x.mul(n)).toVar(),l=F6(t.y.mul(n)).toVar(),h=s.mul(n),u=c2(1e9).toVar(),d=c2(-1e9).toVar();for(let t=-1;t<=1;t++)for(let i=-1;i<=1;i++){let r=$1(a.add(c2(i)),c2(0),n.sub(1)),s=$1(l.add(c2(t)),c2(0),n.sub(1)),o=j6(p5(r.add(h),s)),c=e.load(E2(o));u.assign(W2(u,F6(c.x))),d.assign(j2(d,F6(c.y)))}let c=F6(y.mul(p.mul(2).add(v))),m=F6(W2(B2(x).mul(c),c2(.05))).toVar();A1(u.greaterThanEqual(r.add(b).add(m)),()=>{o.assign(1)}).ElseIf(d.lessThan(r.sub(m)),()=>{o.assign(2)})}),A1(o.equal(1),()=>{a.assign(1)}).ElseIf(o.equal(2),()=>{a.assign(0)}).Else(w)}else w()}function z6(e,t){let i=t;return i.isPointLight?(A5.pcssHookServes++,g8):i.isSpotLight||i.isDirectionalLight?(A5.pcssHookServes++,m8):null}function k6(e){d8.value=e?1:0}function U6(e,t){return i=>{let r=function(e){let t=e,i={};if(null==t)return i;for(let e of p8){let r=t[e];void 0!==r&&(i[e]=r)}return i}(i),s=F6(c8(e,r)),a=F6(c8(t,r));return C1(()=>{let e=c2(1).toVar();return A1(F6(d8).greaterThan(.5),()=>{e.assign(s)}).Else(()=>{e.assign(a)}),e})()}}var F6,j6,G6,W6,q6,H6,$6,Y6,X6,K6,Z6,J6,Q6,e8,t8,i8,r8,s8,a8,n8,o8,l8,h8,u8,d8,c8,p8,m8,g8,f8,y8,v8,b8,x8=n(()=>{b5(),Mu(),P5(),O6(),F6=e=>e,j6=e=>e,G6=e=>e,W6=!0,q6=!0,H6=!0,$6=!0;try{let e=new URLSearchParams(window.location.search),t=e.get("dbgpcss");"classic"===t||"0"===t?(W6=!1,q6=!1,H6=!1,$6=!1):(W6="0"!==e.get("dbgpcsssplit"),q6="0"!==e.get("dbgpcsshw"),H6="0"!==e.get("dbgpcsshiz"),$6="0"!==e.get("dbgshadowmask"))}catch{}Y6=!1,X6=()=>q6&&Y6,K6=()=>H6&&Y6,Z6=()=>$6&&Y6,J6=()=>K6(),Q6=()=>Z6(),e8=[[0,-.333334],[-.5,.333334],[.5,-.777778],[-.75,-.111112],[.25,.555556],[-.25,-.555556],[.75,.111112],[-.875,.777778],[.125,-.925926],[-.375,-.25926],[.625,.407408],[-.625,-.703704],[.375,-.037038],[-.125,.62963],[.875,-.481482],[-.9375,.185186]],t8=80,i8=16,r8=()=>X6()?Math.max(4,i8>>1):i8,s8=()=>W6?Math.max(4,i8>>1):i8,a8=1.25,n8=null,o8=(e,t)=>F6($1(o2(e,t),c2(-.05),c2(.05))),l8=C1(e=>{let{depthTexture:t,shadowCoord:i,shadow:r}=e,s=B6(r),a=j6(i.xy).toVar(),n=F6(i.z).toVar(),o=G6(a3).toVar(),l=j6(N5.pcssHalton),h=F6(v2(L3.xy.add(l))).mul(6.28318530718).toVar(),u=c2(1).toVar();if(Z6()){let e=s.maskChannel,i=F6(N5.shadowMaskEnabled),l=N5.shadowMaskGBuffer,d=N5.shadowMaskTexture,c=c2(0).toVar(),p=c2(1).toVar();A1(i.greaterThan(.5).and(F6(o2(e,g5(1,1,1,1))).greaterThan(.5)),()=>{let t=j6(z3),i=j6(N5.shadowMaskResolution),r=j6(N5.shadowMaskFullResolution),s=F6(x3.z),a=j6(t.mul(i).sub(p5(.5,.5))).toVar(),n=j6(p2(a)).toVar(),o=j6(a.sub(n)).toVar(),h=F6(j2(O1(s).mul(.02),c2(.05))),u=c2(0).toVar(),m=c2(0).toVar();for(let t=0;t<=1;t++)for(let a=0;a<=1;a++){let c=j6($1(n.add(p5(a,t)),p5(0,0),i.sub(p5(1,1)))),p=j6(c.add(p5(.5,.5)).div(i)),g=j6(p2(p.mul(r)).add(p5(.5,.5)).div(r)),f=F6(l.sample(g).w),y=F6(o2(d.sample(p),e)),v=F6(0===a?c2(1).sub(o.x):F6(o.x)),b=F6(0===t?c2(1).sub(o.y):F6(o.y)),x=F6(X3(O1(f.sub(s)),h)),w=F6(v.mul(b).mul(x)).toVar();u.addAssign(w),m.addAssign(y.mul(w))}A1(u.greaterThan(.001),()=>{c.assign(1),p.assign(m.div(u))})}),A1(c.greaterThan(.5),()=>{u.assign(p)}).Else(()=>{L6(t,r,a,n,h,u,o)})}else L6(t,r,a,n,h,u,o);return u}),h8=C1(e=>{let{depthTexture:t,shadowCoord:i,shadow:r}=e,s=B6(r),a=j6(i.xy).toVar(),n=F6(i.z).toVar(),o=I6(s,G6(a3).toVar()),l=F6(s.mapSize),h=F6(s.radius),u=F6(h.mul(c2(1).div(l))).toVar(),d=F6(v2(L3.xy)).mul(6.28318530718).toVar(),c=c2(0).toVar();for(let e=0;e<5;e++){let i=j6(b2(T2(e),T2(5),d)).mul(u).toVar();c.addAssign(F6(e5(t,j6(a.add(i))).compare(n.add(o8(o,i)))))}return c.mul(.2)}),u8=C1(e=>{let{depthTexture:t,bd3D:i,dp:r,shadow:s}=e,a=i8,n=B6(s),o=F6(n.mapSize),l=F6(n.radius),h=c2(1).div(o).toVar(),u=j6(N5.pcssHalton),d=F6(v2(L3.xy.add(u))).mul(6.28318530718).toVar(),c=F6(l.add(5)).toVar(),p=c2(0).toVar();for(let e=0;e<a;e++){let s=j6(b2(T2(e),T2(a),d)).mul(h).toVar(),n=G6(m5(s.x,s.y,F6(s.x).negate()).mul(c)),o=G6(i.add(n));p.addAssign(F6(t2(t,o).compare(r)))}return p.div(a)}),d8=n5(1),c8=(e,t)=>e(t),p8=["depthTexture","shadowCoord","shadow","depthLayer","bd3D","dp"],m8=U6(l8,h8),g8=U6(u8,E1)}),w8=n(()=>{Mu(),v5(),b5(),P5(),x8(),f8=new Oq,y8=new aa,v8=new rs,b8=class{constructor(){this._gBuffer=null,this._maskTarget=null,this._resolveMaterial=null,this._resolveKey="",this._cameraWorld=n5(new As),this._projInv=n5(new As),this._lightRows=[];let e=new UU;e.name="SplineShadowMask.gbuffer",e.fragmentNode=g5(s3,x3.z),e.lights=!1,e.blending=He,e.needsUpdate=!0,this._gBufferMaterial=e}_ensureTarget(e,t,i,r){return e&&e.width===t&&e.height===i?{target:e,changed:!1}:(e?.dispose(),{target:r(),changed:!0})}_buildResolveMaterial(e){let t=new UU;t.name="SplineShadowMask.resolve";let i=e5(this._gBuffer.depthTexture),r=e5(this._gBuffer.texture),s=this._cameraWorld,a=this._projInv,n=this._gBuffer.width,o=this._gBuffer.height;this._lightRows=e.map(()=>({matrix:n5(new As),bias:n5(0),normalBias:n5(0)}));let l=this._lightRows,h=C1(()=>{let t=u5(),h=p2(t.mul(p5(n,o))).add(p5(.5,.5)).div(p5(n,o)).toVar(),u=i.sample(h),d=x2(h,u,a).toVar(),c=r.sample(h).toVar(),p=s,m=p.mul(g5(d,1)).xyz.toVar(),g=n3(p.mul(g5(c.xyz,0)).xyz).toVar(),f=N5.pcssHalton,y=v2(L3.xy.add(f)).mul(6.28318530718).toVar(),v=[c2(1).toVar(),c2(1).toVar(),c2(1).toVar(),c2(1).toVar()];return e.forEach((e,t)=>{let i=l[t],r=m.add(g.mul(i.normalBias)),s=i.matrix.mul(g5(r,1)).toVar(),a=s.xyz.div(s.w),n=m5(a.x,c2(1).sub(a.y),a.z).toVar(),o=n.z.add(i.bias).toVar(),h=n.x.greaterThanEqual(0).and(n.x.lessThanEqual(1)).and(n.y.greaterThanEqual(0)).and(n.y.lessThanEqual(1)).and(o.lessThanEqual(1));A1(h,()=>{L6(e.shadow.map.depthTexture,e.shadow,n.xy,o,y,v[t],g)})}),g5(v[0],v[1],v[2],v[3])})();return t.fragmentNode=h,t.lights=!1,t.blending=He,t.depthTest=!1,t.depthWrite=!1,t.needsUpdate=!0,t}render(e,t,i,r,s){let a=s??e.getDrawingBufferSize(v8),n=Math.max(1,Math.round(a.x)),o=Math.max(1,Math.round(a.y)),l=Math.max(1,Math.round(n/2)),h=Math.max(1,Math.round(o/2)),u=!1,d=this._ensureTarget(this._gBuffer,n,o,()=>{let e=new Ms(n,o,{type:ii,depthTexture:new Do(n,o),minFilter:qt,magFilter:qt});return e.texture.name="SplineShadowMask.gbuffer",e});this._gBuffer=d.target,u=u||d.changed;let c=this._ensureTarget(this._maskTarget,l,h,()=>{let e=new Ms(l,h,{depthBuffer:!1,minFilter:qt,magFilter:qt});return e.texture.name="SplineShadowMask.mask",e});this._maskTarget=c.target,u=u||c.changed;let p=`${this._gBuffer.texture.uuid}:${r.map(e=>e.shadow.map?.depthTexture?.uuid??"none").join(",")}`;(null===this._resolveMaterial||this._resolveKey!==p)&&(this._resolveMaterial?.dispose(),this._resolveMaterial=this._buildResolveMaterial(r),this._resolveKey=p),this._cameraWorld.value.copy(i.matrixWorld),this._projInv.value.copy(i.projectionMatrix).invert(),r.forEach((e,t)=>{e.shadow.updateMatrices?.(e.light);let i=this._lightRows[t];e.shadow.matrix&&i.matrix.value.copy(e.shadow.matrix),i.bias.value=e.shadow.bias??0,i.normalBias.value=e.shadow.normalBias??0});let m=t,g=!0===m.isScene,f=[],y=[];m.traverse(e=>{let t=e;if(!0===t.isMesh&&!1!==t.visible)if((Array.isArray(t.material)?t.material:[t.material]).some(e=>!0===e?.transparent))f.push(t),t.visible=!1;else if(!g){let e=t;y.push({obj:e,material:e.material}),e.material=this._gBufferMaterial}});let v=m.overrideMaterial,b=e.getRenderTarget(),x=e.getMRT(),w=e.getClearColor(y8),_=e.getClearAlpha(),S=i.layers,M=S.mask;S.disable(3),m.overrideMaterial=this._gBufferMaterial,e.setMRT(null),e.setClearColor(0,0),e.setRenderTarget(this._gBuffer),e.render(t,i),m.overrideMaterial=v,S.mask=M;for(let e of f)e.visible=!0;for(let e of y)e.obj.material=e.material;return f8.material=this._resolveMaterial,f8.name="SplineShadowMask.resolve",e.setRenderTarget(this._maskTarget),f8.render(e),e.setRenderTarget(b),e.setMRT(x),e.setClearColor(w,_),N5.shadowMaskTexture.value=this._maskTarget.texture,N5.shadowMaskGBuffer.value=this._gBuffer.texture,N5.shadowMaskResolution.value.set(l,h),N5.shadowMaskFullResolution.value.set(n,o),r.forEach((e,t)=>{V6(e.shadow,t)}),A5.shadowMaskResolves++,{targetsChanged:u}}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._maskTarget?.dispose(),this._maskTarget=null,this._gBufferMaterial.dispose(),this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._resolveKey=""}}});function _8(e,t){let i=0,r=1,s=e;for(;s>0;)r/=t,i+=r*(s%t),s=Math.floor(s/t);return i}function S8(e){return m5(e.x.div(4).add(e.y.div(2)).add(e.z.div(4)),e.x.div(2).sub(e.z.div(2)),e.x.div(-4).add(e.y.div(2)).sub(e.z.div(4)))}function M8(e,t=!0){let i=m5(e.x.add(e.y).sub(e.z),e.x.add(e.z),e.x.sub(e.y).sub(e.z));return t?$1(i,m5(0),m5(1)):j2(i,m5(0))}function T8(){let e=!1;try{let t=new URLSearchParams(window.location.search).get("dbgfp16");e="1"===t||"hist"===t||"st"===t}catch{}let t=!1,i=()=>e||t,r=(e,t,r)=>{let s=new Ms(e,t,{minFilter:qt,magFilter:qt,depthBuffer:!1});return i()?s.texture.type=ii:x5()&&(s.texture.internalFormat="rgba8unorm-srgb"),s.texture.name=r,s},s=r(1,1,"SplineTAA.A"),a=r(1,1,"SplineTAA.B"),n=null,o=!1,l=0,h=0,u=0,d=0;return{rtA:s,rtB:a,flip:!1,valid:!1,jitterIndex:0,unjitteredProjection:new As,jitterOffsetUV:new rs(0,0),beginJitter(e,t,i){if(o)return;let r,s;if(o=!0,(null===n||n.cam!==e)&&(n?.clearViewOffset(),n=new P8(e)),this.unjitteredProjection.copy(e.projectionMatrix),N5.unjitteredProjection.value.copy(e.projectionMatrix),"r2"===E8){let e=++this.jitterIndex;r=(.5+O8*e)%1,s=(.5+B8*e)%1}else if("white"===E8)this.jitterIndex++,r=Math.random(),s=Math.random();else if("h64"===E8)r=_8(this.jitterIndex%64+1,2),s=_8(this.jitterIndex%64+1,3),this.jitterIndex=(this.jitterIndex+1)%64;else if("half"===E8){let[e,t]=R8[this.jitterIndex];r=.5+.5*(e-.5),s=.5+.5*(t-.5),this.jitterIndex=(this.jitterIndex+1)%R8.length}else[r,s]=R8[this.jitterIndex],this.jitterIndex=(this.jitterIndex+1)%R8.length;l=t,h=i,u=r-.5,d=s-.5,N5.cameraJitterPx.value.set(2*u,2*d),n.setViewOffset(t,i,u,d),this.jitterOffsetUV.set(-(r-.5)/t,-(s-.5)/i),A5.taaJitterIndex=this.jitterIndex,A5.taaJitterApplies++},suspendJitter(){o&&n?.clearViewOffset()},resumeJitter(){o&&null!==n&&n.setViewOffset(l,h,u,d)},endJitter(){o=!1,this.jitterOffsetUV.set(0,0),n?.clearViewOffset()},resize(e,t){this.rtA.dispose(),this.rtB.dispose(),this.rtA=r(e,t,"SplineTAA.A"),this.rtB=r(e,t,"SplineTAA.B"),this.valid=!1},setHdr(e){if(t===e)return;let r=i();t=e,i()!==r&&this.resize(this.rtA.width,this.rtA.height)},dispose(){this.rtA.dispose(),this.rtB.dispose(),this.valid=!1,o=!1,n?.clearViewOffset(),n=null}}}var C8,A8,N8,P8,R8,E8,O8,B8,V8,D8,I8,L8,z8,k8,U8,F8,j8,G8,W8=n(()=>{Mu(),b5(),P5(),v5(),b5(),C8=e=>e,A8=e=>e,N8=new Oq,P8=class{constructor(e){this.cam=e,this._savedSkewX=0,this._savedSkewY=0,this._savedShiftX=0,this._savedShiftY=0,this._jitterActive=!1}setViewOffset(e,t,i,r){this.clearViewOffset();let s=this.cam.projectionMatrix.elements,a=-2*i/e,n=2*r/t;this._savedSkewX=s[8],this._savedSkewY=s[9],this._savedShiftX=s[12],this._savedShiftY=s[13],s[8]+=a*s[11],s[9]+=n*s[11],s[12]+=a*s[15],s[13]+=n*s[15],this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!0}clearViewOffset(){if(!this._jitterActive)return;let e=this.cam.projectionMatrix.elements;e[8]=this._savedSkewX,e[9]=this._savedSkewY,e[12]=this._savedShiftX,e[13]=this._savedShiftY,this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!1}},R8=Array.from({length:16},(e,t)=>[_8(t+1,2),_8(t+1,3)]),E8="h16";try{let e=new URLSearchParams(window.location.search).get("dbgjitseq");("r2"===e||"h64"===e||"white"===e||"half"===e)&&(E8=e)}catch{}O8=.7548776662466927,B8=.5698402909980532,V8=class extends CR{constructor(e,t,i,r,s=!1){super("vec4"),this._resolution=n5(new rs(1,1)),this._historyValid=n5(0),this._jitterUV=n5(new rs(0,0)),this._resolveMaterials=null,this._rebuildResolveMaterials=null,this.beautyNode=e,this.depthNode=t,this.velocityNode=i,this._hdr=s,this._history=r??T8(),this._ownsHistory=void 0===r,this._outputTexNode=e5(this._history.rtA.texture)}static get type(){return"SplineTAANode"}get outputTextureNode(){return this._outputTexNode}renderResolve(e){f5.setProjectionMatrix(this._history.unjitteredProjection);let t=this.beautyNode.passNode.renderTarget,i=t.texture.width,r=t.texture.height,s=this._history;(s.rtA.width!==i||s.rtA.height!==r)&&(s.resize(i,r),this._rebuildResolveMaterials?.()),this._resolution.value.set(i,r),this._historyValid.value=s.valid?1:0,this._jitterUV.value.copy(s.jitterOffsetUV);let a=s.flip?s.rtB:s.rtA,n=this._resolveMaterials?this._resolveMaterials[s.flip?1:0]:null,o=e.getRenderTarget(),l=e.getMRT();e.setMRT(null),s.valid||(e.setRenderTarget(s.rtA),e.clear(!0,!1,!1),e.setRenderTarget(s.rtB),e.clear(!0,!1,!1)),e.setRenderTarget(a),n&&(N8.material=n,N8.name="SplineTAA.resolve",N8.render(e)),e.setRenderTarget(o),e.setMRT(l),this._outputTexNode.value=a.texture,s.valid=!0,s.flip=!s.flip,A5.taaResolves++,A5.taaJitterIndex=s.jitterIndex,A5.taaHistoryValid=!0,A5.taaResolveSize=`${i}x${r}`}setup(e){let t=!0===e.renderer.reversedDepthBuffer,i=!0===e.renderer.backend?.isWebGLBackend,r=!1,s=!1,a=!1,n=!1,o=!1,l=!1,h=!1,u=!1,d=!1,c=!1;try{let e=new URLSearchParams(window.location.search).get("dbgtaa");r="1"===e,s="zv"===e,a="nc"===e,n="err"===e,o="hist"===e,l="red"===e,h="ns"===e,u="fb90"===e,d="mark"===new URLSearchParams(window.location.search).get("dbgjit"),c="hold"===e}catch{}let p=this.beautyNode,m=this.velocityNode,g=this.depthNode,f=this._resolution,y=this._historyValid,v=this._jitterUV,b=e=>{let t=p.sample(e);return g5(S8(t.rgb),t.a)},x=e=>{let p=C1(()=>{let p=u5().toVar();if(d)return g5(v.x.mul(400).add(.5),v.y.mul(400).add(.5),c2(.5),c2(1));let x=p,w=p5(c2(1).div(f.x),c2(1).div(f.y)).toVar(),_=[[-1,1],[0,1],[1,1],[-1,0],[0,0],[1,0],[-1,-1],[0,-1],[1,-1]].map(([e,t])=>p.add(p5(w.x.mul(e),w.y.mul(t))).toVar()),S=_,M=c2(t?-1e3:1e3).toVar(),T=p5(_[4]).toVar();for(let e=0;e<9;e++){let i=C8(g.load(E2(_[e].mul(A8(f)))).r).toVar(),r=t?i.greaterThan(M):i.lessThan(M);M.assign(r.select(i,M)),T.assign(r.select(_[e],T))}let C=m.load(E2(T.mul(f))).xy.mul(p5(.5,-.5)).toVar();s&&C.assign(p5(0,0));let A=p.sub(C).toVar(),N=i?p5(A.x,c2(1).sub(A.y)).toVar():A,P=b(x).toVar();if(r)return g5(C.x.mul(20).add(.5),C.y.mul(20).add(.5),y,c2(1));if(l){let e=new Yn(new Uint8Array([255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255]),2,2);return e.needsUpdate=!0,e5(e).sample(p)}if(o){let t=i?p5(p.x,c2(1).sub(p.y)):p;return e.sample(t)}if(n){let t=i?p5(p.x,c2(1).sub(p.y)):p,r=e.sample(N),s=e.sample(t),a=P.x,n=e=>S8(e.rgb).x;return g5(n(r).sub(a).abs().mul(8),n(s).sub(a).abs().mul(8),c2(0),c2(1))}let R=N.mul(f).toVar(),E=p2(R.sub(.5)).add(.5).toVar(),O=R.sub(E).toVar(),B=O.mul(O.mul(O.mul(-.5).add(1)).add(-.5)).toVar(),V=O.mul(O).mul(O.mul(1.5).add(-2.5)).add(1).toVar(),D=O.mul(O.mul(O.mul(-1.5).add(2)).add(.5)).toVar(),I=O.mul(O).mul(O.mul(.5).add(-.5)).toVar(),L=V.add(D).toVar(),z=D.div(L).toVar(),k=E.sub(1).div(f).toVar(),U=E.add(2).div(f).toVar(),F=E.add(z).div(f).toVar(),j=g5(0).toVar();j.addAssign(e.sample(p5(F.x,k.y)).mul(L.x.mul(B.y))),j.addAssign(e.sample(p5(k.x,F.y)).mul(B.x.mul(L.y))),j.addAssign(e.sample(p5(F.x,F.y)).mul(L.x.mul(L.y))),j.addAssign(e.sample(p5(U.x,F.y)).mul(I.x.mul(L.y))),j.addAssign(e.sample(p5(F.x,U.y)).mul(L.x.mul(I.y)));let G=g5(S8(j.rgb),j.a).toVar();if(c)return g5(M8(G.rgb).mul(m5(1,.55,.55)),j.a);let W=b(S[0]).toVar(),q=b(S[1]).toVar(),H=b(S[2]).toVar(),$=b(S[3]).toVar(),Y=b(S[4]).toVar(),X=b(S[5]).toVar(),K=b(S[6]).toVar(),Z=b(S[7]).toVar(),J=b(S[8]).toVar(),Q=g5(W2(W,W2(q,W2(H,W2($,W2(Y,W2(X,W2(K,W2(Z,J))))))))).toVar(),ee=g5(j2(W,j2(q,j2(H,j2($,j2(Y,j2(X,j2(K,j2(Z,J))))))))).toVar(),te=g5(W2(q,W2($,W2(Y,W2(X,Z))))).toVar(),ie=g5(j2(q,j2($,j2(Y,j2(X,Z))))).toVar();Q.assign(Q.add(te).mul(.5)),ee.assign(ee.add(ie).mul(.5));let re=ee.r.sub(Q.r).mul(.25).mul(.5).toVar(),se=P.gb.toVar();h||(Q.y.assign(se.x.sub(re)),Q.z.assign(se.y.sub(re)),ee.y.assign(se.x.add(re)),ee.z.assign(se.y.add(re)));let ae=g5(a?G:$1(G,Q,ee)).toVar(),ne=u||a?c2(.9):c2(.9).mul(y),oe=g5(q2(P,ae,ne)).toVar(),le=N5.tapAngle,he=N3(p.mul(f).add(p5(le.mul(127.1),le.mul(311.7)))).sub(.5).mul(1/255);return g5(M8(oe.rgb,!this._hdr).add(m5(he)),oe.a)}),x=new UU;return x.name="SplineTAA.resolve",x.colorNode=p(),x.depthTest=!1,x.depthWrite=!1,x.blending=He,x.needsUpdate=!0,x};return this._rebuildResolveMaterials=()=>{this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose()),this._resolveMaterials=[x(e5(this._history.rtB.texture)),x(e5(this._history.rtA.texture))]},this._rebuildResolveMaterials(),this._outputTexNode}dispose(){this._ownsHistory&&this._history.dispose(),this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose(),this._resolveMaterials=null),f5.setProjectionMatrix(null)}}}),q8=n(()=>{D8=class{constructor(){this._frames=0}get frames(){return this._frames}get stalled(){return this._frames>=3}update(e,t){this._frames=e>0&&!t?this._frames+1:0}}}),H8=n(()=>{EN(),v5(),b5(),I8=new Oq,L8=new rs,k8=class extends CR{static get type(){return"SMAANode"}constructor(e){super("vec4"),this.textureNode=e,this.updateBeforeType=P1.FRAME,this._renderTargetEdges=new Ms(1,1,{depthBuffer:!1,type:ii}),this._renderTargetEdges.texture.name="SMAANode.edges",this._renderTargetWeights=new Ms(1,1,{depthBuffer:!1,type:ii}),this._renderTargetWeights.texture.name="SMAANode.weights",this._renderTargetBlend=new Ms(1,1,{depthBuffer:!1,type:ii}),this._renderTargetBlend.texture.name="SMAANode.blend";let t=this,i=new Image;i.crossOrigin="anonymous",i.src=PN("smaa-node-area.png"),i.onload=function(){t._areaTexture.needsUpdate=!0},this._areaTexture=new ws,this._areaTexture.name="SMAANode.area",this._areaTexture.image=i,this._areaTexture.minFilter=qt,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let r=new Image;r.crossOrigin="anonymous",r.src=PN("smaa-node-search.png"),r.onload=function(){t._searchTexture.needsUpdate=!0},this._searchTexture=new ws,this._searchTexture.name="SMAANode.search",this._searchTexture.image=r,this._searchTexture.magFilter=jt,this._searchTexture.minFilter=jt,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._invSize=n5(new rs),this._areaTextureUniform=e5(this._areaTexture),this._searchTextureUniform=e5(this._searchTexture),this._edgesTextureUniform=e5(this._renderTargetEdges.texture),this._weightsTextureUniform=e5(this._renderTargetWeights.texture),this._materialEdges=new UU,this._materialEdges.name="SMAANode.edges",this._materialWeights=new UU,this._materialWeights.name="SMAANode.weights",this._materialBlend=new UU,this._materialBlend.name="SMAANode.blend",this._textureNode=m3(this,this._renderTargetBlend.texture)}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),this._renderTargetEdges.setSize(e,t),this._renderTargetWeights.setSize(e,t),this._renderTargetBlend.setSize(e,t)}updateBefore(e){let{renderer:t}=e;z8=yY.resetRendererState(t,z8);let i=t.getDrawingBufferSize(L8);this.setSize(i.width,i.height),t.setRenderTarget(this._renderTargetEdges),I8.material=this._materialEdges,I8.render(t),t.setRenderTarget(this._renderTargetWeights),I8.material=this._materialWeights,I8.render(t),t.setRenderTarget(this._renderTargetBlend),I8.material=this._materialBlend,I8.render(t),yY.restoreRendererState(t,z8)}setup(e){let t=p5(.00625,.0017857142857142857),i=1/7,r=this.textureNode.uvNode||u5(),s=C1(()=>{let e=g5(r.xy,r.xy).add(g5(this._invSize.xy,this._invSize.xy).mul(g5(-1,0,0,-1))),t=g5(r.xy,r.xy).add(g5(this._invSize.xy,this._invSize.xy).mul(g5(1,0,0,1))),i=g5(r.xy,r.xy).add(g5(this._invSize.xy,this._invSize.xy).mul(g5(-2,0,0,-2)));return c5("vec4","vOffset0").assign(e),c5("vec4","vOffset1").assign(t),c5("vec4","vOffset2").assign(i),X2}),a=C1(()=>{let e=c5("vec4","vOffset0"),t=c5("vec4","vOffset1"),i=c5("vec4","vOffset2"),s=p5(.1,.1),a=g5().toVar(),n=this.textureNode.sample(r).rgb.toVar(),o=this.textureNode.sample(e.xy).rgb.toVar(),l=O1(n.sub(o));a.x=j2(l.r,l.g,l.b);let h=this.textureNode.sample(e.zw).rgb.toVar();l=O1(n.sub(h)),a.y=j2(l.r,l.g,l.b);let u=X3(s,a.xy).toVar();o2(u,p5(1,1)).equal(0).discard();let d=this.textureNode.sample(t.xy).rgb.toVar();l=O1(n.sub(d)),a.z=j2(l.r,l.g,l.b);let c=this.textureNode.sample(t.zw).rgb.toVar();l=O1(n.sub(c)),a.w=j2(l.r,l.g,l.b);let p=j2(a.x,a.y,a.z,a.w).toVar(),m=this.textureNode.sample(i.xy).rgb.toVar();l=O1(n.sub(m)),a.z=j2(l.r,l.g,l.b);let g=this.textureNode.sample(i.zw).rgb.toVar();return l=O1(n.sub(g)),a.w=j2(l.r,l.g,l.b),p=j2(p,a.z,a.w),u.xy.mulAssign(p5(X3(c2(.5).mul(p),a.xy))),g5(u,0,0)}),n=C1(([e,t,i,r])=>{let s=p5(t).toVar();return s.r=i.add(s.r.mul(r)),c2(255).mul(e.sample(s)).r}),o=C1(([e,r,s,a,n])=>{let o=c2(16).mul(c2(4).mul(p5(s,a)).round()).add(r);return o=t.mul(o).add(c2(.5).mul(t)),o.y.addAssign(c2(i).mul(n)),e.sample(o).rg}),l=C1(([e,t,i,r])=>{let s=p5(0,1).toVar(),a=p5(i).toVar();return N1({start:T2(0),end:T2(8),type:"int",condition:"<"},()=>{s.assign(e.sample(a).rg),a.subAssign(p5(2,0).mul(this._invSize)),A1(a.x.lessThanEqual(r).or(s.g.lessThanEqual(c2(.8281)).or(s.r.notEqual(c2(0)))),()=>{M1()})}),a.x.addAssign(c2(.25).mul(this._invSize.x)),a.x.addAssign(this._invSize.x),a.x.addAssign(c2(2).mul(this._invSize.x)),a.x.subAssign(this._invSize.x.mul(n(t,s,0,.5))),a.x}),h=C1(([e,t,i,r])=>{let s=p5(0,1).toVar(),a=p5(i).toVar();return N1({start:T2(0),end:T2(8),type:"int",condition:"<"},()=>{s.assign(e.sample(a).rg),a.addAssign(p5(2,0).mul(this._invSize)),A1(a.x.greaterThanEqual(r).or(s.g.lessThanEqual(c2(.8281)).or(s.r.notEqual(c2(0)))),()=>{M1()})}),a.x.subAssign(c2(.25).mul(this._invSize.x)),a.x.subAssign(this._invSize.x),a.x.subAssign(c2(2).mul(this._invSize.x)),a.x.addAssign(this._invSize.x.mul(n(t,s,.5,.5))),a.x}),u=C1(([e,t,i,r])=>{let s=p5(1,0).toVar(),a=p5(i).toVar();return N1({start:T2(0),end:T2(8),type:"int",condition:"<"},()=>{s.assign(e.sample(a).rg),a.addAssign(p5(0,-2).mul(this._invSize)),A1(a.y.lessThanEqual(r).or(s.r.lessThanEqual(c2(.8281)).or(s.g.notEqual(c2(0)))),()=>{M1()})}),a.y.addAssign(c2(.25).mul(this._invSize.y)),a.y.addAssign(this._invSize.y),a.y.addAssign(c2(2).mul(this._invSize.y)),a.y.subAssign(this._invSize.y.mul(n(t,s.gr,0,.5))),a.y}),d=C1(([e,t,i,r])=>{let s=p5(1,0).toVar(),a=p5(i).toVar();return N1({start:T2(0),end:T2(8),type:"int",condition:"<"},()=>{s.assign(e.sample(a).rg),a.subAssign(p5(0,-2).mul(this._invSize)),A1(a.y.greaterThanEqual(r).or(s.r.lessThanEqual(c2(.8281)).or(s.g.notEqual(c2(0)))),()=>{M1()})}),a.y.subAssign(c2(.25).mul(this._invSize.y)),a.y.subAssign(this._invSize.y),a.y.subAssign(c2(2).mul(this._invSize.y)),a.y.addAssign(this._invSize.y.mul(n(t,s.gr,.5,.5))),a.y}),c=C1(()=>{let e=r.xy.div(this._invSize),t=g5(r.xy,r.xy).add(g5(this._invSize.xy,this._invSize.xy).mul(g5(-.25,-.125,1.25,-.125))).toVar(),i=g5(r.xy,r.xy).add(g5(this._invSize.xy,this._invSize.xy).mul(g5(-.125,-.25,-.125,1.25))).toVar(),s=g5(t.xz,i.yw).add(g5(-2,2,-2,2).mul(g5(this._invSize.xx,this._invSize.yy)).mul(c2(8))).toVar();return c5("vec2","vPixcoord").assign(e),c5("vec4","vOffset0").assign(t),c5("vec4","vOffset1").assign(i),c5("vec4","vOffset2").assign(s),X2}),p=C1(()=>{let e=c5("vec2","vPixcoord"),t=c5("vec4","vOffset0"),i=c5("vec4","vOffset1"),s=c5("vec4","vOffset2"),a=g5(0,0,0,0).toVar(),n=g5(0,0,0,0).toVar(),c=this._edgesTextureUniform.sample(r).rg.toVar();return A1(c.g.greaterThan(c2(0)),()=>{let r=p5().toVar(),u=p5().toVar();u.x=l(this._edgesTextureUniform,this._searchTextureUniform,t.xy,s.x),u.y=i.y,r.x=u.x;let d=this._edgesTextureUniform.sample(u).r.toVar(),c=p5().toVar();c.x=h(this._edgesTextureUniform,this._searchTextureUniform,t.zw,s.y),c.y=i.y,r.y=c.x,r=r.div(this._invSize.x).sub(e.x);let p=Y3(O1(r)),m=this._edgesTextureUniform.sample(c.add(p5(1,0).mul(this._invSize))).r.toVar();a.r=m,a.rg=o(this._areaTextureUniform,p,d,m,c2(n.y))}),A1(c.r.greaterThan(c2(0)),()=>{let r=p5().toVar(),l=p5().toVar();l.y=u(this._edgesTextureUniform,this._searchTextureUniform,i.xy,s.z),l.x=t.x,r.x=l.y;let h=this._edgesTextureUniform.sample(l).g.toVar(),c=p5().toVar();c.y=d(this._edgesTextureUniform,this._searchTextureUniform,i.zw,s.w),c.x=t.x,r.y=c.y,r=r.div(this._invSize.y).sub(e.y);let p=Y3(O1(r)),m=this._edgesTextureUniform.sample(c.add(p5(0,1).mul(this._invSize))).g.toVar();a.ba=o(this._areaTextureUniform,p,h,m,c2(n.x))}),a}),m=C1(()=>{let e=g5(r.xy,r.xy).add(g5(this._invSize.xy,this._invSize.xy).mul(g5(1,0,0,1)));return c5("vec4","vOffset1").assign(e),X2}),g=C1(()=>{let e=c5("vec4","vOffset1"),t=g5().toVar(),i=g5().toVar();return i.xz=this._weightsTextureUniform.sample(r).xz,i.y=this._weightsTextureUniform.sample(e.zw).g,i.w=this._weightsTextureUniform.sample(e.xy).a,A1(o2(i,g5(1)).lessThan(1e-5),()=>{t.assign(this.textureNode.sample(r))}).Else(()=>{let e=p5().toVar();e.x=i.a.greaterThan(i.b).select(i.a,i.b.negate()),e.y=i.g.greaterThan(i.r).select(i.g,i.r.negate()),A1(O1(e.x).greaterThan(O1(e.y)),()=>{e.y.assign(0)}).Else(()=>{e.x.assign(0)});let s=this.textureNode.sample(r).toVar(),a=p5(r).toVar();a.addAssign(G3(e).mul(this._invSize));let n=this.textureNode.sample(a).toVar(),o=O1(e.x).greaterThan(O1(e.y)).select(O1(e.x),O1(e.y)).toVar(),l=q2(s,n,o);t.assign(l)}),t});return this._materialEdges.vertexNode=s().context(e.getSharedContext()),this._materialEdges.fragmentNode=a().context(e.getSharedContext()),this._materialEdges.needsUpdate=!0,this._materialWeights.vertexNode=c().context(e.getSharedContext()),this._materialWeights.fragmentNode=p().context(e.getSharedContext()),this._materialWeights.needsUpdate=!0,this._materialBlend.vertexNode=m().context(e.getSharedContext()),this._materialBlend.fragmentNode=g().context(e.getSharedContext()),this._materialBlend.needsUpdate=!0,this._textureNode}dispose(){this._renderTargetEdges.dispose(),this._renderTargetWeights.dispose(),this._renderTargetBlend.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose()}_getAreaTexture(){return""}_getSearchTexture(){return""}},U8=e=>new k8(J1(e))}),$8=n(()=>{Mu(),v5(),b5(),H8(),P5(),F8=new rs,j8=new aa,G8=class{constructor(){this._rt=null,this._texNode=null,this._smaaNode=null,this._material=null,this._quad=null,this._depthTexNode=null,this._seedMaterial=null,this._seedQuad=null}_ensureTarget(e,t,i){if(null===this._rt||this._rt.width!==e||this._rt.height!==t){this._rt?.dispose();let i=new Ms(e,t,{depthBuffer:!0,stencilBuffer:!1,samples:0});i.texture.name="SplineHelperOverlay.color",this._rt=i}if(null===this._texNode){this._texNode=e5(this._rt.texture),this._smaaNode=U8(this._texNode);let e=new UU;e.name="SplineHelperOverlayComposite",e.fragmentNode=this._smaaNode,e.transparent=!0,e.blending=Ze,e.blendEquation=Qe,e.blendSrc=at,e.blendDst=ht,e.blendSrcAlpha=at,e.blendDstAlpha=ht,e.depthTest=!1,e.depthWrite=!1,this._material=e,this._quad=new Oq(e);let t=new UU;t.name="SplineHelperOverlayDepthSeed",this._depthTexNode=e5(i),t.depthNode=this._depthTexNode.x,t.fragmentNode=g5(0),t.colorWrite=!1,t.depthTest=!1,t.depthWrite=!0,this._seedMaterial=t,this._seedQuad=new Oq(t)}else this._texNode.value!==this._rt.texture&&(this._texNode.value=this._rt.texture),this._depthTexNode.value!==i&&(this._depthTexNode.value=i);return this._rt}render(e,t,i,r,s){e.getDrawingBufferSize(F8);let a=this._ensureTarget(F8.x,F8.y,s),n=e.getRenderTarget(),o=e.autoClear;e.getClearColor(j8);let l=e.getClearAlpha();if(e.autoClear=!1,e.setRenderTarget(a),e.setClearColor(0,0),e.clear(!0,!0,!1),this._seedQuad.render(e),t&&e.render(t,r),e.clear(!1,!0,!1),i&&e.render(i,r),e.setRenderTarget(n),e.setClearColor(j8,l),function(){try{return"0"!==new URLSearchParams(window.location.search).get("dbgoutguard")}catch{return!0}}()){let t=e.toneMapping,i=e.outputColorSpace;e.toneMapping=Ct,e.outputColorSpace=ms.workingColorSpace,this._quad.render(e),e.toneMapping=t,e.outputColorSpace=i}else this._quad.render(e);e.autoClear=o}dispose(){this._rt?.dispose(),this._rt=null,this._smaaNode?.dispose(),this._material?.dispose(),this._seedMaterial?.dispose()}}});var Y8,X8,K8,Z8=n(()=>{v5(),Y8=new WeakMap,X8=new Set,K8=0});function J8(e){let t=e.parent?.selectedTexture;return t&&!0===t.isTexture?t:null}function Q8(e){let t=e.src.array,i=e.attr.array;for(let e=0,r=Math.min(t.length,i.length);e<r;e++)i[e]=t[e];e.attr.needsUpdate=!0}var e9,t9,i9,r9,s9=n(()=>{Mu(),v5(),b5(),e9=new WeakMap,t9=new Set,i9=0,r9=new WeakMap});function a9(e,t,i,r){let s=r;switch(i){case 0:return e;case 1:return e.add(t.mul(s));case 16:{let i=c2(1).sub(c2(1).sub(e).mul(c2(1).sub(t))).toVec3();return q2(e,i,s)}case 10:return q2(e,e.mul(t),s);default:return q2(e,t,s)}}function n9(){return null===h9&&(h9=J2({output:u3,velocity:f5})),h9}var o9,l9,h9,u9,d9,c9,p9,m9,g9,f9,y9,v9,b9,x9,w9,_9,S9,M9,T9,C9,A9,N9,P9,R9,E9,O9,B9,V9,D9,I9,L9,z9,k9,U9,F9,j9,G9,W9,q9,H9,$9,Y9,X9,K9,Z9,J9,Q9,e7,t7,i7,r7,s7,a7,n7,o7,l7,h7,u7=n(()=>{Mu(),v5(),b5(),W8(),LN(),P5(),Bv(),o9=e=>e,l9=e=>e,h9=null}),d7=n(()=>{u9={enabled:!1},d9=new WeakMap,c9=new WeakSet}),c7=n(()=>{Mu(),v5(),b5(),DA(),WC(),xC(),p9=C1(e=>{let t=e.lightDistance,i=e.cutoffDistance,r=e.decayExponent,s=i.greaterThan(0).and(r.greaterThan(0));return k3(s,t.div(i).oneMinus().clamp().pow(r),c2(1))}),m9=class extends ZY{static get type(){return"SplinePointLightNode"}setupDirect(e){let t=this.getLightVector(e),i=t.normalize(),r=p9({lightDistance:t.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode});return{lightColor:this.colorNode.mul(r),lightDirection:i}}},g9=class extends QZ{static get type(){return"SplineSpotLightNode"}setupDirect(e){let t,i,r=this.light,s=this.getLightVector(e),a=s.normalize(),n=a.dot(V2(r)),o=this.getSpotAttenuation(e,n),l=p9({lightDistance:s.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}),h=this.colorNode.mul(o).mul(l),u=r;if(u.colorNode?(i=this.getLightCoord(e),t=u.colorNode(i)):u.map&&(i=this.getLightCoord(e),t=e5(u.map,i.xy).onRenderUpdate(()=>u.map)),t&&i){let e=i.mul(2).sub(1).abs().lessThan(1).all();h=k3(e,h.mul(t),h)}return{lightColor:h,lightDirection:a}}}}),p7=n(()=>{f9=null}),m7=n(()=>{Mu(),v5(),b5(),x4(),b4(),bN(),T4(),D4(),e6(),yx(),t6(),Bv(),i6(),jC(),r6(),s6(),p6(),P5(),x8(),O6(),w8(),W8(),q8(),$8(),Z8(),s9(),u7(),d7(),c7(),p7(),y9=new ns,v9=new ns,b9=new aa,x9=new aa,w9=new aa,_9=new ns,S9=new ns,M9=new rs,T9=new ns(1,0,0),C9=new ns(0,1,0),A9=new ns(0,0,1),N9=new ns,P9=new ns,R9=new ns,E9=new ns,O9=new As,B9=new ns,V9=new ns,D9=new uo,I9=new Ss,L9=new Ss,z9=new rs,k9=new rs,U9=new ns,F9=new ns,j9=new ns,G9=new ns,W9=new ns,q9=[],H9=!1,$9=!1,Y9=!1,X9="full",K9="g16",Z9=!1,J9=!1,Q9=!1,e7="default",t7=!1,i7=!0,r7=!0,s7=!0,a7=!0,n7=!0,o7=eA;try{let e=new URLSearchParams(window.location.search),t=e.get("instancing");if(null!==t)if("off"===t||"0"===t||"false"===t||"no"===t)n7=!1;else{let e=Number.parseInt(t,10);Number.isFinite(e)&&e>1&&(o7=e)}H9="0"===e.get("dbgao"),$9="0"===e.get("dbgshadow"),Y9="1"===e.get("dbgfp16"),Z9="0"===e.get("dbgsky"),J9="0"===e.get("dbgssr"),Q9="0"===e.get("dbgibl");let i=e.get("pbrcolor");"0"===i?e7="off":("linear"===i||"aces"===i||"agx"===i||"neutral"===i)&&(e7=i),t7="0"===e.get("dbgplanar"),i7="0"!==e.get("dbgplanarpyr"),r7="0"!==e.get("dbgssrpyr"),s7="0"!==e.get("dbgssrhalf"),a7="0"!==e.get("dbgssrresolve");let r=e.get("dbgprefilter");"0"===r?X9="off":"base"===r?X9="base":"k4"===r&&(K9="k4")}catch{}(h7=l7=class extends _1{constructor(e={}){var t;super({canvas:e.canvas,alpha:e.alpha??!0,antialias:e.antialias??!1,forceWebGL:e.forceWebGL??!1,powerPreference:e.powerPreference,trackTimestamp:e.trackTimestamp??!0===globalThis.__SPLINE_TRACK_TIMESTAMP__,stencil:!1,requiredLimits:e.requiredLimits,canvasColorSpace:"display-p3",outputBufferType:Y9?ii:Xt,asyncCompilation:!0===e.asyncCompilation||"load"===e.asyncCompilation}),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new rs,this.dummyCamera=new fx,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.manageShadowUpdates=!1,this.forceShadowUpdates=!1,this._shadowMapMissingAtSync=!1,this.temporalAAEnabled=!0,this.hdrChainActive=!1,this.isWebGPUSplineRenderer=!0,this.shadowFilterHook=z6,this._gaugeSnapshot="",this._gaugeChangedAt=0,this._gaugeStallWarned=!1,this._skipStalls=new D8,this._stallWarned=!1,this._asyncCompilationMode=!1,this._asyncLoadWarmupsInFlight=0,this.sceneBundlesEnabled=!1,this.sceneBundlesForceRerecord=!1,this._appliedWidth=-1,this._appliedHeight=-1,this._appliedRatio=-1,this._bundleStates=new WeakMap,this._skySystem=null,this._skyFeatureWarned=!1,this.skyAnimationAllowed=!1,this.skyEnvironmentNeeded=!0,this._bundledPages=new Set,this._bundleValveArmed=!1,this._destroyedSubmitErrors=0,this._destroyedSubmitLastFrame=-10,this._warmupTarget=null,this.renderStarted=!1,this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._grabWarmupTarget=null,this._warnedHelperIncompat=new WeakSet,this._maskLights=[],this._maskBlocked=!1,this._grabTargetEpoch=0,this._retiredGrabTargets=[],this._retiredGpuBuffers=[],this._bundleEpochDirty=!1,this._encodeMaterials={},this._transmissionChain=[],this._reflectionColorChain=[],this._reflectionDepthChain=[],this._reflectionPassesKey="",this._reflectionResolveMarchKey="",this._planarChain=[],this._frameSerial=0,this._asyncCompilationMode=e.asyncCompilation??!1,this._updateCompilationBurst(),n6&&function(){if(!d6){if(d6=!0,u6=()=>N5.frameIndex.value,typeof GPUBuffer<"u"){let e=GPUBuffer.prototype.destroy;GPUBuffer.prototype.destroy=function(){return a6("buffer",this.label,this.size),e.call(this)}}if(typeof GPUTexture<"u"){let e=GPUTexture.prototype.destroy;GPUTexture.prototype.destroy=function(){return a6("texture",this.label,`${this.width}x${this.height}`),e.call(this)}}console.info("[spline/webgpu] ?dbgdestroys=1 — GPU resource destroy logging armed; reproduce the error and read the [dbgdestroys] dumps")}}(),this.pipeline=new Q4(this),this.library.addLight(V4,B4),this.shadowMap.enabled=!0,this.shadowMap.type=Ue,t=!0===this.backend?.isWebGPUBackend,Y6=t,this._deferGpuBufferDestruction(),this.outputColorSpace=ur,this.toneMapping=Ct,function(e){let t=e.library;t.addLight(m9,PA),t.addLight(g9,UC),t.addLight(ZZ,yC),t.lightNodes.delete(hh),t.lightNodes.delete(oh),t.addLight(m9,hh),t.addLight(g9,oh)}(this),this.sceneBundlesEnabled=!0===e.sceneBundles||"rerecord"===e.sceneBundles,this.sceneBundlesForceRerecord="rerecord"===e.sceneBundles,this.domElement.removeAttribute?.("data-engine")}get lastFrameIncomplete(){return!!(this._warmupInFlight||this._compilationHasWork&&!this._gaugesStalled)||0!==(this._skippedAsyncDraws??0)&&!this._skipStalls.stalled}get _gaugesStalled(){return this._gaugeChangedAt>0&&performance.now()-this._gaugeChangedAt>l7._GAUGE_STALL_MS}_trackGaugeStall(){let e=this._asyncCompilationGauges,t=void 0!==e&&(e.queued>0||e.pipelines>0),i=t?`${e.queued}/${e.pipelines}`:"";return t?i!==this._gaugeSnapshot?(this._gaugeSnapshot=i,void(this._gaugeChangedAt=performance.now())):void(this._gaugesStalled&&!this._gaugeStallWarned&&(this._gaugeStallWarned=!0,console.warn(`[spline/webgpu] async pipeline driver stalled (${i} in flight, no movement for ${l7._GAUGE_STALL_MS}ms) — treating frames as final so screenshots, thumbnails and the on-demand render loop keep working.`))):(this._gaugeSnapshot="",void(this._gaugeChangedAt=0))}_trackStalledSkips(e){let t=this._compilationHasWork&&!this._gaugesStalled;this._skipStalls.update(e,t),A5.stalledSkipFrames=this._skipStalls.frames,this._skipStalls.stalled&&!this._stallWarned&&(this._stallWarned=!0,console.warn(`[spline/webgpu] ${e} draw(s) are permanently skipped — their render pipelines never became ready (look for "pipeline creation failed" above). Those objects will not appear; the frame is treated as final so screenshots, thumbnails and the on-demand render loop keep working.`))}get _asyncCompilationGauges(){return this.info.asyncCompilation}get _compilationHasWork(){let e=this._asyncCompilationGauges;return void 0!==e&&(e.queued>0||e.pipelines>0)}get asyncCompilationEnabled(){return!0===this._asyncCompilation}get taaHistory(){return this._taaHistory||(this._taaHistory=T8()),this._taaHistory}async init(){await super.init();let e=this.backend.gl;if(e&&"drawingBufferColorSpace"in e)try{e.drawingBufferColorSpace="display-p3"}catch(e){console.warn(e)}return this.backend.device?.lost?.then(e=>{A5.deviceLost=`${e?.reason??"unknown"}: ${e?.message??""}`.trim()}),this}setSize(e,t,i=!0){if(this._appliedWidth!==e||this._appliedHeight!==t||this._appliedRatio!==this.getPixelRatio()){this._appliedWidth=e,this._appliedHeight=t,this._appliedRatio=this.getPixelRatio();let r=this.viewportWidth!==e||this.viewportHeight!==t;this.viewportWidth=e,this.viewportHeight=t,super.setSize(e,t,i),r&&this.pipeline.resize(e,t,i)}return this}setPixelRatio(e=1){return this.getPixelRatio()!==e&&super.setPixelRatio(e),this}get hdTransmission(){return 1===N5.transmissionLod.value}set hdTransmission(e){N5.transmissionLod.value=!0===e?1:2}renderScenePass(e,t){this.render(e,t)}get skySystem(){return this._skySystem}get skyAnimationActive(){return!0===this._skySystem?.animationActive}*_liveBundledPages(){for(let e of this._bundledPages){let t=e.deref();void 0===t?this._bundledPages.delete(e):yield t}}_armBundleValve(){if(this._bundleValveArmed)return;let e=this.backend.device;"function"==typeof e?.addEventListener&&(this._bundleValveArmed=!0,e.addEventListener("uncapturederror",e=>{if(!this.sceneBundlesEnabled||!(e?.error?.message??"").toLowerCase().includes("destroyed"))return;let t=N5.frameIndex.value,i=(t-this._destroyedSubmitLastFrame+16)%16;if(this._destroyedSubmitErrors=i<=2?this._destroyedSubmitErrors+1:1,this._destroyedSubmitLastFrame=t,!(this._destroyedSubmitErrors<4)){this.sceneBundlesEnabled=!1,A5.bundleDisabled=!0;for(let e of this._liveBundledPages()){let t=this._bundleStates.get(e);t&&(t.disabled=!0),e.isBundleGroup=!1}this._bundledPages.clear()}}))}_updateSceneBundle(e,t){if(void 0===this.backend.beginBundle)return;let i=this._bundleStates.get(e);if(void 0===i){let t={signature:-1,rebuilds:0,resourceRebuilds:0,checks:0,disabled:!1,camHash:0,prevCamHash:0,epoch:0,lastEpoch:0,bufferIds:new WeakMap,bufferIdSeq:0,watched:new WeakSet,onResourceDispose:()=>{t.epoch++}};i=t,this._bundleStates.set(e,i),this._bundledPages.add(new WeakRef(e)),this._armBundleValve()}let r=e;if(i.disabled)return;{let e=t.matrixWorld.elements,r=t.projectionMatrix.elements,s=-2128831035;for(let t=0;t<16;t++)s^=1e4*e[t]|0,s=Math.imul(s,16777619),s^=1e4*r[t]|0,s=Math.imul(s,16777619);i.camHash=s}let s=-2128831035,a=e=>{s^=0|e,s=Math.imul(s,16777619)};a(this._grabTargetEpoch),a(null!==e.fog?1:0);let n=i,o=e=>{let t=e;!t||"function"!=typeof t.addEventListener||n.watched.has(t)||(n.watched.add(t),t.addEventListener("dispose",n.onResourceDispose))},l=e=>{if(!e)return 0;let t=n.bufferIds.get(e);return void 0===t&&(t=++n.bufferIdSeq,n.bufferIds.set(e,t)),t},h=e=>{o(e),a(e.id),a(e.version),a(!0===e.transparent?1:0),"function"==typeof e.assetsLoaded&&a(e.assetsLoaded()?1:0)},u=!1;if(e.traverse(e=>{let t=e;if(!0===t.isMesh||!0===t.isLine||!0===t.isPoints||!0===t.isSprite){let e=t;!0===e.isDecalObject&&"function"==typeof e.updateDecal&&e.updateDecal()&&(u=!0),t.frustumCulled&&(t.frustumCulled=!1),a(t.id),a(t.visible?1:0),a(t.layers.mask),a(t.renderOrder);let i=t.geometry;o(i),a(i.id),a(i.drawRange.start),a(i.drawRange.count===1/0?-1:i.drawRange.count),a(l(i.index)),a(l(i.attributes.position)),a(i.instanceCount??-1),a(void 0===t.count?-1:t.count);let r=t.material;if(Array.isArray(r))for(let e of r)h(e);else r&&h(r)}else!0===e.isLight?(a(e.id),a(e.visible?1:0),a(e.castShadow?1:0)):(a(e.id),a(e.visible?1:0))}),a(i.epoch),i.checks++,A5.bundleChecks=i.checks,i.checks%600==0){let e=this._bundleDebug;A5.bundleIncompleteRecords=e?.incompleteRecords??0,A5.bundleRecords=e?.records??0,A5.bundleReplays=e?.replays??0,i.prevCamHash=i.camHash}if(!0!==r.isBundleGroup)return r.isBundleGroup=!0,r.static=!0,"number"!=typeof r.version&&(r.version=0),void(i.signature=s);if(this.sceneBundlesForceRerecord)return r.version=(r.version??0)+1,void(i.signature=s);if(s!==i.signature){if(i.signature=s,r.version=(r.version??0)+1,i.epoch!==i.lastEpoch)return i.lastEpoch=i.epoch,i.resourceRebuilds++,void(A5.bundleResourceRebuilds=i.resourceRebuilds);if(u)return i.lastEpoch=i.epoch,i.resourceRebuilds++,void(A5.bundleResourceRebuilds=i.resourceRebuilds);i.rebuilds++,A5.bundleRebuilds=i.rebuilds,i.checks>30&&i.rebuilds/i.checks>.1&&(i.disabled=!0,r.isBundleGroup=!1,A5.bundleDisabled=!0)}}_ensureWarmupTarget(){if(null===this._warmupTarget){let e=new Ms(2,2,{count:2});e.textures[0].name="output",e.textures[0].type=Xt,e.textures[1].name="velocity",e.textures[1].type=ii;let t=new Do(2,2);t.isRenderTargetTexture=!0,e.depthTexture=t,this._warmupTarget=e}return this._warmupTarget}get warmupInFlight(){return this._warmupInFlight}setRenderTarget(e,t=0,i=0){this._warmupInFlight?this._warmupPendingTarget=[e,t,i]:super.setRenderTarget(e,t,i)}setMRT(e){return this._warmupInFlight?(this._warmupPendingMRT=[e],this):(super.setMRT(e),this)}async compileSceneAsync(e,t){if(!t)return;{let t=e instanceof fN?e.activePage:e;k6(bf.isSoft(t?.data?.shadow)),t&&r4(t)}if(!1!==this._asyncCompilationMode)return"load"===this._asyncCompilationMode&&(this._setThreeAsyncCompilation(!0),this._updateCompilationBurst()),this._compileSceneAsyncBackground(e,t);if(this.renderStarted||this._warmupInFlight)return;let i=this.getRenderTarget(),r=this.getMRT();this._warmupInFlight=!0,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst();try{this.normalizeCameraCoordinateSystem(t),this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(n9())),await this.compileAsync(e,t)}catch(e){console.warn("[spline/webgpu] pipeline warm-up failed:",e)}finally{let e=this._warmupPendingTarget,t=this._warmupPendingMRT;this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst(),null!==e?super.setRenderTarget(e[0],e[1],e[2]):super.setRenderTarget(i),null!==t?super.setMRT(t[0]):super.setMRT(r)}}async _compileSceneAsyncBackground(e,t){this._asyncLoadWarmupsInFlight++,this._updateCompilationBurst();try{await this.init(),this.normalizeCameraCoordinateSystem(t);let i,r=this.getRenderTarget(),s=this.getMRT();try{this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(n9())),i=this.compileAsync(e,t)}finally{super.setRenderTarget(r),super.setMRT(s)}let a=this._warmupGrabContext(e,t);await i,await a}catch(e){console.warn("[spline/webgpu] pipeline warm-up failed:",e)}finally{this._asyncLoadWarmupsInFlight--,this._updateCompilationBurst(),this._maybeCloseAsyncLoadWindow()}}_disposeWarmupTargets(){this._warmupTarget?.depthTexture?.dispose(),this._warmupTarget?.dispose(),this._warmupTarget=null,this._grabWarmupTarget?.depthTexture?.dispose(),this._grabWarmupTarget?.dispose(),this._grabWarmupTarget=null}_warmupGrabContext(e,t){let i=e instanceof fN?e:e.scene;if(!0!==i.needsTransmission?.()&&!0!==i.needsReflection?.())return null;if(null===this._grabWarmupTarget){let e=new Ms(2,2);e.texture.type=Xt;let t=new Do(2,2);t.isRenderTargetTexture=!0,e.depthTexture=t,this._grabWarmupTarget=e}let r=this.getRenderTarget(),s=this.getMRT();try{return super.setRenderTarget(this._grabWarmupTarget),super.setMRT(null),this.compileAsync(e,t)}finally{super.setRenderTarget(r),super.setMRT(s)}}_setThreeAsyncCompilation(e){this.setAsyncCompilation(e)}_updateCompilationBurst(){let e=this._warmupInFlight||this._asyncLoadWarmupsInFlight>0||"load"===this._asyncCompilationMode&&this.asyncCompilationEnabled;this.setCompilationBurst(e),A5.compilationBurst=e}_maybeCloseAsyncLoadWindow(){"load"===this._asyncCompilationMode&&(!this.asyncCompilationEnabled||this._asyncLoadWarmupsInFlight>0||0!==this._frameSerial&&((this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled||this._compilationHasWork||(this._setThreeAsyncCompilation(!1),this._updateCompilationBurst())))}normalizeCameraCoordinateSystem(e){let t=e;(t.coordinateSystem!==this.coordinateSystem||void 0!==t.perspCamera&&t.perspCamera.coordinateSystem!==this.coordinateSystem||void 0!==t.orthoCamera&&t.orthoCamera.coordinateSystem!==this.coordinateSystem)&&(t.coordinateSystem=this.coordinateSystem,void 0!==t.perspCamera&&(t.perspCamera.coordinateSystem=this.coordinateSystem),void 0!==t.orthoCamera&&(t.orthoCamera.coordinateSystem=this.coordinateSystem),e.updateProjectionMatrix?.())}_prepareHelpers(e,t,i){e.traverse(e=>{let r=e;if(!0===e.isPoints){let i=function(e){if(Array.isArray(e.material)||null===e.parent||void 0===e.geometry.getAttribute("position"))return null;let t=e.material;return!0===t.isNodeMaterial?null:!0===t.isPointsMaterial?function(e,t){if(t.size<=1)return null;let i=e9.get(e);return i&&(i.epoch!==i9||i.srcMaterial!==t||i.geometry!==e.geometry||i.position.src!==e.geometry.getAttribute("position")||i.map!==t.map||i.selectedMap!==J8(e))&&(i.sprite.removeFromParent(),i.material.dispose(),i=void 0),i||(i=function(e,t){let i=e.geometry,r=i.getAttribute("position"),s=i.getAttribute("aSelection"),a=i.getAttribute("aVisibility"),n=t.map,o=J8(e),l=new Jn(r.array,3);l.setUsage(Fr);let h={src:r,attr:l,version:r.version},u=[],d=e=>{let t=new Jn(new Float32Array(e.count),1);t.setUsage(Fr);let i={src:e,attr:t,version:e.version};return Q8(i),u.push(i),i},c=s?d(s):null,p=a?d(a):null,m=new TG;m.name=`SplinePointsTwin(${t.name||t.type})`,m.positionNode=S2(h.attr,"vec3"),m.size=t.size,m.sizeAttenuation=t.sizeAttenuation,m.transparent=t.transparent,m.depthTest=t.depthTest,m.depthWrite=t.depthWrite,m.blending=t.blending,m.fog=!1;let g=c?S2(c.attr,"float"):null,f=p?S2(p.attr,"float"):null;m.colorNode=C1(()=>{null!==f?T1(f.lessThan(.5)):null!==g&&T1(g.greaterThan(.5));let e=null!==n?e5(n,u5()):g5(1);return(null!==g&&null!==n&&null!==o?q2(e,e5(o,u5()),g):e).mul(g5(U2,1))})();let y=new Tn(m);y.name=`SplinePointsTwin(${e.name||e.type})`,y.frustumCulled=!1,y.raycast=()=>{};let v={sprite:y,material:m,srcMaterial:t,geometry:i,map:n,selectedMap:o,position:h,mirrors:u,epoch:i9};return t9.add(new WeakRef(v)),v}(e,t),e9.set(e,i)),i.sprite.parent!==e.parent&&e.parent.add(i.sprite),function(e,t){let{sprite:i,position:r,srcMaterial:s}=t;r.version!==r.src.version&&(t.position.attr.needsUpdate=!0,r.version=r.src.version);for(let e of t.mirrors)e.version!==e.src.version&&(Q8(e),e.version=e.src.version);let a=Math.max(0,Math.min(t.geometry.drawRange.count,r.src.count));i.count=a,t.material.size=s.size,t.material.opacity=s.opacity,t.material.color.copy(s.color),i.layers.mask=e.layers.mask,i.renderOrder=e.renderOrder}(e,i),i.sprite}(e,t):function(e,t){if(!0!==t.isShaderMaterial)return!1;let i=t.uniforms,r=i?.pointSize?.value,s=i?.color?.value;return"number"==typeof r&&r>1&&Array.isArray(s)&&s.length>=3&&void 0!==e.geometry.getAttribute("hover")&&void 0!==e.geometry.getAttribute("selected")}(e,t)?function(e,t){let i=r9.get(e);return i&&(i.epoch!==i9||i.srcMaterial!==t||i.geometry!==e.geometry||!function(e,t){let i=[[e.position,"position"],[e.hover,"hover"],[e.selected,"selected"]];for(let[e,r]of i){let i=t.getAttribute(r);if(void 0===i)return!1;if(e.src!==i){if(i.count!==e.attr.count)return!1;e.src=i,e.version=-1}}return!0}(i,e.geometry))&&(i.sprite.removeFromParent(),i.material.dispose(),i=void 0),i||(i=function(e,t){let i=e.geometry,r=t.uniforms,s=(e,t)=>{let i=new Jn(new Float32Array(e.count*t),t);i.setUsage(Fr);let r={src:e,attr:i,version:e.version};return Q8(r),r},a=s(i.getAttribute("position"),3),n=s(i.getAttribute("hover"),1),o=s(i.getAttribute("selected"),1),l=n5(r.pointSize.value),h=n5((new aa).fromArray(r.color.value)),u=new TG;u.name=`SplinePointsTwin(${t.name||t.type})`,u.positionNode=S2(a.attr,"vec3");let d=S2(n.attr,"float"),c=S2(o.attr,"float");u.sizeNode=l.add(d.mul(4)),u.sizeAttenuation=!1,u.transparent=t.transparent,u.depthTest=t.depthTest,u.depthWrite=t.depthWrite,u.blending=t.blending,u.fog=!1,u.colorNode=C1(()=>{let e=B2(u5().mul(2).sub(1)).toVar();T1(e.greaterThan(1));let t=k3(c.equal(1),m5(.22,.9,.7),h.add(d.mul(.25)));return g5(k3(e.greaterThan(.75),m5(1),t),1)})();let p=new Tn(u);p.name=`SplinePointsTwin(${e.name||e.type})`,p.frustumCulled=!1,p.raycast=()=>{};let m={sprite:p,material:u,srcMaterial:t,geometry:i,pointSize:l,color:h,position:a,hover:n,selected:o,epoch:i9};return t9.add(new WeakRef(m)),m}(e,t),r9.set(e,i)),i.sprite.parent!==e.parent&&e.parent.add(i.sprite),function(e,t){for(let e of[t.position,t.hover,t.selected])e.version!==e.src.version&&(Q8(e),e.version=e.src.version);let i=t.srcMaterial.uniforms;t.pointSize.value=i.pointSize.value,t.color.value.fromArray(i.color.value);let r=Math.max(0,Math.min(t.geometry.drawRange.count,t.position.src.count));t.sprite.count=r,t.material.opacity=t.srcMaterial.opacity,t.sprite.layers.mask=e.layers.mask,t.sprite.renderOrder=e.renderOrder}(e,i),i.sprite}(e,t):null}(e);if(null!==i)return i.visible=r.visible,void(r.visible&&(t.push(r),r.visible=!1))}let s=!1,a="",n=Array.isArray(r.material)?r.material:r.material?[r.material]:[];for(let e of n){let t=e;if(!0===t.isShaderMaterial&&!0!==t.isNodeMaterial){s=!0,a=`WebGL-only material "${t.type}"`;break}}if(s&&!Array.isArray(r.material)){let e=!0===(o=r.material).isLineMaterial?function(e){let t=Y8.get(e);if(!t||t.epoch!==K8){let i=new eF;i.name=`SplineHelperTwin(${e.name||e.type})`,i.worldUnits=!1,t={twin:i,epoch:K8},Y8.set(e,t),X8.add(new WeakRef(i))}let i=t.twin,r=e;i.color.copy(r.color),i.linewidth=r.linewidth,i.opacity=r.opacity,i.transparent=r.transparent,i.depthTest=r.depthTest,i.depthWrite=r.depthWrite,i.side=r.side;let s=!0===r.dashed;if(i.dashed!==s&&(i.dashed=s,i.needsUpdate=!0),s){let e=i;e.dashScale=r.dashScale??1,e.dashSize=r.dashSize??1,e.gapSize=r.gapSize??1}let a=!0===r.vertexColors||2===r.vertexColors;return i.vertexColors!==a&&(i.vertexColors=a,i.needsUpdate=!0),i}(o):null;if(e)return i.push({object:r,original:r.material}),void(r.material=e)}var o;!s&&!0===r.geometry?.isInstancedBufferGeometry&&!Number.isFinite(r.geometry.instanceCount??0)&&(s=!0,a="infinite instanceCount geometry"),s&&r.visible&&(this._warnedHelperIncompat.has(e)||this._warnedHelperIncompat.add(e),t.push(r),r.visible=!1)})}renderHelperOverlay(e,t,i,r){let s=[],a=[];if(e&&this._prepareHelpers(e,s,a),t&&this._prepareHelpers(t,s,a),r)this._helperOverlay??(this._helperOverlay=new G8),this._helperOverlay.render(this,e,t,i,r),A5.helperOverlayMode="smaa";else{let r=this.autoClear;this.autoClear=!1,e&&this.render(e,i),t&&(this.clearDepth(),this.render(t,i)),this.autoClear=r,A5.helperOverlayMode="direct"}for(let e of a)e.object.material=e.original;for(let e of s)e.visible=!0}createEffectChain(){return function(e){let t=e.pipeline,i=t.postprocessingState,r=!0===i.enabled,s=p3(t.scene,t.camera),a=e.hdrChainActive;try{let e=new URLSearchParams(window.location.search).get("dbgfp16");("scene"===e||"st"===e)&&(a=!0)}catch{}let n=s.getTextureNode(),o=n,l=null;if(e.temporalAAEnabled){s.setMRT(n9()),l=function(e,t,i,r,s=!1){return new V8(e,t,i,r,s)}(n,s.getTextureNode("depth"),s.getTextureNode("velocity"),e.taaHistory,a),o=l,s.getTexture("velocity").type=ii;try{if("1"===new URLSearchParams(window.location.search).get("dbgvel")){let e=o9(s.getTextureNode("velocity"));o=g5(l9(e.x).mul(20).add(.5),l9(e.y).mul(20).add(.5),c2(.5),c2(1))}}catch{}}a?s.getTexture("output").type=ii:x5()&&(s.getTexture("output").internalFormat="rgba8unorm-srgb");let h=(e,t)=>"number"==typeof e&&Number.isFinite(e)?e:t,u={bloomIntensity:n5(1),caOffset:n5(new rs(0,0)),vignetteOffset:n5(0),vignetteDarkness:n5(0),hue:n5(0),saturationPlus1:n5(1),brightness:n5(0),contrast:n5(0),dofFocusDistance:n5(0),dofFocalLength:n5(0),dofBokehScale:n5(1),dofCameraNear:n5(50),dofCameraFar:n5(1e4),dofOrtho:n5(0),pixelCells:n5(new rs(1,1)),bloomOpacity:n5(1),caOpacity:n5(1),vignetteOpacity:n5(1),noiseOpacity:n5(1),hueSaturationOpacity:n5(1),brightnessContrastOpacity:n5(1),dofOpacity:n5(1)},d=e=>l9(e),c=(e,i)=>{u.bloomIntensity.value=h(e.bloom.intensity,1),u.bloomOpacity.value=h(e.bloom.opacity,1),u.caOffset.value.set(h(e.chromaticAberration.offset?.[0],0),h(e.chromaticAberration.offset?.[1],0)),u.caOpacity.value=h(e.chromaticAberration.opacity,1),u.vignetteOffset.value=h(e.vignette.offset,.5),u.vignetteDarkness.value=h(e.vignette.darkness,.5),u.vignetteOpacity.value=h(e.vignette.opacity,1),u.noiseOpacity.value=h(e.noise.opacity,1),u.hue.value=h(e.hueSaturation.hue,0),u.saturationPlus1.value=h(e.hueSaturation.saturation,0)+1,u.hueSaturationOpacity.value=h(e.hueSaturation.opacity,1),u.brightness.value=h(e.brightnessContrast.brightness,0),u.contrast.value=h(e.brightnessContrast.contrast,0),u.brightnessContrastOpacity.value=h(e.brightnessContrast.opacity,1);let r=t.camera,s=!0===r?.isPerspectiveCamera,a=h(r?.near,50),n=h(r?.far,1e4),o=n-a,l=h(e.depthOfField.focusDistance,0),d=s?l/2e3:(l+992)/2e3;u.dofFocusDistance.value=a+d*o,u.dofFocalLength.value=h(e.depthOfField.focalLength,0)/2e3*o,u.dofBokehScale.value=h(e.depthOfField.bokehScale,1),u.dofOpacity.value=h(e.depthOfField.opacity,1),u.dofCameraNear.value=a,u.dofCameraFar.value=n,u.dofOrtho.value=s?0:1;let c=i.resolution.x?i.resolution:new rs(i.viewportWidth*i.getPixelRatio(),i.viewportHeight*i.getPixelRatio()),p=Math.floor(h(e.pixelation.granularity,30));p%2>0&&(p+=1);let m=p>0;u.pixelCells.value.set(m?c.x/p:c.x,m?c.y/p:c.y)};c(i,e);let p=o9(o),m=p.rgb,g=p.a,f=r&&i.pixelation.enabled,y=u.pixelCells,v=e=>e.mul(y).floor().add(.5).div(y),b=l?l.outputTextureNode:n;if(f){let e=o9(b.sample(v(u5())));m=q2(m,e.rgb,1),g=q2(g,e.a,1)}let x=null;if(r&&i.bloom.enabled){let e=BN("bloom");if(e){let t=i.bloom;x=e(l?l.outputTextureNode:n,{kernelSize:yf(t.kernelSize),blurScale:h(t.blurScale,1),luminanceThreshold:h(t.luminanceThreshold,.9),luminanceSmoothing:h(t.luminanceSmoothing,.025)});let r=$1(o9(x).mul(d(u.bloomIntensity)),0,1);m=a9(m,r.rgb,t.blendFunction,d(u.bloomOpacity)),g=function(e,t,i,r){let s=r;switch(i){case 0:return e;case 1:return e.add(t.mul(s));case 16:{let i=c2(1).sub(c2(1).sub(e).mul(c2(1).sub(t)));return q2(e,i,s)}case 10:return q2(e,e.mul(t),s);default:return q2(e,t,s)}}(g,r.a,t.blendFunction,d(u.bloomOpacity))}else VN("bloom","webgpu")}if(r&&i.chromaticAberration.enabled){let e=i.chromaticAberration,t=u.caOffset.mul(.001),r=f?b:n,s=e=>f?v(e):e,a=u5().sub(.5),o=o9(r.sample(s(u5().add(a.mul(t))))).r,l=o9(r.sample(s(u5()))).g,h=o9(r.sample(s(u5().sub(a.mul(t))))).b;m=a9(m,m5(o,l,h),e.blendFunction,d(u.caOpacity))}if(r&&i.vignette.enabled){let e=i.vignette,t=B2(u5().sub(.5)),r=q3(c2(.8).mul(d(u.vignetteOffset)),d(u.vignetteOffset).add(.799),t.mul(d(u.vignetteDarkness)));m=a9(m,m.mul(r.oneMinus()),e.blendFunction,d(u.vignetteOpacity))}if(r&&i.noise.enabled){let e=i.noise,t=g2(W3(o2(u5().add(g2(i5)),p5(12.9898,78.233))).mul(43758.5453));m=a9(m,m5(t),e.blendFunction,d(u.noiseOpacity))}if(r&&i.hueSaturation.enabled){let e=i.hueSaturation,t=w2(m,d(u.hue));t=I3(t,d(u.saturationPlus1)),m=a9(m,t,e.blendFunction,d(u.hueSaturationOpacity))}if(r&&i.brightnessContrast.enabled){let e=i.brightnessContrast,t=m.add(m5(d(u.brightness)));t=t.sub(.5).mul(d(u.contrast).add(1)).add(.5),m=a9(m,D3(t),e.blendFunction,d(u.brightnessContrastOpacity))}if(r&&i.depthOfField.enabled){let e=BN("depthOfField");if(e){let t=i.depthOfField,r=s.getTextureNode("depth"),a=q2(g3(r,u.dofCameraNear,u.dofCameraFar),h3(r,u.dofCameraNear,u.dofCameraFar),d(u.dofOrtho));m=a9(m,o9(e(g5(m,g),a,u.dofFocusDistance,u.dofFocalLength,u.dofBokehScale)).rgb,t.blendFunction,d(u.dofOpacity))}else VN("depthOfField","webgpu")}let w=g5(m,g);if(t.uiOverlayEnabled&&t.uiCanvasTexture){let e=o9(e5(t.uiCanvasTexture,u5())),i=q2(w.rgb,e.rgb.div($1(e.a,1e-4,1)),e.a),r=$1(w.a.add(e.a),0,1);w=g5(i,r)}let _=t.sceneTransitionFromTexture;if(_){let e=o9(e5(_,u5())),i=t.sceneTransitionPass.uniforms.mixRatio;w=q2(e,w,i)}let S=t.watermarkTexture;if(S){let t=S.image,i=t?.width||128,r=t?.height||32,s=new rs(e.viewportWidth*e.getPixelRatio(),e.viewportHeight*e.getPixelRatio()),a=12*e.getPixelRatio(),n=.5*i*e.getPixelRatio(),o=.5*r*e.getPixelRatio(),l=p5((s.x-n-a)/s.x,a/s.y),h=p5(n/s.x,o/s.y),u=u5().sub(l).div(h),d=u.x.greaterThanEqual(0).and(u.x.lessThanEqual(1)).and(u.y.greaterThanEqual(0)).and(u.y.lessThanEqual(1)),c=$1(u,0,1),p=o9(e5(S,c)),m=p.a.mul(d.select(c2(1),c2(0)));w=g5(q2(w.rgb,p.rgb,m),$1(w.a.add(m),0,1))}let M=new S1(e,w);return{syncValues:c,render(){s.scene=t.scene,s.camera=t.camera,M.render()},renderTAAResolve:l?e=>{s.scene=t.scene,s.camera=t.camera,l.renderResolve(e)}:null,renderBloomPasses:x?e=>{s.scene=t.scene,s.camera=t.camera,x.renderBloom(e)}:null,resize(){},sceneDepthTexture:()=>s.renderTarget?.depthTexture??null,dispose(){l?.dispose(),x?.dispose(),s.dispose(),M.dispose()}}}(this)}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,s=t.width,a=this.viewportWidth/this.viewportHeight;s<r?s=r*a:r=s/a,this.dummyCamera.setViewplaneSize(s,r);for(let t=0;t<i;t++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,t,{sceneHelpers:i=this.sceneHelpers,sceneHelpersOnTop:r=this.sceneHelpersOnTop}={}){if(this._warmupInFlight)return;this._maybeCloseAsyncLoadWindow(),this._frameSerial++,this._disposeRetiredGrabTargets(),(I4()?.drainRetired()??0)+(w4()?.drainRetired()??0)>0&&this._retireBundleRecords(),n6&&function(e){if(null==e||e===c6)return;let t=e;"function"==typeof t.addEventListener&&(c6=e,t.addEventListener("uncapturederror",e=>{let t=e?.error?.message??"";!t.toLowerCase().includes("destroyed")||h6<=0||(h6--,console.warn(`[spline/webgpu][dbgdestroys] submit rejected at frame ${u6()} (t=${Math.round(performance.now())}ms):\n${t.slice(0,400)}\n— last ${l6.length} destroy() calls, newest last (a stack WITHOUT _disposeRetiredGrabTargets bypassed the deferral):`,l6.map(e=>({...e}))))}))}(this.backend.device);let s=this._skippedAsyncDraws??0;A5.skippedAsyncDraws=s,this._skippedAsyncDraws=0,this._trackStalledSkips(s),this._trackGaugeStall(),function(e){if(0===k4.size)return;let t=Array.from(k4);k4.clear();for(let i of t)i.render(e)}(this);let a=e instanceof fN?e.activePage:e,n=a.visible;a.visible=!0;let o=a.scene;if(r4(a),this.renderStarted=!0,n7&&e instanceof fN){let t=e.updateInstanceGroups(a,o7);A5.instancingGroups=t.instancingGroups,A5.instancedDrawsSaved=t.instancedDrawsSaved,A5.instancingRegroups=t.instancingRegroups,A5.instancingParks=t.instancingParks,A5.instancingIneligible=t.instancingIneligible}this.sceneBundlesEnabled&&this._bundleEpochDirty&&(this._bundleEpochDirty=!1,this._updateSceneBundle(a,t)),this.normalizeCameraCoordinateSystem(t),this._applyCIOffscreenTargetIfRequested(),this.setClearColor(a.bgColor,a.bgColor.a),void 0!==this.clearAlphaOverride&&this.setClearAlpha(this.clearAlphaOverride);let l=Z9?null:a.skyState;if(!0===l?.enabled){if(this.skyEnvironmentNeeded=!J9&&(o.needsReflectionDirty||o.needsReflection())||!Q9&&!0===l.lighting,null===this._skySystem){let e=f9;null===e?this._skyFeatureWarned||(this._skyFeatureWarned=!0,console.warn("[spline] scene uses the atmospheric sky, but the sky feature is compiled out of this build")):this._skySystem=e(this)}this._skySystem?.update(a,t)}else this._skySystem?.attached&&this._skySystem.detach();let h=null,u=0;!Q9&&!0===l?.enabled&&this._skySystem&&(h=this._skySystem.iblTexture??null,u=this._skySystem.iblRotationY??0),function(e){if(P4.quality===e)return!1;P4.quality=e;for(let e of R4)C4(e)}("low"===l?.lightingQuality?"low":"full"),function(e){if(P4.texture===e)return!1;P4.texture=e,P4.version++;for(let e of R4)C4(e)}(h),P4.rotation.set(0,-u,0),a.environmentIntensity=!0===l?.enabled?l.lightingIntensity??1:1;{let e="off"===e7?null:a.gradingState,t="default"!==e7&&"off"!==e7,i=t||"linear"===e?.pipeline,r=t?"linear"===e7?"none":e7:e?.toneMapping??"aces";this.toneMapping=i?"aces"===r?Rt:"agx"===r?Et:"neutral"===r?Ot:Ct:Ct,this.toneMappingExposure=i?e?.exposure??1:1,this.outputColorSpace=i?hr:ur,this.hdrChainActive=i,this.temporalAAEnabled&&this.taaHistory.setHdr(i)}N5.pixelRatio.value=this.getPixelRatio(),0!==this.resolution.x&&0!==this.resolution.y?N5.resolution.value.set(this.resolution.x,this.resolution.y):N5.resolution.value.set(this.viewportWidth*this.getPixelRatio(),this.viewportHeight*this.getPixelRatio());let d=(N5.frameIndex.value+1)%16;N5.frameIndex.value=d;let c=e8[d];N5.pcssHalton.value.set(c[0],c[1]),N5.tapAngle.value=Math.random()*Math.PI*2,N5.tapAngle2.value=Math.random()*Math.PI*2,this._syncLightState(a),N5.unjitteredProjection.value.copy(t.projectionMatrix);let p=this.temporalAAEnabled?this.taaHistory:null;if(p){let e=this.getDrawingBufferSize(k9);p.beginJitter(t,e.x,e.y)}this._renderShadowMaskPass(a,t),N5.orthographicUniform.value=0===t.projectionMatrix.elements[11]?1:0;let m=o.shapeBlendIntances.length>0?S4:null;if(null!==m)for(let e of o.shapeBlendIntances)m(e).update(e,this,t);let g=o.hairInstances.length>0?L4:null;if(null!==g)for(let e of o.hairInstances)g(e).update(e,this);o.needsTransmission()&&this._renderTransmissionPass(a,t),o.needsNormal()&&this._renderNormalPass(a,t,o.normalPassNeeds()),a.overrideMaterial=o.wireframeState?mN:null,t.layers.enable(3),t.layers.enable(8),t.layers.enable(4);let f=a.data.ao,y=f.occlusion&&!H9&&!u9.enabled;if(N5.aoEnabled.value=y,N5.aoEnabledUniform.value=y?1:0,y){let e=this,i=e._skippedAsyncDraws??0;this._renderAOPass(a,t,f),(e._skippedAsyncDraws??0)>i&&(N5.aoEnabledUniform.value=0)}if(!J9&&o.needsReflection()?(this._renderReflectionPass(a,t),t7?N5.reflectionPlanarEnabled.value=0:this._renderPlanarReflectionPass(a,t),this._renderReflectionResolvePass(a,t)):N5.reflectionResolveEnabled.value=0,this.sceneBundlesEnabled&&this._updateSceneBundle(a,t),this.pipeline.isUIOverlayEnabled&&a.uiCanvas?.enabled&&a.uiCanvas.texture&&a.uiCanvas.texture.image.width>0){let e=this.getPixelRatio();(a.uiCanvas.width!==this.viewportWidth||a.uiCanvas.height!==this.viewportHeight||a.uiCanvas.dpr!==e)&&a.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},e),a.uiCanvas.render(this),this.pipeline.uiCanvasTexture=a.uiCanvas.texture,this.pipeline.uiOverlayEnabled=!0}else this.pipeline.uiOverlayEnabled=!1;this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=a,this.pipeline.camera=t;let v=function(e){if(!u9.enabled)return e;let t=d9.get(e);return t||(t={...e,bloom:{...e.bloom,kernelSize:0},depthOfField:{...e.depthOfField,enabled:!1}},d9.set(e,t)),t}(a.postprocessing);this.pipeline.postprocessingState!==v&&this.pipeline.updatePostprocessing(v),this.pipeline.render(),p?.endJitter(),A5.outputInterpositions=this._frameBufferTargets?.size??0,this.manageShadowUpdates&&(o.shadowsDirty=this._shadowMapMissingAtSync||this.lastFrameIncomplete),t instanceof fx&&t.copyHistory(),a.visible=n}_fitDirectionalShadowRange(e,t,i){if(0===i)return;let r=e.shadow.camera,s=e.shadow;s.__speRangeEnvelope||(s.__speRangeEnvelope={near:r.near,far:r.far});let a=s.__speRangeEnvelope.near,n=e.data?.depth??s.__speRangeEnvelope.far;if(s.__speRangeEnvelope.far=n,j9.setFromMatrixPosition(e.matrixWorld),e.target?(e.target.updateMatrixWorld(),G9.setFromMatrixPosition(e.target.matrixWorld)):G9.set(0,0,0),W9.subVectors(G9,j9),W9.lengthSq()<1e-10)return;W9.normalize();let o=1/0,l=-1/0;for(let e=0;e<i;e++){let i=4*e,r=(t[i]-j9.x)*W9.x+(t[i+1]-j9.y)*W9.y+(t[i+2]-j9.z)*W9.z,s=t[i+3];r-s<o&&(o=r-s),r+s>l&&(l=r+s)}let h=Math.max(10,.05*(l-o)),u=25*Math.floor((o-h)/25),d=25*Math.ceil((l+h)/25);u=Math.max(u,a),d=Math.min(d,n),d-u>=1&&(r.near!==u||r.far!==d)&&(r.near=u,r.far=d,r.updateProjectionMatrix())}_gatherShadowBounds(e){let t=0;return e.traverseVisible(e=>{let i=e;if(!0!==i.castShadow&&!0!==i.receiveShadow)return;if(!0===i.isHairSystem){let e=i.shadowBoundsRadius??0;if(e>0){U9.setFromMatrixPosition(i.matrixWorld);let r=4*t;q9[r]=U9.x,q9[r+1]=U9.y,q9[r+2]=U9.z,q9[r+3]=e,t++}return}if(!0!==i.isMesh||!i.geometry||!0===i.isInstanceGroup)return;let r=i.geometry.boundingSphere;null===r&&(i.geometry.computeBoundingSphere(),r=i.geometry.boundingSphere);let s=i;if(!0===s.isInstancedMesh&&(null===s.boundingSphere&&s.computeBoundingSphere(),r=s.boundingSphere??r),!r||!Number.isFinite(r.radius)||r.radius<=0)return;U9.copy(r.center).applyMatrix4(i.matrixWorld),F9.setFromMatrixScale(i.matrixWorld);let a=r.radius*Math.max(Math.abs(F9.x),Math.abs(F9.y),Math.abs(F9.z)),n=4*t;q9[n]=U9.x,q9[n+1]=U9.y,q9[n+2]=U9.z,q9[n+3]=a,t++}),t}_syncLightState(e){let t=bf.isSoft(e.data.shadow);k6(t),A5.shadowTypeSoft=t,function(e){switch(e){case"low":i8=8;break;case"high":i8=32;break;default:i8=16}}(e.data.shadow?.softShadowQuality),t&&J6()&&(R6||(this.initTexture?.(g6()),R6=!0));let i=-1;A5.pcssLights=0,A5.pcssPyramidActive=0,this._maskLights.length=0,this._maskBlocked=!1,A5.nodeResurrections=this._nodes?._spResurrections??0;let r=!1,s=N5.toonLightData.array,a=0,n=this.manageShadowUpdates,o=e.scene.shadowsDirty||this.forceShadowUpdates;this._shadowMapMissingAtSync=!1,e.traverseVisible(l=>{let h=l;if(function(e){if(!e.isPointLight&&!e.isSpotLight&&!e.isDirectionalLight)return!1;if(u9.enabled){if(!0===e.castShadow)return e.castShadow=!1,c9.add(e),!0}else if(c9.has(e)&&(c9.delete(e),!1===e.castShadow))return e.castShadow=!0,!0;return!1}(h)&&(e.scene.shadowsDirty=!0),n&&(h.isPointLight||h.isSpotLight||h.isDirectionalLight)&&h.shadow&&(h.shadow.autoUpdate=o,o&&!0===h.castShadow&&null==h.shadow.map&&(this._shadowMapMissingAtSync=!0)),$9&&(h.isPointLight||h.isSpotLight||h.isDirectionalLight)&&h.castShadow&&(h.castShadow=!1),h.isPointLight&&h.castShadow&&h.shadow&&(function(e){void 0!==e.filterNode&&null!==e.filterNode?e.filterNode!==g8&&A5.pcssForeignFilter++:(e.filterNode=g8,A5.pcssInstalled++)}(h.shadow),D6(h.shadow),A5.pcssLights++),(h.isSpotLight||h.isDirectionalLight)&&h.castShadow&&h.shadow){h.isDirectionalLight&&(i<0&&(i=this._gatherShadowBounds(e)),this._fitDirectionalShadowRange(h,q9,i)),function(e){void 0!==e.filterNode&&null!==e.filterNode?e.filterNode!==m8&&A5.pcssForeignFilter++:(Object.defineProperty(e,"penumbraSize",{get:()=>h.data?.penumbraSize??.5,configurable:!0}),e.filterNode=m8,A5.pcssInstalled++)}(h.shadow);let s,a=!n||o||!0===h.shadow.needsUpdate;if(t&&J6()&&(a?function(e){let t=e;t.__spePcssPyramid&&(t.__spePcssPyramid.fresh=!1)}(h.shadow):v6(h.shadow)||function(e,t){let i=t,r=i.map?.depthTexture??null;if(null==r)return!1;let s=y6(t);if(function(e){let t=y6(e);if(t.slot>=0)return t.slot;for(let i=0;i<w6;i++){let r=P6[i];if(null===r||void 0===r.deref())return P6[i]=new WeakRef(e),t.slot=i,i}return-1}(t)<0)return!1;let a=Math.max(1,Math.round(i.mapSize?.x??2048)),n=s.slot*x6,o=`${r.uuid}:${a}`;s.passKey!==o&&(s.toMid?.material?.dispose(),s.toSmall?.material?.dispose(),null===s.mid&&(s.mid=m6(_6,_6),s.mid.texture.name="SplinePCSSPyramidMid"),null===s.small&&(s.small=m6(x6,x6),s.small.texture.name="SplinePCSSPyramidSmall"),s.toMid=new Oq(f6(`SplinePCSSPyramidToMid${a}`,r,Math.ceil(a/_6),a-1,!1,0)),s.toSmall=new Oq(f6("SplinePCSSPyramidToSmall",s.mid.texture,_6/x6,_6-1,!0,0)),s.passKey=o),g6();let l=e.getRenderTarget();e.setRenderTarget(s.mid),s.toMid.render(e),e.setRenderTarget(s.small),s.toSmall.render(e),e.setRenderTarget(l),E6.set(n,0,0),e.copyTextureToTexture(s.small.texture,A6.texture,null,E6),s.fresh=!0,A5.pcssPyramidBuilds++}(this,h.shadow),s={slot:b6(h.shadow),fresh:v6(h.shadow)}),t&&Q6()&&(V6(h.shadow,-1),this._maskLights.push({light:h,shadow:h.shadow}),(a||null==h.shadow.map)&&(this._maskBlocked=!0)),D6(h.shadow,h.data?.penumbraSize??.5,s)&&A5.pcssPyramidActive++,!r){r=!0;let e=h.shadow;A5.pcssRadius0=e.radius??-1,A5.pcssPenumbra0=e.penumbraSize??-1}A5.pcssLights++}if(!(a>=w5))if(h.isPointLight||h.isSpotLight)v9.setFromMatrixPosition(h.matrixWorld),s[a].set(v9.x,v9.y,v9.z,0),a++;else if(h.isDirectionalLight&&h.target){h.target.updateMatrixWorld();let e=v9;e.setFromMatrixPosition(h.matrixWorld),e.sub(y9.setFromMatrixPosition(h.target.matrixWorld)).normalize(),s[a].set(e.x,e.y,e.z,1),a++}}),N5.toonLightCount.value=a}_renderShadowMaskPass(e,t){let i=0;if(Q6()&&this.manageShadowUpdates&&!this._maskBlocked&&this._maskLights.length>=1&&this._maskLights.length<=4&&this._maskLights.every(e=>null!=e.shadow.map?.depthTexture)){this._shadowMask??(this._shadowMask=new b8);let{targetsChanged:r}=this._shadowMask.render(this,e,t,this._maskLights);r&&this._grabTargetEpoch++,i=this._maskLights.length}N5.shadowMaskEnabled.value=i>0?1:0,A5.shadowMaskActive=i}retireRenderTarget(e){e&&this._retiredGrabTargets.push(e),this._grabTargetEpoch++}_disposeRetiredGrabTargets(){if(this._retiredGrabTargets.length>0){for(let e of this._retiredGrabTargets)e.dispose();this._retiredGrabTargets.length=0}if(this._retiredGpuBuffers.length>0){for(let e of this._retiredGpuBuffers)try{e.destroy()}catch{}this._retiredGpuBuffers.length=0}}_retireBundleRecords(){for(let e of this._liveBundledPages())this._bundleStates.get(e)?.onResourceDispose();this._bundleEpochDirty=!0}_deferGpuBufferDestruction(){let e=this.backend,t=this._retiredGpuBuffers;e.destroyUniformBuffer=i=>{let r=e.get(i);r?.buffer&&t.push(r.buffer),e.delete(i),this._retireBundleRecords()};let i=e.attributeUtils;if(i){let r=i._getBufferAttribute.bind(i);i.destroyAttribute=i=>{let s=e.get(r(i));s?.buffer&&t.push(s.buffer),e.delete(i),this._retireBundleRecords()}}}_reallocGrabTarget(e,t,i,r){return e&&e.width===t&&e.height===i?e:(this.retireRenderTarget(e),r())}_withShadowUpdatesSuspended(e,t){let i=[];e.traverse(e=>{let t=e;if(t.isLight&&t.shadow){if(null==t.shadow.map)return;i.push({shadow:t.shadow,auto:t.shadow.autoUpdate,needs:t.shadow.needsUpdate}),t.shadow.autoUpdate=!1,t.shadow.needsUpdate=!1}});try{t()}finally{for(let e of i)e.shadow.autoUpdate=e.auto,e.shadow.needsUpdate=e.needs}}_renderPrepass(e,t){this._withShadowUpdatesSuspended(e,()=>{this.render(e,t)})}_renderAOPass(e,t,i){let r=this.getDrawingBufferSize(k9),s=Math.max(1,Math.round(r.x)),a=Math.max(1,Math.round(r.y));this._aoRenderTarget=this._reallocGrabTarget(this._aoRenderTarget,s,a,()=>new Ms(s,a,{depthBuffer:!1})),N5.aoRenderTarget.value=this._aoRenderTarget.texture,this._hbao||(this._hbao=new v4);let n=e;this._hbao.render(this,e,t,{radius:i.radius,bias:i.bias??.5,aoFullRes:!0===i.aoFullRes,aoColor:n.aoColor??{r:0,g:0,b:0},fogEnabled:null!==(n.fog??null),fogNear:n.backupFog?.near??1,fogFar:n.backupFog?.far??1e3,fogMode:Xg.getModeIndex({mode:e.fogMode}),fogDensity:e.fogDensity??Xg.getDensity({}),fogHeightFalloff:e.fogHeightFalloff??Xg.getHeightFalloff({}),fogHeightBase:e.fogHeightBase??Xg.getHeightBase({})},this.pipeline.blueNoiseTexture,this._aoRenderTarget)}_renderNormalPass(e,t,i){let r=i.outline&&i.cavity?"both":i.cavity?"normals":"hash",s=this.getDrawingBufferSize(k9),a=Math.max(1,Math.round(s.x)),n=Math.max(1,Math.round(s.y));void 0!==this._normalTarget&&this._normalTargetFlavor!==r&&(this.retireRenderTarget(this._normalTarget),this._normalTarget=void 0),this._normalTargetFlavor=r,this._normalTarget=this._reallocGrabTarget(this._normalTarget,a,n,()=>{let e=new Ms(a,n,{count:"both"===r?2:1,type:"normals"===r?ii:ti,depthTexture:new Do(a,n)});"both"===r&&(e.textures[0].name="g0",e.textures[1].name="g1",e.textures[1].type=ii);for(let t of e.textures)t.minFilter=jt,t.magFilter=jt;return e});let o=this._encodeMaterials[r];if(void 0===o){this._depthContrastUniform??(this._depthContrastUniform=n5(1));let e=new UU;e.name=`SplineNormalPassEncode_${r}`;let t=L1("randomColor","vec3"),i=()=>{let e=n3(a3),i=s2.sub(.5).mul(this._depthContrastUniform).add(.5),r=q2(q2(t,e,.2),m5(i),.4);return g5(r,t.x)},s=()=>{let e=n3(s3),i=k3(f2,e,e.negate());return g5(i,t.x)};e.fragmentNode="both"===r?J2({g0:i(),g1:s()}):"normals"===r?s():i(),e.lights=!1,e.blending=He,e.needsUpdate=!0,this._encodeMaterials[r]=e,o=e}this._depthContrastUniform.value=t instanceof fx?(t.far-t.near)/1e4:1;let l=e.overrideMaterial,h=this.getRenderTarget(),u=this.getClearColor(b9),d=this.getClearAlpha();t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),e.overrideMaterial=o,this.setClearColor(0,0),this.setRenderTarget(this._normalTarget),this._renderPrepass(e,t),this.setRenderTarget(h),this.setClearColor(u,d),e.overrideMaterial=l,t.layers.enable(0),t.layers.enable(3);let c=this._normalTarget.textures;N5.normalRenderTarget.value="normals"===r?_5:c[0],N5.normalRenderTargetDepth.value=this._normalTarget.depthTexture,N5.normalViewRenderTarget.value="both"===r?c[1]:"normals"===r?c[0]:_5}blitTextureToTarget(e,t){let i=this._uiBlitPass;if(!i){let e=e5(_5),t=new UU;t.name="SplineUICanvasBlit",t.fragmentNode=e.sample(u5()),t.lights=!1,t.blending=He,t.depthTest=!1,t.depthWrite=!1,t.needsUpdate=!0,i={quad:new Oq(t),input:e},this._uiBlitPass=i}let r=this.getRenderTarget(),s=this.getMRT();i.input.value=e,this.setMRT(null),this.setRenderTarget(t),this.clear(),i.quad.render(this),this.setRenderTarget(r),this.setMRT(s)}_getPrefilterPass(e){this._prefilterPasses||(this._prefilterPasses=[]);let t=this._prefilterPasses[e];if(t)return t;let i=e5(_5),r=n5(new rs(1,0)),s=new UU;s.name="SplineTransmissionPrefilter";let a=u5(),n=r,o=e=>i.sample(a.add(n.mul(e))).rgb,l=o(0).mul(.40262).add(o(1.182408).mul(.29869)).add(o(-1.182408).mul(.29869));return s.fragmentNode=g5(l,1),s.lights=!1,s.blending=He,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,t={quad:new Oq(s),input:i,step:r},this._prefilterPasses[e]=t,t}_getDownsamplePass(e){this._downsamplePasses||(this._downsamplePasses=[]);let t=this._downsamplePasses[e];return t||(t=this._buildDownsamplePassEntry(K9,"SplineTransmissionDownsample"),this._downsamplePasses[e]=t,t)}_buildDownsamplePassEntry(e,t){let i=e5(_5),r=n5(new rs(1,1)),s=new UU;s.name=t;let a=u5(),n=r,o=(e,t)=>i.sample(a.add(p5(e,t).mul(n))).rgb,l=null;if("k4"===e)for(let e=-1;e<=1;e++)for(let t=-1;t<=1;t++){let i=(0===t?2:1)*(0===e?2:1)/16,r=o(t,e).mul(i);l=l?l.add(r):r}else{let e=[-1.5,-.5,.5,1.5],t=[.1665,.3335,.3335,.1665];for(let i=0;i<4;i++)for(let r=0;r<4;r++){let s=t[r]*t[i],a=o(e[r],e[i]).mul(s);l=l?l.add(a):a}}return s.fragmentNode=g5(l,1),s.lights=!1,s.blending=He,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,{quad:new Oq(s),input:i,step:r}}_getPlanarDownsamplePass(e){this._planarDownsamplePasses||(this._planarDownsamplePasses=[]);let t=this._planarDownsamplePasses[e];return t||(t=this._buildDownsamplePassEntry("g16","SplinePlanarDownsample"),this._planarDownsamplePasses[e]=t,t)}_batchedMipCopies(e){let t=this.backend,i=t?.device;if(!i||"function"!=typeof t?.get){for(let t of e)this.copyTextureToTexture(t.src,t.dst,null,null,0,t.dstLevel);return}let r=i.createCommandEncoder({label:"SplineCascadeMipCopies"}),s=0;for(let i of e){let e=t.get(i.src)?.texture,a=t.get(i.dst)?.texture;e&&a?(r.copyTextureToTexture({texture:e,mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a,mipLevel:i.dstLevel,origin:{x:0,y:0,z:0}},{width:i.width,height:i.height,depthOrArrayLayers:1}),s++):this.copyTextureToTexture(i.src,i.dst,null,null,0,i.dstLevel)}s>0&&i.queue.submit([r.finish()])}_getReflectionDownsamplePass(e){this._reflectionDownsamplePasses||(this._reflectionDownsamplePasses=[]);let t=this._reflectionDownsamplePasses[e];return t||(t=this._buildDownsamplePassEntry("g16","SplineReflectionDownsample"),this._reflectionDownsamplePasses[e]=t,t)}_renderTransmissionPass(e,t){let i=this.getDrawingBufferSize(k9),r=this.hdTransmission?1:2,s=Math.max(1,Math.round(i.x/r)),a=Math.max(1,Math.round(i.y/r)),n=!0===this.backend?.isWebGPUBackend?X9:"off";this._transmissionTarget=this._reallocGrabTarget(this._transmissionTarget,s,a,()=>{let e=new Ms(s,a,{depthBuffer:!0}),t=e.texture;return"off"===n?(t.generateMipmaps=!0,t.minFilter=$t):(t.generateMipmaps=!1,t.minFilter=qt),t.magFilter=qt,e});let o=[];e.traverse(e=>{let t=e;if(!(t.isMesh||t.isLine||t.isPoints||t.isSprite))return;let i=t.layers;i&&8&i.mask&&8!==i.mask&&(o.push({layers:i,mask:i.mask}),i.mask=8)});let l=this.getRenderTarget();t.layers.disable(3),this.setRenderTarget(this._transmissionTarget),this._renderPrepass(e,t),this.setRenderTarget(l),t.layers.enable(3);for(let e of o)e.layers.mask=e.mask;let h=this._transmissionTarget.texture;if("off"!==n){let e=(e,t)=>{let i=new Ms(e,t,{depthBuffer:!1});return i.texture.generateMipmaps=!1,i.texture.minFilter=qt,i.texture.magFilter=qt,i};this._transmissionBlurTmp=this._reallocGrabTarget(this._transmissionBlurTmp,s,a,()=>e(s,a));let t=Math.floor(Math.log2(Math.max(s,a)))+1,i=this._transmissionBlurTarget;this._transmissionBlurTarget=this._reallocGrabTarget(this._transmissionBlurTarget,s,a,()=>{let e=new Ms(s,a,{depthBuffer:!1}),i=e.texture;return i.minFilter=$t,i.magFilter=qt,"base"===n?i.generateMipmaps=!0:(i.generateMipmaps=!1,i.mipmaps=Array.from({length:t},(e,t)=>({width:Math.max(1,s>>t),height:Math.max(1,a>>t)}))),e}),"full"===n&&this._transmissionBlurTarget!==i&&this.initTexture(this._transmissionBlurTarget.texture);let r=this._getPrefilterPass(0);r.input.value=this._transmissionTarget.texture,r.step.value.set(1/s,0),this.setRenderTarget(this._transmissionBlurTmp),r.quad.render(this);let o=this._getPrefilterPass(1);if(o.input.value=this._transmissionBlurTmp.texture,o.step.value.set(0,1/a),"base"===n)this.setRenderTarget(this._transmissionBlurTarget),o.quad.render(this);else{for(let i=0;i<t;i++)this._transmissionChain[i]=this._reallocGrabTarget(this._transmissionChain[i],Math.max(1,s>>i),Math.max(1,a>>i),()=>e(Math.max(1,s>>i),Math.max(1,a>>i)));for(let e=t;e<this._transmissionChain.length;e++)this._transmissionChain[e]?.dispose(),this._transmissionChain[e]=void 0;this._transmissionChain.length=t,this.setRenderTarget(this._transmissionChain[0]),o.quad.render(this);for(let e=1;e<t;e++){let t=this._transmissionChain[e-1],i=this._getDownsamplePass(e-1);i.input.value=t.texture,i.step.value.set(1/t.width,1/t.height),this.setRenderTarget(this._transmissionChain[e]),i.quad.render(this)}for(let e=0;e<t;e++)this.copyTextureToTexture(this._transmissionChain[e].texture,this._transmissionBlurTarget.texture,null,null,0,e)}this.setRenderTarget(l),h=this._transmissionBlurTarget.texture}N5.transmissionRenderTarget.value=h,N5.transmissionActualSize.value.set(s,a),N5.aspectRatio.value=i.x>=i.y?N5.aspectRatio.value.set(i.y/i.x,1):N5.aspectRatio.value.set(1,i.x/i.y)}_buildReflectionDepthPasses(e,t,i){if(this._reflectionDepthPasses)for(let e of this._reflectionDepthPasses)e?.quad.material?.dispose();let r=[];{let e=new UU;e.name="SplineReflectionDepthBlit";let t=e5(this._reflectionTarget.depthTexture);e.fragmentNode=g5(m5(t.sample(u5())),1),e.lights=!1,e.blending=He,e.depthTest=!1,e.depthWrite=!1,e.needsUpdate=!0,r.push({quad:new Oq(e)})}for(let s=1;s<i;s++){let i=Math.max(1,e>>s-1),a=Math.max(1,t>>s-1),n=new UU;n.name=`SplineReflectionDepthMin${s}`;let o=e5(this._reflectionDepthChain[s-1].texture),l=L3,h=T2(l.x).mul(2),u=T2(l.y).mul(2),d=(e,t)=>o.load(E2(h.add(e),u.add(t))).x,c=(e,t)=>W2(e,t),p=c(c(d(0,0),d(1,0)),c(d(1,1),d(0,1))),m=!!(1&i),g=!!(1&a);m&&(p=c(p,c(d(2,0),d(2,1)))),g&&(p=c(p,c(d(0,2),d(1,2)))),m&&g&&(p=c(p,d(2,2))),n.fragmentNode=g5(m5(p),1),n.lights=!1,n.blending=He,n.depthTest=!1,n.depthWrite=!1,n.needsUpdate=!0,r.push({quad:new Oq(n)})}this._reflectionDepthPasses=r}_renderReflectionPass(e,t){let i=this.getDrawingBufferSize(k9),r=1/0,s=0,a=0;e.traverse(e=>{let n=e;if(!(n.isMesh&&16&n.layers.mask))return;let o=this._reflectiveMeshCoverage(n,t,i.y),l=Array.isArray(n.material)?n.material:[n.material];for(let e of l){if(!e?.layers)continue;let t=MC(e);!t||(r=Math.min(r,t.min*o.scale),s=Math.max(s,t.max*o.scale),t.max*o.scale>.45&&(a=Math.max(a,o.diameterPx)))}});let n=1;if(s7&&r!==1/0)for(r>=6?n=4:r>=2&&(n=2);n>1&&a>0&&a/n<128;)n>>=1;let o=Math.max(1,Math.round(i.x/n)),l=Math.max(1,Math.round(i.y/n)),h=Math.floor(Math.log2(Math.max(o,l)))+1,u=!0===this.backend?.isWebGPUBackend&&r7;this._reflectionTarget=this._reallocGrabTarget(this._reflectionTarget,o,l,()=>{let e=new Ms(o,l,{depthTexture:new Do(o,l)});return u?(e.texture.generateMipmaps=!1,e.texture.minFilter=qt):(e.texture.generateMipmaps=!0,e.texture.minFilter=$t),e.texture.magFilter=qt,e});let d=(e,t)=>{let i=new Ms(e,t,{depthBuffer:!1,type:ti,format:pi});return i.texture.generateMipmaps=!1,i.texture.minFilter=jt,i.texture.magFilter=jt,i},c=this._reflectionDepthPyramid;this._reflectionDepthPyramid=this._reallocGrabTarget(this._reflectionDepthPyramid,o,l,()=>{let e=d(o,l);return e.texture.mipmaps=Array.from({length:h},(e,t)=>({width:Math.max(1,o>>t),height:Math.max(1,l>>t)})),e}),this._reflectionDepthPyramid!==c&&this.initTexture(this._reflectionDepthPyramid.texture);for(let e=0;e<h;e++)this._reflectionDepthChain[e]=this._reallocGrabTarget(this._reflectionDepthChain[e],Math.max(1,o>>e),Math.max(1,l>>e),()=>d(Math.max(1,o>>e),Math.max(1,l>>e)));for(let e=h;e<this._reflectionDepthChain.length;e++)this._reflectionDepthChain[e]?.dispose(),this._reflectionDepthChain[e]=void 0;this._reflectionDepthChain.length=h;let p=!0===this._skySystem?.attached?this._skySystem.environmentTexture??null:null,m=N5.reflectionEnvMap,g=p??S5;m.value!==g&&(m.value=g,this._grabTargetEpoch++),N5.reflectionEnvEnabled.value=null!==p?1:0;let f=this.getClearColor(x9);N5.reflectionMissColor.value.set(f.r,f.g,f.b);let y=[];e.traverse(e=>{let t=e;if(!(t.isMesh||t.isLine||t.isPoints||t.isSprite))return;let i=t.layers;i&&16&i.mask&&16!==i.mask&&(y.push({layers:i,mask:i.mask}),i.mask=16)});let v=this.getRenderTarget();t.layers.disable(4),this.setRenderTarget(this._reflectionTarget),this._renderPrepass(e,t),t.layers.enable(4);for(let e of y)e.layers.mask=e.mask;this._reflectionPassesKey!==`${o}x${l}`&&(this._buildReflectionDepthPasses(o,l,h),this._reflectionPassesKey=`${o}x${l}`);let b=this._reflectionDepthPasses;for(let e=0;e<h;e++)this.setRenderTarget(this._reflectionDepthChain[e]),b[e].quad.render(this);this._batchedMipCopies(Array.from({length:h},(e,t)=>({src:this._reflectionDepthChain[t].texture,dst:this._reflectionDepthPyramid.texture,dstLevel:t,width:Math.max(1,o>>t),height:Math.max(1,l>>t)})));let x=this._reflectionTarget.texture;if(u){let e=this._reflectionColorPyramid;this._reflectionColorPyramid=this._reallocGrabTarget(this._reflectionColorPyramid,o,l,()=>{let e=new Ms(o,l,{depthBuffer:!1}),t=e.texture;return t.minFilter=$t,t.magFilter=qt,t.generateMipmaps=!1,t.mipmaps=Array.from({length:h},(e,t)=>({width:Math.max(1,o>>t),height:Math.max(1,l>>t)})),e}),this._reflectionColorPyramid!==e&&this.initTexture(this._reflectionColorPyramid.texture);let t=s>0?h:1,i=(e,t)=>{let i=new Ms(e,t,{depthBuffer:!1});return i.texture.generateMipmaps=!1,i.texture.minFilter=qt,i.texture.magFilter=qt,i};for(let e=1;e<t;e++)this._reflectionColorChain[e]=this._reallocGrabTarget(this._reflectionColorChain[e],Math.max(1,o>>e),Math.max(1,l>>e),()=>i(Math.max(1,o>>e),Math.max(1,l>>e)));for(let e=t;e<this._reflectionColorChain.length;e++)this._reflectionColorChain[e]?.dispose(),this._reflectionColorChain[e]=void 0;this._reflectionColorChain.length=t;for(let e=1;e<t;e++){let t=1===e?this._reflectionTarget:this._reflectionColorChain[e-1],i=this._getReflectionDownsamplePass(e-1);i.input.value=t.texture,i.step.value.set(1/t.width,1/t.height),this.setRenderTarget(this._reflectionColorChain[e]),i.quad.render(this)}this._batchedMipCopies([{src:this._reflectionTarget.texture,dst:this._reflectionColorPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:t-1},(e,t)=>({src:this._reflectionColorChain[t+1].texture,dst:this._reflectionColorPyramid.texture,dstLevel:t+1,width:Math.max(1,o>>t+1),height:Math.max(1,l>>t+1)}))]),x=this._reflectionColorPyramid.texture}this.setRenderTarget(v),N5.reflectionRenderTarget.value=x,N5.reflectionDepthPyramid.value=this._reflectionDepthPyramid.texture,N5.reflectionDepthSize.value.set(o,l),N5.reflectionDepthLevels.value=h,this._reflectionGrabInfo={div:n,w:o,h:l,minBlur:r,maxBlur:s}}_reflectiveMeshCoverage(e,t,i){let r=e.geometry;if(!r)return{diameterPx:i,scale:1};null===r.boundingSphere&&r.computeBoundingSphere();let s=r.boundingSphere;if(!s)return{diameterPx:i,scale:1};let a=e.matrixWorld.elements,n=Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10])),o=s.radius*n;_9.copy(s.center).applyMatrix4(e.matrixWorld);let l=t.projectionMatrix.elements[5]*i/2,h=1;!0===t.isPerspectiveCamera&&(S9.setFromMatrixPosition(t.matrixWorld),h=Math.max(_9.distanceTo(S9),t.near??.1));let u=2*o*l/h;return{diameterPx:u,scale:Math.min(1,u/(.66*i))}}_renderReflectionResolvePass(e,t){let i=this._reflectionGrabInfo,r=!0===this.backend?.isWebGPUBackend&&a7&&void 0!==i&&i.maxBlur>.45;if(r){let i=!0;e.traverse(e=>{let r=e;if(!(r.isMesh&&16&r.layers.mask))return;let s=Array.isArray(r.material)?r.material:[r.material],a=null;for(let e of s)if(e?.layers&&(a=TC(e),null!==a))break;"variable"!==a?null!==a?(r.userData.__srMode=a.blur>.45?1+a.tracingMode:0,r.userData.__srBlur=a.blur*this._reflectiveMeshCoverage(r,t,this.getDrawingBufferSize(M9).y).scale,r.userData.__srThickness=a.thickness,r.userData.__srStepSize=a.stepSize,r.userData.__srSteps=a.steps):r.userData.__srMode=0:i=!1}),r=i}let s=r?i.w:4,a=r?i.h:4,n=(e,t)=>()=>{let i=new Ms(e,t,{type:ii,depthBuffer:!1});return i.texture.generateMipmaps=!1,i.texture.minFilter=qt,i.texture.magFilter=qt,i};if(this._reflectionResolveTarget=this._reallocGrabTarget(this._reflectionResolveTarget,s,a,n(s,a)),N5.reflectionResolveTarget.value=this._reflectionResolveTarget.texture,!r)return void(N5.reflectionResolveEnabled.value=0);let{w:o,h:l}=i;if(this._reflectionGBufferTarget=this._reallocGrabTarget(this._reflectionGBufferTarget,o,l,()=>{let e=new Ms(o,l,{count:2,type:ii,depthTexture:new Do(o,l)});for(let t of e.textures)t.generateMipmaps=!1,t.minFilter=jt,t.magFilter=jt;return e.textures[0].name="g0",e.textures[1].name="g1",e}),this._reflectionResolveMarchTarget=this._reallocGrabTarget(this._reflectionResolveMarchTarget,o,l,n(o,l)),this._reflectionResolveBlurTmp=this._reallocGrabTarget(this._reflectionResolveBlurTmp,o,l,n(o,l)),!this._reflectionGBufferMaterial){let e=new UU;e.name="SplineReflectionGBuffer";let t=h5("__splinePlanarMirror","float"),i=N5.reflectionPlanarEnabled.greaterThan(.5),r=h5("__srMode","float"),s=k3(t.greaterThan(.5).and(i),c2(0),r);e.fragmentNode=J2({g0:g5(n3(s3),s),g1:g5(h5("__srBlur","float"),h5("__srThickness","float"),h5("__srStepSize","float"),h5("__srSteps","float"))}),e.lights=!1,e.blending=He,e.needsUpdate=!0,this._reflectionGBufferMaterial=e}let h=this._skippedAsyncDraws??0,u=e.overrideMaterial,d=this.getRenderTarget(),c=this.getClearColor(w9),p=this.getClearAlpha(),m=t.layers.mask;e.overrideMaterial=this._reflectionGBufferMaterial,t.layers.mask=16,this.setClearColor(0,0),this.setRenderTarget(this._reflectionGBufferTarget),this._renderPrepass(e,t),e.overrideMaterial=u,t.layers.mask=m,this.setClearColor(c,p);let g=N5.reflectionRenderTarget.value,f=N5.reflectionEnvMap.value,y=this._reflectionGBufferTarget,v=`${o}x${l}|${y.textures[0].uuid}|${g.uuid}|${this._reflectionDepthPyramid.texture.uuid}|${f.uuid}|${this._reflectionResolveMarchTarget.texture.uuid}|${this._reflectionResolveBlurTmp.texture.uuid}`;v!==this._reflectionResolveMarchKey&&(this._buildReflectionResolveMarch(g,f,o,l),this._reflectionResolveMarchKey=v);let b=this._reflectionResolveMarch;b.proj.value.copy(t.projectionMatrix),b.projInv.value.copy(t.projectionMatrix).invert(),b.camWorld.value.copy(t.matrixWorld),b.near.value=t.near??.1,this.setRenderTarget(this._reflectionResolveMarchTarget),b.quad.render(this),this.setRenderTarget(this._reflectionResolveBlurTmp),this._reflectionResolveBlur.h.render(this),this.setRenderTarget(this._reflectionResolveTarget),this._reflectionResolveBlur.v.render(this),this.setRenderTarget(d),N5.reflectionResolveEnabled.value=1,(this._skippedAsyncDraws??0)>h&&(N5.reflectionResolveEnabled.value=0)}_buildReflectionResolveMarch(e,t,i,r){this._reflectionResolveMarch&&this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose());let s=n5(new As),a=n5(new As),n=n5(new As),o=n5(.1),l=this._reflectionGBufferTarget,h=e5(l.textures[0]),u=e5(l.textures[1]),d=e5(l.depthTexture),c=e5(e),p=e5(this._reflectionDepthPyramid.texture),m=e5(t),g=new UU;g.name="SplineReflectionResolve";let f=C1(()=>{let e=L3,t=E2(T2(e.x),T2(e.y)),i=u5(),r=h.load(t).toVar(),l=d.sample(i).toVar(),g=g5(0).toVar(),f=c2(0).toVar();return A1(r.w.greaterThan(.5),()=>{let e=u.load(t).toVar(),h=Y4(a,i.x,i.y,l),d=K4({dials:{blur:e.x,thickness:e.y,stepSize:e.z,steps:T2(e.w),tracingMode:r.w.sub(1)},surface:{originView:h,normalV:n3(r.xyz),screenUv:i,fragWindowZ:l},camera:{projectionMatrix:s,projectionMatrixInverse:a,worldMatrix:n,near:o},resources:{colorMap:c,depthPyramid:p,depthPyramidNode:p,envMap:m},usePlanar:k1(!1),noisePixel:p5(t),singleRay:{footprintOut:f}});g.assign(g5(d,f.add(1)))}),g});g.fragmentNode=f(),g.lights=!1,g.blending=He,g.depthTest=!1,g.depthWrite=!1,g.needsUpdate=!0,this._reflectionResolveMarch={quad:new Oq(g),proj:s,projInv:a,camWorld:n,near:o};let y=e5(this._reflectionResolveMarchTarget.texture),v=e5(this._reflectionResolveBlurTmp.texture),b=e=>{let t=new UU;t.name=`SplineReflectionResolveBlur${e.toUpperCase()}`;let s="x"===e?y:v,a="x"===e?1/i:1/r,n=C1(()=>{let t=u5(),i=y.sample(t).toVar().w.sub(1).max(0).clamp(.5,12).toVar(),r=g5(0).toVar(),n=0;for(let o=-6;o<=6;o++){let l=Math.exp(o/3*-.5*(o/3));n+=l;let h="x"===e?p5(i.mul(o/6*a),0):p5(0,i.mul(o/6*a)),u=s.sample(t.add(h)).toVar(),d="x"===e?u.w.min(1):u.w;r.addAssign(g5(u.rgb,d).mul(l))}return r.div(n)});return t.fragmentNode=n(),t.lights=!1,t.blending=He,t.depthTest=!1,t.depthWrite=!1,t.needsUpdate=!0,new Oq(t)};this._reflectionResolveBlur={h:b("x"),v:b("y")}}_renderPlanarReflectionPass(e,t){let i=null;if(e.traverse(e=>{let t=e;if(!(t.isMesh&&16&t.layers.mask&&(t.userData.__splinePlanarMirror=0,(Array.isArray(t.material)?t.material:[t.material]).some(e=>e?.layers&&e.getLayersOfType("reflection").some(e=>e.data.visible&&1===e.data.mirror)))))return;let r=t.geometry;if(!r)return;null===r.boundingBox&&r.computeBoundingBox();let s,a,n=r.boundingBox,o=n.max.x-n.min.x,l=n.max.y-n.min.y,h=n.max.z-n.min.z,u=t.matrixWorld.elements,d=Math.hypot(u[0],u[1],u[2]),c=Math.hypot(u[4],u[5],u[6]),p=Math.hypot(u[8],u[9],u[10]);o<=l&&o<=h?(s=T9,a=l*c*(h*p)):l<=o&&l<=h?(s=C9,a=o*d*(h*p)):(s=A9,a=o*d*(l*c)),(!i||a>i.area)&&(i={mesh:t,normalAxis:s,area:a})}),!i)return void(N5.reflectionPlanarEnabled.value=0);let r=i.mesh,s=i.mesh.matrixWorld;if(N9.copy(i.normalAxis).transformDirection(s),P9.setFromMatrixPosition(s),R9.setFromMatrixPosition(t.matrixWorld),E9.subVectors(P9,R9),E9.dot(N9)>0&&N9.negate(),E9.dot(N9)>0)return void(N5.reflectionPlanarEnabled.value=0);r.userData.__splinePlanarMirror=1,(!this._planarVirtualCamera||this._planarVirtualCamera.type!==t.type)&&(this._planarVirtualCamera=t.clone());let a=this._planarVirtualCamera;if(E9.subVectors(P9,R9),E9.reflect(N9).negate(),E9.add(P9),O9.extractRotation(t.matrixWorld),B9.set(0,0,-1).applyMatrix4(O9).add(R9),V9.subVectors(P9,B9),V9.reflect(N9).negate(),V9.add(P9),a.position.copy(E9),a.up.set(0,1,0).applyMatrix4(O9),a.up.reflect(N9),a.lookAt(V9),a.updateMatrixWorld(),a.projectionMatrix.copy(t.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),!0===t.isPerspectiveCamera){D9.setFromNormalAndCoplanarPoint(N9,P9),D9.applyMatrix4(a.matrixWorldInverse),I9.set(D9.normal.x,D9.normal.y,D9.normal.z,D9.constant);let e=a.projectionMatrix.elements;L9.x=(Math.sign(I9.x)+e[8])/e[0],L9.y=(Math.sign(I9.y)+e[9])/e[5],L9.z=-1,L9.w=(1+e[10])/e[14],I9.multiplyScalar(1/I9.dot(L9)),e[2]=I9.x,e[6]=I9.y,e[10]=I9.z,e[14]=I9.w}let n=this.getDrawingBufferSize(z9),o=Math.max(1,Math.round(n.x)),l=Math.max(1,Math.round(n.y)),h=!0===this.backend?.isWebGPUBackend&&i7;this._planarTarget=this._reallocGrabTarget(this._planarTarget,o,l,()=>{let e=new Ms(o,l);return h?(e.texture.generateMipmaps=!1,e.texture.minFilter=qt):(e.texture.generateMipmaps=!0,e.texture.minFilter=$t),e.texture.magFilter=qt,e});let u=[];e.traverse(e=>{let t=e;if(!(t.isMesh||t.isLine||t.isPoints||t.isSprite))return;let i=t.layers;i&&16&i.mask&&16!==i.mask&&(u.push({layers:i,mask:i.mask}),i.mask=16)}),a.layers.mask=-17&t.layers.mask;let d=this.getRenderTarget();this.setRenderTarget(this._planarTarget),this._renderPrepass(e,a),this.setRenderTarget(d);for(let e of u)e.layers.mask=e.mask;let c=this._planarTarget.texture;if(h){let e=Math.floor(Math.log2(Math.max(o,l)))+1,t=this._planarPyramid;this._planarPyramid=this._reallocGrabTarget(this._planarPyramid,o,l,()=>{let t=new Ms(o,l,{depthBuffer:!1}),i=t.texture;return i.minFilter=$t,i.magFilter=qt,i.generateMipmaps=!1,i.mipmaps=Array.from({length:e},(e,t)=>({width:Math.max(1,o>>t),height:Math.max(1,l>>t)})),t}),this._planarPyramid!==t&&this.initTexture(this._planarPyramid.texture);let i=(e,t)=>{let i=new Ms(e,t,{depthBuffer:!1});return i.texture.generateMipmaps=!1,i.texture.minFilter=qt,i.texture.magFilter=qt,i};for(let t=1;t<e;t++)this._planarChain[t]=this._reallocGrabTarget(this._planarChain[t],Math.max(1,o>>t),Math.max(1,l>>t),()=>i(Math.max(1,o>>t),Math.max(1,l>>t)));for(let t=e;t<this._planarChain.length;t++)this._planarChain[t]?.dispose(),this._planarChain[t]=void 0;this._planarChain.length=e;for(let t=1;t<e;t++){let e=1===t?this._planarTarget:this._planarChain[t-1],i=this._getPlanarDownsamplePass(t-1);i.input.value=e.texture,i.step.value.set(1/e.width,1/e.height),this.setRenderTarget(this._planarChain[t]),i.quad.render(this)}this.setRenderTarget(d),this._batchedMipCopies([{src:this._planarTarget.texture,dst:this._planarPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:e-1},(e,t)=>({src:this._planarChain[t+1].texture,dst:this._planarPyramid.texture,dstLevel:t+1,width:Math.max(1,o>>t+1),height:Math.max(1,l>>t+1)}))]),c=this._planarPyramid.texture}let p=N5.reflectionPlanarTarget;p.value!==c&&(p.value=c,this._grabTargetEpoch++),N5.reflectionPlanarEnabled.value=1}renderFromSceneForSceneTransitionPass(e,t,i){let r=this.getDrawingBufferSize(k9),s=Math.max(1,Math.round(r.x)),a=Math.max(1,Math.round(r.y));this._transitionCaptureTarget=this._reallocGrabTarget(this._transitionCaptureTarget,s,a,()=>new Ms(s,a,{depthBuffer:!0}));let n=this.getRenderTarget();this.setRenderTarget(this._transitionCaptureTarget),this.renderSplineScene(e,t),this.setRenderTarget(n),this.pipeline.sceneTransitionFromTexture=this._transitionCaptureTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i;let o=this.pipeline.sceneTransitionPass.uniforms;o.uDPR.value=this.getPixelRatio(),o.uResolution.value.set(r.x,r.y).divideScalar(this.getPixelRatio())}async captureFrame(e,{includeHelpers:t=!1}={}){if(!0===this.xr?.isPresenting)return null;let i=this._frameSerial,r=this.getRenderTarget(),s=this.pipeline.renderToScreen,a=this.pipeline.helpersEnabled;t||this.pipeline.disableHelpers(),this.pipeline.renderToScreen=!1,this.setRenderTarget(null);try{e()}finally{this.pipeline.renderToScreen=s,this.setRenderTarget(r),a&&this.pipeline.enableHelpers()}if(this._frameSerial===i||this.lastFrameIncomplete)return null;let n=this.pipeline.lastOutputTarget;if(!n||!this.backend.get(n.textures[0])?.textureDescriptorGPU)return null;let o=n.width,l=n.height,h=this,u=new Uint8Array(o*l*4),d=4*o,c=256*Math.ceil(d/256),p=Math.max(1,Math.min(l,Math.floor((1<<20)/c)));for(let e=0;e<l;e+=p){let t=Math.min(p,l-e),i=await h.readRenderTargetPixelsAsync(n,0,e,o,t);if(c===d)u.set(i.subarray(0,t*d),e*d);else for(let r=0;r<t;r++){let t=r*c;u.set(i.subarray(t,t+d),(e+r)*d)}}return{pixels:u,width:o,height:l}}_applyCIOffscreenTargetIfRequested(){if(!0!==globalThis.__SPLINE_RENDER_OFFSCREEN__)return;let e=Math.max(1,Math.round(this.viewportWidth*this.getPixelRatio())),t=Math.max(1,Math.round(this.viewportHeight*this.getPixelRatio()));this._ciOffscreenTarget?(this._ciOffscreenTarget.width!==e||this._ciOffscreenTarget.height!==t)&&(this._ciOffscreenTarget.dispose(),this._ciOffscreenTarget=new Ms(e,t,{depthBuffer:!0})):(this._ciOffscreenTarget=new Ms(e,t,{depthBuffer:!0}),globalThis.__splineReadOffscreenPixels=async()=>{let e=this._ciOffscreenTarget,t=await this.readRenderTargetPixelsAsync(e,0,0,e.width,e.height);return{width:e.width,height:e.height,pixels:Array.from(t)}}),null===this.getRenderTarget()&&this.setRenderTarget(this._ciOffscreenTarget)}dispose(){this._disposeRetiredGrabTargets(),this._disposeWarmupTargets(),I4()?.drainRetired(),w4()?.drainRetired(),this._skySystem?.dispose(),this._skySystem=null,this._hbao?.dispose(),this._hbao=void 0,this._shadowMask?.dispose(),this._shadowMask=void 0,function(){for(let e of N6){let t=e.deref();void 0!==t&&(t.mid?.dispose(),t.mid=null,t.small?.dispose(),t.small=null,t.toMid?.material?.dispose(),t.toSmall?.material?.dispose(),t.toMid=null,t.toSmall=null,t.passKey="",t.fresh=!1,t.slot=-1)}N6.clear(),P6.fill(null),A6?.dispose(),A6=null,R6=!1}(),this._aoRenderTarget?.dispose(),this._aoRenderTarget=void 0,this._normalTarget?.dispose(),this._normalTarget=void 0,this._ciOffscreenTarget?.dispose(),this._ciOffscreenTarget=void 0,this._transitionCaptureTarget?.dispose(),this._transitionCaptureTarget=void 0,this._transmissionTarget?.dispose(),this._transmissionTarget=void 0,this._transmissionBlurTmp?.dispose(),this._transmissionBlurTmp=void 0,this._transmissionBlurTarget?.dispose(),this._transmissionBlurTarget=void 0;for(let e of this._transmissionChain)e?.dispose();this._transmissionChain.length=0,this._reflectionTarget?.depthTexture?.dispose(),this._reflectionTarget?.dispose(),this._reflectionTarget=void 0,this._reflectionColorPyramid?.dispose(),this._reflectionColorPyramid=void 0;for(let e of this._reflectionColorChain)e?.dispose();if(this._reflectionColorChain.length=0,this._reflectionDownsamplePasses){for(let e of this._reflectionDownsamplePasses)e?.quad.material?.dispose();this._reflectionDownsamplePasses=void 0}this._planarTarget?.dispose(),this._planarTarget=void 0,this._planarPyramid?.dispose(),this._planarPyramid=void 0;for(let e of this._planarChain)e?.dispose();if(this._planarChain.length=0,this._planarDownsamplePasses){for(let e of this._planarDownsamplePasses)e?.quad.material?.dispose();this._planarDownsamplePasses=void 0}this._reflectionDepthPyramid?.dispose(),this._reflectionDepthPyramid=void 0;for(let e of this._reflectionDepthChain)e?.dispose();if(this._reflectionDepthChain.length=0,this._reflectionDepthPasses){for(let e of this._reflectionDepthPasses)e?.quad.material?.dispose();this._reflectionDepthPasses=void 0}if(this._reflectionPassesKey="",this._reflectionGBufferTarget?.depthTexture?.dispose(),this._reflectionGBufferTarget?.dispose(),this._reflectionGBufferTarget=void 0,this._reflectionResolveMarchTarget?.dispose(),this._reflectionResolveMarchTarget=void 0,this._reflectionResolveBlurTmp?.dispose(),this._reflectionResolveBlurTmp=void 0,this._reflectionResolveTarget?.dispose(),this._reflectionResolveTarget=void 0,this._reflectionGBufferMaterial?.dispose(),this._reflectionGBufferMaterial=void 0,this._reflectionResolveMarch&&(this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveMarch=void 0),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose(),this._reflectionResolveBlur=void 0),this._reflectionResolveMarchKey="",this._reflectionGrabInfo=void 0,this._prefilterPasses){for(let e of this._prefilterPasses)e?.quad.material?.dispose();this._prefilterPasses=void 0}if(this._downsamplePasses){for(let e of this._downsamplePasses)e?.quad.material?.dispose();this._downsamplePasses=void 0}this._uiBlitPass&&(this._uiBlitPass.quad.material.dispose(),this._uiBlitPass=void 0),this._helperOverlay?.dispose(),this._helperOverlay=void 0,function(){for(let e of X8)e.deref()?.dispose();X8.clear(),K8++}(),function(){for(let e of t9){let t=e.deref();void 0!==t&&(t.sprite.removeFromParent(),t.material.dispose())}t9.clear(),i9++}(),this._taaHistory?.dispose(),this._taaHistory=void 0;for(let e of Object.values(this._encodeMaterials))e?.dispose();this._encodeMaterials={},this._bundledPages.clear(),this.pipeline.dispose(),this.dummyCamera.dispose(),super.dispose(),this._disposeRetiredGrabTargets(),N5.transmissionRenderTarget.value=_5,N5.normalRenderTarget.value=_5,N5.aoRenderTarget.value=_5,N5.reflectionRenderTarget.value=S5,N5.reflectionDepthPyramid.value=S5,N5.reflectionEnvMap.value=S5,N5.reflectionPlanarTarget.value=S5,N5.reflectionPlanarEnabled.value=0,N5.reflectionResolveTarget.value=M5,N5.reflectionResolveEnabled.value=0}})._GAUGE_STALL_MS=3e3});function g7(e){return{type:e.type}}function f7(e,t){let{alpha:i,mode:r,isMask:s}=e,a="string"==typeof i?Number(t.getVariable(i)??100)/100:i;return{...g7(e),alpha:a,mode:r,isMask:s}}var y7=n(()=>{Mu(),vC(),AT()});function v7(e){let t=e;return null!=t&&!0===t.isInstancedMesh&&null!=t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute}function b7(e){return x7(x7(K2).mul(function(e){let t=e.spInstanceMatrixNode;if(void 0!==t)return x7(t);let i=e.object,r=i.instanceMatrix,s=Math.max(i.count??1,1);if(!0===r.isStorageInstancedBufferAttribute)return x7(w7(K3(r,"mat4",s),_2));if(16*s*4<=e.getUniformBufferLimit())return x7(w7(U1(r.array,"mat4",s),_2));let a=_7.get(r);void 0===a&&(a=new zh(r.array,16,1),_7.set(r,a));let n=r.usage===Fr?M2:S2;return x7(k2(n(a,"vec4",16,0),n(a,"vec4",16,4),n(a,"vec4",16,8),n(a,"vec4",16,12)))}(e)))}var x7,w7,_7,S7,M7,T7,C7=n(()=>{Mu(),b5(),x7=e=>e,w7=(e,t)=>e.element(t),_7=new WeakMap,S7=C1(e=>v7(e.object)?y3:v3).once()().toVar("speObjectPosition"),M7=C1(e=>{let t=e.material?.shapeBlendObjectNormal;return t||(v7(e.object)?e.geometry.hasAttribute("normal")?i3:m5(0,1,0):r3)}).once()().toVar("speObjectNormal"),x7(C1(e=>x7(v7(e.object)?b7(e):K2)).once()()),T7=C1(e=>{if(!v7(e.object))return Y2;let t=b7(e),i=e=>w7(t,e).xyz;return m5(i(0).length(),i(1).length(),i(2).length()).toVarying("v_speModelScale")}).once()().toVar("speModelScale"),C1(e=>v7(e.object)?z2(b7(e)).inverse().transpose():$2).once()(),x7(C1(e=>x7(v7(e.object)?b7(e).inverse():Z2)).once()())});function A7(e){if(R7.has(e))return;let t={own:e.value,render:e.value};R7.set(e,t),Object.defineProperty(e,"value",{configurable:!0,enumerable:!0,get:()=>t.render,set:e=>{t.render=e,t.own=e}})}function N7(e){let t=R7.get(e);return void 0!==t?t.own:e.value}function P7(e,t){let i=R7.get(e);void 0!==i?i.render=t:e.value=t}var R7,E7,O7=n(()=>{R7=new WeakMap}),B7=n(()=>{O7(),E7=class{constructor(e){this.layerId=e,this.uniforms={},this.byName=new Map,this.liveValues=new Map}set(e,t,i){return this.byName.set(e,t),this.uniforms[`f${this.layerId}_${e}`]=t,void 0!==i&&this.liveValues.set(e,i),this}has(e){return this.byName.has(e)}names(){return[...this.byName.keys()]}get(e){let t=this.byName.get(e);if(void 0===t)throw new Error(`TSLLayerParams: unknown param "${e}" (layer f${this.layerId})`);return t}getFloat(e){return this.get(e)}getInt(e){return this.get(e)}getBool(e){return this.get(e)}getVec2(e){return this.get(e)}getVec3(e){return this.get(e)}getVec4(e){return this.get(e)}getColor(e){return this.get(e)}getValue(e){if(this.liveValues.has(e))return this.liveValues.get(e);let t=this.byName.get(e);return void 0===t?void 0:N7(t)}getLiveValue(e){return this.liveValues.get(e)}getNodeValue(e){let t=this.byName.get(e);return void 0===t?void 0:N7(t)}setValue(e,t){let i=this.byName.get(e);void 0===i||void 0===t||(this.liveValues.has(e)&&this.liveValues.set(e,t),i.value=t)}}});function V7(e,t,i){let r=c2(e).toVar(),s=c2(q2(r.div($1(r.add(t.accumAlpha),c2(1e-5),c2(1))),r,i)).toVar();return t.accumAlpha.addAssign(l3(t.accumAlpha).mul(r).mul(l3(i))),s}function D7(e,t){let i=c2(e).toVar(),r=c2(i.div($1(i.add(t.accumAlpha),c2(1e-5),c2(1)))).toVar();return t.accumAlpha.addAssign(l3(t.accumAlpha).mul(i)),r}function I7(e,t,i,r){return W7({a:e,b:t,alpha:i,mode:r})}function L7(e,t){q7.set(e,t)}function z7(e){let t=q7.get(e);return void 0!==t?t:(H7.has(e)||(H7.add(e),console.warn(`[spe] Material layer type "${e}" is not available in this runtime build (no WebGPU port, or compiled out) — rendering flat red.`)),$7)}function k7(e){return q7.has(e)}var U7,F7,j7,G7,W7,q7,H7,$7,Y7=n(()=>{b5(),C7(),B7(),O7(),U7=0,F7=1,j7=2,G7=3,W7=C1(e=>{let t=e.a.toVar(),i=e.b.toVar(),r=e.alpha.toVar(),s=e.mode,a=m5(1).toVar();return A1(s.equal(T2(U7)),()=>{a.assign(q2(t,i,r))}).ElseIf(s.equal(T2(F7)),()=>{a.assign(q2(t,t.mul(i),r))}).ElseIf(s.equal(T2(j7)),()=>{a.assign(q2(t,l3(l3(t).mul(l3(i))),r))}).ElseIf(s.equal(T2(G7)),()=>{let e=X3(t,m5(.5)),s=q2(l3(l3(t).mul(l3(i)).mul(2)),t.mul(i).mul(2),e);a.assign(q2(t,s,r).clamp(0,1))}),a}),q7=new Map,H7=new Set,$7=(e,t,i)=>{let r=t.alpha.mul(t.mask);return{color:m5(1,0,0),calpha:D7(r,i)}}});function X7(e){let t=J7(N5.aoRenderTarget.sample(z3).rgb),i=Q7(N5.aoEnabledUniform);return null!==e&&(i=Q7(i.mul(k3(e,c2(1),c2(0))))),J7(q2(m5(1),t,i))}var K7,Z7,J7,Q7,eee,tee,iee,ree,see=n(()=>{var e;v5(),b5(),P5(),Y7(),({diffuseContribution:K7,specularColorBlended:Z7}=hZ),J7=e=>e,Q7=e=>e,eee=C1(e=>{let t=s3.dot(J7(e.lightDirection)),i=p5(t.mul(.5).add(.5),0),r=i.fwidth().mul(.5);return q2(m5(.7),m5(1),q3(c2(.7).sub(r.x),c2(.7).add(r.x),i.x))}),tee=C1(e=>{let t=J7(e.lightDirection).add(w3).normalize(),i=s3.dot(t).clamp(),r=w3.dot(t).clamp(),s=r.mul(-5.55473).sub(6.98316).mul(r).exp2(),a=H3.mul(s.oneMinus()).add(s),n=c2(.25),o=j3.mul(.5).add(1).mul(1/Math.PI).mul(i.pow(j3));return a.mul(n).mul(o)}),e=class extends bF{direct(e){let{lightDirection:t,lightColor:i,reflectedLight:r}=e,s=J7(eee({lightDirection:t})).mul(i);r.directDiffuse.addAssign(s.mul(J7(a2.rgb).mul(1/Math.PI))),r.directSpecular.addAssign(s.mul(Q7(tee({lightDirection:t}))))}},iee=class extends e{constructor(){super(...arguments),this.aoOcclusionGate=null}finish(e,...t){super.finish?.call(this,e,...t);let{reflectedLight:i,outgoingLight:r}=e.context,s=X7(this.aoOcclusionGate),a=J7(i.directDiffuse.add(i.indirectDiffuse));r.subAssign(a.mul(l3(s)))}},ree=class extends vj{constructor(){super(...arguments),this.envIrradianceActive=!1}direct(e,t){let i=e;if(!0===i.lightNode?.light?.userData?.splineDiffuseOnly){if(this.envIrradianceActive)return;let e=J7(s3).dot(i.lightDirection).clamp().mul(i.lightColor),t=hZ.BRDF_Lambert({diffuseColor:K7});return void i.reflectedLight.directDiffuse.addAssign(e.mul(t))}super.direct(e,t)}}});function aee(e,t){return cee("x"===t?e.x:"y"===t?e.y:e.z)}function nee(e,t){return pee(Q2(e,m5(t,1)).div(2).add(.5).xy)}function oee(e,t,i){let r=c2(e.div($1(e.add(t.accumAlpha),c2(1e-5),c2(1)))).toVar();return t.accumAlpha.addAssign(l3(t.accumAlpha).mul(e).mul(l3(i))),r}function lee(e){let t=e.getValue("projection")??0,i=e.getValue("axis")??0,r=i>=0&&i<=2?i:0,s=e.getValue("projectionAxis")??-1,a=s>=0&&s<=2?s:1,n=fee(e.get("mat")),o=e.getVec2("size");if(1===t){let e=S7,t=0===r?e.zy:1===r?e.xz:e.xy,i=p5(t.add(1).div(2)).toVar(),s=p5(nee(n,pee(i.mul(2).sub(1).div(o.mul(.5))))).toVar();return{uvs:[pee(s)],weights:null}}if(2===t){let e=m5(n3(S7)).toVar(),{a:t,b:i,pole:r}=yee[a],s=c2(I1(aee(e,t),aee(e,i)).div(6.283).add(.5)).toVar(),o=c2(D1(aee(e,r)).div(3.1415).add(.5)).toVar(),l=p5(s,o).toVar(),h=p5(nee(n,pee(l.mul(2).sub(1)))).toVar();return{uvs:[pee(h)],weights:null}}if(3===t){let e=m5(n3(S7)).toVar(),{a:t,b:i,pole:r}=yee[a],s=c2(I1(aee(e,t),aee(e,i)).div(6.283).add(.5)).toVar(),l=c2(aee(mee(S7),r).div(o.y.mul(.5))).toVar(),h=c2(l.div(2).add(.5)).toVar(),u=p5(s,h).toVar(),d=p5(nee(n,pee(u.mul(2).sub(1)))).toVar();return{uvs:[pee(d)],weights:null}}if(4===t){let t=e.getFloat("blending"),i=m5(S7).toVar(),r=p5(i.xy.add(1).div(2)).toVar(),s=p5(i.zy.add(1).div(2)).toVar(),a=p5(i.xz.add(1).div(2)).toVar();for(let e of[r,s,a])e.assign(nee(n,pee(e.mul(2).sub(1).div(o.mul(.5)))));let l=c2(l3(t).mul(125).add(3)).toVar(),h=m5(M7).toVar(),u=m5(O1(n3(h))).toVar();return u.assign(S3(u,m5(l))),u.divAssign(o2(u,m5(1))),{uvs:[pee(r),pee(s),pee(a)],weights:mee(u)}}let l=p5(nee(n,pee(u5().mul(2).sub(1)))).toVar();return{uvs:[pee(l)],weights:null}}function hee(e,t,i){let r=p5(t).toVar(),s=p5(i2(r)).toVar(),a=p5(r2(r)).toVar(),n=t=>cee(i.mul(L2(gee(e.sample(t)).rgb))),o=c2(n(pee(r))).toVar(),l=c2(n(pee(r.add(s))).sub(o)).toVar(),h=c2(n(pee(r.add(a))).sub(o)).toVar();return pee(p5(l,h))}function uee(e,t,i){let r=m5(i2(e)).toVar(),s=m5(r2(e)).toVar(),a=m5(n3(t)).toVar(),n=m5(n3(e2(s,a))).toVar(),o=m5(n3(e2(a,r))).toVar(),l=c2(o2(r,n).mul(d2)).toVar(),h=m5(G3(l).mul(i.x.mul(n).add(i.y.mul(o)))).toVar();return mee(n3(O1(l).mul(a).sub(h)))}function dee(e,t){let i,r=e.get("texture"),s=e.has("loaded")?e.getFloat("loaded"):c2(1),a=e=>{let i=gee(r.sample(e)),s="luminance"===t?L2(i.rgb):i[t];return c2(s).toVar()},{uvs:n,weights:o}=lee(e);if(null!==o){let e=a(n[0]),t=a(n[1]),r=a(n[2]);i=cee(e.mul(o.z).add(t.mul(o.x)).add(r.mul(o.y)))}else i=cee(a(n[0]));return cee(q2(c2(1),i,s))}var cee,pee,mee,gee,fee,yee,vee,bee=n(()=>{b5(),Y7(),cee=e=>e,pee=e=>e,mee=e=>e,gee=e=>e,fee=e=>e,yee=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],L7("texture",vee=(e,t,i)=>{let r,s=e.getValue("projection")??0,a=e.getValue("axis")??0,n=a>=0&&a<=2?a:0,o=e.getValue("side")??0,l=e.get("texture"),h=e.getFloat("crop"),{uvs:u,weights:d}=lee(e),c=[...u],p=null;if(1===s){if(r=gee(l.sample(u[0])),2!==o){let e=0===n?m5(1,0,0):1===n?m5(0,1,0):m5(0,0,1),t=o2(M7,e);p=cee(X3(c2(0),1===o?t.mul(-1):t))}}else if(2===s||3===s)r=function(e,t){let i=p5(i2(t)).toVar(),r=p5(r2(t)).toVar();return i.x.subAssign(p2(i.x.add(.5))),r.x.subAssign(p2(r.x.add(.5))),gee(e.sample(t).grad(i,r))}(l,u[0]);else if(4===s){let e=d,t=gee(l.sample(u[0])),i=gee(l.sample(u[1])),s=gee(l.sample(u[2]));r=gee(t.mul(e.z).add(i.mul(e.x)).add(s.mul(e.y)))}else r=gee(l.sample(u[0]));let m=e.has("loaded")?e.getFloat("loaded"):c2(1),g=g5(q2(g5(0,0,0,1),gee(r),m)).toVar(),f=m5(g.rgb).toVar(),y=c2(t.alpha.mul(g.a)).toVar();return null!==p&&y.mulAssign(p),function(e,t,i){A1(e.greaterThan(.5),()=>{for(let e of i)A1(e.x.lessThan(0).or(e.x.greaterThan(1)).or(e.y.lessThan(0)).or(e.y.greaterThan(1)),()=>{t.assign(0)})})}(h,cee(y),c),y.mulAssign(t.mask),{color:mee(f),calpha:oee(cee(y),i,t.isMask)}}),L7("video",vee)});function xee(e){return Lee({c:e})}function wee(e){return zee({p:e})}function _ee(e){return kee({m:e})}function See(e){return Uee({x:e})}function Mee(e){return Fee({r:e})}function Tee(e){return jee({v:e})}function Cee(e){return Wee({x:e})}function Aee(e){return Hee({x:e})}function Nee(e){return Yee({P:e})}function Pee(e){return Kee({p3:e})}function Ree(e,t,i){return Zee({a:e,b:t,k:i})}function Eee(e,t,i){return Jee({a:e,b:t,k:i})}function Oee(e,t,i,r,s){return Qee({value:e,input_min:t,input_max:i,output_min:r,output_max:s})}function Bee(e,t,i,r,s){return ete({x:e,style:t,smoothness:i,seed:r,quality:s})}var Vee,Dee,Iee,Lee,zee,kee,Uee,Fee,jee,Gee,Wee,qee,Hee,$ee,Yee,Xee,Kee,Zee,Jee,Qee,ete,tte,ite=n(()=>{b5(),Vee=o3,Dee=N1,Iee=.1666667,Lee=C1(e=>{let t=e.c,i=W3(o2(t,m5(17,59.4,15))).mul(4096),r=g2(i.mul(512)),s=i.mul(.125),a=g2(s.mul(512)),n=s.mul(.125),o=g2(n.mul(512));return m5(a,o,r).sub(.5)}).setLayout({name:"spe_random3",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),zee=C1(e=>{let t=e.p,i=p2(t.add(o2(t,m5(.3333333)))).toVar(),r=t.sub(i).add(o2(i,m5(Iee))).toVar(),s=X3(m5(0),r.sub(r.yzx)).toVar(),a=s.mul(l3(s.zxy)).toVar(),n=l3(s.zxy.mul(l3(s))).toVar(),o=r.sub(a).add(Iee).toVar(),l=r.sub(n).add(2*Iee).toVar(),h=r.sub(1).add(3*Iee).toVar(),u=g5(o2(r,r),o2(o,o),o2(l,l),o2(h,h)).toVar();u.assign(g5(.6).sub(u).max(0));let d=g5(o2(xee(i),r),o2(xee(i.add(a)),o),o2(xee(i.add(n)),l),o2(xee(i.add(1)),h)).toVar();return u.mulAssign(u),u.mulAssign(u),d.mulAssign(u),o2(d,g5(52))}).setLayout({name:"spe_simplexFast",type:"float",inputs:[{name:"p",type:"vec3"}]}),kee=C1(e=>{let t=e.m,i=z2(m5(-.37,.36,.85),m5(-.14,-.93,.34),m5(.92,.01,.4)),r=z2(m5(-.55,-.39,.74),m5(.33,-.91,-.24),m5(.77,.12,.63)),s=z2(m5(-.71,.52,-.47),m5(-.08,-.72,-.68),m5(-.7,-.45,.56));return wee(t.mul(i)).mul(.5333333).add(wee(t.mul(2).mul(r)).mul(.2666667)).add(wee(t.mul(4).mul(s)).mul(.1333333)).add(wee(t.mul(8)).mul(.0666667))}).setLayout({name:"spe_simplexFractal",type:"float",inputs:[{name:"m",type:"vec3"}]}),Uee=C1(e=>{let t=e.x;return H2(t.mul(34).add(1).mul(t),289)}).setLayout({name:"spe_permute",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),Fee=C1(e=>Z3(1.79284291400159,e.r.mul(.85373472095314))).setLayout({name:"spe_taylorInvSqrt",type:"vec4",inputs:[{name:"r",type:"vec4"}]}),jee=C1(e=>{let t=e.v,i=p5(1/6,1/3),r=g5(0,.5,1,2),s=p2(t.add(o2(t,i.yyy))).toVar(),a=t.sub(s).add(o2(s,i.xxx)).toVar(),n=X3(a.yzx,a.xyz).toVar(),o=l3(n).toVar(),l=W2(n.xyz,o.zxy).toVar(),h=j2(n.xyz,o.zxy).toVar(),u=a.sub(l).add(i.xxx.mul(1)).toVar(),d=a.sub(h).add(i.xxx.mul(2)).toVar(),c=a.sub(1).add(i.xxx.mul(3)).toVar();s.assign(H2(s,289));let p=See(See(See(s.z.add(g5(0,l.z,h.z,1))).add(s.y).add(g5(0,l.y,h.y,1))).add(s.x).add(g5(0,l.x,h.x,1))).toVar(),m=r.wyz.mul(1/7).sub(r.xzx).toVar(),g=p.sub(p2(p.mul(m.z).mul(m.z)).mul(49)).toVar(),f=p2(g.mul(m.z)).toVar(),y=p2(g.sub(f.mul(7))).toVar(),v=f.mul(m.x).add(m.yyyy).toVar(),b=y.mul(m.x).add(m.yyyy).toVar(),x=Z3(1,O1(v)).sub(O1(b)).toVar(),w=g5(v.xy,b.xy).toVar(),_=g5(v.zw,b.zw).toVar(),S=p2(w).mul(2).add(1).toVar(),M=p2(_).mul(2).add(1).toVar(),T=X3(x,g5(0)).negate().toVar(),C=w.xzyw.add(S.xzyw.mul(T.xxyy)).toVar(),A=_.xzyw.add(M.xzyw.mul(T.zzww)).toVar(),N=m5(C.xy,x.x).toVar(),P=m5(C.zw,x.y).toVar(),R=m5(A.xy,x.z).toVar(),E=m5(A.zw,x.w).toVar(),O=Mee(g5(o2(N,N),o2(P,P),o2(R,R),o2(E,E))).toVar();N.mulAssign(O.x),P.mulAssign(O.y),R.mulAssign(O.z),E.mulAssign(O.w);let B=j2(Z3(.6,g5(o2(a,a),o2(u,u),o2(d,d),o2(c,c))),0).toVar();return B.mulAssign(B),o2(B.mul(B),g5(o2(N,a),o2(P,u),o2(R,d),o2(E,c))).mul(42)}).setLayout({name:"spe_simplexAshima",type:"float",inputs:[{name:"v",type:"vec3"}]}),Gee=C1(e=>{let t=e.x;return t.sub(p2(t.mul(1/289)).mul(289))}).setLayout({name:"spe_mod289",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),Wee=C1(e=>{let t=e.x;return Gee({x:t.mul(34).add(1).mul(t)})}).setLayout({name:"spe_perm",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),qee=C1(e=>{let t=e.p,i=p2(t).toVar(),r=t.sub(i).toVar();r.assign(r.mul(r).mul(Z3(3,r.mul(2))));let s=i.xxyy.add(g5(0,1,0,1)).toVar(),a=Cee(s.xyxy).toVar(),n=Cee(a.xyxy.add(s.zzww)).toVar().add(i.zzzz).toVar(),o=Cee(n).toVar(),l=Cee(n.add(1)).toVar(),h=g2(o.mul(1/41)).toVar(),u=g2(l.mul(1/41)).toVar().mul(r.z).add(h.mul(l3(r.z))).toVar(),d=u.yw.mul(r.x).add(u.xz.mul(l3(r.x))).toVar();return d.y.mul(r.y).add(d.x.mul(l3(r.y)))}).setLayout({name:"spe_valueNoise",type:"float",inputs:[{name:"p",type:"vec3"}]}),Hee=C1(e=>{let t=m5(e.x).toVar(),i=c2(0).toVar(),r=c2(.5).toVar(),s=m5(100).toVar();return N1(5,()=>{i.addAssign(r.mul(function(e){return qee({p:e})}(t))),t.assign(t.mul(2).add(s)),r.mulAssign(.5)}),i}).setLayout({name:"spe_fbm",type:"float",inputs:[{name:"x",type:"vec3"}]}),$ee=C1(e=>{let t=e.t;return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"spe_fade",type:"vec3",inputs:[{name:"t",type:"vec3"}]}),Yee=C1(e=>{let t=e.P,i=p2(t).toVar(),r=i.add(m5(1)).toVar();i.assign(H2(i,289)),r.assign(H2(r,289));let s=g2(t).toVar(),a=s.sub(m5(1)).toVar(),n=g5(i.x,r.x,i.x,r.x).toVar(),o=g5(i.yy,r.yy).toVar(),l=g5(i.zzzz).toVar(),h=g5(r.zzzz).toVar(),u=See(See(n).add(o)).toVar(),d=See(u.add(l)).toVar(),c=See(u.add(h)).toVar(),p=d.div(7).toVar(),m=g2(p2(p).div(7)).sub(.5).toVar();p.assign(g2(p));let g=g5(.5).sub(O1(p)).sub(O1(m)).toVar(),f=X3(g,g5(0)).toVar();p.subAssign(f.mul(X3(0,p).sub(.5))),m.subAssign(f.mul(X3(0,m).sub(.5)));let y=c.div(7).toVar(),v=g2(p2(y).div(7)).sub(.5).toVar();y.assign(g2(y));let b=g5(.5).sub(O1(y)).sub(O1(v)).toVar(),x=X3(b,g5(0)).toVar();y.subAssign(x.mul(X3(0,y).sub(.5))),v.subAssign(x.mul(X3(0,v).sub(.5)));let w=m5(p.x,m.x,g.x).toVar(),_=m5(p.y,m.y,g.y).toVar(),S=m5(p.z,m.z,g.z).toVar(),M=m5(p.w,m.w,g.w).toVar(),T=m5(y.x,v.x,b.x).toVar(),C=m5(y.y,v.y,b.y).toVar(),A=m5(y.z,v.z,b.z).toVar(),N=m5(y.w,v.w,b.w).toVar(),P=Mee(g5(o2(w,w),o2(S,S),o2(_,_),o2(M,M))).toVar();w.mulAssign(P.x),S.mulAssign(P.y),_.mulAssign(P.z),M.mulAssign(P.w);let R=Mee(g5(o2(T,T),o2(A,A),o2(C,C),o2(N,N))).toVar();T.mulAssign(R.x),A.mulAssign(R.y),C.mulAssign(R.z),N.mulAssign(R.w);let E=o2(w,s).toVar(),O=o2(_,m5(a.x,s.yz)).toVar(),B=o2(S,m5(s.x,a.y,s.z)).toVar(),V=o2(M,m5(a.xy,s.z)).toVar(),D=o2(T,m5(s.xy,a.z)).toVar(),I=o2(C,m5(a.x,s.y,a.z)).toVar(),L=o2(A,m5(s.x,a.yz)).toVar(),z=o2(N,a).toVar(),k=function(e){return $ee({t:e})}(s).toVar(),U=q2(g5(E,O,B,V),g5(D,I,L,z),k.z).toVar(),F=q2(U.xy,U.zw,k.y).toVar();return q2(F.x,F.y,k.x).toVar().mul(2.2)}).setLayout({name:"spe_perlin",type:"float",inputs:[{name:"P",type:"vec3"}]}),Xee=C1(e=>{let t=g2(e.p3.mul(.1031)).toVar();return t.addAssign(o2(t,t.yzx.add(33.33))),g2(t.x.add(t.y).mul(t.z))}).setLayout({name:"spe_hashwithoutsine13",type:"float",inputs:[{name:"p3",type:"vec3"}]}),Kee=C1(e=>{let t=g2(e.p3.mul(m5(.1031,.103,.0973))).toVar();return t.addAssign(o2(t,t.yxz.add(33.33))),g2(t.xxy.add(t.yxx).mul(t.zyx))}).setLayout({name:"spe_hashwithoutsine33",type:"vec3",inputs:[{name:"p3",type:"vec3"}]}),Zee=C1(e=>{let{a:t,b:i,k:r}=e,s=q3(0,1,i.sub(t).mul(.5).div(r).add(.5)).toVar(),a=r.mul(s).mul(l3(s)).toVar();return q2(i,t,s).sub(a)}).setLayout({name:"spe_smin",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),Jee=C1(e=>{let{a:t,b:i,k:r}=e,s=q3(1,0,t.sub(i).mul(.5).div(r).add(.5)).toVar(),a=r.mul(s).mul(l3(s)).toVar();return q2(t,i,s).add(a)}).setLayout({name:"spe_smax",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),Qee=C1(e=>{let{value:t,input_min:i,input_max:r,output_min:s,output_max:a}=e,n=r.sub(i).toVar(),o=a.sub(s).toVar(),l=t.sub(i).div(n).toVar();return s.add(l.mul(o))}).setLayout({name:"spe_remap",type:"float",inputs:[{name:"value",type:"float"},{name:"input_min",type:"float"},{name:"input_max",type:"float"},{name:"output_min",type:"float"},{name:"output_max",type:"float"}]}),ete=C1(e=>{let{x:t,style:i,smoothness:r,seed:s,quality:a}=e,n=O2(p2(t)).toVar(),o=g2(t).toVar(),l=c2(8).toVar(),h=c2(8).toVar(),u=c2(8).toVar(),d=c2(8).toVar(),c=c2(8).toVar(),p=c2(8).toVar(),m=O2(0).toVar(),g=m5(0).toVar(),f=T2(a).toVar(),y=()=>({start:f.negate(),end:f,condition:"<=",type:"int"});Dee(y(),y(),y(),({i:e,j:t,k:i})=>{let a=O2(e,t,i).toVar(),u=m5(a).add(Pee(m5(n.add(a)).add(s))).sub(o).toVar(),c=B2(u).toVar();l.assign(Ree(c,l,r)),A1(c.lessThan(h),()=>{d.assign(h),h.assign(c),m.assign(O2(e,t,i)),g.assign(u)}).ElseIf(c.lessThan(d),()=>{d.assign(c)})}),A1(i.notEqual(T2(0)).and(i.notEqual(T2(5))).and(i.notEqual(T2(7))),()=>{Dee(y(),y(),y(),({i:e,j:t,k:i})=>{let a=m.add(O2(e,t,i)).toVar(),l=m5(a).add(Pee(m5(n.add(a)).add(s))).sub(o).toVar(),h=o2(g.add(l).mul(.5),l.sub(g)).toVar(),d=o2(g.add(l).mul(.5),n3(l.sub(g))).toVar();c.assign(Ree(h,c,r)),p.assign(W2(p,d));let f=O2(e,t,i).toVar();A1(V1(Vee(f,m)),()=>{let e=m5(f).add(Pee(m5(n.add(f)).add(s))).sub(o).toVar(),t=B2(e).toVar();u.assign(Ree(t,u,r))})})});let v=c2(0).toVar();return A1(i.equal(T2(0)),()=>{v.assign(l)}).ElseIf(i.equal(T2(1)),()=>{v.assign(u)}).ElseIf(i.equal(T2(2)),()=>{v.assign(u.sub(l))}).ElseIf(i.equal(T2(3)),()=>{let e=c2(3).toVar(),t=j2(e.sub(O1(h.sub(d))),0).div(e).toVar();v.assign(W2(h,d).sub(t.mul(t).mul(e).mul(1/4)))}).ElseIf(i.equal(T2(4)),()=>{v.assign(h2(c.mul(5)))}).ElseIf(i.equal(T2(5)),()=>{v.assign(S3(l,3))}).ElseIf(i.equal(T2(6)),()=>{let e=r.mul(.25).add(.0125).toVar(),t=S3(r,3).mul(.25).add(.0125).toVar();v.assign(q3(e.sub(e.mul(t)),e.add(e.mul(t)),p))}).ElseIf(i.equal(T2(7)),()=>{v.assign(function(e){return Xee({p3:e})}(m5(n.add(m)).add(s)))}),v}).setLayout({name:"spe_voronoi",type:"float",inputs:[{name:"x",type:"vec3"},{name:"style",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"quality",type:"int"}]}),tte=[wee,_ee,Tee,Aee,Nee]});function rte(e,t,i,r){return ate(e.add(t).mul(i).mul(.001).add(nte).add(r.mul(.1)))}function ste(e,t,i){let r=function(e,t){let i=Math.trunc(e.getValue("noiseType")??0),r={n:t,scale:e.getFloat("scale"),intensity:e.getFloat("intensity"),offset:e.getVec3("offset"),movement:e.getFloat("movement")};if(5===i)return t=>ate(hte({...r,p:t,voronoiStyle:e.getInt("voronoiStyle"),smoothness:e.getFloat("smoothness"),seed:e.getFloat("seed"),highCut:e.getFloat("highCut"),lowCut:e.getFloat("lowCut"),quality:e.getInt("quality")}));let s=function(e){let t=lte.get(e);if(void 0===t){let i=tte[e]??tte[0];t=C1(e=>{let{n:t,scale:r,intensity:s,offset:a,movement:n}=e,o=ate(e.p);return o.add(t.mul(i(rte(o,a,r,n))).mul(s))}).setLayout({name:`spe_displaceScalar${e}`,type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"}]}),lte.set(e,t)}return t}(i);return e=>ate(s({...r,p:e}))}(e,i),s=m5(r(t)).toVar(),a=m5(function(e){return ote({v:e})}(i)).toVar(),n=n3(e2(i,a)).toVar(),o=m5(r(ate(t.add(a)))).toVar(),l=m5(r(ate(t.add(n)))).toVar();return{position:s,normal:ate(n3(e2(o.sub(s),l.sub(s))))}}var ate,nte,ote,lte,hte,ute,dte,cte,pte,mte,gte=n(()=>{b5(),ite(),ate=e=>e,nte=1e-4,ote=C1(e=>{let t=ate(e.v);return n3(ate(k3(O1(t.x).greaterThan(O1(t.z)),m5(t.y.negate(),t.x,0),m5(0,t.z.negate(),t.y))))}).setLayout({name:"spe_displaceOrthogonal",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),lte=new Map,hte=C1(e=>{let{n:t,scale:i,intensity:r,offset:s,movement:a,smoothness:n}=e,o=ate(e.p),l=c2(Bee(rte(o,s,i,a),e.voronoiStyle,n,e.seed,e.quality)).toVar();return l.assign(Oee(l,e.lowCut,e.highCut,c2(0),c2(1))),l.assign(Eee(l,c2(0),n.mul(.25))),l.assign(Ree(l,c2(1),n.mul(.25))),o.add(t.mul(l).mul(r))}).setLayout({name:"spe_displaceVoronoi",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"},{name:"voronoiStyle",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"highCut",type:"float"},{name:"lowCut",type:"float"},{name:"quality",type:"int"}]})}),fte=n(()=>{Y7(),L7("color",(e,t,i)=>{let r=t.alpha.mul(t.mask);return{color:e.getColor("color"),calpha:D7(r,i)}})}),yte=n(()=>{b5(),Y7(),ute=e=>e,dte=e=>e,L7("depth",(e,t,i)=>{let r,s=e.get("colors"),a=e.get("steps"),n=(e.getValue("colors")??s.array).length,o=!0===e.getValue("smooth"),l=(e.getValue("isVector")??1)>.5,h=0===(e.getValue("gradientType")??0),u=(e.getValue("isWorldSpace")??0)>.5,d=e.getFloat("near"),c=e.getFloat("far");if(l){let t=e.getVec3("origin"),i=u?_3:S7;if(h){let s=n3(e.getVec3("direction"));r=o2(s,i.sub(t))}else r=B2(i.sub(t))}else r=B2(_3.sub(j1));let p=r.sub(d).div(c.sub(d)).toVar(),m=g5(s.element(0)).toVar();for(let e=1;e<n;e++){let t=ute(a.element(e-1)),i=ute(a.element(e)),r=$1(p.sub(t).div(i.sub(t)),c2(0),c2(1)),n=o?q3(c2(0),c2(1),r):r;m.assign(q2(m,dte(s.element(e)),n))}let g=t.alpha.mul(m.a).mul(t.mask);return{color:m.rgb,calpha:V7(g,i,t.isMask)}})}),vte=n(()=>{b5(),Y7(),P5(),L7("cavity",(e,t,i)=>{let r=$1(e.getFloat("ridge"),0,2),s=$1(e.getFloat("valley"),0,2),a=N5.normalViewRenderTarget,n=N5.resolution,o=L1("randomColor","vec3").x.toVar(),l=z3.toVar(),h=p5(c2(1).div(n.x),c2(1).div(n.y)).toVar(),u=(e,t)=>a.sample(l.add(p5(e,t)).toVar()).toVar(),d=u(c2(0),h.y.negate()),c=u(c2(0),h.y),p=u(h.x.negate(),c2(0)),m=u(h.x,c2(0)),g=e=>e.a.equal(o).and(o2(e.xyz,e.xyz).greaterThan(.5)),f=g(d).and(g(c)).and(g(p)).and(g(m)),y=d.y.sub(c.y).add(m.x.sub(p.x)).toVar(),v=c2(.5).div(j2(r.mul(r),c2(1e-4))).toVar(),b=c2(.7).div(j2(s.mul(s),c2(1e-4))).toVar(),x=(e,t)=>k3(e.lessThan(c2(.5).div(t)),e.mul(c2(1).sub(e.mul(t))),c2(.25).div(t)),w=k3(f,k3(y.greaterThan(0),x(y,v).mul(2),x(y.negate(),b).mul(-2)),c2(0)).toVar(),_=k3(w.abs().lessThan(.001),c2(0),w).toVar(),S=m5($1(_.mul(.5).add(.5),0,1)),M=k3(_.notEqual(0),c2(1),c2(0)),T=k3(t.isMask,c2(1),M);return{color:S,calpha:V7(t.alpha.mul(t.mask).mul(T),i,t.isMask)}})}),bte=n(()=>{b5(),Y7(),ite(),L7("dust",(e,t,i)=>{let r=e.getFloat("coverage"),s=e.getFloat("softness"),a=e.getFloat("noiseStrength"),n=e.getFloat("noiseScale"),o=o2(n3(a3),m5(0,1,0)),l=c2(0).toVar();A1(a.notEqual(0),()=>{let e=wee(S7.div(n).toVar().add(m5(1.7,9.2,1)));l.assign(e.mul(a))});let h=j2(s,1e-4).toVar(),u=q2(h.add(1),h.add(1).negate(),$1(r,0,1)).toVar(),d=q3(u.sub(h),u.add(h),o.add(l)).mul(t.alpha).mul(t.mask);return{color:e.getColor("color"),calpha:V7(d,i,t.isMask)}})}),xte=n(()=>{b5(),Y7(),cte=(e,t)=>e.element(t),L7("fresnel",(e,t,i)=>{let r=cte(G1,2).w.equal(-1),s=m5(cte(q1,0).z,cte(q1,1).z,cte(q1,2).z).negate(),a=_3.sub(j1),n=k3(r,a,s),o=e.getFloat("bias").add(e.getFloat("scale").mul(S3(O1(e.getFloat("factor").add(o2(n3(n),n3(a3)))),e.getFloat("intensity")))),l=$1(o,0,1).mul(t.alpha).mul(t.mask);return{color:e.getColor("color"),calpha:V7(l,i,t.isMask)}})}),wte=n(()=>{b5(),Y7(),pte=e=>e,mte=e=>e,L7("gradient",(e,t,i)=>{let r=e.get("colors"),s=e.get("steps"),a=(e.getValue("colors")??r.array).length,n=(e.getValue("steps")??s.array).length,o=Math.min(10,a,n),l=e.getInt("gradientType"),h=e.getBool("smooth"),u=e.getVec2("offset"),d=e.getVec2("morph"),c=e.getFloat("angle"),p=u5(),m=g5(r.element(0)).toVar(),g=p5(d.div(p)).toVar(),f=p5(c2(.5).add(g.x),g.y).toVar(),y=p5(Q1(c).mul(f.x).sub(W3(c).mul(f.y)),W3(c).mul(f.x).add(Q1(c).mul(f.y))).toVar(),v=p5(p.sub(.5).add(u).div(2).add(y.div(2))),b=c2(o2(v,y).div(o2(y,y))).toVar();A1(l.equal(T2(1)),()=>{b.assign(n2(p.add(d).mul(3),p.add(u).add(1)).add(c))}).ElseIf(l.equal(T2(2)),()=>{let e=I1(p.x.add(d.x).sub(.5).add(u.x),p.y.add(d.y).sub(.5).add(u.y)).mul(-1);b.assign(g2(c.div(R1).div(-2).add(e.div(R1).mul(.5))))});for(let e=1;e<o;e++){let t=pte(s.element(e-1)),i=pte(s.element(e)),a=$1(b.sub(t).div(i.sub(t)),c2(0),c2(1)),n=pte(k3(h,q3(c2(0),c2(1),a),a));m.assign(q2(m,mte(r.element(e)),n))}let x=t.alpha.mul(m.a).mul(t.mask);return{color:m.rgb,calpha:V7(x,i,t.isMask)}})}),_te=n(()=>{b5(),Y7(),L7("matcap",(e,t,i)=>{let r=e.getFloat("rotation"),s=n3(x3.negate()),a=n3(m5(s.z,0,s.x.negate())),n=e2(s,a),o=p5(o2(a,s3),o2(n,s3)),l=Q1(r),h=W3(r),u=p5(l.mul(o.x).sub(h.mul(o.y)),h.mul(o.x).add(l.mul(o.y))).mul(.495).add(.5),d=e.get("texture").sample(u),c=t.alpha.mul(t.mask);return{color:d.rgb,calpha:V7(c,i,t.isMask)}})}),Ste=n(()=>{b5(),Y7(),ite(),L7("noise",(e,t,i)=>{try{if("0"===new URLSearchParams(window.location.search).get("dbgnoise"))return{color:m5(0),calpha:c2(0)}}catch{}let r=Math.trunc(e.getValue("noiseType")??0),s=c2(j2(O1(e.getFloat("scale")),.001)).toVar(),a=m5(S7.div(e.getVec3("size"))).toVar();a.divAssign(s);let n=e.getFloat("move"),o=e.getVec4("colorA"),l=e.getVec4("colorC"),h=g5(0).toVar();if(5===r){let t=e.getFloat("smoothness"),i=c2(Bee(a.add(n),e.getInt("voronoiStyle"),t,e.getFloat("seed"),e.getInt("quality"))).toVar();i.assign(Oee(i,e.getFloat("lowCut"),e.getFloat("highCut"),c2(0),c2(1))),i.assign(Eee(i,c2(0),t.mul(.25))),i.assign(Ree(i,c2(1),t.mul(.25))),h.assign(q2(o,l,i))}else{let t=tte[r]??tte[0],i=e.getVec4("colorB"),s=e.getVec4("colorD"),u=m5(e.getVec2("distortion"),1).toVar(),d=m5(e.getVec2("fA"),1).toVar(),c=m5(e.getVec2("fB"),1).toVar(),p=m5(t(a),t(a.add(m5(1))),t(a.add(m5(1)))).toVar(),m=m5(t(a.add(u.mul(p)).add(d).add(n)),t(a.add(u.mul(p)).add(c).add(n)),t(a.mul(p))).toVar(),g=c2(t(a.add(m))).toVar();h.assign(q2(o,i,$1(g.mul(g).mul(4),c2(0),c2(1)))),h.assign(q2(h,l,$1(B2(p),c2(0),c2(1)))),h.assign(q2(h,s,$1(B2(m.x),c2(0),c2(1))))}let u=t.alpha.mul(h.a).mul(t.mask);return{color:$1(h,c2(0),c2(1)).rgb,calpha:V7(u,i,t.isMask)}})}),Mte=n(()=>{b5(),Y7(),L7("normal",(e,t,i)=>({color:c3(n3(s3)).mul(X3(m5(.5),e.getVec3("cnormal"))),calpha:D7(t.alpha.mul(t.mask),i)}))});function Tte(e){return Ete({p:e})}function Cte(e,t){return Ote({uv:e,a:t})}function Ate(e,t,i,r,s){return Bte({uv:e,frequency:t,variation:i,zigzag:r,rotation:s})}function Nte(e,t){let i={uv:t.uv,frequency:t.frequency,size:t.size,variation:t.variation,smoothness:t.smoothness,zigzag:t.zigzag,rotation:t.rotation};switch(e){case 1:return Dte(i);case 2:return Lte({...i,sides:t.sides});case 3:return kte(i);case 4:return Fte(i);case 5:return jte(i);case 6:return Gte(i);case 7:return qte(i);default:return Vte(i)}}var Pte,Rte,Ete,Ote,Bte,Vte,Dte,Ite,Lte,zte,kte,Ute,Fte,jte,Gte,Wte,qte,Hte,$te,Yte,Xte,Kte,Zte,Jte,Qte,eie,tie,iie,rie,sie,aie,nie=n(()=>{b5(),Y7(),Pte=2*Math.PI,Rte=Math.PI/180,Ete=C1(e=>{let t=g2(e.p.xyx.mul(.1031)).toVar();return t.addAssign(o2(t,t.yzx.add(33.33))),g2(t.x.add(t.y).mul(t.z))}).setLayout({name:"spe_pattern_hash12",type:"float",inputs:[{name:"p",type:"vec2"}]}),Ote=C1(e=>{let t=e.uv,i=.5,r=c2(e.a.mul(Rte)).toVar(),s=p5(Q1(r).mul(t.x.sub(i)).add(W3(r).mul(t.y.sub(i))).add(i),Q1(r).mul(t.y.sub(i)).sub(W3(r).mul(t.x.sub(i))).add(i));return g2(s)}).setLayout({name:"spe_pattern_rotate_uv",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"a",type:"float"}]}),Bte=C1(e=>{let t=p5(e.uv.mul(e.frequency)).toVar(),i=p5(p2(t)).toVar(),r=c2(H2(i.y,2)).toVar();t.x.addAssign(r.mul(e.zigzag));let s=p5(g2(t)).toVar();s.assign(s.mul(2).sub(1)),i.assign(p2(t));let a=c2(Tte(i).mul(5).add(1)).toVar(),n=c2(q2(c2(1),a,e.variation)).toVar();return s.mulAssign(n),s}).setLayout({name:"spe_pattern_tile_and_center",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"variation",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Vte=C1(e=>{let t=p5(Ate(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return q3(e.smoothness.negate(),e.smoothness,B2(t).sub(e.size))}).setLayout({name:"spe_pattern_circle",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Dte=C1(e=>{let t=p5(Ate(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar(),i=c2(B2(t)).toVar(),r=c2(q3(e.smoothness.negate(),e.smoothness,i.sub(e.size))).toVar(),s=c2(q3(e.smoothness.negate(),e.smoothness,i.sub(e.size.mul(.5)))).toVar();return r.add(l3(s))}).setLayout({name:"spe_pattern_ring",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Ite=C1(e=>{let t=c2(c2(Pte).div(c2(e.n))).toVar(),i=c2(e.r.mul(Q3(t.mul(.5)))).toVar(),r=p5(e.p.yx.negate()).toVar(),s=c2(t.mul(p2(I1(r.y,r.x).add(t.mul(.5)).div(t)))).toVar(),a=p5(Q1(s),W3(s)).toVar();return r.assign(p5(a.x.mul(r.x).add(a.y.mul(r.y)),a.y.negate().mul(r.x).add(a.x.mul(r.y)))),B2(r.sub(p5(e.r,$1(r.y,i.negate(),i)))).mul(G3(r.x.sub(e.r)))}).setLayout({name:"spe_pattern_sdf_ngon",type:"float",inputs:[{name:"p",type:"vec2"},{name:"r",type:"float"},{name:"n",type:"int"}]}),Lte=C1(e=>{let t=p5(Ate(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return q3(e.smoothness.negate(),e.smoothness,Ite({p:t,r:e.size,n:e.sides}))}).setLayout({name:"spe_pattern_polygon",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"},{name:"sides",type:"int"}]}),zte=C1(e=>{let t=e.b,i=p5(O1(e.p)).toVar();i.assign(k3(i.y.greaterThan(i.x),i.yx,i.xy));let r=p5(i.sub(t)).toVar(),s=c2(j2(r.y,r.x)).toVar(),a=p5(k3(s.greaterThan(0),r,p5(t.y.sub(i.x),s.negate()))).toVar();return G3(s).mul(B2(j2(a,p5(0)))).add(e.r)}).setLayout({name:"spe_pattern_sdf_cross",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"},{name:"r",type:"float"}]}),kte=C1(e=>{let t=p5(Ate(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return q3(e.smoothness.negate(),e.smoothness,zte({p:t,b:p5(e.size,e.size.mul(.25)),r:e.smoothness}))}).setLayout({name:"spe_pattern_xcross",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Ute=C1(e=>{let t=e.b,i=p5(O1(e.p)).toVar(),r=p5(t.sub(i.mul(2))).toVar(),s=r.x.mul(t.x).sub(r.y.mul(t.y)),a=c2($1(s.div(o2(t,t)),c2(-1),c2(1))).toVar();return c2(B2(i.sub(t.mul(.5).mul(p5(l3(a),a.add(1)))))).toVar().mul(G3(i.x.mul(t.y).add(i.y.mul(t.x)).sub(t.x.mul(t.y))))}).setLayout({name:"spe_pattern_sdf_diamond",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"}]}),Fte=C1(e=>{let t=p5(Ate(e.uv,e.frequency,e.variation,e.zigzag,e.rotation)).toVar();return q3(e.smoothness.negate(),e.smoothness,Ute({p:t,b:p5(e.size)}))}).setLayout({name:"spe_pattern_diamond",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),jte=C1(e=>{let t=p5(e.uv.mul(e.frequency)).toVar(),i=p5(p2(t)).toVar(),r=c2(H2(i.y,2)).toVar();t.x.addAssign(r.add(e.zigzag.mul(r)));let s=c2(p2(t.x)).toVar();return H2(s,2)}).setLayout({name:"spe_pattern_checkerboard",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Gte=C1(e=>{let t=p5(Ate(e.uv,e.frequency,c2(0),e.zigzag,e.rotation)).toVar(),i=c2(p2(e.uv.mul(e.frequency)).y).toVar(),r=c2(Tte(p5(i))).toVar(),s=c2(q2(e.size,e.size.mul(r),e.variation)).toVar();return q3(s.sub(e.smoothness),s.add(e.smoothness),O1(t.y))}).setLayout({name:"spe_pattern_line",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),Wte=C1(e=>{let{a:t,b:i,c:r,d:s}=e,a=p5(e.p.sub(p5(s,t)).mul(r)).toVar();a.x.assign(H2(a.x,Pte)),A1(a.x.greaterThan(Math.PI),()=>{a.x.assign(c2(Pte).sub(a.x))});let n=c2(0).toVar(),o=c2(Pte).toVar();N1(24,()=>{let e=c2(n.add(o).mul(.5)).toVar(),t=c2(e.sub(a.x).add(i.mul(r).mul(W3(e)).mul(a.y.sub(i.mul(r).mul(Q1(e)))))).toVar();A1(t.lessThan(0),()=>{n.assign(e)}).Else(()=>{o.assign(e)})});let l=c2(n.add(o).mul(.5)).toVar(),h=p5(l,i.mul(r).mul(Q1(l))).toVar();return B2(a.sub(h)).div(r)}).setLayout({name:"spe_pattern_udf_cos",type:"float",inputs:[{name:"p",type:"vec2"},{name:"a",type:"float"},{name:"b",type:"float"},{name:"c",type:"float"},{name:"d",type:"float"}]}),qte=C1(e=>{let t=c2(e.frequency.x).toVar(),i=p5(e.uv.mul(t)).toVar(),r=p5(p2(i)).toVar(),s=c2(H2(r.y,2)).toVar();i.x.addAssign(s.mul(e.zigzag));let a=p5(i.x,g2(i.y)).toVar(),n=c2(e.frequency.y.mul(.1)).toVar(),o=c2(Wte({p:a,a:c2(.5),b:c2(.125),c:n.mul(Pte),d:c2(0)})).toVar(),l=c2(Tte(p5(r.y))).toVar(),h=c2(q2(e.size,e.size.mul(l),e.variation)).toVar();return q3(e.smoothness.negate(),e.smoothness,o.sub(h.mul(.5)))}).setLayout({name:"spe_pattern_wave",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),L7("pattern",(e,t,i)=>{let r,s,a=e.getValue("style")??0,n=e.getValue("projection")??0,o=e.getValue("axis")??0,l=e.getFloat("blending"),h=e.getVec2("offset"),u=e.getVec4("colorA"),d=e.getVec4("colorB"),c=e.getVec2("frequency"),p=e.getFloat("size"),m=e.getFloat("variation"),g=e.getFloat("smoothness"),f=e.getFloat("zigzag"),y=e.getFloat("rotation"),v=e.getVec2("vertical"),b=e.getVec2("horizontal"),x=e.getInt("sides"),w={frequency:c,size:p,variation:m,smoothness:c2(S3(g,5)).toVar(),zigzag:f,rotation:y,sides:x};if(4===n){let e=m5(S7).toVar(),t=c2(.0125).toVar(),i=p5(g2(e.xy.mul(t))).toVar(),n=p5(g2(e.zy.mul(t))).toVar(),o=p5(g2(e.xz.mul(t))).toVar();i.assign(Cte(i.add(h),y)),n.assign(Cte(n.add(h),y)),o.assign(Cte(o.add(h),y));let u=c2(Nte(a,{uv:i,...w})).toVar(),d=c2(Nte(a,{uv:n,...w})).toVar(),c=c2(Nte(a,{uv:o,...w})).toVar(),p=c2(l3(l).mul(125).add(3)).toVar(),m=m5(M7).toVar(),g=m5(O1(n3(m))).toVar();g.assign(S3(g,m5(p))),g.divAssign(o2(g,m5(1))),u.mulAssign(g.z),d.mulAssign(g.x),c.mulAssign(g.y),r=c2(u.add(d).add(c)).toVar(),s=p5(i.mul(g.z).add(n.mul(g.x)).add(o.mul(g.y))).toVar()}else{let e=p5(0).toVar();if(0===n)e.assign(u5());else if(2===n){let t,i,r=m5(S7).toVar(),s=c2(B2(r)).toVar();0===o?(t=c2(I1(r.y,r.z)).toVar(),i=c2(B1(r.x.div(s))).toVar()):1===o?(t=c2(I1(r.x,r.z)).toVar(),i=c2(B1(r.y.div(s))).toVar()):(t=c2(I1(r.y,r.x)).toVar(),i=c2(B1(r.z.div(s))).toVar()),e.assign(p5(t,i).div(Math.PI))}e.addAssign(h),e.assign(g2(e)),e.assign(Cte(e,y)),r=Nte(a,{uv:e,...w}),s=e}let _=g5(q2(u,d,r)).toVar();_.a.assign($1(_.a,c2(0),c2(1))),_.a.mulAssign(X3(v.x,s.y).mul(X3(s.y,v.y))),_.a.mulAssign(X3(b.x,O1(s.x)).mul(X3(O1(s.x),b.y)));let S=t.alpha.mul($1(_.a,c2(0),c2(1))).mul(t.mask);return{color:$1(_,g5(0),g5(1)).rgb,calpha:V7(S,i,t.isMask)}})}),oie=n(()=>{b5(),Y7(),ite(),Hte=(e,t)=>e.element(t),L7("rainbow",(e,t,i)=>{let r=e.getFloat("filmThickness"),s=e.getFloat("movement"),a=e.getVec3("wavelengths"),n=e.getFloat("noiseStrength"),o=e.getFloat("noiseScale"),l=e.getVec3("offset"),h=c2(0).toVar();!1!==t.noiseCompiledIn&&A1(n.notEqual(0),()=>{let e=S7.div(o).toVar(),t=wee(e.mul(1.6).add(m5(1.8,1.5,1.9).mul(wee(e))).add(m5(1.7,9.2,1)));h.assign(t.mul(n))});let u=a.mul(m5(1,.8,.6)).add(1),d=Hte(G1,2).w.equal(-1),c=m5(Hte(q1,0).z,Hte(q1,1).z,Hte(q1,2).z).negate(),p=_3.sub(j1),m=k3(d,p,c),g=o2(n3(m.add(l.mul(-.001))),n3(a3)),f=Q1(r.add(h).div(u).mul(g).add(s)).mul(.5).add(.5),y=m5($1(f,0,2)).toVar(),v=$1(y.r.add(y.g).add(y.b),0,1);return{color:y,calpha:V7(t.alpha.mul(v).mul(t.mask),i,t.isMask)}})}),lie=n(()=>{b5(),Y7(),P5(),$te=e=>e,Yte=e=>e,Xte=N1,Kte=N1,Zte=C1(e=>{let t=e.x,i=m5(o2(t,m5(127.1,311.7,74.7)),o2(t,m5(269.5,183.3,246.1)),o2(t,m5(113.5,271.9,124.6)));return g2(W3(i).mul(43758.5453123))}).setLayout({name:"spe_toonHash3",type:"vec3",inputs:[{name:"x",type:"vec3"}]}),Jte=C1(e=>{let t=e.x,i=p2(t).toVar(),r=g2(t).toVar(),s=c2(100).toVar(),a=()=>({start:T2(-1),end:T2(1),condition:"<=",type:"int"});return Kte(a(),a(),a(),({i:e,j:t,k:a})=>{let n=m5(e,t,a).toVar(),o=n.sub(r).add(function(e){return Zte({x:e})}(i.add(n))).toVar(),l=o2(o,o).toVar();A1(l.lessThan(s),()=>{s.assign(l)})}),s.sqrt()}).setLayout({name:"spe_toonVoronoiF1",type:"float",inputs:[{name:"x",type:"vec3"}]}),L7("toon",(e,t,i)=>{let r=e.getInt("positioning"),s=e.get("colors"),a=e.get("steps"),n=e.getVec3("source"),o=e.getBool("isWorldSpace"),l=e.getFloat("noiseStrength"),h=e.getFloat("noiseScale"),u=e.getVec4("shadowColor"),d=e.getVec3("offset"),c=n3(a3),p=c2(0).toVar();!0===i.lightsAvailable&&A1(r.equal(T2(0)),()=>{Xte({start:T2(0),end:N5.toonLightCount,condition:"<",type:"int"},({i:e})=>{let t=N5.toonLightData.element(e).toVar(),i=t.xyz,r=t.w,s=k3(r.greaterThan(.5),n3(i),n3(i.sub(_3))),a=o2(s,c).mul(.5).add(.5);p.assign(j2(p,a))}),p.assign($1(p,0,1))}),A1(r.equal(T2(1)),()=>{let e=q2(S7,_3,k3(o,c2(1),c2(0))),t=n3(n.sub(e));p.assign(o2(t,c).mul(.5).add(.5))}).ElseIf(r.equal(T2(2)),()=>{let e=j1.sub(d),t=n3(e.sub(_3));p.assign(o2(t,c).mul(.5).add(.5))}),A1(l.greaterThan(0),()=>{let e=S7.div(h),t=c2(1).sub(Jte({x:e}));p.addAssign(t.mul(l))}),p.assign($1(p,0,1));let m=(e.getValue("colors")??s.array).length,g=(e.getValue("steps")??a.array).length,f=Math.min(10,m,g),y=g5(s.element(0)).toVar();for(let e=1;e<f;e++){let t=$te(a.element(e-1)),i=$te(a.element(e)),r=$1(p.sub(t).div(i.sub(t)),c2(0),c2(1));y.assign(q2(y,Yte(s.element(e)),q3(0,1,r)))}!0===i.lightsAvailable&&A1(r.equal(T2(0)),()=>{let e=c2(1),t=q2(y.rgb,u.rgb,u.a);y.rgb.assign(q2(t,y.rgb,e))});let v=t.alpha.mul(y.a).mul(t.mask);return{color:y.rgb,calpha:D7(v,i)}})}),hie=n(()=>{b5(),Y7(),C7(),P5(),Qte=e=>e,eie=(e,t)=>e.element(t),tie=e=>e,iie=e=>e,rie=e=>e,L7("transmission",(e,t,i)=>{let r=e.getFloat("thickness"),s=e.getFloat("ior"),a=e.getFloat("roughness"),n=N5.transmissionRenderTarget,o=N5.transmissionSamplerSize,l=e=>eie(q1,e),h=n3(m5(l(0).z.negate(),l(1).z.negate(),l(2).z.negate())),u=n3(_3.sub(j1)),d=N5.orthographicUniform,c=k3(d.greaterThan(.5),h,u).toVar(),p=n3(a3).toVar(),m=E3(c,p,c2(1).div(s)).toVar(),g=n3(m).mul(r).mul(T7).toVar(),f=e=>{let t=N5.unjitteredProjection.mul(q1).mul(g5(e,1)),i=t.xy.div(t.w);return p5(i.x.mul(.5).add(.5),i.y.mul(-.5).add(.5))},y=f(_3.add(g).toVar()).toVar(),v=(f(_3).toVar(),a.mul($1(s.mul(2).sub(2),c2(0),c2(1))).toVar()),b=I2(o.x).mul(v).toVar(),x=v,w=W2(b.div(5.5),c2(8.5)).toVar(),_=null,S="fit",M=!0,T=!1,C=12,A="white",N=1;try{let e=new URLSearchParams(window.location.search),t=e.get("dbglod");null!==t&&(_=Number(t));let i=e.get("dbgtap");"ring"===i&&(S="ring"),("single"===i||"1"===i)&&(S="single"),("r50"===i||"r75"===i||"full"===i)&&(S=i),"singlewide"===i&&(S="singlewide"),("fit"===i||"singlefit"===i)&&(S="fit");let r=e.get("dbgwidth");null!==r&&Number.isFinite(Number(r))&&(N=Math.max(0,Number(r))),"6"===i&&(S="ring",C=6),"0"===e.get("dbgwarp")&&(M=!1),"1"===e.get("dbgdither")&&(T=!0);let s=e.get("dbgangle");("classic"===s||"0"===s)&&(A=s)}catch{}null!==_&&Number.isFinite(_)&&w.assign(c2(_));let P,R=(()=>{if("singlewide"===S)return W2(w.add(1),c2(8.5)).toVar();if("fit"!==S)return w;let e=N5.transmissionActualSize.x.div(N5.resolution.x),t=x.mul(w).mul(5*N).mul(e).toVar();return W2(I2(u2(w.mul(2)).add(t.mul(t).mul(3))).mul(.5),c2(8.5)).toVar()})(),E=e=>n.sample(M?(e=>{let t=N5.transmissionActualSize.div(u2(p2(R))),i=e.mul(t).sub(.5),r=p2(i),s=i.sub(r),a=s.mul(s).mul(p5(3,3).sub(s.mul(2)));return r.add(.5).add(a).div(t)})(e):e).level(R).rgb,O="r50"===S?.5:"r75"===S?.75:1;if("single"===S||"singlewide"===S||"fit"===S)if("fit"===S){let e=p2(R).toVar(),t=R.sub(e).toVar(),i=Y3(u2(t.mul(2)).sub(1)).mul(1.1547).toVar(),r=p5(u2(e)).div(N5.transmissionActualSize).mul(i).toVar(),s=m5(0).toVar(),a=12;for(let t=0;t<a;t++){let i=tie(b2(t,a,c2(0))),o=tie(y.add(i.mul(r)));s.addAssign(iie(rie(n.sample(o).level(e)).rgb))}P=s.div(a).toVar()}else P=E(y).toVar();else{let e=p5(c2(1).div(N5.resolution.x),c2(1).div(N5.resolution.y)).toVar(),t=v2("classic"===A?L3.xy.add(N5.cameraJitterPx):L3.xy).mul(6.28318530718);"white"===A&&(t=t.add(N5.tapAngle));let i=t.toVar(),r=N5.tapAngle.mul(13.7).toVar(),s=N5.tapAngle2.mul(5.3).toVar(),a=p5(u2(p2(R).add(1))).div(N5.transmissionActualSize).toVar(),n=v2(L3.xy.add(p5(r,s))).toVar(),o=v2(L3.xy.add(p5(s.mul(1.71),r.mul(2.39)))).toVar(),l=m5(0).toVar();for(let t=0;t<C;t++){let r=tie(b2(t,C,i)).mul(e).mul(x).mul(w.mul(10)).mul(O),s=tie(y.add(r));if(T){let e=Qte(g2(n.add(.7548776662*t))),i=Qte(g2(o.add(.5698402911*t))),r=tie(p5(e.sub(.5),i.sub(.5)).mul(a));s=tie(s.add(r))}l.addAssign(E(s))}P=l.div(C).toVar()}if(e.has("attenuationDistance")){let t=e.getFloat("attenuationDistance"),i=m5(e.getColor("attenuationColor")).toVar();A1(t.greaterThan(0),()=>{let e=S3(j2(i,m5(1e-4)),m5(r.div(t)));P.mulAssign(e)})}let B=t.alpha.mul(t.mask).toVar(),V=B.div($1(B.add(i.accumAlpha),c2(1e-5),c2(1))).toVar();return i.accumAlpha.addAssign(c2(1).sub(i.accumAlpha).mul(t.alpha)),{color:P,calpha:V}})}),uie=n(()=>{b5(),Y7(),P5(),r6(),L7("reflection",(e,t,i)=>{let r=e.getFloat("blur"),s=e.getFloat("thickness"),a=e.getInt("steps"),n=e.getFloat("stepSize"),o=e.getValue("tracingMode")??0,l=N5.reflectionRenderTarget,h=N5.reflectionDepthPyramid,u=N5.reflectionDepthPyramid,d=N5.reflectionDepthLevels,c=N5.reflectionEnvMap,p=N5.reflectionPlanarTarget,m=N5.reflectionPlanarEnabled,g=h5("__splinePlanarMirror","float"),f=m.greaterThan(.5).and(g.greaterThan(.5)),y=N5.reflectionResolveTarget,v=N5.reflectionResolveEnabled,b=N5.orthographicUniform.greaterThan(.5),x=k3(b,m5(0,0,-1),n3(x3)).toVar(),w=n3(s3).toVar(),_=R3(x,w).toVar(),S=$1(r.mul(.1),c2(0),c2(1)).toVar(),M=N5.resolution,T=m5(0).toVar(),C=v.greaterThan(.5).and(S.greaterThan(.05)).and(f.not()),A=n3(r5(_,H1)).toVar(),N=X4(c,A,S).toVar(),P=y.sample(z3).level(c2(0)).toVar();A1(C,()=>{let e=P.a.toVar();T.assign(q2(N,P.rgb.div(e.max(1e-4)),$1(e.mul(2),c2(0),c2(1))))}).Else(()=>{T.assign(K4({dials:{blur:r,thickness:s,steps:a,stepSize:n,tracingMode:o},surface:{originView:x3,normalV:w,screenUv:z3,fragWindowZ:s2},camera:{projectionMatrix:G1,projectionMatrixInverse:W1,worldMatrix:H1,near:F1},resources:{colorMap:l,depthPyramid:h,depthPyramidNode:u,envMap:c},usePlanar:f,noisePixel:z3.mul(M).floor()}))}),A1(f,()=>{let e=p5(c2(1).sub(z3.x),z3.y).toVar(),t=c2(d.sub(1)),i=W2(I2(S.mul(M.y).mul(H4).add(1)),t).toVar(),r=i.sub(1).max(0).floor().toVar(),s=c2(2).pow(i).sub(1).max(0).toVar(),a=s.mul(.75).div(M.y).toVar();T.assign($4(p,e,a,s.mul(.75),r))});let R=t.alpha.mul(t.mask).toVar(),E=R.div($1(R.add(i.accumAlpha),c2(1e-5),c2(1))).toVar();return i.accumAlpha.addAssign(c2(1).sub(i.accumAlpha).mul(R)),{color:T,calpha:E}})}),die=n(()=>{b5(),Y7(),P5(),sie=e=>e,aie=e=>e,L7("outline",(e,t,i)=>{let r=e.getColor("outlineColor"),s=e.getColor("contourColor"),a=e.getFloat("outlineWidth"),n=e.getFloat("contourWidth"),o=e.getFloat("outlineThreshold"),l=e.getFloat("contourThreshold"),h=e.getFloat("outlineSmoothing"),u=e.getFloat("contourFrequency"),d=e.getVec3("contourDirection"),c=e.getBool("positionalLines"),p=e.getBool("compensation"),m=N5.normalRenderTarget,g=N5.normalRenderTargetDepth,f=N5.resolution,y=N5.pixelRatio,v=L1("randomColor","vec3").x.toVar(),b=s2.toVar(),x=z3.toVar(),w=p5(c2(1).div(f.x),c2(1).div(f.y)).toVar(),_=N5.pcssHalton,S=v2(L3.xy.add(_)).mul(6.28318530718).toVar(),M=p.select(a.div(2),a),T=w.mul(M).mul(y).toVar(),C=[[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]],A=e=>b2(e,9,S).mul(w),N=[],P=c2(0).toVar();for(let e=0;e<9;e++){let[t,i]=C[e],r=4===e?x:sie(x.add(p5(T.x.mul(t),T.y.mul(i))).add(A(e))),s=sie(r).toVar(),a=aie(m.sample(s)).toVar();N.push(a),A1(a.a.notEqual(v).and(a.a.notEqual(0)),()=>{let e=g.sample(s).r.add(1e-4);A1(b.greaterThan(e),()=>{P.assign(1)})})}let R=N[2].rgb.add(N[5].rgb.mul(2)).add(N[8].rgb).sub(N[0].rgb.add(N[3].rgb.mul(2)).add(N[6].rgb)),E=N[0].rgb.add(N[1].rgb.mul(2)).add(N[2].rgb).sub(N[6].rgb.add(N[7].rgb.mul(2)).add(N[8].rgb)),O=Y3(o2(R,R).add(o2(E,E))).mul(P.oneMinus()).toVar(),B=m5(r).toVar(),V=q3(o.sub(h),o.add(h),O).toVar(),D=n3(a3).toVar(),I=c2(1).sub(l).toVar();A1(c,()=>{let e=S7.mul(d),t=e.x.add(e.y).add(e.z).toVar(),i=g2(t.mul(u).mul(.01)),r=y2(t.mul(u)),a=q3(r.mul(n.mul(.01)),r.mul(n.mul(.02)),i).toVar();A1(a.lessThan(1).and(V.equal(0)),()=>{B.assign(s),V.assign(1)})}).Else(()=>{let e=D.mul(d),t=e.x.add(e.y).add(e.z).toVar(),i=y2(t.mul(l)).toVar(),r=W3(t.mul(u)).toVar(),a=q3(c2(0),i.mul(n),c2(1).sub(r)).toVar();A1(i.greaterThan(I.mul(.5)).and(a.lessThan(1)).and(V.equal(0)),()=>{B.assign(s),V.assign(c2(1).sub(a))})});let L=t.alpha.mul(V).mul(t.mask).toVar(),z=L.div($1(L.add(i.accumAlpha),c2(1e-5),c2(1))).toVar();return i.accumAlpha.addAssign(c2(1).sub(i.accumAlpha).mul(L)),{color:B,calpha:z}})}),cie=n(()=>{b5(),Y7(),L7("vertexColor",(e,t,i)=>{let r=y5(),s=t.alpha.mul(t.mask).mul(r.a);return{color:r.rgb,calpha:D7(s,i)}})}),pie=n(()=>{fte(),yte(),vte(),bte(),xte(),wte(),_te(),Ste(),Mte(),nie(),oie(),bee(),lie(),hie(),uie(),die(),cie(),see()});function mie(e){let t=e.data,i=[e.kind,e.type,`v=${!!t.visible}`,`m=${!!t.isMask}`,`p=${e.params.names().join(",")}`];if("light"!==e.type){let r=_T[e.type];if(void 0!==r)for(let e of r)i.push(`${e}=${String(t[e])}`)}for(let[t,r]of e.uniformKinds)("vec4array"===r||"floatArray"===r)&&i.push(`${t}#${(e.params.getValue(t)??[]).length}`);if("rainbow"===e.type&&i.push(`noise=${!1!==e.noiseCompiledIn}`,`forced=${!0===e.noiseForced}`),"displace"===e.type&&i.push(`dt=${String(t.displacementType)}`),"texture"===e.type||"video"===e.type||"matcap"===e.type){if(0===e.holders.length)throw new Error(`structuralKey: ${e.type} layer has no holder`);let r=t.texture??{};i.push(`holder=${e.holders.map(e=>e.instanceId).join(",")}`,`wrap=${String(r.wrapping)}`,`min=${String(r.minFilter)}`,`mag=${String(r.magFilter)}`)}return i.join(";")}var gie=n(()=>{AT()});function fie(e,t=1){let i=new aa(e);return new Yx(i.r,i.g,i.b,t)}function yie(e,t){if(e instanceof Yx)return e;if(e instanceof aa)return new Yx(e.r,e.g,e.b,1);if("number"==typeof e)return fie(e);if("object"==typeof e&&null!==e&&"r"in e&&"g"in e&&"b"in e){let t=e;return new Yx(t.r,t.g,t.b,t.a??1)}return t()}function vie(){let e=new Array(10).fill(new Ss(0,0,0,1)).map(e=>e.clone());return e[1]=new Ss(1,1,1,1),e}function bie(){let e=new Array(10).fill(1);return e[0]=0,e}function xie(e,t){let i=e.material;if((null==i||!0!==i.isTSLNodeMaterial)&&(i=e.object?.material,null==i||!0!==i.isTSLNodeMaterial))return t;if("light"===t.kind){let e=i.lightLayer;if(null==e)return t;let r=e.data?.category,s=t.data?.category;return r===s?e:t}let r=i.layers?.[t.structIndex];return void 0!==r&&r.type===t.type?r:t}function wie(e,t){if("number"!=typeof t||!Number.isInteger(t)||t<0)throw new Error(`[spe] ${e}.element() needs a build-time constant index (got ${String(t)}). Array params are inlined as per-slot uniforms; a dynamic index needs a real uniformArray.`);return t}function _ie(e,t,i,r){let s,a,n=e.params;switch(i){case"float":s=n5(Number(r??0));break;case"int":s=n5(Number(r??0),"int");break;case"axis":s=n5(["x","y","z"].indexOf(String(r)),"int");break;case"bool":s=n5(!!r);break;case"vec2":s=n5(r instanceof rs?r:new rs);break;case"vec3":s=n5(r instanceof ns?r:new ns);break;case"vec4":s=n5(r instanceof Ss?r:new Ss);break;case"color":{let e=yie(r,()=>fie(16777215));s=n5(e),a=e;break}case"colorVec4":{let i=yie(r,()=>new Yx(1,1,1,1)),n=new Ss(i.r,i.g,i.b,i.a),o=n5(n);o.onObjectUpdate(r=>{let s=xie(r,e).params.getLiveValue(t)??i;n.set(s.r,s.g,s.b,s.a)}),s=o,a=i;break}case"vec4array":{let i=Array.isArray(r)?r:[];s=function(e,t,i){let r=new Map;return{element(s){let a=wie(t,s),n=r.get(a);if(void 0===n){let s=n5(i[a]??new Ss);s.onObjectUpdate(r=>(xie(r,e).params.getValue(t)??i)[a]??Eie),n=s,r.set(a,n)}return n},array:i,get value(){return i},set value(e){if(Array.isArray(e))for(let t=0;t<Math.min(i.length,e.length);t++){let r=e[t];Array.isArray(r)?i[t].set(r[0]??0,r[1]??0,r[2]??0,r[3]??1):r&&"object"==typeof r&&i[t].set(r.x??0,r.y??0,r.z??0,r.w??1)}}}}(e,t,i.length>0?i:[new Ss]),a=i;break}case"floatArray":{let i=Array.isArray(r)?r:[0];s=function(e,t,i){let r=new Map;return{element(s){let a=wie(t,s),n=r.get(a);if(void 0===n){let s=n5(i[a]??0);s.onObjectUpdate(r=>{let s=xie(r,e).params.getValue(t);return Number((s??i)[a]??0)}),n=s,r.set(a,n)}return n},array:i,get value(){return i},set value(e){if(Array.isArray(e))for(let t=0;t<Math.min(i.length,e.length);t++)i[t]=Number(e[t])}}}(e,t,i.length>0?i:[0]),a=i;break}}"vec4array"!==i&&"floatArray"!==i&&"colorVec4"!==i&&(A7(s),s.onObjectUpdate(i=>{let r=xie(i,e).params.getValue(t);void 0!==r&&P7(s,r)})),n.set(t,s,a),e.uniformKinds.set(t,i)}function Sie(e,t){let i=e.data;"displace"!==i.type?("alpha"in i&&e.params.has("alpha")&&e.params.setValue("alpha",xT(i.alpha,t)*(i.visible?1:0)),"outline"===i.type&&e.params.has("compensation")&&e.params.setValue("compensation",!!i.compensation&&!!i.visible)):e.params.has("intensity")&&e.params.setValue("intensity",(wT(i.intensity,t)??1)*(i.visible?1:0))}function Mie(e,t){_ie(e,"alpha","float",t.alpha??1),_ie(e,"mode","int",t.mode??0),_ie(e,"isMask","float",t.isMask?1:0)}function Tie(e,t,i,r){let s=new Vie(e,t,i),a=i;if(_ie(s,"alpha","float",xT(a.alpha,r)),_ie(s,"mode","int",a.mode??0),_ie(s,"bumpMapIntensity","float",a.bumpMapIntensity??5),_ie(s,"alphaOverride","float",xT(a.alphaOverride,r)),i.visible)if("lambert"===a.category)_ie(s,"emissive","color",r.color(a.emissive)??fie(0)),_ie(s,"occlusion","bool",a.occlusion??!0);else if("toon"===a.category)_ie(s,"shininess","float",a.shininess??30),_ie(s,"specular","color",r.color(a.specular)??fie(1118481));else if("physical"===a.category){_ie(s,"roughness","float",a.roughness??.3),_ie(s,"metalness","float",a.metalness??0),_ie(s,"reflectivity","float",a.reflectivity??.5),_ie(s,"occlusion","bool",a.occlusion??!0),_ie(s,"normalScale","float",a.normalScale??1),_ie(s,"aoMapIntensity","float",a.aoMapIntensity??1),_ie(s,"emissive","color",void 0!==a.emissive?r.color(a.emissive)??fie(0):fie(0)),_ie(s,"emissiveIntensity","float",a.emissiveIntensity??1);let e=a;void 0!==e.clearcoat&&(_ie(s,"clearcoat","float",e.clearcoat),_ie(s,"clearcoatRoughness","float",e.clearcoatRoughness??.1)),void 0!==e.sheen&&(_ie(s,"sheen","float",e.sheen),_ie(s,"sheenColor","color",void 0!==e.sheenColor?r.color(e.sheenColor)??fie(16777215):fie(16777215)),_ie(s,"sheenRoughness","float",e.sheenRoughness??.5)),void 0!==e.ior&&(_ie(s,"ior","float",e.ior),_ie(s,"specularIntensity","float",e.specularIntensity??1),_ie(s,"specularColor","color",void 0!==e.specularColor?r.color(e.specularColor)??fie(16777215):fie(16777215))),void 0!==e.iridescence&&(_ie(s,"iridescence","float",e.iridescence),_ie(s,"iridescenceIOR","float",e.iridescenceIOR??1.3),_ie(s,"iridescenceThickness","float",e.iridescenceThickness??400))}else _ie(s,"shininess","float",a.shininess??30),_ie(s,"specular","color",void 0!==a.specular?r.color(a.specular)??fie(1118481):fie(1118481)),_ie(s,"occlusion","bool",a.occlusion??!0);return s.node.alphaOverride=s.params.get("alphaOverride"),Sie(s,r),s}function Cie(e,t,i,r){let s=new Bie("fragment",e,t,i),a="texture"===i.type?null!=i.texture.image?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.getImage(""):"video"===i.type?r.video(i.texture.video):null!=i.texture.image?r.image(i.texture.image):r.getImage("");s.holders.push(a);let n=i.texture.wrapping??("texture"===i.type?1e3:1001),o=function(e,t,i,r){let s=e5(e.getTexture(t,i,r));return s.onRenderUpdate(()=>e.getTexture(t,i,r)),s}(a,n,i.texture.minFilter??1008,i.texture.magFilter??1006);s.params.set("texture",o);let l=wT(i.texture.rotation??0,r)??0;if("matcap"===i.type)_ie(s,"rotation","float",l*ts.DEG2RAD);else{let e=n5(new rs(1,1));e.onRenderUpdate(()=>{let t=a.getTexture(n,i.texture.minFilter??1008,i.texture.magFilter??1006).image;e.value.set(t?.width??1,t?.height??1)}),s.params.set("textureSize",e),s.uniformKinds.set("textureSize","vec2");let t=n5(a.loaded||a.isBuffer?1:0);t.onRenderUpdate(()=>a.loaded||a.isBuffer?1:0),s.params.set("loaded",t),s.uniformKinds.set("loaded","float"),_ie(s,"crop","float",i.crop?1:0),_ie(s,"projection","int",i.projection??0),_ie(s,"axis","axis",i.axis),_ie(s,"projectionAxis","axis",i.projectionAxis),_ie(s,"side","int",i.side??0);let o=i.size?new rs(wT(i.size[0],r)??0,wT(i.size[1],r)??0):new rs(100,100);_ie(s,"size","vec2",o),_ie(s,"blending","float",i.blending??0);let h=new us,u=new Oie([wT(i.texture.repeat?.[0]??1,r)??1,wT(i.texture.repeat?.[1]??1,r)??1],[wT(i.texture.offset?.[0]??0,r)??0,wT(i.texture.offset?.[1]??0,r)??0],l,h),d=n5(h);A7(d),d.onObjectUpdate(e=>{let t=xie(e,s).params.getNodeValue("mat");void 0!==t&&P7(d,t)}),s.params.set("mat",d,u)}return Mie(s,{alpha:xT(i.alpha,r),mode:i.mode??0,isMask:i.isMask??!1}),Sie(s,r),s}function Aie(e,t,i,r){if("light"===i.type)return Tie(e,t,i,r);if("texture"===i.type||"video"===i.type||"matcap"===i.type)return Cie(e,t,i,r);if("displace"===i.type)return function(e,t,i,r){if("noise"!==i.displacementType)throw new Error;let s=new Bie("vertex",e,t,i),a=(e,t)=>wT(e,r)??t;return _ie(s,"offset","vec3",new ns(...i.offset.map(e=>a(e,0)))),_ie(s,"scale","float",a(i.scale,10)),_ie(s,"intensity","float",a(i.intensity,8)),_ie(s,"movement","float",a(i.movement,1)),_ie(s,"noiseType","int",i.noiseType??0),_ie(s,"voronoiStyle","int",i.voronoiStyle??0),_ie(s,"smoothness","float",a(i.smoothness,.5)),_ie(s,"seed","float",a(i.seed,0)),_ie(s,"highCut","float",a(i.highCut,1)),_ie(s,"lowCut","float",a(i.lowCut,0)),_ie(s,"quality","int",wT(i.quality,r)??1),Sie(s,r),s}(e,t,i,r);let s=new Bie("fragment",e,t,i),a=function(e,t){switch(e.type){case"cavity":return function(e,t){return{...f7(e,t),ridge:e.ridge,valley:e.valley}}(e,t);case"dust":return function(e,t){return{...f7(e,t),color:gC(e.color,t),coverage:wT(e.coverage,t)??.2,softness:wT(e.softness,t)??.2,noiseStrength:wT(e.noiseStrength,t)??.2,noiseScale:wT(e.noiseScale,t)??1}}(e,t);case"fresnel":return function(e,t){let{bias:i,scale:r,intensity:s,factor:a,color:n}=e;return{...f7(e,t),color:gC(n,t),bias:i,scale:r,intensity:s,factor:a}}(e,t);case"gradient":return function(e,t){let{gradientType:i,smooth:r,colors:s,steps:a,angle:n,offset:o,morph:l}=e;return{...f7(e,t),gradientType:i,smooth:r,colors:s.map(e=>new Ss(e[0],e[1],e[2],e[3])),num:s.length,steps:a,offset:new rs(...o.map(e=>"number"==typeof e?e:0)),morph:new rs(...l.map(e=>"number"==typeof e?e:0)),angle:n}}(e,t);case"depth":return function(e,t){let{gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:o,direction:l,colors:h,steps:u,smooth:d}=e;return{...f7(e,t),gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:new ns(...o),direction:l?new ns(...l):new ns(1,0,0),colors:h.map(e=>void 0!==e?new Ss(e[0],e[1],e[2],e[3]):new Ss(0,0,0,0)),steps:u.slice(0,h.length),smooth:d}}(e,t);case"normal":return function(e,t){let{cnormal:i}=e;return{...f7(e,t),cnormal:new ns(i[0],i[1],i[2])}}(e,t);case"noise":return function(e,t){return{...f7(e,t),scale:e.scale,move:e.move,fA:new rs(...e.fA.map(e=>"number"==typeof e?e:0)),fB:new rs(...e.fB.map(e=>"number"==typeof e?e:0)),size:new ns(...e.size),distortion:new rs(...e.distortion.map(e=>"number"==typeof e?e:0)),colorA:gC(e.colorA,t),colorB:gC(e.colorB,t),colorC:gC(e.colorC,t),colorD:gC(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}(e,t);case"rainbow":return function(e,t){return{...f7(e,t),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new ns(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new ns(...e.offset)}}(e,t);case"toon":return function(e,t){return{...f7(e,t),positioning:e.positioning,colors:e.colors.map(e=>new Ss(e[0],e[1],e[2],e[3])),num:e.colors.length,steps:e.steps,source:new ns(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:gC(e.shadowColor,t),offset:new ns(...e.offset)}}(e,t);case"outline":return function(e,t){return{...f7(e,t),outlineColor:gC(e.outlineColor,t),contourColor:gC(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new ns(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}(e,t);case"transmission":return function(e,t){return{...f7(e,t),thickness:e.thickness,ior:e.ior,roughness:e.roughness,attenuationColor:void 0!==e.attenuationColor?gC(e.attenuationColor,t):{r:1,g:1,b:1,a:1},attenuationDistance:e.attenuationDistance??0}}(e,t);case"reflection":return function(e,t){return{...f7(e,t),blur:wT(e.blur,t)??0,thickness:wT(e.thickness,t)??.001,steps:wT(e.steps,t)??60,stepSize:wT(e.stepSize,t)??.005,tracingMode:e.tracingMode,mirror:e.mirror??0}}(e,t);case"pattern":return function(e,t){return{...f7(e,t),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new rs(...e.offset.map(e=>"number"==typeof e?e:0)),colorA:gC(e.colorA,t),colorB:gC(e.colorB,t),frequency:new rs(...e.frequency.map(e=>"number"==typeof e?e:0)),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new rs(...e.vertical.map(e=>"number"==typeof e?e:0)),horizontal:new rs(...e.horizontal.map(e=>"number"==typeof e?e:0)),sides:e.sides}}(e,t);case"vertexColor":return f7(e,t);default:return function(e,t){return{...f7(e,t),color:gC(e.color,t)}}(e,t)}}(i,r),n=Rie[i.type]??Rie.color;for(let[e,t]of Object.entries(n))_ie(s,e,t.kind,a[e]??t.def());if("transmission"===i.type){let e=typeof window<"u"?window.innerWidth:1,t=typeof window<"u"?window.innerHeight:1;_ie(s,"aspectRatio","vec2",e>=t?new rs(t/e,1):new rs(1,e/t))}return Mie(s,a),Sie(s,r),s}var Nie,Pie,Rie,Eie,Oie,Bie,Vie,Die,Iie,Lie,zie=n(()=>{Mu(),v5(),b5(),Bv(),vT(),y7(),AT(),rw(),gw(),Y7(),see(),D4(),bee(),gte(),pie(),T4(),gie(),Nie=e=>e,Pie=e=>e,Rie={color:{color:{kind:"color",def:()=>fie(ym)}},vertexColor:{},cavity:{ridge:{kind:"float",def:()=>1},valley:{kind:"float",def:()=>1}},fresnel:{color:{kind:"color",def:()=>fie(16777215)},bias:{kind:"float",def:()=>.1},scale:{kind:"float",def:()=>1},intensity:{kind:"float",def:()=>2},factor:{kind:"float",def:()=>1}},dust:{color:{kind:"color",def:()=>fie(10323813)},coverage:{kind:"float",def:()=>.2},softness:{kind:"float",def:()=>.2},noiseStrength:{kind:"float",def:()=>.2},noiseScale:{kind:"float",def:()=>1}},rainbow:{filmThickness:{kind:"float",def:()=>30},movement:{kind:"float",def:()=>0},wavelengths:{kind:"vec3",def:()=>new ns},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},offset:{kind:"vec3",def:()=>new ns}},transmission:{thickness:{kind:"float",def:()=>10},ior:{kind:"float",def:()=>1.5},roughness:{kind:"float",def:()=>.5},attenuationColor:{kind:"color",def:()=>fie(16777215)},attenuationDistance:{kind:"float",def:()=>0}},reflection:{blur:{kind:"float",def:()=>0},thickness:{kind:"float",def:()=>.001},steps:{kind:"int",def:()=>60},stepSize:{kind:"float",def:()=>.005},tracingMode:{kind:"int",def:()=>1}},toon:{positioning:{kind:"int",def:()=>0},colors:{kind:"vec4array",def:vie},steps:{kind:"floatArray",def:bie},source:{kind:"vec3",def:()=>new ns},isWorldSpace:{kind:"bool",def:()=>!0},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},shadowColor:{kind:"colorVec4",def:()=>new Yx(0,0,0,0)},offset:{kind:"vec3",def:()=>new ns}},outline:{outlineColor:{kind:"color",def:()=>fie(16777215)},contourColor:{kind:"color",def:()=>fie(16777215)},outlineWidth:{kind:"float",def:()=>.1},contourWidth:{kind:"float",def:()=>.1},outlineThreshold:{kind:"float",def:()=>.1},contourThreshold:{kind:"float",def:()=>.1},outlineSmoothing:{kind:"float",def:()=>.1},contourFrequency:{kind:"float",def:()=>.1},contourDirection:{kind:"vec3",def:()=>new ns(0,1,0)},positionalLines:{kind:"bool",def:()=>!1},compensation:{kind:"bool",def:()=>!0}},depth:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},near:{kind:"float",def:()=>50},far:{kind:"float",def:()=>200},isVector:{kind:"float",def:()=>1},isWorldSpace:{kind:"float",def:()=>0},origin:{kind:"vec3",def:()=>new ns},direction:{kind:"vec3",def:()=>new ns(1,0,0)},colors:{kind:"vec4array",def:()=>[new Ss(0,0,0,1),new Ss(1,1,1,1)]},steps:{kind:"floatArray",def:()=>[0,1]}},noise:{scale:{kind:"float",def:()=>1},size:{kind:"vec3",def:()=>new ns(100,100,100)},move:{kind:"float",def:()=>1},fA:{kind:"vec2",def:()=>new rs(1.7,9.2)},fB:{kind:"vec2",def:()=>new rs(8.3,2.8)},distortion:{kind:"vec2",def:()=>new rs(1,1)},colorA:{kind:"colorVec4",def:()=>new Yx(.4,.4,.4,1)},colorB:{kind:"colorVec4",def:()=>new Yx(.4,.4,.4,1)},colorC:{kind:"colorVec4",def:()=>new Yx(1,1,1,1)},colorD:{kind:"colorVec4",def:()=>new Yx(1,1,1,1)},noiseType:{kind:"int",def:()=>0},voronoiStyle:{kind:"int",def:()=>0},highCut:{kind:"float",def:()=>1},lowCut:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},seed:{kind:"float",def:()=>.5},quality:{kind:"int",def:()=>1}},normal:{cnormal:{kind:"vec3",def:()=>new ns(1,1,1)}},gradient:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},colors:{kind:"vec4array",def:vie},steps:{kind:"floatArray",def:bie},offset:{kind:"vec2",def:()=>new rs},morph:{kind:"vec2",def:()=>new rs},angle:{kind:"float",def:()=>0}},pattern:{style:{kind:"int",def:()=>0},projection:{kind:"int",def:()=>0},axis:{kind:"axis",def:()=>"x"},blending:{kind:"float",def:()=>0},offset:{kind:"vec2",def:()=>new rs},colorA:{kind:"colorVec4",def:()=>new Yx(0,0,0,1)},colorB:{kind:"colorVec4",def:()=>new Yx(1,1,1,1)},frequency:{kind:"vec2",def:()=>new rs(10,10)},size:{kind:"float",def:()=>.5},variation:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},zigzag:{kind:"float",def:()=>0},rotation:{kind:"float",def:()=>0},vertical:{kind:"vec2",def:()=>new rs(0,1)},horizontal:{kind:"vec2",def:()=>new rs(0,1)},sides:{kind:"int",def:()=>6}}},Eie=new Ss,Oie=class{constructor(e,t,i,r){this.repeat=e,this.offset=t,this.rotation=i,this.target=r,this.updateMatrix()}updateMatrix(){this.target.setUvTransform(this.offset[0],this.offset[1],this.repeat[0],this.repeat[1],0,0,0).premultiply((new us).makeRotation(this.rotation*ts.DEG2RAD))}},Bie=class{constructor(e,t,i,r){this.kind=e,this.id=t,this.uuid=i,this.data=r,this.uniformKinds=new Map,this.holders=[],this.structIndex=-1,this.params=new E7(t)}get type(){return this.data.type}get uniforms(){return this.params.uniforms}get alphaNode(){return this.params.getFloat("alpha")}get modeNode(){return this.params.getInt("mode")}get isMaskNode(){return this.params.getFloat("isMask")}get isMaskEnabled(){return"isMask"in this.data&&!!this.data.isMask}hasValue(e){return this.params.has(e)}setValue(e,t){if("noiseStrength"===e&&!1===this.noiseCompiledIn&&"number"==typeof t&&0!==t&&void 0!==this.onNoiseMismatch){let i=this.onNoiseMismatch;return this.onNoiseMismatch=void 0,this.params.setValue(e,t),void(i(t)&&(this.noiseCompiledIn=!0))}this.params.setValue(e,t)}getNode(e){return this.params.has(e)?this.params.get(e):void 0}getValue(e){return this.params.getValue(e)}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){return this.params.names()}get assetsLoaded(){return this.holders.every(e=>e.loaded)}dispose(){for(let e of this.holders)e instanceof cw||e.deref();this.holders.length=0}},Vie=class extends Bie{constructor(e,t,i){super("light",e,t,i),this.node={alphaOverride:void 0,alpha:{value:1}}}get lightData(){return this.data}get category(){return this.lightData.category??"phong"}},Die={displace_noise:[{nums:["intensity","scale","movement","smoothness","seed","highCut","lowCut"],vecs:["offset"]}],displace_map:[{nums:["intensity"],vecs:[]}],depth:[{nums:["near","far"],vecs:["origin","direction"]}],cavity:[{nums:["ridge","valley"],vecs:[]}],fresnel:[{nums:["bias","scale","intensity","factor"],vecs:[]}],dust:[{nums:["coverage","softness","noiseStrength","noiseScale"],vecs:[]}],rainbow:[{nums:["filmThickness","movement","noiseStrength","noiseScale"],vecs:["offset","wavelengths"]}],noise:[{nums:["scale","move","seed","highCut","lowCut","smoothness"],vecs:["size","distortion","fA","fB"]}],pattern:[{nums:["blending","size","variation","smoothness","zigzag","rotation"],vecs:["offset","frequency","vertical","horizontal"]}],outline:[{nums:["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],vecs:["contourDirection"]}],toon:[{nums:["noiseStrength","noiseScale"],vecs:["offset","source"]}],transmission:[{nums:["roughness","thickness","ior"],vecs:[]}],reflection:[{nums:["blur","thickness","steps","stepSize"],vecs:[]}],texture:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],video:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],gradient:[{nums:["angle"],vecs:["offset","morph"]}],matcap:[{nums:["rotation"],vecs:[],path:["texture"]}]},Iie=class extends UU{constructor(e,t,i=!0,r){super(),this.allowVariableSaves=i,this.isTSLNodeMaterial=!0,this.layerIdGen=0,this.layers=[],this.flavors=[],this.flatShading=!1,this.wireframe=!1,this.emissiveNode=null,this.shapeBlendOptions=null,this.envMapRotation=P4.rotation,this._shapeBlendResources=null,this._shapeBlendColorNode=null,this.shapeBlendObjectNormal=null,this.displacedObjectNormal=null,this.syntheticMapLayers=new Map,this._structuralKey=null,this._structuralKeyVersion=-1,this.forceRainbowNoise=new Set,this.root=r??this,this.fog=!0,this.dithering=!0,this.vertexColors=!1,this.transparent=!0,r?(this.lastContext=r.lastContext,this.syncFromRoot()):this.reset0(e,t),R4.add(this),this.addEventListener("dispose",()=>function(e){R4.delete(e)}(this))}_invalidateStructuralKey(){this._structuralKey=null,this._structuralKeyVersion=-1}customProgramCacheKey(){let e=this._structuralKey;if(null===e||this._structuralKeyVersion!==this.version){try{e=function(e){let t=e.lightLayer,i=t.data,r=t=>{if(!t)return-1;if("string"!=typeof t){let i=e.syntheticMapLayers?.get(t);return void 0!==i?`img(${mie(i)};o=${JSON.stringify(t.offset??null)};r=${JSON.stringify(t.repeat??null)})`:"img"}let i=e.layers.findIndex(e=>e.uuid===t);if(-1===i||"fragment"!==e.layers[i].kind)return-1;let r=e.layers[i].type;return"texture"===r||"video"===r?i:-1},s="physical"===e.category,a=["spe-tsl-v1",`lights=${e.lights}`,`cat=${e.category}`,`lvis=${!0===i.visible}`,`lidx=${e.layers.indexOf(t)}`,`bump=${r(i.bumpMap)}`,`rough=${s?r(i.roughnessMap):-1}`,`metal=${s?r(i.metalnessMap):-1}`,`nrm=${s?r(i.normalMap):-1}`,`ao=${s?r(i.aoMap):-1}`,`emis=${s?r(i.emissiveMap):-1}`,`rch=${s?i.roughnessMapChannel??"luminance":""}`,`mch=${s?i.metalnessMapChannel??"b":""}`,`ach=${s?i.aoMapChannel??"r":""}`];for(let t of e.layers)a.push(mie(t));return a.join("|")}(this),null!==this.shapeBlendOptions&&(e+=`|sb:${this.uuid}:${null!==this._shapeBlendResources?1:0}`)}catch{e=super.customProgramCacheKey()}this._structuralKey=e,this._structuralKeyVersion=this.version}let t=this.envNode instanceof O4?P4.version:0,i=this.physicalLobes();return`${e}|env${t}|lobes${(i.clearcoat?1:0)|(i.sheen?2:0)|(i.iridescence?4:0)}`}get isRoot(){return this.root===this}get category(){return this.lightLayer.category}envReflectiveInLow(){let e=!1;for(let t of this.layers){let i=t.data;if("physical"===i?.category&&(e=!0,void 0!==i.roughnessMap||void 0!==i.metalnessMap||"number"!=typeof i.roughness||"number"!=typeof i.metalness||void 0!==i.clearcoat||void 0!==i.sheen||void 0!==i.iridescence||void 0!==i.ior||i.metalness>.3||i.roughness<.4))return!0}return!e}get hasAO(){return this.lightLayer.getValue("occlusion")??!1}get fragment(){}reset(e,t,i=!1){(this.data!==e||i)&&this.reset0(e,t)}reset0(e,t){this.lastContext=t,this.data=e;let i=e.layers??Lg.defaultTwoLayerData("phong").layers;for(let e of this.layers)e.dispose();for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear();let r=[];for(let e of i)try{let i=Aie(this.layerIdGen++,e.id,e.data,t.shared);"rainbow"===i.type&&this.armRainbowNoiseSpecialization(i),r.push(i)}catch(t){console.warn(`[spe] material layer '${e.data.type}' (${e.id}) failed to build — skipping this layer`,t)}this.layers=r,this.layers.reverse();for(let e=0;e<this.layers.length;e++)this.layers[e].structIndex=e;this.name=e.name??"Untitled Material";let s=this.layers.find(e=>e instanceof Vie);if(void 0===s&&(s=Tie(0,"",{...Ig.defaultData("light","phong"),visible:!1},t.shared)),this.lightLayer=s,this.lights=!!this.lightLayer.data.visible,this.ctx={accumAlpha:c2(0).toVar("accumAlpha"),lightsAvailable:this.lights&&("phong"===this.category||"lambert"===this.category||"physical"===this.category)},this.colorNode=C1(()=>this.buildColorStack())(),this.buildVertexStack(),this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=this.lights&&"lambert"===this.category&&this.lightLayer.params.has("emissive")?this.lightLayer.params.get("emissive"):null,this.aoNode=null,this.lights&&"physical"===this.category){let e=this.lightLayer.params,t=this.lightLayer.lightData;if(e.has("emissive")){let i=this.findTextureMapLayer(t.emissiveMap);this.emissiveNode=C1(()=>{let t=m5(e.getColor("emissive")).mul(e.getFloat("emissiveIntensity"));return null!==i&&(t=t.mul(function(e){let t,i=e.get("texture"),r=e.has("loaded")?e.getFloat("loaded"):c2(1),{uvs:s,weights:a}=lee(e);if(null!==a){let e=m5(gee(i.sample(s[0])).rgb).toVar(),r=m5(gee(i.sample(s[1])).rgb).toVar(),n=m5(gee(i.sample(s[2])).rgb).toVar();t=mee(e.mul(a.z).add(r.mul(a.x)).add(n.mul(a.y)))}else t=mee(m5(gee(i.sample(s[0])).rgb));return mee(q2(m5(0),t,r))}(i.params))),t})()}let i=this.findTextureMapLayer(t.aoMap);null!==i&&(this.aoNode=C1(()=>q2(c2(1),dee(i.params,t.aoMapChannel??"r"),e.getFloat("aoMapIntensity")))())}this.transparent=yT(e,t.shared),C4(this),this.needsUpdate=!0;for(let e of this.flavors)e?.syncFromRoot();this.saveVariableLocations(t)}setTransparent(e,t){if(this.isRoot){if(this.transparent!==e){this.transparent=e,this.needsUpdate=!0;for(let t of this.flavors)void 0!==t&&(t.transparent=e,t.needsUpdate=!0);t?.markNeedsUpdateRendererDirty()}}else this.root.setTransparent(e,t)}syncFromRoot(){let e=this.root;this.data=e.data,this.layers=e.layers,this.lightLayer=e.lightLayer,this.ctx=e.ctx,this.name=e.name,this.lights=e.lights,this.colorNode=e.colorNode,this.positionNode=e.positionNode,this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=e.emissiveNode,this.aoNode=e.aoNode,this.transparent=e.transparent,this._applyShapeBlendGraph(),C4(this),this.needsUpdate=!0}getFlavor(e,t,i,r){if(!this.isRoot)return this.root.getFlavor(e,t,i,r);let s=i?6:(e?3:0)+t;if(s+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),0===s)return this;s-=1;let a=this.flavors[s];return void 0===a&&(a=new Iie(this.data,this.lastContext,this.allowVariableSaves,this),a.flatShading=e,a.side=t,a.wireframe=i,r&&(a.shapeBlendOptions={...r},a.defines={SHAPEBLEND:r.resolutionLevel,SHAPEBLEND_C:r.useChildrenColors?1:0},a._invalidateStructuralKey()),this.flavors[s]=a),a}getShapeBlendBaseColor(){let e=this.layers.find(e=>"fragment"===e.kind&&"color"===e.type),t=e?.getValue("color"),i=e?.getValue("alpha");return{r:t?.r??1,g:t?.g??1,b:t?.b??1,a:i??1}}setShapeBlendResources(e){this._shapeBlendResources=e,this._applyShapeBlendGraph()}_applyShapeBlendGraph(){if(!this.shapeBlendOptions||!this._shapeBlendResources)return;if(null===_4)return;let e=_4(this._shapeBlendResources);this.positionNode=e.position,this.shapeBlendObjectNormal=e.normal,this.normalNode=this.buildNormalNode(e3(s5(e.normal))),this.castShadowPositionNode=e.position,this.shapeBlendOptions.useChildrenColors&&(this._shapeBlendColorNode=e.color,this.colorNode=C1(()=>this.buildColorStack())()),this.needsUpdate=!0}lightLayerIndex(){return this.layers.findIndex(e=>e instanceof Vie)}findTextureMapLayer(e){if(!e)return null;if("string"!=typeof e)return Cg.is(e)?this.syntheticMapLayer(e):null;let t=this.layers.find(t=>t.uuid===e);return void 0===t||"fragment"!==t.kind?null:"texture"===t.type||"video"===t.type?t:null}syntheticMapLayer(e){if(!this.isRoot)return this.root.syntheticMapLayer(e);let t=this.syntheticMapLayers.get(e);if(void 0!==t)return t;try{let t=Ig.defaultData("texture"),i={...t,visible:!1,texture:{...t.texture,image:e.image,wrapping:e.wrapping??1e3,offset:e.offset??[0,0],repeat:e.repeat??[1,1],minFilter:e.minFilter??1008,magFilter:e.magFilter??1006}},r=Cie(this.layerIdGen++,`mapImage${this.layerIdGen}`,i,this.lastContext.shared);return this.syntheticMapLayers.set(e,r),r}catch(e){return console.warn("[spe] light-layer map image failed to build — skipped",e),null}}buildNormalNode(e){if(this.lights&&"physical"===this.category&&!this.wireframe){let t=this.lightLayer.lightData,i=this.findTextureMapLayer(t.normalMap);if(null!==i){let t=this.lightLayer.params.getFloat("normalScale");return C1(()=>function(e,t,i){let r=m5(i??s3).toVar(),s=mee(x3),a=e.get("texture"),n=e.has("loaded")?e.getFloat("loaded"):c2(1),o=e=>{let i=p5(e).toVar(),o=m5(gee(a.sample(i)).rgb.mul(2).sub(1)).toVar(),l=m5(q2(m5(0,0,1),mee(o),n)).toVar();l.xy.mulAssign(t);let h=m5(i2(s)).toVar(),u=m5(r2(s)).toVar(),d=p5(i2(i)).toVar(),c=p5(r2(i)).toVar(),p=m5(n3(mee(r))).toVar(),m=m5(e2(mee(u),p)).toVar(),g=m5(e2(p,mee(h))).toVar(),f=m5(mee(m).mul(d.x).add(mee(g).mul(c.x))).toVar(),y=m5(mee(m).mul(d.y).add(mee(g).mul(c.y))).toVar(),v=c2(j2(o2(mee(f),mee(f)),o2(mee(y),mee(y)))).toVar(),b=c2(k3(v.equal(0),c2(0),cee(d2).mul(C2(v)))).toVar();return mee(n3(mee(f).mul(l.x.mul(b)).add(mee(y).mul(l.y.mul(b))).add(p.mul(l.z))))},{uvs:l,weights:h}=lee(e);if(null!==h){let e=o(l[0]),t=o(l[1]),i=o(l[2]);return mee(n3(e.mul(h.z).add(t.mul(h.x)).add(i.mul(h.y))))}return o(l[0])}(i.params,t,e))()}}let t=this.findTextureMapLayer(this.lightLayer.lightData.bumpMap),i=this.lights&&"lambert"!==this.category;if(null===t||!i||this.wireframe)return e;let r=this.lightLayer.params.getFloat("bumpMapIntensity");return C1(()=>function(e,t,i){let r=m5(i??s3).toVar(),s=mee(x3),a=e.get("texture"),{uvs:n,weights:o}=lee(e);if(null!==o){let e=uee(s,mee(r),hee(a,n[0],t)),i=uee(s,mee(r),hee(a,n[1],t)),l=uee(s,mee(r),hee(a,n[2],t));return mee(n3(e.mul(o.z).add(i.mul(o.x)).add(l.mul(o.y))))}return uee(s,mee(r),hee(a,n[0],t))}(t.params,r,e))()}buildVertexStack(){let e=this.layers.filter(e=>"vertex"===e.kind);if(0===e.length)return this.positionNode=null,void(this.displacedObjectNormal=null);let t=function(e){let t=c5("vec3","vDisplacedNormal");return{position:C1(i=>{let r=ate(v3),s=ate(r3);for(let t=0;t<e.length;t++){let i=ste(e[t],ate(v3),s);r=0===t?i.position:ate(r.add(i.position).mul(.5)),s=i.normal}let a=m5(r).toVar();return t.assign(s),!0===i.needsPreviousData?.()&&b3.assign(a),a})(),normal:t}}(e.map(e=>e.params));this.positionNode=t.position,this.displacedObjectNormal=t.normal}displacedNormalView(){let e=this.root.displacedObjectNormal;return null===e?null:e3(s5(e))}maskSourceFor(e){let t=this.layers[e];if("fragment"===t.kind&&t.isMaskEnabled)return null;let i=this.layers[e+1];return void 0!==i&&"fragment"===i.kind&&i.isMaskEnabled&&i.data.visible?i:null}runLayerBuilder(e,t,i){let r=c2(1);null!==t&&(r=this.evaluateMask(t));let s={alpha:i?.alpha??e.alphaNode,isMask:e.isMaskNode,mask:r,mode:e.modeNode,noiseCompiledIn:e.noiseCompiledIn},a=z7(e.type)(e.params,s,this.ctx);return i?.color?{...a,color:i.color}:a}evaluateMask(e){let t=this.runLayerBuilder(e,null);return L2(t.color.mul(t.calpha))}buildColorStack(){let e=this.lightLayerIndex(),t=-1===e?0:e,i=null;for(let e=0;e<t;e++){let t=this.layers[e];if("fragment"!==t.kind)continue;if(null===i){let r=this._shapeBlendColorNode;i=Pie(this.runLayerBuilder(t,this.maskSourceFor(e),r?{color:Pie(r.rgb),alpha:Nie(r.w)}:void 0).color);continue}if(t.isMaskEnabled)continue;let r=this.runLayerBuilder(t,this.maskSourceFor(e));i=I7(i,r.color,r.calpha,t.modeNode)}return i??Z1(ym)}setup(e){e.context.setupClearcoatNormal=()=>J3(s3,"NORMAL","vec3"),super.setup(e)}setupLightingModel(){let e=this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null;return function(e,t=null,i=null,r=!1){switch(e){case"physical":{let e=new ree(!0===i?.clearcoat,!0===i?.sheen,!0===i?.iridescence,!1,!1,!1);return e.envIrradianceActive=r,e}case"lambert":return new bF(!1);case"toon":{let e=new iee;return e.aoOcclusionGate=t,e}default:return new bF}}(this.category,e,this.physicalLobes(),this.envNode instanceof O4)}physicalLobes(){let e=this.lightLayer.params;return{clearcoat:e.has("clearcoat"),sheen:e.has("sheen"),iridescence:e.has("iridescence")}}setupVariants(e){if(!this.lights)return;let t=null,i=null;if("physical"===this.category){let e=this.lightLayer.lightData,r=this.findTextureMapLayer(e.roughnessMap);null!==r&&(t=C1(()=>dee(r.params,e.roughnessMapChannel??"luminance"))());let s=this.findTextureMapLayer(e.metalnessMap);null!==s&&(i=C1(()=>dee(s.params,e.metalnessMapChannel??"b"))())}!function(e,t,i=null,r=null){if("phong"===e||"toon"===e)j3.assign(t.getFloat("shininess").max(1e-4)),H3.assign(t.getColor("specular"));else if("physical"===e){let e=t.getFloat("metalness"),s=t.getFloat("roughness"),a=t.getFloat("reflectivity");if(null!==i&&(s=Q7(i.mul(s))),null!==r&&(e=Q7($1(r.mul(e),c2(0),c2(1)))),G2.assign(e),B3.assign($1(s,c2(.0525),c2(1))),t.has("ior")){let i=t.getFloat("ior"),r=t.has("specularColor")?m5(t.getColor("specularColor")):m5(1),s=t.has("specularIntensity")?t.getFloat("specularIntensity"):c2(1);A2.assign(i),H3.assign(W2(M3(A2.sub(1).div(A2.add(1))).mul(r),m5(1)).mul(s)),Z7.assign(q2(J7(H3),J7(a2.rgb),e)),$3.assign(q2(s,c2(1),e))}else{let t=m5(a.pow(2).mul(.16));H3.assign(t),Z7.assign(q2(t,J7(a2.rgb),e)),$3.assign(c2(1))}if(K7.assign(J7(a2.rgb).mul(l3(e))),t.has("clearcoat")&&(Y1.assign(t.getFloat("clearcoat")),K1.assign($1(t.getFloat("clearcoatRoughness"),c2(.0525),c2(1)))),t.has("sheen")){let e=t.has("sheenColor")?m5(t.getColor("sheenColor")):m5(1);U3.assign(e.mul(t.getFloat("sheen"))),F3.assign($1(t.getFloat("sheenRoughness"),c2(.07),c2(1)))}t.has("iridescence")&&(N2.assign(t.getFloat("iridescence")),P2.assign(t.getFloat("iridescenceIOR")),R2.assign(t.getFloat("iridescenceThickness")))}}(this.category,this.lightLayer.params,t,i)}setupLighting(e){let t=!0===this.lights||null!==this.lightsNode,i=!0===this.lights?this.setupMaterialLightings(e):[],r=t?this.lightsNode??e.lightsNode:null,s=!0===this.lights?m5(0):a2.rgb,a=m5(0),n=m5(0);if(r&&(i.length>0||r.getScope().hasLights)){let e=this.setupLightingModel()||null,t=D2(r,e,i,this.backdropNode,this.backdropAlphaNode),o=t,l=o._value??(o._value=o.getContext());a=l.reflectedLight.directSpecular,n=l.reflectedLight.indirectSpecular,s=t}return null!==this.emissiveNode&&void 0!==this.emissiveNode&&(l2.assign(m5(this.emissiveNode)),s=s.add(l2)),C1(()=>this.applyPostLighting(s,a,n))()}applyPostLighting(e,t,i){let r,s=this.ctx.accumAlpha,a=!0===this.lights,n=this.lightLayerIndex(),o=-1===n?0:n+1,l=c2(1);if(a){let s=-1===n?null:this.maskSourceFor(n);null!==s&&(l=this.evaluateMask(s)),r=function(e){let{outgoing:t,directSpecular:i,indirectSpecular:r,shadingAlpha:s,shadingBlend:a,mask:n,occlusion:o=null,ctx:l}=e,h=m5(t).toVar();return A1(V1(o3(h,J7(a2.rgb))),()=>{let e=$1(B2(i.add(r)),c2(0),c2(1));l.accumAlpha.addAssign(l3(l.accumAlpha).mul(s).mul(n).mul(e)),h.assign(I7(J7(a2.rgb),h,s.mul(n),a)),h.mulAssign(X7(o))}),h}({outgoing:e,directSpecular:t,indirectSpecular:i,shadingAlpha:this.lightLayer.alphaNode,shadingBlend:this.lightLayer.modeNode,mask:l,occlusion:this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null,ctx:this.ctx})}else r=m5(e).toVar();let h=r,u=!1;for(let e=o;e<this.layers.length;e++){let t=this.layers[e];if("fragment"!==t.kind||t.isMaskEnabled)continue;let i=this.runLayerBuilder(t,this.maskSourceFor(e));h=I7(h,i.color,i.calpha,t.modeNode),u=!0}if(u&&r.assign(h),!a){let e=-1===n?null:this.maskSourceFor(n);null!==e&&(l=this.evaluateMask(e))}let d=this.lightLayer.params.has("alphaOverride")?this.lightLayer.params.getFloat("alphaOverride"):c2(1),c=a?s:s.mul(l);if(a2.a.assign(c.mul(d)),a2.a.lessThanEqual(c2(0)).discard(),this.dithering){let e=N3(L3.xy),t=m5(.25/255,-.25/255,.25/255),i=q2(t.mul(2),t.mul(-2),e);r.assign(r.add(i))}return r}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}armRainbowNoiseSpecialization(e){let t=this.root.forceRainbowNoise.has(e.uuid),i=e.data;if(e.noiseForced=t,e.noiseCompiledIn=t||bT(i.noiseStrength),!1===e.noiseCompiledIn){let t=e.uuid;e.onNoiseMismatch=e=>this.root.ensureRainbowNoiseCompiled(t,e)}}ensureRainbowNoiseCompiled(e,t){if(!this.isRoot)return this.root.ensureRainbowNoiseCompiled(e,t);let i=this.data.layers?.data(e);return void 0!==i&&"rainbow"===i.type&&(!this.forceRainbowNoise.has(e)&&!bT(i.noiseStrength)||!1===this.getLayerByUuid(e)?.noiseCompiledIn)&&(this.forceRainbowNoise.add(e),this.reset0(this.data,this.lastContext),void 0!==t&&this.getLayerByUuid(e)?.setValue("noiseStrength",t),!0)}updateByOp(e,t,i){if(this.isRoot)if(void 0!==t?this.data=t:t=this.data,this.setTransparent(yT(t,i.shared),i.scene),"layers"===e.path[0]){let r=e.path[1];if(void 0===r)return i.scene.markNeedsUpdateRendererDirty(),void this.reset0(t,i);0===e.type&&void 0!==e.props.occlusion&&i.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(e=>e.uuid===r);if(!s)return;let a=t.layers.data(r);if(!a)return;this.updateLayerByOp(s,{...e,path:e.path.slice(2)},a,i)?this.reset0(t,i):C4(this)}else this.reset0(t,i);else this.root.updateByOp(e,t,i)}static hasVariableString(e){return"string"==typeof e||Array.isArray(e)&&e.some(e=>"string"==typeof e)}updateLayerTextureByOp(e,t,i){if(1!==t.path.length||0!==t.type)return!0;let r=t.props,s=i.texture;if(!s)return!0;let a=e.data.texture;for(let e of Object.keys(r))if("repeat"!==e&&"offset"!==e&&"rotation"!==e||Iie.hasVariableString(s[e])||Iie.hasVariableString(a?.[e]))return!0;if("matcap"===e.type)return"repeat"in r||"offset"in r||(e.data=i,e.setValue("rotation",(s.rotation??0)*ts.DEG2RAD),!1);let n=e.getValue("mat");if(!n)return!0;if(e.data=i,"repeat"in r){let e=s.repeat;n.repeat=[e?.[0]??1,e?.[1]??1]}if("offset"in r){let e=s.offset;n.offset=[e?.[0]??0,e?.[1]??0]}return"rotation"in r&&(n.rotation=s.rotation??0),n.updateMatrix(),!1}updateLayerByOp(e,t,i,r){if("texture"===t.path[0])return this.updateLayerTextureByOp(e,t,i);if(void 0!==t.path[0]||0!==t.type)return!0;let s=t.props;if("type"in s||"category"in s||"visible"in s||"noiseType"in s)return r.scene.markNeedsUpdateRendererDirty(),!0;for(let t of Object.keys(s)){if("isMask"===t)return!0;if("rainbow"===e.type&&"noiseStrength"===t&&void 0!==e.noiseCompiledIn){let r=i[t];if((!0===e.noiseForced||bT(r))!==e.noiseCompiledIn)return!0}let r=_T[e.type];if(void 0!==r&&r.includes(t))return!0;let a=ST[e.type];if(void 0!==a&&a.includes(t)){let i=e.getValue(t),r=s[t];if(Array.isArray(i)&&Array.isArray(r)&&i.length!==r.length)return!0}let n=i[t],o=e.data[t];if("axis"!==t&&("string"==typeof n||"string"==typeof o)||Array.isArray(n)&&n.some(e=>"string"==typeof e)||Array.isArray(o)&&o.some(e=>"string"==typeof e))return!0}e.data=i;for(let t of Object.keys(s))this.applyLayerValue(e,t,i,r.shared);return!1}applyLayerValue(e,t,i,r){let s=i;if(("alpha"===t||"visible"===t||"intensity"===t)&&(Sie(e,r),"intensity"!==t||"displace"===e.type))return;if("alphaOverride"===t&&e instanceof Vie)return void e.setValue("alphaOverride",xT(s[t],r));if(!e.hasValue(t))return;let a=e.uniformKinds.get(t),n=s[t];switch(a){case"color":case"colorVec4":{let i=e.getValue(t),s="string"==typeof n?r.color(n):yie(n,()=>i??new Yx(1,1,1,1));i&&s&&i.setRGBA(s.r,s.g,s.b,"a"in s?s.a:1);break}case"vec2":{let i=e.getValue(t);i&&Array.isArray(n)&&i.set(Number(n[0]??i.x),Number(n[1]??i.y));break}case"vec3":{let i=e.getValue(t);i&&Array.isArray(n)&&i.set(Number(n[0]??i.x),Number(n[1]??i.y),Number(n[2]??i.z));break}case"vec4array":{let i=e.getValue(t);if(i&&Array.isArray(n))for(let e=0;e<Math.min(i.length,n.length);e++){let t=n[e];i[e].set(t[0],t[1],t[2],t[3])}break}case"floatArray":{let i=e.getValue(t);if(i&&Array.isArray(n))for(let e=0;e<Math.min(i.length,n.length);e++)i[e]=Number(n[e]);break}case"axis":e.setValue(t,["x","y","z"].indexOf(String(n)));break;case"bool":e.setValue(t,!!n);break;default:("number"==typeof n||"boolean"==typeof n)&&e.setValue(t,n)}}onVariableUpdate(e,t,i){if("alphaOverride"===e[0])return this.setTransparent(yT(this.data,i.shared),i.scene),void this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));if("layer"!==e[0])return;let r=e[1],s=e[2];if(!r||!s)return;let a=this.layers.find(e=>e.uuid===r);if(!a?.hasValue(s))return;if("alpha"===s)return this.setTransparent(yT(this.data,i.shared),i.scene),void a.setValue(s,Math.max(0,Math.min(Number(t)/100,1)));let n=a.getValue(s),o=e[3];("x"===o||"y"===o||"z"===o)&&n?.isVector3||("x"===o||"y"===o)&&n?.isVector2?n[o]=Number(t):n instanceof ws||a.setValue(s,t)}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers?.find(e=>"light"===e.data.type);t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(t=>{let i=t.data;"alpha"in i&&"string"==typeof i.alpha&&e.shared.getVariable(i.alpha,["material",this.uuid,"layer",t.id,"alpha"]);let r="displace"===t.data.type?"noise"===i.displacementType?"displace_noise":"displace_map":t.data.type,s=Die[r];if(s)for(let r of s){let s=i;for(let e of r.path??[])e in s&&(s=s[e]);for(let i of r.nums)i in s&&e.shared.getVariable(s[i],["material",this.uuid,"layer",t.id,...r.path??[],i]);for(let i of r.vecs)i in s&&s[i].forEach((s,a)=>{e.shared.getVariable(s,["material",this.uuid,"layer",t.id,...r.path??[],i,0===a?"x":1===a?"y":"z"])})}})}clampUniformsForPreview(e,t){let i=(e,t,i)=>Math.min(Math.max(e,t),i);for(let r of this.layers)if("displace"===r.type){let s=r.uniforms[`f${r.id}_intensity`];s.value=i(s.value,e,t)}}updateFrame(){}assetsLoaded(){if(!this.layers.every(e=>e.assetsLoaded))return!1;for(let e of this.root.syntheticMapLayers.values())if(!e.assetsLoaded)return!1;return!0}nodeMaterialDispose(){if(this.isRoot){for(let e of this.layers)e.dispose();for(let e of this.syntheticMapLayers.values())e.dispose();this.syntheticMapLayers.clear()}this.dispose();for(let e of this.flavors)e?.dispose()}},Lie=class extends Iie{constructor(e,t,i){super(e,t,!1),this.isTSLSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}}}),kie=n(()=>{}),Uie=n(()=>{}),Fie=n(()=>{}),jie=n(()=>{});function Gie(e,t,i){let r=qie(e.element(t));return Wie(r.element(i))}var Wie,qie,Hie,$ie,Yie,Xie=n(()=>{Mu(),v5(),b5(),Wie=e=>e,qie=e=>e,Hie=c5("vec4","vSplatColor"),$ie=c5("vec2","vSplatPosition"),Yie=class extends UU{constructor(e){super(),this.uniformsNeedUpdate=!1,this._covariancesTex=e5(new ws),this._centersColorsTex=e5(new ws),this._meshMatrixWorldsTex=e5(new ws),this._focal=n5(new rs),this._viewport=n5(new rs),this._basisViewport=n5(new rs),this._covariancesTextureSize=n5(new rs(1024,1024)),this._centersColorsTextureSize=n5(new rs(1024,1024)),this._orthoZoom=n5(-1),this._velocityMRT=J2({velocity:g5(0)}),this.name="WebGPUSplatMaterial",this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.side=qe,this.lights=!1;let t=e=>({get value(){return e.value},set value(t){t&&t.isTexture&&(e.value=t)}}),i=e=>({get value(){return e.value},set value(t){e.value=t}}),r=e=>({value:e});this.uniforms={covariancesTexture:t(this._covariancesTex),centersColorsTexture:t(this._centersColorsTex),meshMatrixWorldsTexture:t(this._meshMatrixWorldsTex),focal:i(this._focal),viewport:i(this._viewport),basisViewport:i(this._basisViewport),covariancesTextureSize:i(this._covariancesTextureSize),centersColorsTextureSize:i(this._centersColorsTextureSize),orthoZoom:i(this._orthoZoom),meshIndexIntervals:r(e),debugColor:r(new aa)},this._buildGraph(e)}_buildGraph(e){let t=this._covariancesTex,i=this._centersColorsTex,r=this._meshMatrixWorldsTex,s=this._focal,a=this._basisViewport,n=this._covariancesTextureSize,o=this._centersColorsTextureSize,l=this._orthoZoom,h=C1(()=>{let h=L1("splatIndex","uint"),u=(e,t,i)=>{let r=h.mul(a5(e)).add(a5(t)).toFloat().div(Wie(i.x));return p5(g2(r),p2(r).div(Wie(i.y)))},d=i.sample(u(1,0,o)).toVar(),c=qie(z1(d5(d.y,d.z,d.w),"vec3")).toVar(),p=d.x;Hie.assign(g5(p.bitAnd(a5(255)).toFloat(),p.shiftRight(a5(8)).bitAnd(a5(255)).toFloat(),p.shiftRight(a5(16)).bitAnd(a5(255)).toFloat(),p.shiftRight(a5(24)).bitAnd(a5(255)).toFloat()).mul(1/255));let m=qie(L1("position","vec3")).xy.mul(2).toVar();$ie.assign(m);let g=c2(0);for(let t=1;t<e.length-1;t++)g=Wie(g.add(h.greaterThanEqual(a5(e[t])).select(c2(1),c2(0))));let f=g.mul(4).toVar(),y=e=>r.sample(p5(f.add(e).div(1024),0)),v=k2(y(0),y(1),y(2),y(3)),b=q1.mul(v).toVar(),x=b.mul(g5(c,1)).toVar(),w=G1.mul(x).toVar(),_=t.sample(u(3,0,n)).xy.toVar(),S=t.sample(u(3,1,n)).xy.toVar(),M=t.sample(u(3,2,n)).xy.toVar(),T=Wie(_.x),C=Wie(_.y),A=Wie(S.x),N=Wie(S.y),P=Wie(M.x),R=Wie(M.y),E=z2(T,C,A,C,N,P,A,P,R),O=c2(1).div(Wie(x.z).mul(Wie(x.z))).toVar(),B=b,V=z2(qie(B.element(0).xyz),qie(B.element(1).xyz),qie(B.element(2).xyz)).transpose(),D=z2(Wie(s.x).div(Wie(x.z)),0,Wie(s.x).mul(Wie(x.x)).negate().mul(O),0,Wie(s.y).div(Wie(x.z)),Wie(s.y).mul(Wie(x.y)).negate().mul(O),0,0,0),I=e=>{let t=e.transpose().mul(E).mul(e);return qie(g5(Gie(t,0,0).add(.3),Gie(t,0,1),Gie(t,1,1).add(.3),0).xyz)},L=l.greaterThan(0),z=qie(L.select(I(V),I(V.mul(D)))).toVar(),k=qie(w.xyz.div(Wie(w.w))).toVar(),U=Wie(z.x),F=Wie(z.z),j=Wie(z.y),G=U.mul(F).sub(j.mul(j)),W=U.add(F),q=W.mul(.5),H=Y3(j2(W.mul(W).div(4).sub(G),0)).toVar(),$=q.add(H).toVar(),Y=j2(q.sub(H),0).toVar(),X=n3(p5(j,$.sub(U))).toVar(),K=p5(Wie(X.y),Wie(X.x).negate()).toVar(),Z=X.mul(W2(Y3($.mul(2)),1024)).toVar(),J=K.mul(W2(Y3(Y.mul(2)),1024)).toVar(),Q=Z.mul(Wie(m.x)).add(J.mul(Wie(m.y))).mul(a).toVar();return Q.assign(L.select(Q.mul(l),Q)),g5(k.xy.add(Q),Wie(k.z),1)}),u=C1(()=>{let e=$ie.dot($ie).negate().toVar();e.lessThan(-4).discard();let t=h2(e).mul(Wie(Hie.w));return g5(qie(Hie.xyz),t)});this.vertexNode=h(),this.colorNode=u(),this.needsUpdate=!0}setup(e){let t=e.renderer.getMRT?.();this.mrtNode=t?this._velocityMRT:null,super.setup(e)}nodeMaterialDispose(){this.dispose()}}});function Kie(){let e=n5(1),t=n5(.6),i=n5(1),r=n5(1),s=n5(new aa(16603997)),a=n5(new aa(2857471)),n=n5(new aa(3728051)),o=n5(9),l=n5(new rs),h=new UU;h.name="EditorGridNodeMaterial",h.transparent=!0,h.lights=!1,h.fog=!1;let u=k3(Zie(o).equal(10),Jie(n),Jie(a)),d=k3(Zie(o).equal(8),Jie(n),Jie(s)),c=k3(v3.x.equal(Zie(l.x)),u,k3(v3.z.equal(Zie(l.y)),d,m5(.5)));h.colorNode=Jie(c);let p=x3.z.negate(),m=q3(Zie(i).mul(500),Zie(i).mul(4500),p).mul(Zie(r));h.opacityNode=Zie(q2(Zie(e).mul(Zie(t)),c2(0),m));let g={get value(){return 0===r.value?1/0:i.value},set value(e){Number.isFinite(e)?(i.value=e,r.value=1):r.value=0}};return h.uniforms={angleFadeFactor:e,opacityFactor:t,gridScale:g,red:s,blue:a,green:n,mode:o,offset:l},h}var Zie,Jie,Qie=n(()=>{Mu(),v5(),b5(),Zie=e=>e,Jie=e=>e}),ere={};function tre(){return typeof navigator<"u"&&void 0!==navigator.gpu}async function ire(e={}){let t=!1;try{t="default"===new URLSearchParams(window.location.search).get("dbglimits")}catch{}let i=t?{}:e.requiredLimits??await async function(e){if(!(e.forceWebGL||typeof navigator>"u"||void 0===navigator.gpu))try{let t=await navigator.gpu.requestAdapter({powerPreference:e.powerPreference,featureLevel:"compatibility"});if(!t)return;let i={},r=t.limits;for(let e of rre){let t=r[e];"number"==typeof t&&Number.isFinite(t)&&(i[e]=t)}return i}catch{return}}(e),r=new h7({...e,requiredLimits:i});await r.init();try{let e=new URLSearchParams(window.location.search);if("off"===e.get("taa")&&(r.temporalAAEnabled=!1),"1"===e.get("nojit")){let e=r.taaHistory;e.beginJitter=()=>{},e.endJitter=()=>{}}"1"===e.get("dbghdt")&&(r.hdTransmission=!0)}catch{}return r}l(ere,{SPE_BLENDING_MULTIPLY:()=>F7,SPE_BLENDING_NORMAL:()=>U7,SPE_BLENDING_OVERLAY:()=>G7,SPE_BLENDING_SCREEN:()=>j7,TSLLayerParams:()=>E7,TSLRootMaterial:()=>Iie,TSLSharedMaterial:()=>Lie,WebGPUPostPipeline:()=>Q4,WebGPUSplineRenderer:()=>h7,createEditorGridNodeMaterial:()=>Kie,createWebGPUSplineRenderer:()=>ire,getTSLLayerBuilder:()=>z7,hasTSLLayerBuilder:()=>k7,isWebGPUSupported:()=>tre,ownUniformValue:()=>N7,registerTSLLayer:()=>L7,setRenderUniformValue:()=>P7,simpleCalpha:()=>D7,speBlend:()=>I7,speObjectNormal:()=>M7,speObjectPosition:()=>S7,splitUniformValueSlots:()=>A7,standardCalpha:()=>V7,unsupportedTSLLayerBuilder:()=>$7,webgpuGlobals:()=>N5});var rre,sre=n(()=>{m7(),v5(),Mu(),gT(),zie(),pie(),kie(),Uie(),Fie(),jie(),iN(),Xie(),m7(),s6(),P5(),Qie(),Y7(),XA={createSplatMaterial:e=>new Yie(e)},hT={createRootMaterial:(e,t)=>new Iie(e,t),createSharedMaterial:(e,t,i)=>new Lie(e,t,i)},pT={tsl:hZ,NodeMaterial:UU,MeshBasicNodeMaterial:pF,MeshStandardNodeMaterial:uG,MeshPhysicalNodeMaterial:cG,MeshPhongNodeMaterial:SF,MeshLambertNodeMaterial:wF,MeshToonNodeMaterial:fG,MeshMatcapNodeMaterial:bG,MeshNormalNodeMaterial:iF,SpriteNodeMaterial:_G,PointsNodeMaterial:TG,LineBasicNodeMaterial:jU,LineDashedNodeMaterial:WU,Color:aa,Vector2:rs,Vector3:ns,Vector4:Ss,Matrix3:us,Matrix4:As,Texture:ws,CanvasTexture:Vo,DataTexture:Yn,VideoTexture:Eo,FrontSide:Ge,BackSide:We,DoubleSide:qe,NormalBlending:$e,AdditiveBlending:Ye,MultiplyBlending:Ke,SubtractiveBlending:Xe,RepeatWrapping:kt,ClampToEdgeWrapping:Ut,MirroredRepeatWrapping:Ft,NearestFilter:jt,LinearFilter:qt,LinearMipmapLinearFilter:$t,SRGBColorSpace:hr,LinearSRGBColorSpace:ur},cT=()=>{let e=new PG;return e.depthWrite=!1,e.opacity=.5,e},rre=["maxUniformBuffersPerShaderStage","maxSampledTexturesPerShaderStage","maxSamplersPerShaderStage","maxStorageBuffersPerShaderStage","maxStorageBufferBindingSize","maxBufferSize","maxVertexBuffers","maxVertexAttributes","maxUniformBufferBindingSize","maxColorAttachmentBytesPerSample"]}),are={};function nre(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function ore(e){return e instanceof lA?"SubdivObject":"NonParametricGeometry"===e.geometry.type?"NonParametric":"Mesh"}function lre(e,t){let i=function(e,t){let i={};return e.traverseEntity(e=>{if(!e.visible||!(e instanceof qx)||"Mesh"!==e.type||Array.isArray(e.material)||e.states&&Object.keys(e.states).length)return;let r=e.parent;for(;r;){if(r instanceof qx&&e.states&&Object.keys(e.states).length)return;r=r.parent}let s=e.material.uuid,a=t.shared.materials[s];if(a){if(!Lg.isMergable(a))return}else{let i=t.scene.objects.get(e.uuid)?.data;if(i&&"material"in i&&"string"!=typeof i.material){if(!Lg.isMergable(i.material))return;s=Lg.getHash(i.material)}}i[s]||(i[s]={});let n=i[s][ore(e)];if(n){if(n.push(e),e.cloner)for(let t of e.cloner.children)n.push(t)}else if(i[s][ore(e)]=[e],e.cloner)for(let t of e.cloner.children)i[s][ore(e)].push(t)}),i}(t,e),r=function(e){let t=0;return Object.values(e).forEach(e=>{Object.values(e).forEach(e=>{let i=e.length;i>t&&(t=i)})}),t}(i),s=new Array(r),a=0,n=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),d=0;for(let[e,r]of Object.entries(i))for(let c of Object.values(r)){if(o=0,h=0,c.forEach(e=>{e instanceof qx&&(n[o++]=e.geometry.clone(),l[h++]=e)}),h<2)continue;for(let e=0;e<h;e++)l[e].updateWorldMatrix(!0,!1),n[e].applyMatrix4(l[e].matrixWorld),l[e].matrixWorld.determinant()<0&&nre(n[e]);let r=Hy(n.slice(0,o),!1);if(r){let n;"SubdivObject"===e?(console.warn("Turning subdiv object into mesh"),n=new Hn(r,l[0].material)):n=new Hn(r,l[0].material),n.castShadow=l[0].castShadow,n.receiveShadow=l[0].receiveShadow,t.add(n);let o=e=>{d=0;for(let t of e)t.children&&o(t.children),t instanceof qx&&(Array.isArray(t.material)||i[t.material.uuid]&&i[t.material.uuid][ore(t)]&&i[t.material.uuid][ore(t)].length>1||(u[d++]=t));for(let e=0;e<d;e++)t.attach(u[e])};for(let e=0;e<h;e++){let t=l[e];o(t.children),s[a++]=t}}}for(let e=0;e<a;e++)s[e].removeFromParent()}l(are,{mergeStaticGeometries:()=>lre,reverseWindingOrder:()=>nre});var hre=n(()=>{Bv(),Mu(),Yy(),Hx(),hA()});Mu();var ure=".",dre=Symbol("target"),cre=Symbol("unsubscribe");function pre(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}var mre=Array.isArray;function gre(e){return"symbol"==typeof e}var fre={after:(e,t)=>mre(e)?e.slice(t.length):""===t?e:e.slice(t.length+1),concat:(e,t)=>mre(e)?(e=[...e],t&&e.push(t),e):t&&void 0!==t.toString?(""!==e&&(e+=ure),gre(t)?e+t.toString():e+t):e,initial:e=>{if(mre(e))return e.slice(0,-1);if(""===e)return e;let t=e.lastIndexOf(ure);return-1===t?"":e.slice(0,t)},last:e=>{if(mre(e))return e[e.length-1]||"";if(""===e)return e;let t=e.lastIndexOf(ure);return-1===t?e:e.slice(t+1)},walk:(e,t)=>{if(mre(e))for(let i of e)t(i);else if(""!==e){let i=0,r=e.indexOf(ure);if(-1===r)t(e);else for(;i<e.length;)-1===r&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(ure,i)}},get(e,t){return this.walk(t,t=>{e&&(e=e[t])}),e}},yre=fre;function vre(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&gre(i)||t.ignoreUnderscores&&"_"===i.charAt(0)||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var bre=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return void 0===this._descriptorCache&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return void 0===r&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return void 0===n&&(n=void 0===s?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,yre.get(t,this.getPath(e)))}defineProperty(e,t,i){return!!Reflect.defineProperty(e,t,i)&&(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0)}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let s=this._getOwnPropertyDescriptor(e,t);return void 0!==s&&"set"in s?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return void 0!==e&&void 0!==r&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return void 0!==i&&!0!==i.configurable&&!0!==i.writable}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function xre(e){return"[object Object]"===toString.call(e)}function wre(){return!0}function _re(e,t){return e.length!==t.length||e.some((e,i)=>t[i]!==e)}var Sre=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),Mre=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Tre={push:wre,pop:wre,shift:wre,unshift:wre,copyWithin:_re,reverse:_re,sort:_re,splice:_re,flat:_re,fill:_re},Cre=new Set([...Sre,...Mre,...Object.keys(Tre)]);function Are(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var Nre=["keys","values","entries"],Pre=new Set(["has","toString"]),Rre={add:Are,clear:Are,delete:Are,forEach:Are},Ere=new Set([...Pre,...Object.keys(Rre),...Nre]);function Ore(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||void 0===i&&!t.has(r))return!0;return!1}var Bre=new Set([...Pre,"get"]),Vre={set:Ore,clear:Ore,delete:Ore,forEach:Ore},Dre=new Set([...Bre,...Object.keys(Vre),...Nre]),Ire=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=void 0===t?e:this._shallowClone(e)}static isHandledMethod(e){return Sre.has(e)}_shallowClone(e){let t=e;if(xre(e))t={...e};else if(mre(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(e=>this._shallowClone(e)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(mre(r)?this._onIsChanged=Tre[t]:r instanceof Set?this._onIsChanged=Rre[t]:r instanceof Map&&(this._onIsChanged=Vre[t]),r):i}update(e,t,i){let r=yre.after(e,this._path);if("length"!==t){let e=this.clone;yre.walk(r,t=>{e&&e[t]&&(this._clonedCache.has(e[t])||(e[t]=this._shallowClone(e[t])),e=e[t])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),e&&e[t]&&(e[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;-1!==i;i--)t=this._changes[i],yre.get(e,t.path)[t.property]=t.previous}isChanged(e){return void 0===this._onIsChanged?this._isChanged:this._onIsChanged(this.clone,e)}},Lre=class extends Ire{static isHandledMethod(e){return Cre.has(e)}},zre=class extends Ire{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},kre=class extends Ire{static isHandledMethod(e){return Ere.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},Ure=class extends Ire{static isHandledMethod(e){return Dre.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},Fre=class extends Ire{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},jre=class extends Ire{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Gre=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return xre(e)||mre(e)||pre(e)}static isHandledMethod(e,t){return xre(e)?Ire.isHandledMethod(t):mre(e)?Lre.isHandledMethod(t):e instanceof Set?kre.isHandledMethod(t):e instanceof Map?Ure.isHandledMethod(t):pre(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Ire;mre(e)?r=Lre:e instanceof Date?r=zre:e instanceof Set?r=kre:e instanceof Map?r=Ure:e instanceof WeakSet?r=Fre:e instanceof WeakMap&&(r=jre),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=Gre.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){void 0!==this._previousClone&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},Wre={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},qre=(e,t,i={})=>{i={...Wre,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new bre(s),h="function"==typeof i.onValidate,u=new Gre(h),d=(e,t,r,s,a)=>!h||u.isCloning||!0===i.onValidate(yre.concat(l.getPath(e),t),r,s,a),c=(t,r,s,a)=>{!vre(l,i,r)&&(!n||!l.isDetached(t,e))&&p(l.getPath(t),r,s,a)},p=(e,i,r,s,a)=>{u.isCloning?u.update(e,i,s):t(yre.concat(e,i),r,s,a)},m=e=>e&&(e[r]||e),g=(t,s,o,h)=>function(e){return("object"==typeof e?null===e:"function"!=typeof e)||e instanceof RegExp}(t)||"constructor"===o||a&&!Gre.isHandledMethod(s,o)||vre(l,i,o)||l.isGetInvariant(s,o)||n&&l.isDetached(s,e)?t:(void 0===h&&(h=l.getPath(s)),l.getProxy(t,yre.concat(h,o),f,r)),f={get(e,t,i){if(gre(t)){if(t===r||t===dre)return e;if(t===cre&&!l.isUnsubscribed&&0===l.getPath(e).length)return l.unsubscribe(),e}let s=pre(e)?Reflect.get(e,t):Reflect.get(e,t,i);return g(s,e,t)},set(e,t,i,a){i=m(i);let n=e[r]||e,o=n[t];if(s(o,i)&&t in e)return!0;let h=d(e,t,i,o);return h&&l.setProperty(n,t,i,a,o)?(c(e,t,e[t],o),!0):!h},defineProperty(e,t,i){if(!l.isSameDescriptor(i,e,t)){let r=e[t];d(e,t,i.value,r)&&l.defineProperty(e,t,i,r)&&c(e,t,i.value,r)}return!0},deleteProperty(e,t){if(!Reflect.has(e,t))return!0;let i=Reflect.get(e,t),r=d(e,t,void 0,i);return r&&l.deleteProperty(e,t,i)?(c(e,t,void 0,i),!0):!r},apply(t,i,a){let n=i[r]||i;if(l.isUnsubscribed)return Reflect.apply(t,n,a);if((!1===o||!0!==o&&!o.includes(t.name))&&Gre.isHandledType(n)){let r=yre.initial(l.getPath(t)),o=Gre.isHandledMethod(n,t.name);u.start(n,r,a);let h=Reflect.apply(t,u.preferredThisArg(t,i,n),o?a.map(e=>m(e)):a),c=u.isChanged(n,s),y=u.stop();if(Gre.isHandledType(h)&&o&&(i instanceof Map&&"get"===t.name&&(r=yre.concat(r,a[0])),h=l.getProxy(h,r,f)),c){let i={name:t.name,args:a,result:h},s=u.isCloning?yre.initial(r):r,o=u.isCloning?yre.last(r):"";d(yre.get(e,s),o,n,y,i)?p(s,o,n,y,i):u.undo(n)}return(i instanceof Map||i instanceof Set)&&function(e){return"object"==typeof e&&"function"==typeof e.next}(h)?function(e,t,i,r,s){let a=e.next;if("entries"===t.name)e.next=function(){let e=a.call(this);return!1===e.done&&(e.value[0]=s(e.value[0],t,e.value[0],r),e.value[1]=s(e.value[1],t,e.value[0],r)),e};else if("values"===t.name){let n=i[dre].keys();e.next=function(){let e=a.call(this);return!1===e.done&&(e.value=s(e.value,t,n.next().value,r)),e}}else e.next=function(){let e=a.call(this);return!1===e.done&&(e.value=s(e.value,t,e.value,r)),e};return e}(h,t,i,r,g):h}return Reflect.apply(t,i,a)}},y=l.getProxy(e,i.pathAsArray?[]:"",f);return t=t.bind(y),h&&(i.onValidate=i.onValidate.bind(y)),y};qre.target=e=>e&&e[dre]||e,qre.unsubscribe=e=>e[cre]||e;var Hre=qre;md(),md(),Mu(),Vv();var $re=class extends Uh{constructor(){super(),function(e){for(let t of hv)e.enable(t)}(this.layers)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(e=>{e.visible&&this.intersectObject(e,t,i)}),i}createRaycastLineHelper(){let e=new vo({color:65280,linewidth:10}),t=new ns(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new ns(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=(new ns).addVectors(t,i.multiplyScalar(r)),a=new an;return a.setFromPoints([t,s]),new Co(a,e)}};tx(),Qb(),mC(),Yv();var Yre=e=>e instanceof Zb||$v(e);function Xre(e,t){return e.distance-t.distance}function Kre(e,t,i){if(zb(t)&&t.visible){hC(t)&&t.raycast(e,i);for(let r of t.children)Kre(e,r,i)}}function Zre(e,t,i,r=!1){if(!r&&!i.some(t=>void 0!==ese(e,t)))return[];let s=[];return t.children.forEach(t=>Kre(e,t,s)),s.sort(Xre),s}function Jre(e){let t=[];if(e.length){let i=e[0].object;zb(i)&&t.push(i);let r=i.parent;for(;r;)Yre(r)&&t.push(r),r=r.parent}return t}function Qre(e,t,i,r){let s=e.frame;if(s){let e=t[0]*s.width,a=(1-t[1])*s.height;for(let t of i){let i=t===s.uuid?s:s.find(t);if(i?.intersects(e,a))return r(i),!0}}return!1}function ese(e,t){if(hC(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(Yre(t))return tse(e,t)}function tse(e,t){if(zb(t)&&t.visible){if(hC(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let t=tse(e,i);if(t)return t}}}var ise=class{constructor(e,t,i,r,s,a,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=a,this.isExport=n,this.frame=o,this.raycaster=new $re,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents="window"===t.mouseEventTarget,this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(e){this._domRect=e}get domRect(){return this._domRect}updateRaycaster(e){let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.pointerWorld=function(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-(t-(i.top+window.scrollY))/i.height*2+1}}(t,i,this._domRect),this.pointerScreen=function(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}dispose(){this.scene=void 0,this.sharedAssets=void 0,this.publish=void 0,this.getCamera=void 0,this.requestRender=void 0,this.frame=void 0,this.isExport=void 0}},rse=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}dispose(){this.disconnect(),this.eventContext=void 0}};md(),Bv();var sse=new Map;hb(),Object.keys({mousehover:!0,scroll:!0,dragdrop:!0,tracking:!0,resize:!0,conditional:!0,variables:!0,"api-services":!0,"ai-assistant":!0,textinputs:!0,audio:!0,video:!0,"create-destroy":!0,"scene-transition":!0,timeline:!0,transitions:!0,"misc-actions":!0});var ase={MouseHover:"mousehover",Scroll:"scroll",DragDrop:"dragdrop",Follow:"tracking",LookAt:"tracking",Resize:"resize",Conditional:"conditional",VariableChange:"variables",API:"api-services",WEBHOOK:"api-services",AIAssistantListener:"ai-assistant",AIAssistantTrigger:"ai-assistant"},nse={Audio:"audio",Video:"video",Particles:"particles",Link:"misc-actions",Reset:"misc-actions",SwitchCamera:"misc-actions",ClearLocalStorage:"misc-actions",Create:"create-destroy",Destroy:"create-destroy",Transition:"transitions",Animation:"transitions",TimelineAnimation:"timeline",SceneTransition:"scene-transition",SetVariable:"variables",DynamicVariablePlay:"variables",UserAPI:"api-services"};function ose(e,t,i,r,s,a){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},o=t=>({id:l,data:h})=>{try{if("Conditional"===h.type)return void(Fp[e.type].includes("Conditional")&&(h.ifActions.forEach(o({expression:h.condition,negate:!1})),h.elseActions.forEach(o({expression:h.condition,negate:!0}))));if(!Fp[e.type].includes(h.type))return;let u=function(e){return sse.get(e)}(h.type);if(void 0===u)return void Kv(nse[h.type]??"misc-actions",`a "${h.type}" action`);let d=u({id:l,data:h,object:a,page:i,shared:r,eventManager:s,eventType:e.type,actionCondition:t});null!=d&&h.type in n&&n[h.type].push(d)}catch(e){Su&&console.error(e)}};return t.forEach(o()),n}function lse(e){Object.values(e).forEach(e=>{e.forEach(e=>{"function"==typeof e.dispose&&e.dispose()})})}var hse=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],use=e=>hse.find(([t,i])=>i===e)?.[0],dse=e=>hse.find(([t])=>t===e)?.[1],cse=(e,t)=>{let i=use(e);if(i){let e=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(e,"target",{writable:!1,value:t}),e}},pse=class extends rse{constructor(){super(...arguments),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=e=>{if(!e.eventName||!e.target||"Scroll"===e.eventName)return;let t=this.splineEvents[use(e.eventName)]?.[e.target.uuid];if(!t)return;"Scroll"===e.eventName&&void 0!==e.deltaY&&Object.assign(t,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(t)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(e=>{if(e.data?.events.length)for(let[t,i]of hse)if(e.data.events.some(e=>e.data.type===i&&!e.data.disabled)){this.objectsPerEvents.has(t)?this.objectsPerEvents.get(t)?.push(e):this.objectsPerEvents.set(t,[e]);let r={id:e.uuid,name:e.name},s=cse(i,r),a=this.splineEvents[t];a?a[e.uuid]=s:this.splineEvents[t]={[e.uuid]:s}}}),this.objectsPerEvents.forEach(e=>{e.forEach(e=>{e.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(e=>{e.removeEventListener("beginEvent",this.onBeginEvent)})})}};JT(),Yv(),qC();var mse=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,("KeyDown"===t.type||"KeyUp"===t.type||"KeyPress"===t.type)&&!t.key)throw new Error("Missing property");this.actions=ose(t,t.actions,r,s,a,i)}disconnect(){lse(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),"MousePress"===this.data.type||"KeyPress"===this.data.type?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(e=>e.playing&&"Toggle"!==e.data.runMode)||this.actions.Transition.forEach(e=>{"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.SwitchCamera.some(e=>e.playing&&"Toggle"!==e.data.runMode)||this.actions.SwitchCamera.forEach(e=>{"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.Animation.forEach(e=>{"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&"Toggle"===e.data.runMode?e.toggle():e.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),!1===e&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),e?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}},gse=class extends rse{constructor(e,t,i){super(e),this.eventManager=t,this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=e=>{if(!0===this.useForRaycastProperty&&null===this.sceneInterects){this.eventContext.updateRaycaster(e);let{raycaster:t,page:i}=this.eventContext,r=Zre(t,i,[],!0);this.sceneInterects=r,r.length&&(this.eventContext.sharedAssets.raycastProperty={x:r[0].point.x,y:r[0].point.y,z:r[0].point.z,objX:r[0].object.matrixWorld.elements[12],objY:r[0].object.matrixWorld.elements[13],objZ:r[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||"SPLINE-VIEWER"===e.target.tagName)&&this.canvasMouseEvents.forEach(t=>{("MouseDown"===t.data.type||"MousePress"===t.data.type)&&(this.onCanvasRaycast(e),t.dispatch())})},this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||"SPLINE-VIEWER"===e.target.tagName)&&this.canvasMouseEvents.forEach(t=>{"MouseUp"===t.data.type?(this.onCanvasRaycast(e),t.dispatch()):"MousePress"===t.data.type&&t.dispatchRelease()})},this.onMouseDown=e=>{zu.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))},this.onMouseUp=e=>{zu.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=e=>{zu.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())},this.onMousePressRelease=e=>{zu.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))},this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0},this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)},this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0},this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)},this.releaseHeldKey=e=>{delete this.heldKeys[e.key]},this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]},this._onUserEvent=({eventName:e,target:t,reverse:i})=>{if(!e||!t)return;let r=dse(e);r&&("MouseDown"===r||"MouseUp"===r||"MousePress"===r?(t.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[t.uuid]?.forEach(e=>{e.dispatchUserEvent(i)}),this.canvasMouseEvents.forEach(e=>{e.dispatchUserEvent(i)})):("KeyDown"===r||"KeyUp"===r||"KeyPress"===r)&&(t.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[t.uuid]?.forEach(e=>{e.dispatchUserEvent()})))}}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext,r=(i,r)=>{if(!i.data?.events.length)return;let s=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let a of s){let s=this.eventsPerObjects[a];if(i.data.events.filter(({data:e})=>e.type===a&&!0!==e.disabled).forEach(({id:r,data:a})=>{try{let n=new mse(r,a,i,e,t,this.eventManager);n.actions.Video.length&&(this.hasVideoAction=!0),"MouseDown"!==a.type&&"MouseUp"!==a.type&&"MousePress"!==a.type||"Canvas"!==a.mode&&"Window"!==a.mode?(s[i.uuid]?s[i.uuid].some(e=>e.id===n.id)||s[i.uuid].push(n):s[i.uuid]=[n],jv(i)&&i.traverseChildren(e=>{if(!e.visible)return!0;e instanceof YT&&"shapeBlendNode"in e.data.geometry&&2!==e.data.geometry.shapeBlendNode?.operation&&(s[e.uuid]?s[e.uuid].push(n):s[e.uuid]=[n])})):this.canvasMouseEvents.push(n)}catch(e){Su&&console.error(e)}}),s[i.uuid]?.length&&(this.objectsPerTypes[a].push(!Gv(i)||"MouseDown"!==a&&"MouseUp"!==a&&"MousePress"!==a?i:r),jv(i))){let e=this.objectsPerTypes[a];i.traverseChildren(t=>{if(!t.visible)return!0;t instanceof YT&&-1===e.indexOf(t)&&e.push(t)})}}};e.traverseEntity(e=>{(Wv(e)||e instanceof FC)&&e.frame?.traverse(t=>{r(t,e)}),r(e)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([e,t])=>{t.forEach(e=>{e.addEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(e=>{e.object.addEventListener("userEvent",this._onUserEvent)})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(e=>{Object.values(e).forEach(e=>{e.forEach(e=>{e.disconnect()})})}),this.canvasMouseEvents.forEach(e=>{e.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([e,t])=>{t.forEach(e=>{e.removeEventListener("userEvent",this._onUserEvent)})}),this.canvasMouseEvents.forEach(e=>{e.object.removeEventListener("userEvent",this._onUserEvent)})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r,pointerScreen:s}=this.eventContext,a=this.objectsPerTypes[e],n=a.filter(e=>!Gv(e));if((a.length||this.useForRaycastProperty)&&(!r.uiCanvas||!Qre(r,[s.x,s.y],Object.keys(this.eventsPerObjects[e]),t=>{this.handleObjectMouseEventDispatch(t,e)}))){if(t||this.useForRaycastProperty){let s;if(null===this.sceneInterects?s=Zre(i,r,n,this.useForRaycastProperty):(s=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]}),t){let t=[s[0]?.uv?.x??0,s[0]?.uv?.y??0];Jre(s).forEach(i=>{Wv(i)&&Qre(i,t,Object.keys(this.eventsPerObjects[e]),t=>{this.handleObjectMouseEventDispatch(t,e)}),this.eventsPerObjects[e][i.uuid]&&this.handleObjectMouseEventDispatch(i,e)})}}t||n.forEach(t=>{let r=ese(i,t);r&&(this.handleObjectMouseEventDispatch(t,e),Wv(t)&&Qre(t,[r?.uv?.x??0,r?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),t=>{this.handleObjectMouseEventDispatch(t,e)}))})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=i.filter(e=>!Gv(e)),s=[];if(i.length){if(!e){let{stopRaycast:e,raycaster:i,page:a,pointerScreen:n}=this.eventContext,o=!1;if(a.uiCanvas&&(o=Qre(a,[n.x,n.y],Object.keys(this.eventsPerObjects[t]),e=>{s.push(e)})),e&&!o){let e=Zre(i,a,r);s=Jre(e),e.forEach(e=>{Wv(e.object)&&Qre(e.object,[e?.uv?.x??0,e?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),e=>{s.push(e)})})}else r.forEach(e=>{let r=ese(i,e);r&&(s.push(e),Wv(e)&&Qre(e,[r?.uv?.x??0,r?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),e=>{s.push(e)}))})}this._prevObjects.length&&this._prevObjects.forEach(e=>{s.includes(e)||this.handleObjectMouseEventDispatchRelease(e,t)}),s.length&&s.forEach(e=>{this.handleObjectMouseEventDispatch(e,t)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(e=>{e.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(e=>{e.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:t})=>"key"in t&&t.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(t=>{"key"in t.data&&t.data.key===e.key&&(i?t.dispatchRelease():t.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(t=>{"key"in t.data&&t.data.key===e.key&&t.dispatchHeld(i)})})}};Yv(),qC();var fse=e=>!0===e?.isPlayAudioAction,yse=e=>!0===e?.isPauseAudioAction,vse=e=>!0===e?.isPlayVideoAction,bse=e=>!0===e?.isPauseVideoAction,xse=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=ose(t,t.actions,r,s,a,i)}disconnect(){lse(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.TimelineAnimation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(fse(t.interaction)?t.interaction.audioPlayer?.play():yse(t.interaction)&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(vse(t.interaction)?t.interaction.play("autoplay"===i):bse(t.interaction)&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}async seekVideos(e){let t=[];this.actions.Video.forEach(i=>{"autoplay"===(i.interaction.data.triggerAfter??"autoplay")&&vse(i.interaction)&&t.push(i.interaction.seek(e))}),await Promise.all(t)}pauseVideos(){this.actions.Video.forEach(e=>{vse(e.interaction)&&e.interaction.pause()})}dispatchUserEvent(e){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),e?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.TimelineAnimation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{fse(e.interaction)?e.interaction.audioPlayer?.play():yse(e.interaction)&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{vse(e.interaction)?e.interaction.play():bse(e.interaction)&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},wse=class extends rse{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(e=>{e.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(e=>{e.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(e=>{e.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(e=>{e.actions.Audio.forEach(e=>{fse(e.interaction)&&e.interaction.audioPlayer?.play()}),e.actions.Video.forEach(e=>{let t=e.interaction.data.triggerAfter??"autoplay";vse(e.interaction)&&e.interaction.play("autoplay"===t)}),e.actions.Particles.forEach(e=>{e.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(e=>{e.dispatchAfter("autoplay")})})},this.seekVideos=async e=>{let t=[];[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{!i.data.visible||r.forEach(i=>{t.push(i.seekVideos(e))})}),await Promise.all(t)},this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,t])=>{t.forEach(e=>{e.pauseVideos()})})},this.onUserEvent=({eventName:e,target:t,reverse:i})=>{if(!e||!t)return;let r=dse(e);r&&"Start"===r&&(Gv(t)||t.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(t)?.forEach(e=>{e.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(t)?.forEach(e=>{e.dispatchUserEvent(i)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext,i=i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||"Start"!==s.type)continue;let a=new xse(r,s,i,t,e,this.eventManager);(a.actions.Transition.length||a.actions.TimelineAnimation.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.Reset.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length||a.actions.ClearLocalStorage.length||a.actions.UserAPI.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(a):this.eventsPerObject.set(i,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a])),a.actions.Particles.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a]))}};if(t.traverseEntity(e=>{(Wv(e)||e instanceof FC)&&e.frame?.traverse(e=>{i(e)}),i(e)}),[...this.eventsAfterPerObject.values()].some(e=>e.length)){if(0===this.eventManager.activateCount){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),i.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),i.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([e,t])=>{e.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(e=>e.dispatch()),e.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(e=>e.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(e=>e.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},_se=new Map;hb();var Sse=class{constructor(e,t,i,r,s){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=e=>{let t=window.parent!==window,i=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(e.touches.length>1||this.preventTouchScroll||!1===t&&!1===i)&&e.preventDefault()},this.onMouseWheelPreventScroll=e=>{this.preventScroll&&e.preventDefault()},this.onMouseMove=e=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(e),pressed:e.buttons>0}},this.onMouseDown=e=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(e),pressed:!0}},this.onMouseUp=e=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(e),pressed:!1}},this.getMousePosition=e=>{let{domRect:t}=this.eventContext,{pageX:i,pageY:r}=e.touches?.length>0?e.touches[0]:e;return{x:i-(t.left+window.scrollX),y:r-(t.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}warnMissingEventFeatures(){this.eventContext.page.traverseEntity(e=>{for(let t of e.dataPatched.events){if(!0===t.data.disabled)continue;let e=t.data.type;if(void 0!==this.handlers[e])continue;let i=ase[e];void 0!==i&&Kv(i,`a "${e}" event`)}})}activate(e=!1){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown));let t={eventContext:this.eventContext,eventManager:this,sharedVariables:this.sharedVariables,needsMouse:this.needsMouse,needsRaycast:this.needsRaycast};this.handlers={};let i=(e,i)=>{let r=(s=e,_se.get(s));var s;void 0!==r?this.handlers[e]=r(t):void 0!==i&&(this.handlers[e]=i())};i("Spline",()=>new pse(this.eventContext)),i("VariableChange"),i("API"),i("WEBHOOK"),i("AIAssistantListener"),i("AIAssistantTrigger"),i("Conditional"),i("Start",()=>new wse(this.eventContext,this)),i("Basic",()=>new gse(this.eventContext,this,this.needsRaycast)),i("MouseHover"),i("Scroll"),i("Follow"),i("DragDrop"),i("LookAt"),i("Resize"),i("Textfields"),this.warnMissingEventFeatures();let{page:r,domElement:s}=this.eventContext;this.hideCursor&&(s.style.cursor="none"),r.traverseEntity(e=>{e.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(e=>e.connect()),s.addEventListener("wheel",this.onMouseWheelPreventScroll),s.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,e||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(e=!1){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:i}=this.eventContext;i.style.cursor="",Object.values(this.handlers).forEach(e=>e.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(e=>{e.removeEventListener("requestRender",this.requestRender),e.destroyedInAction=!1}),i.removeEventListener("touchmove",this.onTouchMovePreventScroll),i.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),e||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}dispose(){this.deactivate(),Object.values(this.handlers).forEach(e=>e.dispose())}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if("Conditional"===i.data.type&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),"Conditional"===i.data.type||"SetVariable"===i.data.type)for(let e of"Conditional"===i.data.type?i.data.condition:i.data.expression)"id"in e&&Array.isArray(e.id)&&("mouse"===e.id[0]&&(this.needsMouse=!0),"raycast"===e.id[0]&&(this.needsRaycast=!0));"DynamicVariablePlay"===i.data.type&&""!==i.data.variableId&&("Play"===i.data.mode||"PlayPause"===i.data.mode||"Toggle"===i.data.mode)&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(e=>{if(e.data?.events.length)for(let i of e.data.events)if("VariableChange"===i.data.type&&("mouseProperty"===i.data.variableId&&(this.needsMouse=!0),"raycastProperty"===i.data.variableId&&(this.needsRaycast=!0)),"Conditional"===i.data.type)for(let e of["inActions","outActions"])i.data[e].forEach(t);else if("DragDrop"===i.data.type)for(let e of["drag","drop"])i.data.dragDropActions[e].forEach(t);else if("GameControl"===i.data.type)for(let e of["idle","move","jump","run"])i.data.gameActions[e].forEach(t);else if("Resize"===i.data.type)for(let e of i.data.breakpoints)e.data.actions.forEach(t);else"LookAt"===i.data.type||"API"===i.data.type||i.data.actions.forEach(t)})}};Mu(),md(),md();var Mse={type:"change"},Tse={type:"start"},Cse={type:"end",nonOrbit:!0},Ase={type:"end",nonOrbit:!1},Nse={type:"end",isZoom:!0,nonOrbit:!0},Pse={type:"end",changed:!1},Rse={type:"cameraAnimatingInTimeline"},Ese=new ss,Ose=new rs,Bse=2*Math.PI,Vse=new ns,Dse=new rs,Ise=new ns,Lse=new ss,zse=new As,kse={type:"requestRender"},Use=class extends Kr{constructor(e,t,i={isPlayMode:!1,isExport:!1},r){super(),this.object=e,this.domElement=t,this.options=i,this.timelineState=r,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,ze.DOLLY_ROTATE,ze.PAN],this.offset=new ns,this.eye=new ns,this.lastPosition=new ns,this.lastQuaternion=new ss,this.current=new rs,this.overShoot=new rs,this.overRatio=new rs,this.spherical=new Fh,this.sphericalDelta=new Fh,this.panOffset=new ns,this.panLeftV=new ns,this.panUpV=new ns,this.panV=new ns,this.rotateStart=new rs,this.rotateEnd=new rs,this.rotateDelta=new rs,this.panStart=new rs,this.panEnd=new rs,this.panDelta=new rs,this.dollyStart=new rs,this.dollyEnd=new rs,this.dollyDelta=new rs,this.rotationRangeFactor=new rs,this.panRangeFactor=new rs,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.lastTrackpadPanTime=-1/0,this.lastMouseWheelZoomTime=-1/0,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.isTouchZoom=!0,this.autoRotateSpeed=2,this.dampingFactor=.125,this.zoomSpeed=2,this.rotateSpeed=1,this.rotateFactor=1,this.panSpeed=1,this.hoverRotatePanStrength=.1,this.hoverRotateDamping=this.dampingFactor,this.isCurrentlyDamping=!1,this.thetaIsFree=!1,this.phiIsFree=!1,this.needsUpdate=!0,this.onCameraChange=e=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=e.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)},this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(Ise,Lse,Vse),this.offset.copy(Ise).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&-1===this.state&&this.rotateLeft((!0===this.autoRotateClockwise?1:-1)*this.getAutoRotationAngle()),0!==this.rotationLimitsMode&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),2!==this.rotationLimitsMode&&(this.spherical.phi+=this.sphericalDelta.phi),(1!==this.rotationLimitsMode||!0===this.autoRotate)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),0!==this.panLimitsMode&&(this.target.applyQuaternion(Ese.copy(Lse).invert()),this.panOffset.applyQuaternion(Ese),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(Lse),this.panOffset.applyQuaternion(Lse)),2===this.panLimitsMode&&(this.panOffset.y=0),1===this.panLimitsMode&&(this.panOffset.x=0),-1!==this.state||this.gesture?(this.target.add(this.panOffset),this.panOffset.set(0,0,0)):(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)),this.offset.setFromSpherical(this.spherical),Ise.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&(zse.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4(zse));let e=this.spherical.phi%Bse;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(ea.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),e>0&&e>Math.PI||e<0&&e>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),-1===this.state||!0===this.enableDamping){let e=1===this.hoverRotatePanMode?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-e,this.sphericalDelta.phi*=1-e}else this.sphericalDelta.set(0,0,0);if(this.scale=1,this.lastPosition.distanceToSquared(this.object.position)>.01||8*(1-this.lastQuaternion.dot(this.object.quaternion))>1e-8)return this.dispatchEvent(Mse),this.object.dispatchEvent(kse),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),void(this.isCurrentlyDamping=!0);this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.isCurrentlyDamping=!1},this.onPointerDown=e=>{!1!==this.enabled&&("touch"===e.pointerType||"pen"===e.pointerType&&_u?this.onPointerDownTouch(e):this.onPointerDownMouse(e),-1!==this.state&&(this.isPointerDown=!0,this.dispatchEvent(Tse),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),e.stopPropagation(),"touch"===e.pointerType||"pen"===e.pointerType&&_u||this.domElement.setPointerCapture(e.pointerId)))},this.onPointerLeave=e=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(1===this.hoverRotatePanMode?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,Vse.subVectors(this.position0,this.target0),this.spherical.setFromVector3(Vse),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):2===this.hoverRotatePanMode&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=e},this.onPointerEnter=e=>{this.resetHoverEffectOnPointerLeave||void 0===this.pointerLeaveEvent?Dse.set(e.clientX-this.domElement.clientWidth/2,e.clientY-this.domElement.clientHeight/2):Dse.set(e.clientX-this.pointerLeaveEvent.clientX,e.clientY-this.pointerLeaveEvent.clientY),1===this.hoverRotatePanMode?(this.rotateDelta.copy(Dse).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(Ose,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(e.clientX,e.clientY)):2===this.hoverRotatePanMode&&(this.panDelta.copy(Dse).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(e.clientX,e.clientY)),this.update()},this.onPointerMove=e=>{this.timelineState?.isPlayingCameraAnimation?this.dispatchEvent(Rse):!1!==this.enabled&&(this.checkRaycastLock()||("touch"===e.pointerType||"pen"===e.pointerType&&_u?this.onPointerMoveTouch(e):this.onPointerMoveMouse(e),e.stopPropagation()))},this.onPointerUp=e=>{this.isPointerDown=!1,0===zu.length&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),zu.length>1&&e.preventDefault(),this.hasChange?this.dispatchEvent(0===this.state?Ase:Cse):this.dispatchEvent(Pse),this.state=-1,e&&(e.stopPropagation(),"touch"===e.pointerType||"pen"===e.pointerType&&_u||this.domElement.releasePointerCapture(e.pointerId))},this.onPointerDownMouse=e=>{let t;switch(t=this.useKeyEvents?this.mouseButtons[e.button]:this.mouseButtonsPlay[e.button],t){case 0:if(!0!==e.altKey||e.shiftKey||Au(e)){if(" "===this.key){if(!1===this.enablePan)return;this.handleMouseDownPan(e),this.state=2}}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(e),this.state=0}break;case 4:if(!1===this.enablePan)return;this.handleMouseDownPan(e),this.state=2;break;case 3:if(Au(e)||e.shiftKey){if(!1===this.enablePan)return;this.handleMouseDownPan(e),this.state=2}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(e),this.state=0}break;case 5:if(Au(e)||e.shiftKey){if(!1===this.enableRotate)return;this.handleMouseDownRotate(e),this.state=0}else{if(!1===this.enablePan)return;this.handleMouseDownPan(e),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=e=>{switch(this.state){case 0:if(!1===this.enableRotate)return;this.handleMouseMoveRotate(e);break;case 1:if(!1===this.enableZoom)return;this.handleMouseMoveDolly(e);break;case 2:if(!1===this.enablePan)return;this.handleMouseMovePan(e)}this.object.wasMovedByUser=!0},this.onPointerDownTouch=e=>{switch(zu.length>1&&e.preventDefault(),this.touches[zu.length-1]){case ze.ROTATE:if(!1===this.enableRotate)return void(this.state=-1);this.handleTouchStartRotate(),this.state=3;break;case ze.PAN:if(!1===this.enablePan)return void(this.state=-1);this.handleTouchStartPan(),this.state=4;break;case ze.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchStartDollyPan(),this.state=5;break;case ze.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=e=>{switch(zu.length>1&&e.preventDefault(),this.state){case 3:if(!1===this.enableRotate)return;this.handleTouchMoveRotate(e),this.update();break;case 4:if(!1===this.enablePan)return;this.handleTouchMovePan(e),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchMoveDollyPan(e),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchMoveDollyRotate(e),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0},this.dispatchEndDebounced=$u(()=>{this.zoomChanged?this.dispatchEvent(Nse):this.dispatchEvent(Cse),this.zoomChanged=!1},33),this.onMouseWheel=e=>{if(!1!==this.enabled&&(!1!==this.enableZoom||!1!==this.enablePan)&&!this.checkRaycastLock()){if(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&e.preventDefault(),this.dispatchEvent(Tse),this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(Rse);this.handleMouseWheel(e),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0}},this.onGesture=e=>{if(e.preventDefault(),!1!==this.enabled&&!this.checkRaycastLock()&&!xu){if(this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(Rse);if("gesturechange"===e.type){if(!1===this.enableZoom||!1===this.isTouchZoom)return;this.dispatchEvent(Tse),e.scale>this.prevScale?this.dollyIn(this.getZoomScale()):e.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=e.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(Cse)}},this.onContextMenu=e=>{e.preventDefault()},this.onTouchEnd=e=>{e.preventDefault()},this.onKeyDown=e=>{!1!==this.enabled&&(this.key=e.key," "===e.key&&this.dispatchEvent(Tse))},this.onKeyUp=e=>{this.key=void 0,!1!==this.enabled&&(-1!==this.state&&"Alt"===e.key&&this.onPointerUp(zu[0])," "===e.key&&this.dispatchEvent(Cse))},this.onPointerHover=e=>{"mouse"!==e.pointerType||!1===this.enabled||-1!==this.state||2===this.hoverRotatePanMode&&this.isPanOverShoot||1===this.hoverRotatePanMode&&this.isRotateOverShoot||(this.isPointerDown=!0,2===this.hoverRotatePanMode?this.handleMouseMovePan(e,this.hoverRotatePanStrength):1===this.hoverRotatePanMode&&this.handleMouseMoveRotate(e,this.hoverRotatePanStrength))},this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1},this.onCompleteState=e=>{e.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(Ise,Lse,Vse),this.offset.copy(Ise).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(e){"start"===e.type?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(e)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(e){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=e,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let e=this.useWindowEvents?window:this.domElement;e.addEventListener("pointerleave",this.onPointerLeave),e.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(e,t){this.rotateFactor=e.rotationSpeed??1,this.setEnableDampingSpeed(e.enableDamping),this.enablePan=e.enablePan,this.enableZoom=e.enableZoom,this.enableRotate=e.enableRotate,this.rotationLimitsMode=e.rotationLimitsMode,this.thetaIsFree=e.rotationHorizontalOffset.min===e.rotationHorizontalOffset.max&&e.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=e.rotationVerticalOffset.min===e.rotationVerticalOffset.max&&e.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=e.panLimitsMode,this.panSoftLimit=e.panSoftLimit,this.rotationSoftLimit=e.rotationSoftLimit,this.hoverRotatePanMode=e.hoverRotatePanMode,this.hoverRotateDamping=e.hoverRotateDamping??this.dampingFactor,this.useWindowEvents="window"===t,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=e.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=e.zoomLimitsEnabled,this.minZoom=e.zoomLimits.min,this.maxZoom=Math.max(e.zoomLimits.min,e.zoomLimits.max),this.minDistance=1e3/this.maxZoom,this.maxDistance=Math.max(this.minDistance,1e3/e.zoomLimits.min),this.autoRotate=e.autoRotate,this.autoRotateSpeed=e.autoRotateSpeed,this.autoRotateClockwise=e.autoRotateClockwise;let r=this.object.getTarget().applyQuaternion(Ese.copy(this.object.quaternion).invert());this.minV=-e.panVerticalOffset.min+r.y,this.maxV=e.panVerticalOffset.max+r.y,this.minH=-e.panHorizontalOffset.min+r.x,this.maxH=e.panHorizontalOffset.max+r.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Fse(this.spherical.phi-e.rotationVerticalOffset.min),this.maxPhi=Fse(this.spherical.phi+e.rotationVerticalOffset.max),this.minTheta=Fse(Fse(this.spherical.theta)-e.rotationHorizontalOffset.min),this.maxTheta=Fse(Fse(this.spherical.theta)+e.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,1===e.orbitTouches&&(this.touches[0]=ze.ROTATE),1===e.panTouches&&(this.touches[0]=ze.PAN),2===e.orbitTouches&&(this.touches[1]=ze.DOLLY_ROTATE),2===e.panTouches&&(this.touches[1]=ze.DOLLY_PAN),3===e.orbitTouches&&(this.touches[2]=ze.ROTATE),3===e.panTouches&&(this.touches[2]=ze.PAN),this.isTouchZoom=e.isTouchZoom,this.resetHoverEffectOnPointerLeave=e.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let e=this.useWindowEvents?window:this.domElement;e.addEventListener("pointerleave",this.onPointerLeave),e.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(e,t,i,r,s,a,n,o){let l,h,u;this.overShoot.set(0,0),e instanceof ns?(l=e.x,h=e.y,this.current.set(this.target.x,this.target.y),u=!0):(l=e.theta,h=e.phi,this.current.set(Fse(this.spherical.theta),Fse(this.spherical.phi)),u=!1),0===i&&(this.current.x+=l,this.current.y+=h),(3===t||2===t)&&(!u&&this.isThetaFlipped?this.current.x>r&&this.current.x<0?this.overShoot.x=r-this.current.x:this.current.x<s&&this.current.x>0&&(this.overShoot.x=s-this.current.x):this.current.x>r?this.overShoot.x=r-this.current.x:this.current.x<s&&(this.overShoot.x=s-this.current.x)),(3===t||1===t)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<n&&(this.overShoot.y=n-this.current.y)),u||(this.overShoot.x=Fse(this.overShoot.x),this.overShoot.y=Fse(this.overShoot.y)),0!==i?(this.overRatio.copy(this.overShoot).divide(o),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),1===i&&(this.overRatio.x=jse(Math.abs(this.overRatio.x)),this.overRatio.y=jse(Math.abs(this.overRatio.y))),this.isPointerDown||1===i?2===i&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(l*this.overShoot.x<0&&!this.thetaIsFree&&(l*=1-this.overRatio.x),h*this.overShoot.y<0&&!this.phiIsFree&&(h*=1-this.overRatio.y)):2===i&&(!u&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||u&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(l=.05*this.overShoot.x),this.phiIsFree||(h=.05*this.overShoot.y),u?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):u?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(l+=this.overShoot.x,h+=this.overShoot.y),e instanceof ns?(e.x=l,e.y=h):(this.thetaIsFree||(e.theta=l),this.phiIsFree||(e.phi=h))}setEnableDampingSpeed(e){this.enableDamping=e,this.rotateSpeed=(!0===e?.2:1)*this.rotateFactor}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0,this.panOffset.set(0,0,0)}setTarget(e,t,i){this.stopDamping(),this.target.set(e,t,i)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(e){this.sphericalDelta.theta-=e}rotateUp(e){this.sphericalDelta.phi-=e}panLeft(e,t){this.panLeftV.setFromMatrixColumn(t,0),this.panLeftV.multiplyScalar(-e),this.panOffset.add(this.panLeftV)}panUp(e,t){this.panUpV.setFromMatrixColumn(t,1),this.panUpV.multiplyScalar(e),this.panOffset.add(this.panUpV)}pan(e,t){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let r=this.object.position;this.panV.copy(r).sub(this.target);let s=this.panV.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*s/i.clientHeight,this.object.matrixWorld),this.panUp(2*t*s/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(Mse)}dollyOut(e){this.object.isPerspectiveCamera?this.scale/=e:this.object.isOrthographicCamera&&(this.object.zoom*=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(Mse)}dollyIn(e){this.object.isPerspectiveCamera?this.scale*=e:this.object.isOrthographicCamera&&(this.object.zoom/=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(Mse)}setZoom(e){if(this.dispatchEvent(Tse),this.object.isPerspectiveCamera){let t=this.initialSphericalRadius/e/this.spherical.radius;this.scale=t}else this.object.isOrthographicCamera&&(this.object.zoom=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(Cse)}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleMouseMoveRotate(e,t=1){void 0!==e.movementX?this.rotateDelta.set(e.movementX,e.movementY):(this.rotateEnd.set(e.clientX,e.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*t).rotateAround(Ose,-this.object.angleOffsetFromUp);let i=this.domElement,r=this.useWindowEvents?window.innerHeight:i.clientHeight,s=2*Math.PI*this.rotateDelta.x/r,a=2*Math.PI*this.rotateDelta.y/r;this.rotateLeft(s),this.rotateUp(a),this.update()}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(e,t=1){void 0!==e.movementX?this.panDelta.set(e.movementX,e.movementY):(this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*t),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(e){if(0===e.deltaX&&0===e.deltaY)return;let t=!0===e.ctrlKey||!0===Au(e),i=!1===Au(e)&&!0===(0===(a=e).wheelDeltaY||0===a.deltaY?!(bu&&a.shiftKey&&Math.abs(a.wheelDeltaX)>=120)&&(a.wheelDeltaX?Nu(a.wheelDeltaX,a.deltaX):0===a.deltaMode):a.wheelDeltaY?Nu(a.wheelDeltaY,a.deltaY):0===a.deltaMode),r=!1===t&&(!0===this.gesture||e.timeStamp-this.lastTrackpadPanTime<300),s=!1===t&&!1===r&&e.timeStamp-this.lastMouseWheelZoomTime<300;var a;if(!1!==wu||!1!==s||!0!==i&&!0!==r){if(!1===this.enableZoom)return;this.gesture&&(window.clearTimeout(this.timer),this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(Cse)),!1===t&&!1===i&&(this.lastMouseWheelZoomTime=e.timeStamp),0===e.deltaY?e.deltaX<0?this.dollyIn(this.getZoomScale()):e.deltaX>0&&this.dollyOut(this.getZoomScale()):e.deltaY<0?this.dollyIn(this.getZoomScale()):e.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}else{if(!1===this.enablePan)return;let t=!1===this.gesture&&!1===r;this.lastTrackpadPanTime=e.timeStamp,this.gesture||(this.gesture=!0,this.isPointerDown=!0),!1===t&&(this.panDelta.set(-e.deltaX,-e.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),e.altKey?this.pan(0,this.panDelta.y):e.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(Cse)},100)}}handleTouchStartRotate(){if(2===zu.length){let e=.5*(zu[0].pageX+zu[1].pageX),t=.5*(zu[0].pageY+zu[1].pageY);this.rotateStart.set(e,t)}else this.rotateStart.set(zu[0].pageX,zu[0].pageY)}handleTouchStartPan(){if(2===zu.length){let e=.5*(zu[0].pageX+zu[1].pageX),t=.5*(zu[0].pageY+zu[1].pageY);this.panStart.set(e,t)}else this.panStart.set(zu[0].pageX,zu[0].pageY)}handleTouchStartDolly(){let e=zu[0].pageX-zu[1].pageX,t=zu[0].pageY-zu[1].pageY,i=Math.sqrt(e*e+t*t);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(e){if(2===zu.length){let t=Du(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this.rotateEnd.set(i,r)}else{if(e.pointerId!==zu[0].pointerId)return;this.rotateEnd.set(e.pageX,e.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;t&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/t.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/t.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(e){if(2===zu.length){let t=Du(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this.panEnd.set(i,r)}else{if(e.pointerId!==zu[0].pointerId)return;this.panEnd.set(e.pageX,e.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(e){let t=Du(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this.dollyEnd.set(0,s),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(e){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(e),this.enablePan&&this.handleTouchMovePan(e)}handleTouchMoveDollyRotate(e){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(e),this.enableRotate&&this.handleTouchMoveRotate(e)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let e=this.options?.showCameraLock;return e&&e(),!0}}return!1}};function Fse(e){let t=2*Math.PI;for(;e<=-Math.PI;)e+=t;for(;e>Math.PI;)e-=t;return e}function jse(e){return 1-Math.pow(1-e,4)}Mu();var Gse=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=(new rs).copy(i),this._editorSize=(new rs).copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||"PerspectiveCamera"!==this._camera.cameraType)return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if("PerspectiveCamera"===this._camera.cameraType){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){r*=t/i,r*=1-((t-1080)/1080*14+1)/100}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};Hx(),JT();var Wse=class extends YT{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");void 0!==i?Fx(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}};hb(),Jv("VectorGeometry",(e,t,i)=>new Wse(e,t,i)),Xv("vector-shapes"),Mu(),JT();var qse=new ns,Hse=new As,$se=new Bn,Yse=class extends YT{constructor(e,t,i){super(e,t,i),this.data=t}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,"number"==typeof e.geometry.height?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,t){let{matrixWorld:i}=this;if(!isNaN(e.ray.origin.x)&&0!==this.scale.x&&0!==this.scale.y&&0!==this.scale.z&&(Hse.copy(i).invert(),$se.copy(e.ray).applyMatrix4(Hse),$se.intersectBox(this.singleBBox,qse))){let r=qse.applyMatrix4(i),s=e.ray.origin.distanceTo(r);t.push({distance:s,point:r.clone(),object:this})}}};SM(),Mu();var Xse,Kse,Zse=class{constructor(){this.type="ShapePath",this.color=new aa,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new nl,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath?.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={loc:0,t:0};function t(t,r,s,a){let n=t.x,o=r.x,l=s.x,h=a.x,u=t.y,d=r.y,c=s.y,p=a.y,m=(h-l)*(u-c)-(p-c)*(n-l),g=(p-c)*(o-n)-(h-l)*(d-u),f=m/g,y=((o-n)*(u-c)-(d-u)*(n-l))/g;if(0===g&&0!==m||f<=0||f>=1||y<0||y>1)return null;if(0===m&&0===g){for(let l=0;l<2;l++){if(i(0===l?s:a,t,r),0===e.loc){let t=0===l?s:a;return{x:t.x,y:t.y,t:e.t}}if(2===e.loc)return{x:+(n+e.t*(o-n)).toPrecision(10),y:+(u+e.t*(d-u)).toPrecision(10),t:e.t}}return null}for(let n=0;n<2;n++)if(i(0===n?s:a,t,r),0===e.loc){let t=0===n?s:a;return{x:t.x,y:t.y,t:e.t}}return{x:+(n+f*(o-n)).toPrecision(10),y:+(u+f*(d-u)).toPrecision(10),t:f}}function i(t,i,r){let s,a=r.x-i.x,n=r.y-i.y,o=t.x-i.x,l=t.y-i.y,h=a*l-o*n;return t.x===i.x&&t.y===i.y?(e.loc=0,void(e.t=0)):t.x===r.x&&t.y===r.y?(e.loc=1,void(e.t=1)):void(h<-Number.EPSILON?e.loc=3:h>Number.EPSILON?e.loc=4:a*o<0||n*l<0?e.loc=5:Math.sqrt(a*a+n*n)<Math.sqrt(o*o+l*l)?e.loc=6:(s=0!==a?o/a:l/n,e.loc=2,e.t=s))}let r=0,s=999999999,a=-999999999,n=[];this.subPaths.forEach(e=>{let t=e.getPoints(),i=-999999999,o=999999999,l=-999999999,h=999999999;for(let e=0;e<t.length;e++){let r=t[e];r.y>i&&(i=r.y),r.y<o&&(o=r.y),r.x>l&&(l=r.x),r.x<h&&(h=r.x)}a<=l&&(a=l+1),s>=h&&(s=h-1),t.length&&n.push({curves:e.curves,points:t,isCW:hl.isClockWise(t),identifier:r++,boundingBox:new qh(new rs(h,o),new rs(l,i))})});let o=n.map(e=>function(e,i,r,s,a){(null==a||""===a)&&(a="nonzero");let n=new rs;e.boundingBox.getCenter(n);let o=function(e,i,r){let s=new rs;i.getCenter(s);let a=[];return r.forEach(i=>{i.boundingBox.containsPoint(s)&&function(e,i){let r=[],s=[];for(let a=1;a<e.length;a++){let n=e[a-1],o=e[a];for(let e=1;e<i.length;e++){let a=t(n,o,i[e-1],i[e]);null!==a&&void 0===r.find(e=>e.t<=a.t+Number.EPSILON&&e.t>=a.t-Number.EPSILON)&&(r.push(a),s.push(new rs(a.x,a.y)))}}return s}(e,i.points).forEach(e=>{a.push({identifier:i.identifier,isCW:i.isCW,point:e})})}),a.sort((e,t)=>e.point.x-t.point.x),a}([new rs(r,n.y),new rs(s,n.y)],e.boundingBox,i);o.sort((e,t)=>e.point.x-t.point.x);let l=[],h=[];o.forEach(t=>{t.identifier===e.identifier?l.push(t):h.push(t)});let u=l[0].point.x,d=[],c=0;for(;c<h.length&&h[c].point.x<u;)d.length>0&&d[d.length-1]===h[c].identifier?d.pop():d.push(h[c].identifier),c++;if(d.push(e.identifier),"evenodd"===a){let t=d.length%2==0,i=d[d.length-2];return{identifier:e.identifier,isHole:t,for:i}}if("nonzero"===a){let t=!0,r=null,s=null;for(let e=0;e<d.length;e++){let a=d[e];i[a]&&(t?(s=i[a].isCW,t=!1,r=a):s!==i[a].isCW&&(s=i[a].isCW,t=!0))}return{identifier:e.identifier,isHole:t,for:r}}console.warn('fill-rule: "'+a+'" is currently not implemented.')}(e,n,s,a,this.userData?.style.fillRule)),l=[];return n.forEach(e=>{let t=o[e.identifier];if(t&&!t.isHole){let t=new ol;t.curves=e.curves,o.filter(t=>t?.isHole&&t.for===e.identifier).forEach(e=>{if(e){let i=n[e.identifier],r=new nl;r.curves=i.curves,t.holes.push(r)}}),l.push(t)}}),l}},Jse=!1,Qse=new Promise(e=>{Xse=e}),eae=!1;function tae(){if(Jse=!0,!eae)return Kse||(Kse=async function(){let e=await import("./opentype.js");Xse(e),eae=!0}())}var iae=new class{async load(e,t,i=()=>{}){let{load:r}=await Qse;r(e,(e,r)=>{e||!r?i(e??"Something went wrong"):t(r)})}async parse(e){let{parse:t,Bidi:i}=await Qse;try{let r=t(e),s=new i,a=e=>r.charToGlyphIndex(e.char);return s.registerModifier("glyphIndex",null,a),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(e){console.error(e)}}};function rae(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}Mu(),Ow(),hb(),Jv("TextGeometry",(e,t,i)=>new Yse(e,t,i));var sae={create:(e,t)=>new _M(e,t)};eb("TextGeometry",sae),eb("InputGeometry",sae),Ew=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=this.load(e)}async load(e){try{let t=await async function(e){let t,i,r=!1;if(e.url?(t=await async function(e){let t;try{t=await fetch(e)}catch(t){throw new Error(`could not fetch the font at ${e}: ${t}`)}if(!t.ok)throw new Error(`${t.status} ${t.statusText} fetching the font at ${e}`);return await t.arrayBuffer()}(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength)),t){if(!Jse)return{font:void 0,url:i,intercepted:r,arr:t,bidi:null};{let e=await iae.parse(t);if(e)return{font:e.font,url:i,intercepted:r,arr:t,bidi:e.bidi}}}}(e);t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)}catch(t){console.warn(`Could not load the font "${e.url??"(inline data)"}"`,t)}}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,a=[],n=0,o=i.length===s.length;for(let r=0;r<i.length;r++){let l=i[r].index,h=String.fromCharCode(i[r].unicode),u=s[n];if(rae(l,u)||o)a.push({char:h,index:l,replacements:[u.state.glyphIndex],replacementChars:[u.char]}),n++;else{let i=u.char,r="",s=[u.state.glyphIndex],o=[],d=!1;for(;!d;)n++,r=t.charAt(n),i+=r,s.push(e.charToGlyphIndex(r)),o=e.stringToGlyphs(i),1===o.length&&o[0].index===l&&(d=!0),n>t.length&&(d=!0);a.push({char:h,index:l,replacements:s,replacementChars:Array.from(i)}),n++}}return a}generateShapes(e,t,i){if(!this._isLoaded)return;let r=this.font,s=t.fontSize/this.unitsPerEm,a=t.fontSize*t.lineHeight,n=e.map(e=>this.getTextWidth(e,t)),o="string"==typeof t.width?Number(i.getVariable(t.width)):t.width,l="string"==typeof t.height?Number(i.getVariable(t.height)):t.height,h=this.getCharWidth("\n",t),u=1===t.horizontalAlign?h:0,d=this.getLineInitialOffsetX(n[0],o,t.horizontalAlign,e[0],h),c=this.getLineInitialOffsetY(a,e.length,l,s,t.verticalAlign),p=[],m=e.map(()=>[]),g=e.map(()=>[]);for(let l=0;l<e.length;l++){let f=e[l],y={features:{liga:!0},letterSpacing:t.letterSpacing},v=[];try{v=r.stringToGlyphs(f,y)}catch(e){console.warn(e)}d=this.getLineInitialOffsetX(n[l],o,t.horizontalAlign,f,h);let b=[];try{b=this.reverseLigaturesTable(r,f,v)}catch(e){console.warn(e)}let x=this.computeSpaceWidthForLine(e,l,t,i),w=0,_=v[0];_&&2===t.horizontalAlign&&void 0!==_.leftSideBearing&&(d-=_.leftSideBearing*s),this.font?.forEachGlyph(f,d,c,t.fontSize,y,(e,i,a,n,o)=>{let h=0===e.index?"\n":e.unicode?String.fromCharCode(e.unicode):void 0,d=b[w],c=0;if("\n"===h)c=u;else if(" "===h)c=x;else{let r=this.createPath(e,s,i,a,t);r&&(c=r.offsetX,p.push(r.path))}if(1===d.replacements.length)g[l].push([i,a]),m[l].push(c);else{let e=d.replacements.map(e=>(r.glyphs.get(e).advanceWidth??0)*s),t=e.reduce((e,t)=>e+t,0),n=e.map(e=>e/t),o=i;for(let e=0;e<n.length;e++){let t=c*n[e];g[l].push([o,a]),m[l].push(t),o+=t}}w++}),c-=a}let f=[];for(let e=0,t=p.length;e<t;e++)f.push(...p[e].toShapes());return{shapes:f,charWidths:m,lineWidths:n,charCoords:g}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(e,t,i,r,s){return(3===i||2===i)&&r.indexOf("\n")>=0&&(e-=s),3===i?.5*t-.5*e:2===i?t-e:0}getLineInitialOffsetY(e,t,i,r,s){let a=t*e,n=e-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-n/2;return 3===s?-(i-a-o):2===s?-(.5*i-.5*a-o):o}createPath(e,t,i,r,s){let a=e.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!a)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");let n=new Zse,o=(e.advanceWidth??1)*t;if(e)for(let e of a.commands){let t=n.currentPath?.currentPoint;if(!t||"Z"===e.type||t.x!==e.x||-t.y!==e.y)switch(e.type){case"M":n.moveTo(e.x,-e.y);break;case"L":n.lineTo(e.x,-e.y);break;case"Q":n.quadraticCurveTo(e.x1,-e.y1,e.x,-e.y);break;case"C":n.bezierCurveTo(e.x1,-e.y1,e.x2,-e.y2,e.x,-e.y)}}return n.subPaths.forEach(e=>{let t=function(e){if(e.length){let t=e[0];if(t instanceof Qo)return t.v1;if(t instanceof Zo||t instanceof tl)return t.v0}}(e.curves);void 0!==t&&e.currentPoint.distanceTo(t)>0&&e.lineTo(t.x,t.y)}),{offsetX:o,path:n}}getCharWidth(e,t){return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}getTextWidth(e,t){return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}computeSpaceWidthForLine(e,t,i,r){let s=this.getCharWidth(" ",i),a=e[t];if(a){let n=this.countSpaces(a.trimEnd());if(4===i.horizontalAlign&&t<e.length-1&&n)return(("string"==typeof i.width?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(a,i)-n*s))/n}return s}countSpaces(e){return(e.match(/ /g)||[]).length}},Xv("text"),hb(),JT(),qC(),bN(),XT();var aae=class{get sharedAssets(){return this.shared}constructor(e,t={},i=!0){this.shared=new FT(e.shared,t,!0,i),this.scene=new fN(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof FC&&!e.uiScene&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.scene.releaseInstanceGroups(),this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof YT&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};Bv(),Bv(),Qb(),Mu(),yx(),JT(),Yv();var nae,oae,lae=new ns;function hae(e){e.traverseEntity(t=>{for(let i of t.data.events){let t=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":t.push(...i.data.actions);break;case"GameControl":for(let e of Object.values(i.data.gameActions))t.push(...e);break;case"DragDrop":t.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":t.push(...i.data.inActions,...i.data.outActions)}for(let i of t)if("Create"===i.data.type&&"Yes"===i.data.hideBase){let t=e.scene.find(i.data.object);t&&(t.visible=!1)}}})}function uae(e,t,i,r,s=!1){if(e.markShadowsDirty(),t instanceof YT&&!jv(t)&&t.removeInteractionGeometry(r),Gv(t)?t.changeSelectedState(i,{shared:r},s):t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof YT&&t.updateGeometryGroupsIfNeeded(),t instanceof fx&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),!Gv(t)){if(t.cloner){let i=!1;for(let e of t.cloner.children)e.playModeVisible=void 0,void 0!==e.transformOverride&&(e.transformOverride=void 0,i=!0);i&&e.addPendingUpdateCloner(t),t.cloner.syncInstanceMatrices()}t.updateVisible()}}function dae(e){return oae||(oae=Promise.resolve().then(()=>(NN(),xN)).then(({DRACOLoader:t})=>((nae=new t).setDecoderPath(void 0!==e?`${e}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload(),nae.decoderPending))),oae}async function cae(e){if(nae){let t,i={attributeIDs:nae.defaultAttributeIDs,attributeTypes:nae.defaultAttributeTypes,useUniqueIDs:!1};try{t=await nae.decodeGeometry(new Int8Array(e).buffer,i)}catch(e){console.error(e)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([e,t])=>({name:e,itemSize:t.itemSize,array:t.array}))}}return null}async function pae(e){for(let t of e){let e=await cae(t.geometry.data.draco);if(e){let i=t.geometry.data;e.index&&(i.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let r={};e.attributes.forEach(({name:e,array:t,itemSize:i})=>{r[e]={array:t,itemSize:i,type:"Float32Array",normalized:!1}}),i.attributes=r,i.draco=void 0}}}bN(),um(),Dx(),cC(),hA(),Ow(),mC(),Bv(),md();var mae,gae,fae=new Promise(e=>{mae=e});function yae(e){return gae||(gae=async function(){let t=e??(Su?".":"https://cdn.spline.design/@splinetool/runtime@2.0.2/build"),i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${t}/physics.wasm`).then(e=>e.arrayBuffer())]);await r.init(s),mae(r)}())}function vae(e){let t=!1;return e.scene.objects.forEach(i=>{"Page"===i.data.type&&!t&&i.data.publish.gameControlObject&&Yf.traverseModuleInstances(e,i.id,(e,i,r)=>{for(let e of r)"GameControl"===e.data.type&&e.data.navmesh.enabled&&(t=!0)})}),t}function bae(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,s=t[8]**2+t[9]**2+t[10]**2,a=t[0]**2+t[4]**2+t[8]**2,n=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||s<l||a<l||n<l||o<l}function xae(e,t){let i=new an;if(t&&bae(t))return i.setAttribute("position",new Ha([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new Ha([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=DM(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Ha(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}Yv(),Qb(),md(),Bv(),hb(),LA(),Mu(),Mu(),XM(),Yy();var wae,_ae=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=ose(t,t.actions,r,s,a,i),this.target=t.target}disconnect(){lse(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>{"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.Animation.forEach(e=>{"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}},Sae=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=ose(t,t.actions,r,s,a,i),this.target=t.target,this.triggeringObjects=[];for(let e of t.triggeringObjects){let t=r.scene.find(e);t&&this.triggeringObjects.push(t)}}isValidTriggeringObject(e){return"all"===this.target||this.triggeringObjects.some(t=>t===e||t.isAncestorOf(e.uuid)||e.isAncestorOf(t.uuid))}disconnect(){lse(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(e=>{"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.SwitchCamera.forEach(e=>{"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&"Toggle"===e.data.runMode?e.toggle():e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}};Yv(),fae.then(e=>wae=e);var Mae,Tae,Cae=new ns,Aae=new ss,Nae=new ns,Pae=(new Ls(0,0,0,"YXZ"),new Ls(0,0,0,"XYZ")),Rae=new ns,Eae=new ns,Oae=new ns(1,1,1),Bae=new ss,Vae=new As,Dae=new As,Iae={type:"updateMatrix"},Lae=new ss,zae=new Ka,kae=.01,Uae={type:"beginEvent",eventName:"Collision"},Fae={type:"beginEvent",eventName:"Trigger"},jae=class{constructor(e){this.eventContext=e,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=e=>{if(e.bodyType()!==wae.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[t,i,r]=this.rigidBodyToMesh.get(e.handle);if(Cae.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Aae.copy(e.rotation()),t.matrixWorld.compose(Cae,Aae,i),t.hasNonUniformScale&&t.matrixWorld.multiply(t.shearScale),t.dispatchEvent(Iae),r){let e=t.cloner;if(e&&void 0===e.objectForSample){e.matrixWorld.copy(t.matrixWorld);for(let t of e.children)t.updateMatrixWorld(!0)}for(let e of t.children)e.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,t,i)=>{if(!1===i)return;let r,s;if(this.sensorToTriggerEvent[e]?(r=this.sensorToTriggerEvent[e],s=this.sharedGameControlGlobals.colliderToEntity.get(t)):this.sensorToTriggerEvent[t]&&(r=this.sensorToTriggerEvent[t],s=this.sharedGameControlGlobals.colliderToEntity.get(e)),r&&s&&r.isValidTriggeringObject(s))r.dispatch();else{for(let i=this.sharedGameControlGlobals.createdObjects.length-1;i>=0;i--){let r=this.sharedGameControlGlobals.createdObjects[i];if(r.userData.hasCollisionDestroy&&(r.rigidBody?.collider(0).handle===e||r.rigidBody?.collider(0).handle===t)){this.sharedGameControlGlobals.createdObjects.splice(i,1),r.removeFromParent(),requestAnimationFrame(()=>this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(r.rigidBody));break}}if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let e=this.sharedGameControlGlobals.colliderToEntity.get(t),i=this.sharedGameControlGlobals.entityToCollisionEvents[e.uuid];if(void 0===i)return;for(let r of i)"character"===r.data.target&&this.dispatchCollisionEvent(r,e,t)}else if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(t)){let t=this.sharedGameControlGlobals.colliderToEntity.get(e),i=this.sharedGameControlGlobals.entityToCollisionEvents[t.uuid];if(void 0===i)return;for(let r of i)"character"===r.data.target&&this.dispatchCollisionEvent(r,t,e)}else{let i=this.sharedGameControlGlobals.colliderToEntity.get(e),r=this.sharedGameControlGlobals.entityToCollisionEvents[i.uuid];if(void 0!==r)for(let t of r)"scene"===t.data.target&&this.dispatchCollisionEvent(t,i,e);let s=this.sharedGameControlGlobals.colliderToEntity.get(t),a=this.sharedGameControlGlobals.entityToCollisionEvents[s?.uuid];if(void 0!==a)for(let e of a)"scene"===e.data.target&&this.dispatchCollisionEvent(e,s,t)}}},this.isExport=e.isExport,this.sharedAssets=e.sharedAssets,this.renderer=e.renderer,this.requestRender=e.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(e=>{let t=e.dataPatched;for(let e of t.events){if(!0===e.data.disabled)continue;let t=e.data.actions?.find(e=>"Destroy"===e.data.type)?.data;if(t)for(let e of t.objects){let t=this.page.scene.find(e);t&&(t.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(e=>{let t=e.dataPatched;for(let e of t.events)if(!0!==e.data.disabled&&"DragDrop"===e.data.type)for(let t of e.data.objects){let e=this.page.scene.find(t);e&&(e.userData.hasDrag=!0)}})}_staticBVHIdOf(e){let t=this._staticBVHAttrIds.get(e);return void 0===t&&(t=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(e,t)),t}initBVH(){Kv("collision-bvh","trigger/collision detection")}addRigidBody(e,t,i){if(bae(e.matrixWorld))return;let r=[],s="geometry"in e?e.geometry:void 0,a=t.dataPatched;if(void 0!==s?.getAttribute("position")&&r.push(xae(s,e.shearScale)),a.physics.fusedBody){let t=this.gatherChildrenGeom(e,r);e.traverseObject(t),e.children.forEach(e=>e.updateMatrixWorld(!0));let i=e.cloner;i&&void 0===i.objectForSample&&"dynamic"===a.physics.rigidBody&&(i.traverseObject(t),i.children.forEach(e=>e.updateMatrixWorld(!0)))}if(r.length>0){let n,o=!1,l=!i.fromCreate&&"dynamic"===a.physics.rigidBody||i.fromCreate&&i.dynamic;l?(n=wae.RigidBodyDesc.dynamic(),n.setLinearDamping(a.physics.damping).setAngularDamping(a.physics.damping).setAdditionalMass(1e-9).setGravityScale(a.physics.gravityScale).enabledRotations(...a.physics.enabledRotation).enabledTranslations(...a.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(n=wae.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),o=!0):n=wae.RigidBodyDesc.fixed();let h=Hy(r);(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(Cae,Aae,Nae),e.position0=Cae.clone().divideScalar(this.pixelsPerMeter),e.rotation0=Aae.clone(),Cae.divideScalar(this.pixelsPerMeter),n.setTranslation(Cae.x,Cae.y,Cae.z).setRotation(Aae),s?h?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):h?.scale(Nae.x/this.pixelsPerMeter,Nae.y/this.pixelsPerMeter,Nae.z/this.pixelsPerMeter);let u=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);l?this.rigidBodyToMesh.set(u.handle,[e,Nae.clone(),a.physics.fusedBody]):o?this.sharedGameControlGlobals.kinematicBodyToEntity.set(u.handle,e):this.fixedBodiesToWatch.push([e,u,(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).clone()]);let d=!(void 0===a.geometry||"SubdivGeometry"===a.geometry.type||"NonParametricGeometry"===a.geometry.type||"BooleanGeometry"===a.geometry.type||"VectorGeometry"===a.geometry.type||"StarGeometry"===a.geometry.type||"RectangleGeometry"===a.geometry.type||"EllipseGeometry"===a.geometry.type||"TriangleGeometry"===a.geometry.type||"TorusGeometry"===a.geometry.type||"HelixGeometry"===a.geometry.type);try{this.addCollider(u,a.physics,h,t,d)}catch{try{this.addCollider(u,a.physics,h,t,!1)}catch(e){console.error(e)}}e.rigidBody=u}}addBoundsTree(e){let t=[];if(void 0!==e.geometry?.getAttribute("position")&&e.geometry?.getAttribute("position").count>0&&t.push(xae(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,t)),e.children.forEach(e=>e.updateMatrixWorld(!0)),t.length>0){let i=Hy(t,!1);e.bvhGeometry=i,i.getAttribute("position").count>0?(e.bvhGeometry.boundsTree=new null(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e)):Su&&console.warn(`ControlsManager.addBoundsTree: object "${e.name}" has empty geometry`)}}addCollider(e,t,i,r,s=!0){if(0===i?.getAttribute("position").count||0===i?.getIndex()?.count)return;let a;i&&(a="trimesh"===t.colliderType?wae.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):wae.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),a.setFrictionCombineRule(wae.CoefficientCombineRule.Average).setRestitutionCombineRule(wae.CoefficientCombineRule.Average).setDensity(t.density).setFriction(t.friction).setRestitution(t.restitution);let n=this.sharedGameControlGlobals.rapierWorld.createCollider(a,e);this.sharedGameControlGlobals.colliderToEntity.set(n.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(e=>"scene"===e.target)&&n.setActiveEvents(wae.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(e,t){return(i,r)=>{if(0===r)return;let s;if(qv(i)){if(!i.objectForSample)return!0===i.object.dataPatched.physics.fusedBody&&"dynamic"===i.object.dataPatched.physics.rigidBody||void 0;if(i.objectForSample.dataPatched.physics.fusedBody)return;s=i.object}else if(Hv(i))s=i.object;else if(s=i,s.dataPatched.cloner?.hideBase)return!0;let a=s.dataPatched;if("visibility"===a.physics.enabled?!a.visible:!a.physics.enabled)return!0;1===r?e.hasNonUniformScale?i.matrixWorld.multiplyMatrices(e.shearScale,i.hiddenMatrix):i.matrixWorld.copy(i.hiddenMatrix):i.matrixWorld.multiplyMatrices(i.parent.matrixWorld,i.hiddenMatrix),i.matrixWorld.multiply(i.matrix);let n=i.geometry;void 0!==n?.getAttribute("position")&&t.push(xae(n,i.matrixWorld))}}activate(e){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=e,this.usePhysics=this.page.data.globalPhysics.usePhysics;let t=this.page.playCamera,i=!1;this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(!1===t.data.disabled&&"Trigger"===t.data.type)return this.needsCollisionDetection=!0,!0});if(null!==this.page.data.publish.gameControlObject&&Kv("game-controls","the scene's game controls"),!1===i){let{enableRotate:e,enablePan:i,enableZoom:r,autoRotate:s,hoverRotatePanMode:a}=this.eventManager.publish.orbitControls;(e||i||r||s||0!==a)&&(this.orbitControls=new Use(t,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}this.renderer.domElement.width,this.renderer.getPixelRatio(),this.renderer.domElement.height,this.renderer.getPixelRatio(),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(e=>e.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new wae.World(new wae.Vector3(0,this.gravity,0)),this.events=new wae.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(i=>{let r;if(qv(i)){if(!i.objectForSample)return!0===i.object.dataPatched.physics.fusedBody&&"dynamic"===i.object.dataPatched.physics.rigidBody||void 0;if(i.objectForSample.dataPatched.physics.fusedBody)return;r=i.object}else if(Hv(i))r=i.object;else{if(Uv(i)||i instanceof EA)return;if(r=i,!1===r.dataPatched.cloner?.disabled&&r.dataPatched.cloner?.hideBase&&!0!==r.dataPatched.physics?.fusedBody)return!0}let s,a=r.dataPatched;for(let e of a.events)!0!==e.data.disabled&&"GameControl"===e.data.type&&(s=e.data);if(!a.physics||("visibility"===a.physics.enabled?!a.visible:!a.physics.enabled))return!0;i.updateMatrixWorldRigid();let n=a.states.some(e=>void 0!==e.data.position||void 0!==e.data.rotation||void 0!==e.data.hiddenMatrix||void 0!==e.data.cloner||void 0!==e.data.pathSnapping),o=!1,l=r.userData.hasDestroy,h=r.userData.hasDrag,u=!1;for(let e of a.events)if(!0!==e.data.disabled)if("Collision"===e.data.type){o=!0;let t=new _ae(e.id,e.data,r,this.page,this.sharedAssets,this.eventManager);t.initialDisabled=!0,this.collisionEvents.push(t),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid].every(t=>t.id!==e.id)?this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid].push(t):this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]=[t]}else if("Follow"===e.data.type){u=!0;let t=e.data.target;i.traverseVisible(e=>{e.userData.isFollowingObj=t})}"dynamic"===a.physics.rigidBody&&!1===a.physics.fusedBody&&(i.matrixWorldFusedFalse=i.matrixWorld.clone());let d=i.geometry;if(void 0!==s){let e=wae.RigidBodyDesc.kinematicPositionBased();(i.hasNonUniformScale?i.matrixWorldRigid:i.matrixWorld).decompose(Cae,Aae,Nae),i.position0=Cae.clone().divideScalar(this.pixelsPerMeter),i.rotation0=Aae.clone(),Cae.divideScalar(this.pixelsPerMeter),e.setTranslation(Cae.x,Cae.y,Cae.z).setRotation(Aae);let t,n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(e);i.rigidBody=n,t="sphere"===s.collider.type?wae.ColliderDesc.ball(s.collider.radius/this.pixelsPerMeter):"capsule"===s.collider.type?wae.ColliderDesc.capsule((s.collider.height/2-s.collider.radius)/this.pixelsPerMeter,s.collider.radius/this.pixelsPerMeter):wae.ColliderDesc.cuboid(s.collider.width/this.pixelsPerMeter/2,s.collider.height/this.pixelsPerMeter/2,s.collider.depth/this.pixelsPerMeter/2),t.setFrictionCombineRule(wae.CoefficientCombineRule.Average).setDensity(a.physics.density).setFriction(a.physics.friction).setRestitution(0).setRestitutionCombineRule(wae.CoefficientCombineRule.Min);let o=this.sharedGameControlGlobals.rapierWorld.createCollider(t,n);this.sharedGameControlGlobals.colliderToEntity.set(o.handle,r),Cae.fromArray(s.collider.position.map(e=>"number"==typeof e?e:0)).multiply(Nae.setFromMatrixScale(r.matrixWorld)).divideScalar(this.pixelsPerMeter),o.setTranslationWrtParent(Cae);let l=(new ss).setFromEuler((new Ls).setFromVector3((new ns).fromArray(s.collider.rotation.map(e=>"number"==typeof e?e:0))));o.setRotationWrtParent(l),o.setActiveEvents(wae.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(r,!0)}else"dynamic"===a.physics.rigidBody||n||u||l||h||o?(this.addRigidBody(i,r,{hasFollow:u,hasTransformAnim:n,hasDrag:h}),this.generateSensorColliderDescs(r,a.physics.fusedBody)):(d&&e.push(xae(d,i.matrixWorld)),a.physics.fusedBody&&i.traverseObject((t,i)=>{if(0===i)return;let r;if(qv(t)){if(!t.objectForSample)return!0===t.object.dataPatched.physics.fusedBody&&"dynamic"===t.object.dataPatched.physics.rigidBody||void 0;if(t.objectForSample.dataPatched.physics.fusedBody)return;r=t.object}else{if(Uv(t)||t instanceof EA)return;if(Hv(t))r=t.object;else if(r=t,r.dataPatched.cloner?.hideBase)return!0}let s=r.dataPatched;if("visibility"===s.physics.enabled?!s.visible:!s.physics.enabled)return!0;let a=t.geometry;void 0!==a?.getAttribute("position")&&e.push(xae(a,t.matrixWorld))}),this.generateSensorColliderDescs(r,a.physics.fusedBody,t));return!(!0!==a.physics?.fusedBody&&!s)||void 0}),0===e.length)return;let i=Hy(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=wae.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),a=wae.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(wae.CoefficientCombineRule.Multiply).setRestitutionCombineRule(wae.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);for(let[e,i]of t){let t=this.sharedGameControlGlobals.rapierWorld.createCollider(e,s);this.sensorToTriggerEvent[t.handle]=i}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if("Trigger"===t.data.type&&!0!==t.data.disabled){let i=new Sae(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=(new As).compose(Rae.fromArray(t.data.position.map(e=>"number"==typeof e?e:0)),Bae.setFromEuler(Pae.fromArray(t.data.rotation.map(e=>"number"==typeof e?e:0))),Oae);if("box"===t.data.triggerZone){let s=new Sa;s.min.fromArray(t.data.size.map(e=>"number"==typeof e?e:0)).multiplyScalar(-.5),s.max.fromArray(t.data.size.map(e=>"number"==typeof e?e:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e){if(!this.isEnabled)return!0;let t=!0;if(void 0!==this.orbitControls&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),t=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,t=!1):2===this.initializationCounter&&this.gameControl&&(t=!this.gameControl.update(e)&&t),!1===this.usePhysics&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(0===e)t=this.stepPhysics()&&t;else{let r=e/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let s=performance.now(),a=0,n=6;for(;this.accumulator>=i&&a<n&&(t=this.stepPhysics()&&t,this.accumulator-=i,a++,!(performance.now()-s>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=t}recordPhysicsPose(e){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(Cae,Aae,Nae);let t=e;void 0===t.prevQ?(t.prevQ=Aae.clone(),t.prevT=Cae.clone()):(t.prevQ.copy(Aae),t.prevT.copy(Cae))}promoteMovedFixedBodies(){for(let e=this.fixedBodiesToWatch.length-1;e>=0;e--){let[t,i,r]=this.fixedBodiesToWatch[e];(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).equals(r)||(i.setBodyType(wae.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t),this.fixedBodiesToWatch.splice(e,1))}}clampPushedBodies(){let e=this.gameControl?.object.rigidBody;if(void 0===e)return;let t=this.sharedGameControlGlobals.rapierWorld,i=e.linvel(),r=e.translation(),s=Math.hypot(i.x,i.z);for(let a=0;a<e.numColliders();a++){let n=e.collider(a);t.contactPairsWith(n,e=>{let a=e.parent();if(null===a||!a.isDynamic())return;let o=a.translation(),l=-1/0,h=0,u=0;if(t.contactPair(n,e,e=>{let t=e.normal(),s=t.x*(o.x-r.x)+t.y*(o.y-r.y)+t.z*(o.z-r.z)<0?-1:1;if(Math.abs(t.y)>.7)return;let a=s*t.x,n=s*t.z,d=Math.hypot(a,n);if(d<1e-4)return;let c=(i.x*a+i.z*n)/d;c>l&&(l=c,h=a/d,u=n/d)}),l===-1/0)return;let d=i.x*h+i.z*u;if(d<-kae)return;let c=a.linvel();if(s>kae&&d>kae){let e=c.x*h+c.z*u;if(e<=0)return;let t=Math.min(e,d);return void a.setLinvel({x:h*t,y:c.y,z:u*t},!0)}let p=c.x*h+c.z*u-Math.max(0,d);if(p<=0)return;let m=.5*p;a.setLinvel({x:c.x-h*m,y:c.y,z:c.z-u*m},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();for(let e of this.sharedGameControlGlobals.kinematicBodyToEntity.values())this.recordPhysicsPose(e),e.rigidBody.setNextKinematicTranslation(Cae.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(Aae);for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim)!0!==e.rigidBody?.isKinematic()&&this.recordPhysicsPose(e);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r,s=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(t.cloner)for(let e of t.cloner.children)if(e.rigidBody===s){r=e;break}e.dispatch(r),t.dispatchEvent(Uae)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=Dae.copy(e.matrixWorld).invert();e.traverseEntity((s,a)=>{if(!1===t&&1===a)return!0;for(let t of s.dataPatched.events)if("Trigger"===t.data.type&&!0!==t.data.disabled){let a,n=new Sae(t.id,t.data,s,this.page,this.sharedAssets,this.eventManager);if(a="box"===t.data.triggerZone?wae.ColliderDesc.cuboid(...t.data.size.map(e=>("number"==typeof e?e:1)/(2*this.pixelsPerMeter))):wae.ColliderDesc.ball(t.data.radius/this.pixelsPerMeter),a.setDensity(0).setSensor(!0).setActiveEvents(wae.ActiveEvents.COLLISION_EVENTS),Rae.fromArray(t.data.position.map(e=>"number"==typeof e?e:0)),Bae.setFromEuler(Pae.fromArray(t.data.rotation.map(e=>"number"==typeof e?e:0))),Vae.compose(Rae,Bae,Oae).premultiply(s.matrixWorld),i?(Vae.decompose(Rae,Bae,Eae),a.setActiveCollisionTypes(wae.ActiveCollisionTypes.KINEMATIC_FIXED|wae.ActiveCollisionTypes.DYNAMIC_FIXED)):(Vae.premultiply(r).decompose(Rae,Bae,Eae),e.rigidBody.bodyType()===wae.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===wae.RigidBodyType.Fixed?a.setActiveCollisionTypes(wae.ActiveCollisionTypes.KINEMATIC_FIXED|wae.ActiveCollisionTypes.DYNAMIC_FIXED):a.setActiveCollisionTypes(wae.ActiveCollisionTypes.KINEMATIC_KINEMATIC|wae.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Rae.divideScalar(this.pixelsPerMeter),a.setTranslation(Rae.x,Rae.y,Rae.z),a.setRotation(Bae),i)i.push([a,n]);else{let t=this.sharedGameControlGlobals.rapierWorld.createCollider(a,e.rigidBody);this.sensorToTriggerEvent[t.handle]=n}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,a]=this.sharedGameControlGlobals.triggers[t];for(let t=0;t<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;t++){let n=this.sharedGameControlGlobals.entitiesWithTransformAnim[t];if(s===n||!1===a.isValidTriggeringObject(Lb.is(n)?n:n.object))continue;let o=Dae.copy(s.matrixWorld).decompose(Rae,Lae,Eae).compose(Rae,Lae,Oae).multiply(r),l=Vae.copy(n.matrixWorld).invert().multiply(o),h=n.bvhGeometry.boundsTree;i instanceof Sa?e=h.intersectsBox(i,l):(zae.radius=i,zae.center.setFromMatrixPosition(l),e=h.intersectsSphere(zae)),e?-1===a.currentIntersectedObjects.indexOf(n)&&(a.currentIntersectedObjects.push(n),a.dispatch(),s.dispatchEvent(Fae)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(e=>e!==n)}}}};function Gae(e){return Tae||(Tae=async function(){let t=e??(Su?".":"https://cdn.spline.design/@splinetool/runtime@2.0.2/build"),i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(e=>e.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});Mae(n)}())}function Wae(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+e,a=this._loopCount,n=r===Qi;if(0===e)return-1===a||!n||1&~a?s:t-(s-i);if(r===Zi){-1===a&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else{if(!(s<0)){this.time=s;break e}s=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===a&&(e>=0?(a=0,this._setEndings(!0,0===this.repetitions,n)):this._setEndings(0===this.repetitions,!0,n)),s>=t||s<i){let r=Math.floor((s-i)/(t-i));s-=(t-i)*r,a+=Math.abs(r);let o=this.repetitions-a;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n||(s=e>0?t:i,1===this.repetitions&&(s=t)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){let t=e<0;this._setEndings(t,!t,n)}else this._setEndings(!1,!1,n);this._loopCount=a,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:r})}}else this.time=s;if(n&&!(1&~a))return t-(s-i)}return s}PM(),nN(),yN(),rw(),md(),new Promise(e=>{Mae=e}),Mu(),Mu(),md();var qae=!1,Hae=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=e=>{"Empty"===e.data.type&&Array.isArray(e.data.animations)&&e.data.animations.forEach((t,i)=>{let r=t[0]+"/";if(Array.isArray(e.identity)?r+=e.identity[0]:r+=e.uuid,this.clipIdToAction[r])return;let s=zl.parse(JSON.parse(t[2]));e.animations[i]=s;let a=this.mixer.clipAction(s,e);!1===qae&&(Object.getPrototypeOf(a)._updateTime=Wae,qae=!0),a.clampWhenFinished=!0,this.clipIdToAction[r]=a})},this.mixer=new Lh(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(t=>t.uuid===e);if(!r)return;let s=this.clipIdToAction[e];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(t=>t.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.scene.markShadowsDirty(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=Ji}),this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),"pingpong"===e.direction&&0!==e.repeat&&(i.loop=Qi)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.scene.markShadowsDirty(),this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.scene.markShadowsDirty(),this.requestRender()}update(e){if(this.needsUpdate)this.needsUpdate=!1;else if(!1===this.isPlaying||this.animationInspectorState?.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return function(e){let t=e?.tracks.filter(e=>"vector"===e.ValueTypeName||"quaternion"===e.ValueTypeName).map(e=>e.times.length);if(t?.length){let e=function(e){if(!e||0===e.length)return;let t;for(let i of e)i==i&&(void 0===t||i>t)&&(t=i);return t}(t);return e&&e>2?e:2}return 2}(this.activeClip??void 0)}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(e/(this.maxFrames-1),.9999)*this.activeClip.duration),this.scene.markShadowsDirty(),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}};Vv(),qC(),Mw(),ZT(),pC(),nw(),EN();var $ae={bloom:()=>Promise.resolve().then(()=>(H5(),q5)),depthOfField:()=>Promise.resolve().then(()=>(K5(),X5))};function Yae(e){return function(e,t){return Promise.all(e.map(e=>t[e]?.().catch(t=>{console.warn(`[spline] Failed to load the ${e} postprocessing effect (webgpu); the effect will be skipped.`,t)}))).then(()=>{})}(e,$ae)}md();var Xae=h(Z5(),1);function Kae(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Zae(e){return{id:e.uuid,name:e.name,type:e.object.data?.type??e.object.type,visible:!1!==e.playModeVisible,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x*ts.RAD2DEG,y:e.rotation.y*ts.RAD2DEG,z:e.rotation.z*ts.RAD2DEG},scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},spawned:!0}}function Jae(e){return{id:e.uuid,name:e.name,type:e.type??"Object",visible:e.visible,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x*ts.RAD2DEG,y:e.rotation.y*ts.RAD2DEG,z:e.rotation.z*ts.RAD2DEG},scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z}}}function Qae(e,t,i){let r=t=>e.findObjectById(t)??e.findObjectByName(t),s=new Map,a=e=>{let t=s.get(e);if(t)return t;for(let t of s.values())if(t.name===e)return t};return{setVariable:(t,i)=>t in e.getVariables()?(e.setVariable(t,i),{ok:!0}):{ok:!1,warning:`spline.setVariable: no variable named "${t}" in this scene.`},getVariable:t=>e.getVariable(t),getVariables:()=>e.getVariables(),getAllObjects:()=>e.getAllObjects().map(Jae),findObject:e=>{let t=r(e);return t?Jae(t):void 0},getGeometry:(e,t)=>{if(!i)return{warning:"spline.getGeometry: not available in this runtime integration."};let s=a(e),n=s?s.object:(()=>{let t=r(e);return t?i.findEntity(t.uuid):void 0})();if(!n)return{warning:`spline.getGeometry: no object named "${e}" (names/ids come from getAllObjects).`};let o,l=s??n;"world"===t.space&&(l.updateWorldMatrix?.(!0,!1),o=l.matrixWorld?.elements);let h=function(e,t){let i=e?.getAttribute("position");if(!i||!i.count)return null;let r=i.count,s=t??null,a=e.getIndex?.()??null,n=Math.floor((a?a.count:r)/3),o=1/0,l=1/0,h=1/0,u=-1/0,d=-1/0,c=-1/0,p=new Float32Array(3*r);for(let e=0;e<r;e++){let t=i.getX(e),r=i.getY(e),a=i.getZ(e);s&&([t,r,a]=hd(s,t,r,a)),t<o&&(o=t),r<l&&(l=r),a<h&&(h=a),t>u&&(u=t),r>d&&(d=r),a>c&&(c=a),p[3*e]=t,p[3*e+1]=r,p[3*e+2]=a}let m={space:s?"world":"local",vertexCount:r,triangleCount:n,indexed:null!==a,bounds:{min:[o,l,h],max:[u,d,c],size:[u-o,d-l,c-h]},vertices:p};if(a){let e=new Uint32Array(a.count);for(let t=0;t<a.count;t++)e[t]=a.getX(t);m.indices=e}let g=e.getAttribute("normal");if(g&&g.count===r){let e=s?function(e){let t=e[0],i=e[4],r=e[8],s=e[1],a=e[5],n=e[9],o=e[2],l=e[6],h=e[10],u=t*(a*h-n*l)-i*(s*h-n*o)+r*(s*l-a*o);if(!isFinite(u)||Math.abs(u)<1e-12)return null;let d=1/u,c=[(a*h-n*l)*d,(r*l-i*h)*d,(i*n-r*a)*d,(n*o-s*h)*d,(t*h-r*o)*d,(r*s-t*n)*d,(s*l-a*o)*d,(i*o-t*l)*d,(t*a-i*s)*d];return[c[0],c[3],c[6],c[1],c[4],c[7],c[2],c[5],c[8]]}(s):void 0;if(!s||e){let t=new Float32Array(3*r);for(let i=0;i<r;i++){let r=g.getX(i),s=g.getY(i),a=g.getZ(i);if(e){let t=e[0]*r+e[1]*s+e[2]*a,i=e[3]*r+e[4]*s+e[5]*a,n=e[6]*r+e[7]*s+e[8]*a,o=Math.hypot(t,i,n);o>1e-12?(r=t/o,s=i/o,a=n/o):(r=t,s=i,a=n)}t[3*i]=r,t[3*i+1]=s,t[3*i+2]=a}m.normals=t}}let f=e.getAttribute("uv");if(f&&f.count===r){let e=new Float32Array(2*r);for(let t=0;t<r;t++)e[2*t]=f.getX(t),e[2*t+1]=f.getY(t);m.uvs=e}return m}(n.geometry,o);return h?{data:{id:l.uuid,name:l.name,geometry:n.data?.geometry?.type,...h}}:{warning:`spline.getGeometry: "${l.name}" has no readable geometry — only meshes do (lights, cameras and groups have none; read a group's child meshes instead).`}},updateObject:(t,s)=>{let n=a(t);if(n){let{position:t,rotation:i,scale:r,visible:a}=s;return t&&("number"==typeof t.x&&(n.position.x=t.x),"number"==typeof t.y&&(n.position.y=t.y),"number"==typeof t.z&&(n.position.z=t.z)),i&&("number"==typeof i.x&&(n.rotation.x=i.x*ts.DEG2RAD),"number"==typeof i.y&&(n.rotation.y=i.y*ts.DEG2RAD),"number"==typeof i.z&&(n.rotation.z=i.z*ts.DEG2RAD)),r&&("number"==typeof r.x&&(n.scale.x=r.x),"number"==typeof r.y&&(n.scale.y=r.y),"number"==typeof r.z&&(n.scale.z=r.z)),"boolean"==typeof a&&(n.playModeVisible=a),n.updateMatrix(),e.requestRender(),!0}let o=r(t);if(!o)return!1;let{position:l,rotation:h,scale:u,visible:d,geometry:c,material:p}=s;if(c&&"object"==typeof c&&i){let e=i.findEntity(o.uuid);if(e){let{vertices:t,normals:r,uvs:s,indices:a,...n}=c;Kae(t)&&i.shared.updateEntityGeometryVertices(e,{vertices:t,normals:Kae(r)?r:void 0,uvs:Kae(s)?s:void 0,indices:Kae(a)?a:void 0}),Object.keys(n).length>0&&i.shared.updateEntityGeometryParams(e,n)}}if(p&&"object"==typeof p&&i){let e=i.findEntity(o.uuid);e&&i.shared.updateEntityMaterialParams(e,p)}return l&&("number"==typeof l.x&&(o.position.x=l.x),"number"==typeof l.y&&(o.position.y=l.y),"number"==typeof l.z&&(o.position.z=l.z)),h&&("number"==typeof h.x&&(o.rotation.x=h.x*ts.DEG2RAD),"number"==typeof h.y&&(o.rotation.y=h.y*ts.DEG2RAD),"number"==typeof h.z&&(o.rotation.z=h.z*ts.DEG2RAD)),u&&("number"==typeof u.x&&(o.scale.x=u.x),"number"==typeof u.y&&(o.scale.y=u.y),"number"==typeof u.z&&(o.scale.z=u.z)),"boolean"==typeof d&&(o.visible=d),e.requestRender(),!0},createObject:async(t,i)=>Jae(await e.createObject(t,i)),createCustomMaterial:t=>e.createCustomMaterial(t),setMaterial:(t,i)=>e.setMaterial(t,i),cloneObject:(t,i)=>Jae(e.cloneObject(t,i)),removeObject:t=>e.removeObject(t),spawnObject:(t,a)=>{if(!i)return{warning:"spline.spawnObject: not available in this runtime integration."};let n=r(t),o=n?i.findEntity(n.uuid):void 0;if(!o)return{warning:`spline.spawnObject: no object named "${t}" to use as a template.`};if(s.size>=500)return{warning:"spline.spawnObject: spawn budget reached (500 live copies) — destroyObject old copies (or reuse them) instead of spawning more."};let l=i.shared.spawnRuntimeClone(o,a??{});return l?(s.set(l.uuid,l),e.requestRender(),{object:Zae(l)}):{warning:`spline.spawnObject: "${t}" cannot be spawned from.`}},destroyObject:t=>{let r=a(t);return!(!i||!r||(s.delete(r.uuid),i.shared.destroyRuntimeClone(r),e.requestRender(),0))},setInstanceTransforms:(t,s)=>{if(!i)return-1;let a=r(t),n=a?i.findEntity(a.uuid):void 0;if(!n)return-1;let o=i.shared.setEntityInstanceTransforms(n,s);return o>=0&&e.requestRender(),o},emitEvent:(e,t,i)=>{let s=r(t);return s?(i?s.emitEventReverse(e):s.emitEvent(e),{ok:!0}):{ok:!1,warning:`spline.emitEvent: no object named "${t}".`}},requestRender:()=>e.requestRender(),addSplineEventListener:(t,i)=>{let r=e=>{i({target:{id:e.target?.id??"",name:e.target?.name??""}})};return e.addEventListener(t,r),()=>e.removeEventListener(t,r)},getCanvas:()=>t}}Mu(),md();var ene=class{constructor(e,t,i){this.iframe=e,this.bridge=t,this.observer=i}static mount(e,t,i,r){if(typeof document>"u")return null;let s=t.parentElement;if(!s)return null;"static"===getComputedStyle(s).position&&(s.style.position="relative");let a=document.createElement("iframe");a.setAttribute("sandbox","allow-scripts allow-forms allow-pointer-lock"),a.title="Spline HTML content";let n=a.style;n.position="absolute",n.border="0",n.background="transparent",n.pointerEvents="auto",n.colorScheme="normal";let o=()=>{n.left=`${t.offsetLeft}px`,n.top=`${t.offsetTop}px`,n.width=`${t.offsetWidth}px`,n.height=`${t.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(t),l.observe(s),a.srcdoc=function(e){let t=`<script>${Ju}<\/script>`,i=/<head(\s[^>]*)?>/i.exec(e);if(i){let r=i.index+i[0].length;return e.slice(0,r)+t+e.slice(r)}let r=/<html(\s[^>]*)?>/i.exec(e);if(r){let i=r.index+r[0].length;return e.slice(0,i)+`<head>${t}</head>`+e.slice(i)}return t+e}(i),s.insertBefore(a,t.nextSibling);let h=new dd(a,Qae(e,t,r),(e,t)=>{"warn"===e?console.warn(`[spline html] ${t}`):"error"===e&&console.error(`[spline html] ${t}`)});return h.attach(),new ene(a,h,l)}dispose(){this.bridge.dispose(),this.observer.disconnect(),this.iframe.remove()}};md();var tne="data-spline-html-content",ine=`\n[${tne}] { pointer-events: none; }\n[${tne}] > * { pointer-events: auto; }\n[${tne}] [data-spline-passthrough] { pointer-events: none; }\n`,rne=class{constructor(e,t,i,r,s){this.container=e,this.host=t,this.observer=i,this.previousSplineGlobal=r,this.removeLateLifecycleShim=s}static mount(e,t,i,r){if(typeof document>"u")return null;let s=t.parentElement;if(!s)return null;"static"===getComputedStyle(s).position&&(s.style.position="relative");let a=document.createElement("div");a.setAttribute(tne,"");let n=a.style;n.position="absolute",n.overflow="hidden";let o=()=>{n.left=`${t.offsetLeft}px`,n.top=`${t.offsetTop}px`,n.width=`${t.offsetWidth}px`,n.height=`${t.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(t),l.observe(s);let h=document.createElement("style");h.textContent=ine,a.appendChild(h);let u=(new DOMParser).parseFromString(i,"text/html"),d=Array.from(u.querySelectorAll("script"));for(let e of d)e.remove();for(let e of Array.from(u.head.children))("STYLE"===e.tagName||"LINK"===e.tagName&&"stylesheet"===e.rel)&&a.appendChild(e);for(;u.body.firstChild;)a.appendChild(u.body.firstChild);s.insertBefore(a,t.nextSibling);let c=new Map,p=new Qu(Qae(e,t,r),(e,t)=>{"warn"===e?console.warn(`[spline html] ${t}`):"error"===e&&console.error(`[spline html] ${t}`)},(e,t)=>{let i=c.get(e);if(i)for(let e of i)try{e(t)}catch(e){console.error(e)}}),m=(e,t)=>{try{return Promise.resolve(p.execute(e,t))}catch(e){return Promise.reject(e)}},g={ready:Promise.resolve(),setVariable:(e,t)=>m("setVariable",[e,t]),setVariables:e=>m("setVariables",[e]),getVariable:e=>m("getVariable",[e]),getVariables:()=>m("getVariables",[]),getAllObjects:()=>m("getAllObjects",[]),findObjectByName:e=>m("findObjectByName",[e]),findObjectById:e=>m("findObjectById",[e]),getGeometry:(e,t)=>m("getGeometry",[e,t??{}]),updateObject:(e,t)=>m("updateObject",[e,t]),createObject:(e,t)=>m("createObject",[e,t??{}]),createCustomMaterial:e=>m("createCustomMaterial",[e]),setMaterial:(e,t)=>m("setMaterial",[e,t]),cloneObject:(e,t)=>m("cloneObject",[e,t??{}]),removeObject:e=>m("removeObject",[e]),spawnObject:(e,t)=>m("spawnObject",[e,t??{}]),destroyObject:e=>m("destroyObject",[e]),setInstanceTransforms:(e,t)=>m("setInstanceTransforms",[e,t??null]),emitEvent:(e,t)=>m("emitEvent",[e,t]),emitEventReverse:(e,t)=>m("emitEventReverse",[e,t]),requestRender:()=>m("requestRender",[]),addEventListener:(e,t)=>{if("function"!=typeof t)return;let i=c.get(e);i||(i=new Set,c.set(e,i),m("listenEvent",[e])),i.add(t)},removeEventListener:(e,t)=>{let i=c.get(e);!i||(i.delete(t),0===i.size&&(c.delete(e),m("unlistenEvent",[e])))}},f=window.spline;window.spline=g;let y=function(){if(typeof document>"u"||"loading"===document.readyState)return()=>{};let e=[],t=(t,i)=>{let r=new Set,s=t.addEventListener.bind(t),a=t.removeEventListener.bind(t);Object.defineProperty(t,"addEventListener",{configurable:!0,writable:!0,value:(e,a,n)=>{if(s(e,a,n),!i.includes(e)||null==a)return;let o={type:e,listener:a};r.add(o),queueMicrotask(()=>{!r.delete(o)||((e,t,i)=>{let r=new Event(i);try{"function"==typeof t?t.call(e,r):t.handleEvent?.(r)}catch(e){console.error(e)}})(t,o.listener,o.type)})}}),Object.defineProperty(t,"removeEventListener",{configurable:!0,writable:!0,value:(e,t,i)=>{a(e,t,i);for(let i of r)i.type===e&&i.listener===t&&r.delete(i)}}),e.push(()=>{delete t.addEventListener,delete t.removeEventListener,r.clear()})};t(document,["DOMContentLoaded"]),t(window,["load"]);let i=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:e=>{"function"==typeof e&&queueMicrotask(()=>{try{e.call(window,new Event("load"))}catch(e){console.error(e)}})}}),e.push(()=>{i?Object.defineProperty(window,"onload",i):delete window.onload}),()=>{for(let t of e)t()}}();for(let e of d){let t=document.createElement("script");for(let i of Array.from(e.attributes))t.setAttribute(i.name,i.value);e.src?t.async=!1:t.textContent=e.textContent,a.appendChild(t)}return new rne(a,p,l,f,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),void 0!==window.spline&&(window.spline=this.previousSplineGlobal)}};function sne(e){return"object"==typeof e&&null!==e&&!0===e.isMaterial}function ane(e){if("function"==typeof e.material)throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation — this entry point does not support it.");if(!sne(e.material))return{options:e};let t=e.material;if(!0===t.isNodeMaterial){let i=oT()?.NodeMaterial;if(void 0!==i&&t instanceof i)return{options:{...e,material:void 0},material:t};throw new Error("createObject: this TSL NodeMaterial comes from your own three/webgpu module instance, which cannot compile in the runtime's bundled three. Build it with app.createCustomMaterial((three) => …) instead, or use a built-in material (MeshStandardMaterial, MeshBasicMaterial, …).")}if(!0===t.isShaderMaterial)throw new Error("createObject: a GLSL ShaderMaterial cannot compile on the WebGPU backend — port the shader to TSL with app.createCustomMaterial((three) => …), or use a built-in material (MeshStandardMaterial, …).");return{options:{...e,material:void 0},material:t}}Bv(),um(),Mu(),KM(),rw(),um(),Bv(),ev(),gT();var nne=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),one="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",lne={cube:"CubeGeometry",box:"CubeGeometry",sphere:"SphereGeometry",plane:"PlaneGeometry",rectangle:"RectangleGeometry",ellipse:"EllipseGeometry",circle:"EllipseGeometry",triangle:"TriangleGeometry",polygon:"PolygonGeometry",star:"StarGeometry",cone:"ConeGeometry",cylinder:"CylinderGeometry",pyramid:"PyramidGeometry",torus:"TorusGeometry",torusknot:"TorusKnotGeometry",dodecahedron:"DodecahedronGeometry",icosahedron:"IcosahedronGeometry",helix:"HelixGeometry",backdrop:"BackdropGeometry",lathe:"LatheGeometry",text:"TextGeometry",custommesh:"NonParametricGeometry",nonparametric:"NonParametricGeometry"},hne={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},une={shapeblend:"Shape Blends are built from member meshes in the editor and cannot be created empty.",path:"Path shapes need authored path data — clone an existing one with cloneObject() instead.",vector:"Vector shapes need authored shape data — clone an existing one with cloneObject() instead.",shape:"Vector shapes need authored shape data — clone an existing one with cloneObject() instead.",boolean:"Boolean operations are not creatable at runtime — clone an existing Boolean object with cloneObject() instead.",decal:"Decals need a surface to project onto — clone an existing Decal with cloneObject() instead.",ui:"UI objects need a 2D frame — clone an existing one with cloneObject() instead.",input:"Text inputs are not creatable at runtime — clone an existing one with cloneObject() instead.",particle:"Particle emitters are not creatable at runtime — clone an existing one with cloneObject() instead.",particlecollider:"Particle forces are not creatable at runtime — clone an existing one with cloneObject() instead.",hair:"Hair systems are not creatable at runtime — clone an existing one with cloneObject() instead.",camera:"Cameras are not creatable at runtime.",perspectivecamera:"Cameras are not creatable at runtime.",orthographiccamera:"Cameras are not creatable at runtime.",hemispherelight:"Hemisphere lights are not creatable at runtime.",splat:"Splats are not creatable at runtime.",page:"Pages are not creatable at runtime.",component:"Components are authored in the editor.",instance:"Instances are authored in the editor — clone an existing one with cloneObject() instead.",bone:"Bones are not creatable at runtime.",mesh:"pass the shape name directly, e.g. createObject('Cube')."},dne={CubeGeometry:"Cube",SphereGeometry:"Sphere",PlaneGeometry:"Plane",RectangleGeometry:"Rectangle",EllipseGeometry:"Ellipse",TriangleGeometry:"Triangle",PolygonGeometry:"Pentagon",StarGeometry:"Star",ConeGeometry:"Cone",CylinderGeometry:"Cylinder",PyramidGeometry:"Pyramid",TorusGeometry:"Torus",TorusKnotGeometry:"Torus Knot",DodecahedronGeometry:"Dodecahedron",IcosahedronGeometry:"Icosahedron",HelixGeometry:"Helix",BackdropGeometry:"Backdrop",LatheGeometry:"Lathe",TextGeometry:"Text",NonParametricGeometry:"Custom Mesh"},cne={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function pne(e,t){return void 0===e?[t[0],t[1],t[2]]:Array.isArray(e)?[e[0]??t[0],e[1]??t[1],e[2]??t[2]]:[e.x??t[0],e.y??t[1],e.z??t[2]]}function mne(e){return"number"==typeof e?[e,e,e]:pne(e,[1,1,1])}function gne(e){let t=new Yx(0,0,0,1);return t.setStyle(e),{r:t.r,g:t.g,b:t.b}}function fne(e,t){let i=e.material??(void 0!==e.color?{color:e.color}:void 0);if(void 0===i)return Lg.defaultColorMaterial(yne(ym),"physical","layer1","layer2");if("string"==typeof i){for(let[e,r]of Object.entries(t.shared.materials))if(e===i||r.name===i)return e;if(function(e){let t=e.trim().toLowerCase();return/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)||/^(rgb|hsl)a?\(/.test(t)||void 0!==aa.NAMES[t]}(i))return Lg.defaultColorMaterial(gne(i),"physical","layer1","layer2");throw new Error(`createObject: material '${i}' matches no shared material in this document (available: ${function(e){let t=Object.entries(e.shared.materials).map(([,e])=>`'${e.name}'`).filter(e=>"'undefined'"!==e);return t.length?t.join(", "):"(none)"}(t)}) and is not a valid CSS color.`)}if("function"==typeof i)throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation — this entry point does not support it.");if(sne(i))throw new Error("createObject: a three.js material instance cannot be stored in the document — this entry point does not support it.");let r=void 0!==i.color?gne(i.color):yne(ym),s=Lg.defaultColorMaterial(r,"physical","layer1","layer2"),a=s.layers.find(e=>"light"===e.data.type);if(a){let e={};void 0!==i.roughness&&(e.roughness=i.roughness),void 0!==i.metalness&&(e.metalness=i.metalness),void 0!==i.reflectivity&&(e.reflectivity=i.reflectivity),Object.assign(a.data,e)}if(void 0!==i.alpha){let e=s.layers.find(e=>"color"===e.data.type);e&&Object.assign(e.data,{alpha:i.alpha})}return s}function yne(e){return{r:(e>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}}function vne(e){let t=Yg.defaultData("TextGeometry"),{text:i,...r}=e,s=r.fontSize;return void 0!==s&&void 0===r.width&&(r.width=350*s/16),void 0!==s&&void 0===r.height&&(r.height=50*s/16),Object.assign(t,r),void 0!==i&&Object.assign(t,{text:{textValue:String(i)}}),t}function bne(e){return Array.isArray(e)?e:!ArrayBuffer.isView(e)||e instanceof DataView?null:Array.from(e)}function xne(e,t){return Ky({userData:{type:e,...$M[e].normalizeInputs({parameters:t})}})}function wne(e,t,i){let{objectType:r,geometryType:s}=e,a=function(e){let t={};for(let[i,r]of Object.entries(e))!nne.has(i)&&void 0!==r&&(t[i]=r);return t}(t),n={states:new jd,events:new jd,timelineAnimations:new Pd};if("Mesh"===r&&s){if("NonParametricGeometry"===s){let{geometry:e,doubleSide:r}=function(e){let t=bne(e.vertices);if(!t||t.length<9||t.length%3!=0)throw new Error("createObject('CustomMesh'): `vertices` must be a flat number[] of x,y,z triples (length a multiple of 3, at least one triangle).");let i=t.length/3;if(i>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${i}); keep it under 60000.`);let r=bne(e.indices);if(r&&r.length){let e=r.find(e=>!Number.isInteger(e)||e<0||e>=i);if(void 0!==e)throw new Error(`createObject('CustomMesh'): index ${e} is out of range (mesh has ${i} vertices).`)}else r=null;let s=new an;s.setAttribute("position",new Ha(t,3));let a=bne(e.normals),n=null!==a&&a.length===t.length;n&&s.setAttribute("normal",new Ha(a,3));let o=bne(e.uvs);o&&o.length===2*i&&s.setAttribute("uv",new Ha(o,2));let l=!1;if(!n){let e=r??Array.from({length:i},(e,t)=>t),{closed:s,inverted:a}=function(e,t){let i=e.length/3,r=new Map,s=new Array(i);for(let t=0;t<i;t++){let i=`${Math.round(1e4*e[3*t])},${Math.round(1e4*e[3*t+1])},${Math.round(1e4*e[3*t+2])}`,a=r.get(i);void 0===a?(r.set(i,t),s[t]=t):s[t]=a}let a=new Map;for(let e=0;e+2<t.length;e+=3){let i=s[t[e]],r=s[t[e+1]],n=s[t[e+2]];for(let[e,t]of[[i,r],[r,n],[n,i]]){if(e===t)continue;let i=e<t?e+"_"+t:t+"_"+e;a.set(i,(a.get(i)??0)+1)}}let n=a.size>0;for(let e of a.values())if(2!==e){n=!1;break}if(!n)return{closed:!1,inverted:!1};let o=0;for(let i=0;i+2<t.length;i+=3){let r=3*t[i],s=3*t[i+1],a=3*t[i+2],n=e[r],l=e[r+1],h=e[r+2],u=e[s],d=e[s+1],c=e[s+2],p=e[a],m=e[a+1],g=e[a+2];o+=n*(d*g-c*m)+l*(c*p-u*g)+h*(u*m-d*p)}return{closed:!0,inverted:o<0}}(t,e);if(s&&a){for(let t=0;t+2<e.length;t+=3){let i=e[t+1];e[t+1]=e[t+2],e[t+2]=i}r=e}else s||(l=!0)}return r&&s.setIndex(r),n||s.computeVertexNormals(),{geometry:Ky({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:s.toJSON().data}),doubleSide:l}}(a);Object.assign(n,Df.defaultData,{geometry:e,materials:[fne(t,i)]}),r&&(n.side=2)}else Object.assign(n,Df.defaultData,{geometry:"TextGeometry"===s?vne(a):xne(s,a),material:fne(t,i)});void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow)}else"Empty"===r?Object.assign(n,Rf.defaultData):(Object.assign(n,Lf.defaultData(r),a),void 0!==t.color&&(n.color=gne(t.color)));n.visible=t.visible??!0,n.position=pne(t.position,[0,0,0]),n.rotation=pne(t.rotation,[0,0,0]),n.scale=mne(t.scale);let o=(s&&dne[s])??cne[r]??r;return n.name=t.name??_ne(o,i.scene.objects),n}function _ne(e,t){let i=new Set;if(t.traverse((e,t)=>{i.add(t.name??"")}),!i.has(e))return e;let r=2;for(;i.has(`${e} ${r}`);)r++;return`${e} ${r}`}function Sne(e,t){let i=ts.generateUUID();if("Component"===e.data.type)return{data:{...kf.fromComponentData(e),name:e.data.name+" Instance"},id:i,fi:e.fi,children:[]};t[e.id]=i;let r=e.data;return"Empty"===r.type&&r.animations?.length&&(r={...r,animations:r.animations.map(([e,t,i])=>{let r=ts.generateUUID(),s=i.indexOf(e);return[r,t,-1!==s?i.slice(0,s)+r+i.slice(s+e.length):i]})}),{...e,id:i,data:r,children:e.children.map(e=>Sne(e,t))}}function Mne(e){let t={};return function(e,t){return Kd(e,t,null)??e}(Sne(e,t),t)}function Tne(e){let t=!1;return e.scene.objects.traverse((e,i)=>{("Mesh"===i.type&&"UIGeometry"===i.geometry.type||"Page"===i.type&&void 0!==i.uiFrame)&&(t=!0)}),t}gT(),Yv(),Pw();var Cne={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},Ane={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},Nne=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Pne={CSS:{},springs:{}};function Rne(e,t,i){return Math.min(Math.max(e,t),i)}function Ene(e,t){return e.indexOf(t)>-1}function One(e,t){return e.apply(null,t)}var Bne={arr:function(e){return Array.isArray(e)},obj:function(e){return Ene(Object.prototype.toString.call(e),"Object")},pth:function(e){return Bne.obj(e)&&Object.prototype.hasOwnProperty.call(e,"totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||Bne.svg(e))},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return Bne.hex(e)||Bne.rgb(e)||Bne.hsl(e)},key:function(e){return!Object.prototype.hasOwnProperty.call(Cne,e)&&!Object.prototype.hasOwnProperty.call(Ane,e)&&"targets"!==e&&"keyframes"!==e}};function Vne(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function Dne(e,t){var i=Vne(e),r=Rne(Bne.und(i[0])?1:i[0],.1,100),s=Rne(Bne.und(i[1])?100:i[1],.1,100),a=Rne(Bne.und(i[2])?10:i[2],.1,100),n=Rne(Bne.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=a/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,u=l<1?(l*o-n)/h:-n+o;function d(e){var i=t?t*e/1e3:e;return i=l<1?Math.exp(-i*l*o)*(1*Math.cos(h*i)+u*Math.sin(h*i)):(1+u*i)*Math.exp(-i*o),0===e||1===e?e:1-i}return t?d:function(){var t=Pne.springs[e];if(t)return t;for(var i=1/6,r=0,s=0;;)if(1===d(r+=i)){if(++s>=16)break}else s=0;var a=r*i*1e3;return Pne.springs[e]=a,a}}function Ine(e){return void 0===e&&(e=10),function(t){return Math.ceil(Rne(t,1e-6,1)*e)*(1/e)}}var Lne,zne,kne=function(){var e=.1;function t(e,t){return 1-3*t+3*e}function i(e,t){return 3*t-6*e}function r(e){return 3*e}function s(e,s,a){return((t(s,a)*e+i(s,a))*e+r(s))*e}function a(e,s,a){return 3*t(s,a)*e*e+2*i(s,a)*e+r(s)}return function(t,i,r,n){if(0<=t&&t<=1&&0<=r&&r<=1){var o=new Float32Array(11);if(t!==i||r!==n)for(var l=0;l<11;++l)o[l]=s(l*e,t,r);return function(l){return t===i&&r===n||0===l||1===l?l:s(function(i){for(var n=0,l=1;10!==l&&o[l]<=i;++l)n+=e;--l;var h=n+(i-o[l])/(o[l+1]-o[l])*e,u=a(h,t,r);return u>=.001?function(e,t,i,r){for(var n=0;n<4;++n){var o=a(t,i,r);if(0===o)return t;t-=(s(t,i,r)-e)/o}return t}(i,h,t,r):0===u?h:function(e,t,i,r,a){var n,o,l=0;do{(n=s(o=t+(i-t)/2,r,a)-e)>0?i=o:t=o}while(Math.abs(n)>1e-7&&++l<10);return o}(i,n,n+e,t,r)}(l),i,n)}}}}(),Une=(Lne={linear:function(){return function(e){return e}}},zne={Sine:function(){return function(e){return 1-Math.cos(e*Math.PI/2)}},Circ:function(){return function(e){return 1-Math.sqrt(1-e*e)}},Back:function(){return function(e){return e*e*(3*e-2)}},Bounce:function(){return function(e){for(var t,i=4;e<((t=Math.pow(2,--i))-1)/11;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*t-2)/22-e,2)}},Elastic:function(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var i=Rne(e,1,10),r=Rne(t,.1,2);return function(e){return 0===e||1===e?e:-i*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/i))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach(function(e,t){zne[e]=function(){return function(e){return Math.pow(e,t+2)}}}),Object.keys(zne).forEach(function(e){var t=zne[e];Lne["easeIn"+e]=t,Lne["easeOut"+e]=function(e,i){return function(r){return 1-t(e,i)(1-r)}},Lne["easeInOut"+e]=function(e,i){return function(r){return r<.5?t(e,i)(2*r)/2:1-t(e,i)(-2*r+2)/2}}}),Lne);function Fne(e,t){if(Bne.fnc(e))return e;var i=e.split("(")[0],r=Une[i],s=Vne(e);switch(i){case"spring":return Dne(e,t);case"cubicBezier":return One(kne,s);case"steps":return One(Ine,s);default:return One(r,s)}}function jne(e){try{return document.querySelectorAll(e)}catch{return}}function Gne(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],a=0;a<i;a++)if(a in e){var n=e[a];t.call(r,n,a,e)&&s.push(n)}return s}function Wne(e){return e.reduce(function(e,t){return e.concat(Bne.arr(t)?Wne(t):t)},[])}function qne(e){return Bne.arr(e)?e:(Bne.str(e)&&(e=jne(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Hne(e,t){return e.some(function(e){return e===t})}function $ne(e){var t={};for(var i in e)t[i]=e[i];return t}function Yne(e,t){var i=$ne(e);for(var r in e)i[r]=Object.prototype.hasOwnProperty.call(t,r)?t[r]:e[r];return i}function Xne(e,t){var i=$ne(e);for(var r in t)i[r]=Bne.und(e[r])?t[r]:e[r];return i}function Kne(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function Zne(e,t){return Bne.fnc(e)?e(t.target,t.id,t.total):e}function Jne(e,t){return e.getAttribute(t)}function Qne(e,t,i){if(Hne([i,"deg","rad","turn"],Kne(t)))return t;var r=Pne.CSS[t+i];if(!Bne.und(r))return r;var s=document.createElement(e.tagName),a=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;a.appendChild(s),s.style.position="absolute",s.style.width=100+i;var n=100/s.offsetWidth;a.removeChild(s);var o=n*parseFloat(t);return Pne.CSS[t+i]=o,o}function eoe(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?Qne(e,s,i):s}}function toe(e,t){return Bne.dom(e)&&!Bne.inp(e)&&(Jne(e,t)||Bne.svg(e)&&e[t])?"attribute":Bne.dom(e)&&Hne(Nne,t)?"transform":Bne.dom(e)&&"transform"!==t&&eoe(e,t)?"css":null!=e[t]?"object":void 0}function ioe(e){if(Bne.dom(e)){for(var t,i=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,s=new Map;t=r.exec(i);)s.set(t[1],t[2]);return s}}function roe(e,t,i,r){switch(toe(e,t)){case"transform":return function(e,t,i,r){var s=Ene(t,"scale")?1:0+function(e){return Ene(e,"translate")||"perspective"===e?"px":Ene(e,"rotate")||Ene(e,"skew")?"deg":void 0}(t),a=ioe(e).get(t)||s;return i&&(i.transforms.list.set(t,a),i.transforms.last=t),r?Qne(e,a,r):a}(e,t,r,i);case"css":return eoe(e,t,i);case"attribute":return Jne(e,t);default:return e[t]||0}}function soe(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Kne(e)||0,s=parseFloat(t),a=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+a+r;case"-":return s-a+r;case"*":return s*a+r}}function aoe(e,t){if(Bne.col(e))return function(e){return Bne.rgb(e)?function(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}(e):Bne.hex(e)?function(e){var t=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,t,i,r){return t+t+i+i+r+r}),i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return"rgba("+parseInt(i[1],16)+","+parseInt(i[2],16)+","+parseInt(i[3],16)+",1)"}(e):Bne.hsl(e)?function(e){var t,i,r,s=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),a=parseInt(s[1],10)/360,n=parseInt(s[2],10)/100,o=parseInt(s[3],10)/100,l=s[4]||1;function h(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e}if(0==n)t=i=r=o;else{var u=o<.5?o*(1+n):o+n-o*n,d=2*o-u;t=h(d,u,a+1/3),i=h(d,u,a),r=h(d,u,a-1/3)}return"rgba("+255*t+","+255*i+","+255*r+","+l+")"}(e):void 0}(e);if(/\s/g.test(e))return e;var i=Kne(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function noe(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function ooe(e){for(var t,i=e.points,r=0,s=0;s<i.numberOfItems;s++){var a=i.getItem(s);s>0&&(r+=noe(t,a)),t=a}return r}function loe(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return function(e){return 2*Math.PI*Jne(e,"r")}(e);case"rect":return function(e){return 2*Jne(e,"width")+2*Jne(e,"height")}(e);case"line":return function(e){return noe({x:Jne(e,"x1"),y:Jne(e,"y1")},{x:Jne(e,"x2"),y:Jne(e,"y2")})}(e);case"polyline":return ooe(e);case"polygon":return function(e){var t=e.points;return ooe(e)+noe(t.getItem(t.numberOfItems-1),t.getItem(0))}(e)}}function hoe(e,t){var i=t||{},r=i.el||function(e){for(var t=e.parentNode;Bne.svg(t)&&Bne.svg(t.parentNode);)t=t.parentNode;return t}(e),s=r.getBoundingClientRect(),a=Jne(r,"viewBox"),n=s.width,o=s.height,l=i.viewBox||(a?a.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function uoe(e,t){function i(i){void 0===i&&(i=0);var r=t+i>=1?t+i:0;return e.el.getPointAtLength(r)}var r=hoe(e.el,e.svg),s=i(),a=i(-1),n=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return 180*Math.atan2(n.y-a.y,n.x-a.x)/Math.PI}}function doe(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=aoe(Bne.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:Bne.str(e)||t?r.split(i):[]}}function coe(e){return Gne(e?Wne(Bne.arr(e)?e.map(qne):qne(e)):[],function(e,t,i){return i.indexOf(e)===t})}function poe(e){var t=coe(e);return t.map(function(e,i){return{target:e,id:i,total:t.length,transforms:{list:ioe(e)}}})}function moe(e,t){var i=$ne(t);if(/^spring/.test(i.easing)&&(i.duration=Dne(i.easing)),Bne.arr(e)){var r=e.length;2!==r||Bne.obj(e[0])?Bne.fnc(t.duration)||(i.duration=t.duration/r):e={value:e}}var s=Bne.arr(e)?e:[e];return s.map(function(e,i){var r=Bne.obj(e)&&!Bne.pth(e)?e:{value:e};return Bne.und(r.delay)&&(r.delay=i?0:t.delay),Bne.und(r.endDelay)&&(r.endDelay=i===s.length-1?t.endDelay:0),r}).map(function(e){return Xne(e,i)})}var goe={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var a="";r.list.forEach(function(e,t){a+=t+"("+e+") "}),e.style.transform=a}}};function foe(e,t){poe(e).forEach(function(e){for(var i in t){var r=Zne(t[i],e),s=e.target,a=Kne(r),n=roe(s,i,a,e),o=soe(aoe(r,a||Kne(n)),n),l=toe(s,i);goe[l](s,i,o,e.transforms,!0)}})}function yoe(e,t){return Gne(Wne(e.map(function(e){return t.map(function(t){return function(e,t){var i=toe(e.target,t.name);if(i){var r=function(e,t){var i;return e.tweens.map(function(r){var s=function(e,t){var i={};for(var r in e){var s=Zne(e[r],t);Bne.arr(s)&&1===(s=s.map(function(e){return Zne(e,t)})).length&&(s=s[0]),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}(r,t),a=s.value,n=Bne.arr(a)?a[1]:a,o=Kne(n),l=roe(t.target,e.name,o,t),h=i?i.to.original:l,u=Bne.arr(a)?a[0]:h,d=Kne(u)||Kne(l),c=o||d;return Bne.und(n)&&(n=h),s.from=doe(u,c),s.to=doe(soe(n,u),c),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=Fne(s.easing,s.duration),s.isPath=Bne.pth(a),s.isColor=Bne.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}(e,t)})})),function(e){return!Bne.und(e)})}function voe(e,t){var i=e.length,r=function(e){return e.timelineOffset?e.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(e){let t=e.startOnceDelay??0,i=e.pingPongDelayCorrection??0,s=e.pingPongEndDelayCorrection??0;return r(e)+t+i+s+e.duration*(e.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(e){let t=e.startOnceDelay??0,i=e.pingPongDelayCorrection??0;return r(e)+t+i+e.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(e){let t=e.startOnceDelay??0,i=e.pingPongDelayCorrection??0,s=e.pingPongEndDelayCorrection??0;return r(e)+t+i+e.duration*(e.loop??1)-e.endDelay-s})):t.endDelay,s}var boe,xoe=0,woe=[],_oe=[],Soe=function(){let e=0,t=!0;function i(e){let r=woe.length;if(r){let s=0;for(;s<r;){let t=woe[s];t.paused?(woe.splice(s,1),r--):(t.tick(e),s++)}t&&(boe=requestAnimationFrame(i))}else boe&&(cancelAnimationFrame(boe),boe=null)}return{get isUsingInternalRaf(){return t},set isUsingInternalRaf(e){t=e},play:function(){e=performance.now(),boe=requestAnimationFrame(i)},update:function(t){e+=t,i(e)}}}();function Moe(e){!Soe.isUsingInternalRaf||(document.hidden?(woe.forEach(function(t){return t.pause(e.timeStamp)}),_oe=woe.slice(0),Toe.running=woe=[]):(_oe.forEach(function(t){return t.play(e.timeStamp)}),_oe=[]))}function Toe(e){void 0===e&&(e={});var t,i,r=0,s=0,a=0,n=0,o=null;function l(e){var t=window.Promise&&new Promise(function(e){return o=e});return e.finished=t,t}var h=function(e){var t=Yne(Cne,e),i=Yne(Ane,e),r=function(e,t){var i=[],r=t.keyframes;for(var s in r&&(t=Xne(function(e){for(var t=Gne(Wne(e.map(function(e){return Object.keys(e)})),function(e){return Bne.key(e)}).reduce(function(e,t){return e.indexOf(t)<0&&e.push(t),e},[]),i={},r=function(r){var s=t[r];i[s]=e.map(function(e){var t={};for(var i in e)Bne.key(i)?i==s&&(t.value=e[i]):t[i]=e[i];return t})},s=0;s<t.length;s++)r(s);return i}(r),t)),t)Bne.key(s)&&i.push({name:s,tweens:moe(t[s],e)});return i}(i,e),s=poe(e.targets),a=yoe(s,r),n=voe(a,i),o=xoe;return xoe++,Xne(t,{id:o,children:[],animatables:s,animations:a,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}(e);function u(){var e=h.direction;"alternate"!==e&&(h.direction="normal"!==e?"normal":"reverse"),h.reversed=!h.reversed,i.forEach(function(e){(1===e.loop||e.loop%2==0)&&(e.reversed=h.reversed)})}function d(e,t,i=!1){t&&(h.reversed?t.seek(t.duration*t.loop-(e-t.timelineOffset-t.pingPongDelayCorrection),i):t.seek(e-t.timelineOffset-t.startOnceDelay-t.pingPongDelayCorrection,i))}function c(e){var t=0,i=h.animations,r=i.length;for("alternate"!==h.direction&&"alternate"===h.parent?.direction?!1===h.parent?.rewind&&!0===h.reversePlayback&&!1===h.rewind&&(e=h.parent?.reversed&&"alternate"===h.direction?h.duration-h.delay+h.endDelay-e:h.duration+h.delay-h.endDelay-e):g(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(e=h.parent?.reversed&&"alternate"===h.direction?h.duration-h.delay+h.endDelay-e:h.duration+h.delay-h.endDelay-e);t<r;){var s=i[t],a=s.animatable,n=s.tweens,o=n.length-1,l=n[o];let r;o&&(l=Gne(n,function(t){return e<t.end})[0]||l),r=h.parent?.reversed&&"alternate"===h.direction?Rne(e-l.start-l.endDelay,0,l.duration)/l.duration:Rne(e-l.start-l.delay,0,l.duration)/l.duration;for(var u=isNaN(r)?1:l.easing(r),d=l.to.strings,c=l.round,p=[],m=l.to.numbers.length,f=void 0,y=0;y<m;y++){var v=void 0;let e,t;"alternate"!==h.direction?!1===h.parent?.rewind&&!0===h.reversePlayback&&!1===h.rewind?(e=l.to.numbers[y],t=l.from.numbers[y]||0):(t=l.to.numbers[y],e=l.from.numbers[y]||0):g(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(e=l.to.numbers[y],t=l.from.numbers[y]||0):(t=l.to.numbers[y],e=l.from.numbers[y]||0),v=l.isPath?uoe(l.value,u*t):e+u*(t-e),c&&(l.isColor&&y>2||(v=Math.round(v*c)/c)),p.push(v)}var b=d.length;if(b){f=d[0];for(var x=0;x<b;x++){var w=d[x+1],_=p[x];isNaN(_)||(f+=w?_+w:_+" ")}}else f=p[0];goe[s.type](a.target,s.property,f,a.transforms),s.currentValue=f,t++}}function p(e){h[e]&&!h.passThrough&&h[e](h)}l(h);let m={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function g(e,t,i,r,s){return m[e<<4|t<<3|i<<2|r<<1|s]}function f(e,t=!1){var s=h.duration;let a=h.delay,m=s-h.endDelay;h.parent?.reversed&&"alternate"===h.direction&&(a=h.endDelay,m=s-h.delay);var g=function(e){return h.reversed?h.duration-e:e}(e);if(h.progress=Rne(g/s*100,0,100),t||(h.reversePlayback=g<h.currentTime),n&&function(e,t=!1){if(h.reversed)for(var r=n;r--;)d(e,i[r],t);else for(var s=0;s<n;s++)d(e,i[s],t)}(g,t),!h.began&&g>=a&&(h.began=!0),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,p("loopBegin")),(h.reversed||g>=0)&&g<=a&&0!==h.currentTime&&(c(0),p("change")),(g>=m&&h.currentTime!==s+h.pingPongDelayCorrection||!s)&&(c(s),p("change")),g>a&&g<m?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,p("changeBegin")),c(g),p("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,p("change"),n&&p("timelineChangeComplete")):h.began&&g>m&&p("changeComplete"),h.currentTime=Rne(g,0,s+h.pingPongDelayCorrection),h.began&&p("update"),e>=s)if(h.remaining&&!0!==h.remaining&&h.remaining--,h.remaining){r+=n?h.duration/Toe.speed:h.duration;for(let e of i)e.setStartTime(0),e.remaining=e.loop;p("loopComplete"),h.loopBegan=!1,"alternate"===h.direction?u():n&&(h.direction="normal",h.reversed=!1,i.forEach(function(e){return e.reversed=!1}))}else h.paused=!0,h.completed||(h.completed=!0,p("loopComplete"),p("complete"),!h.passThrough&&"Promise"in window&&(o(),l(h)))}return h.reset=function(){var e=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversed="reverse"===e,h.remaining=h.loop,i=h.children;for(var t=n=i.length;t--;)h.children[t].reset();c(h.reversed?h.duration:0)},h.setStartTime=function(e){r=e},h.set=function(e,t){return foe(e,t),h},h.tick=function(e){a=e,r||(r=a),f((a+(s-r))*Toe.speed)},h.seek=function(e,t=!1){f(e-r,t)},h.pause=function(e){h.paused=!0,n&&(t=e??performance.now())},h.play=function(e){!h.paused||(h.completed&&h.reset(),h.paused=!1,woe.push(h),n&&void 0!==t&&(r+=(e??performance.now())-t),!boe&&Soe.isUsingInternalRaf&&Soe.play())},h.reverse=function(e=0){u(),h.completed=!h.reversed,r=void 0,s=e},h.restart=function(){h.reset(),r=void 0,s=0,h.play()},h.destroy=function(){h.paused=!0;var e=woe.indexOf(h);e>-1&&woe.splice(e,1),(e=_oe.indexOf(h))>-1&&_oe.splice(e,1),h.children&&h.children.forEach(function(e){e.destroy&&e.destroy()}),h.animations=[],h.animatables=[],h.children=[],h.update=null,h.begin=null,h.complete=null,h.loopBegin=null,h.loopComplete=null,h.change=null,h.changeBegin=null,h.changeComplete=null,h.timelineChangeComplete=null,h.parent=null,o=null,i=[],n=0},h.reset(),h.autoplay&&h.play(),h}function Coe(e,t){for(var i=t.length;i--;)Hne(e,t[i].animatable.target)&&t.splice(i,1)}Toe.version="3.2.0",Toe.speed=1,Toe.running=woe,Toe.remove=function(e){for(var t=coe(e),i=woe.length;i--;){var r=woe[i],s=r.animations,a=r.children;Coe(t,s);for(var n=a.length;n--;){var o=a[n],l=o.animations;Coe(t,l),!l.length&&!o.children.length&&a.splice(n,1)}!s.length&&!a.length&&r.pause()}},Toe.get=roe,Toe.set=foe,Toe.convertPx=Qne,Toe.path=function(e,t){var i=Bne.str(e)?jne(e)[0]:e,r=t||100;return function(e){return{property:e,el:i,svg:hoe(i),totalLength:loe(i)*(r/100)}}},Toe.setDashoffset=function(e){var t=loe(e);return e.setAttribute("stroke-dasharray",t),t},Toe.stagger=function(e,t){void 0===t&&(t={});var i=t.direction||"normal",r=t.easing?Fne(t.easing):null,s=t.grid,a=t.axis,n=t.from||0,o="first"===n,l="center"===n,h="last"===n,u=Bne.arr(e),d=parseFloat(u?e[0]:e),c=u?parseFloat(e[1]):0,p=Kne(u?e[1]:e)||0,m=t.start||0+(u?d:0),g=[],f=0;return function(e,t,y){if(o&&(n=0),l&&(n=(y-1)/2),h&&(n=y-1),!g.length){for(var v=0;v<y;v++){if(s){var b=l?(s[0]-1)/2:n%s[0],x=l?(s[1]-1)/2:Math.floor(n/s[0]),w=b-v%s[0],_=x-Math.floor(v/s[0]),S=Math.sqrt(w*w+_*_);"x"===a&&(S=-w),"y"===a&&(S=-_),g.push(S)}else g.push(Math.abs(n-v));f=Math.max.apply(Math,g)}r&&(g=g.map(function(e){return r(e/f)*f})),"reverse"===i&&(g=g.map(function(e){return a?e<0?-1*e:-e:Math.abs(f-e)}))}return m+(u?(c-d)/f:d)*(Math.round(100*g[t])/100)+p}},Toe.timeline=function(e){void 0===e&&(e={});var t=Toe(e);return t.duration=0,t.add=function(i,r){var s=woe.indexOf(t),a=t.children;function n(e){e.passThrough=!0}s>-1&&woe.splice(s,1);for(var o=0;o<a.length;o++)n(a[o]);var l=Xne(i,Yne(Ane,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=Bne.und(r)?h:soe(r,h),n(t);var u=Toe(l);n(u),a.push(u),u.parent=t;var d=voe(a,e);return t.delay=d.delay,t.endDelay=d.endDelay,t.duration=d.duration,!0===u.loop&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t},Toe.easing=Fne,Toe.penner=Une,Toe.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e},Toe.removeAll=function(){woe.forEach(function(e){e.destroy&&e.destroy()}),woe=[],_oe=[],Toe.running=woe,boe&&(cancelAnimationFrame(boe),boe=null)},Toe.clearCache=function(){Pne.CSS={},Pne.springs={}},Toe.init=function(){typeof document<"u"&&(document.removeEventListener("visibilitychange",Moe),document.addEventListener("visibilitychange",Moe))},Toe.dispose=function(e){Toe.removeAll(),Toe.clearCache(),document.removeEventListener("visibilitychange",Moe)};var Aoe=Toe;function Noe(e){let t=Array.isArray(e)?e[0]:e,i=t.layers?.map(Poe)??[],r=t.layers?.find(e=>"light"===e.type);return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function Poe(e){return"texture"===e.type||"video"===e.type||"matcap"===e.type?{...e.data,updateTexture:t=>e.color.texture.image.updateSrc(t)}:{...e.data}}rw();var Roe=new Yx(0,0,0,1),Eoe={color:["color"],cavity:[],dust:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],reflection:[],matcap:[],pattern:["colorA","colorB"],vertexColor:[],light:[],displace:[],rainbow:[],particle:[]};Bv(),Bv();var Ooe=new rs;function Boe(e){let t=new Yx(0,0,0,1);try{t.setStyle(e)}catch(e){console.error(e)}return t}var Voe=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r,renderer:s,htmlContentMode:a="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=e=>{if(this.time=e,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!("manual"===this.renderMode&&!this._renderRequested||"auto"===this.renderMode&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<cv?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(e=>{"ParticleSystem"===e.type&&(e.update(this.dt),this._skipRender=!1),Fv(e)&&(!0!==this._renderer?.isWebGPUSplineRenderer&&e.warnClassicFallbackOnce(),e.isSimulating&&(e.update(this.dt),this._skipRender=!1))}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&(this._eventManager.handlers?.Follow?.onAnimationFrameDamping(),this._eventManager.handlers?.LookAt?.onAnimationFrameDamping(),this._eventManager.handlers?.DragDrop?.onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera),!0===this._renderer.lastFrameIncomplete&&(this._skipRender=!1),!0===this._renderer.skyAnimationActive&&(this._skipRender=!1)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()}else this._perfs?.end();else this._perfs?.end()},this._resize=e=>{if(this._renderer){if(1===this._viewportMode&&this._frameView&&(this._frameView.frameSize=Ooe.set(this._viewportWidth,this._viewportHeight)),e){let e=this._viewportWidth,t=this._viewportHeight;this._renderer.setSize(e-1,t-1,!1),this._renderer.setSize(e,t,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);if(this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let e=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera("fullscreen"!==e),"PerspectiveCamera"===this._camera.cameraType&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=$u(this._resize,10),this._onScroll=e=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this._htmlContentMode=a,this.renderMode=t?"auto":i,void 0!==r&&(this._wasmPath=function(e){let t=e.length;for(;t>0&&"/".includes(e[t-1]);)t--;return e.slice(0,t)}(r)),this._rendererBackend=s??"webgl",void 0===s){let e=null;try{e=new URLSearchParams(window.location.search).get("renderer")}catch{}"webgpu"===e||"webgl"===e||"webgl2"===e?this._rendererBackend="webgl2"===e?"webgl":e:(this._rendererAuto=!0,this._rendererBackend=typeof navigator<"u"&&"gpu"in navigator?"webgpu":"webgl")}this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&Promise.resolve().then(()=>(t4(),J5)).then(({Perfs:e})=>{this._perfs=new e({x:10,y:10})}),function(e){e.addEventListener("pointerdown",Ou,!0),e.addEventListener("pointerdown",Vu,!0),e.addEventListener("pointermove",Vu,!0),e.addEventListener("pointerup",Bu,!0),e.addEventListener("pointercancel",Bu,!0),e.addEventListener("pointerleave",Bu,!0),window.addEventListener("keydown",Iu,!0),window.addEventListener("keyup",Lu,!0)}(e)}async _createRenderer(){if("webgpu"===this._rendererBackend&&this._rendererAuto)try{await(navigator.gpu?.requestAdapter())||(this._rendererBackend="webgl")}catch{this._rendererBackend="webgl"}if("webgpu"===this._rendererBackend)try{let{createWebGPUSplineRenderer:e,isWebGPUSupported:t}=await Promise.resolve().then(()=>(sre(),ere));t();let i=!0,r=!1,s=!0;try{let e=new URLSearchParams(window.location.search),t=e.get("bundles");"rerecord"===t?i="rerecord":("off"===t||"0"===t||"false"===t||"no"===t)&&(i=!1),r="1"===e.get("forcegl");let a=e.get("asynccomp");("off"===a||"0"===a||"false"===a||"no"===a)&&(s=!1)}catch{}let a=await e({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:!r&&s});return a.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},a.skyAnimationAllowed=!0,a}catch(e){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",e),this._rendererBackend="webgl"}throw this._failWebGPURequired(),new Error("[spline] This runtime build is WebGPU-only and the browser provides no WebGPU adapter.")}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let e=window.devicePixelRatio||1,t=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=t*e,this.canvas.height=i*e;let r=this.canvas.getContext("2d");r&&(r.scale(e,e),r.fillStyle="rgba(127, 127, 127, 0.85)",r.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",r.textAlign="center",r.textBaseline="middle",r.fillText("This scene requires a WebGPU-capable browser.",t/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(e,t,i){(function(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)})(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;Aoe.init();let r=await async function(e){let[t,i]=dc(kp.deserialize(new Uint8Array(e)));if(130!==(t.schema??0)){let{updateDocumentSchema:e}=await Promise.resolve().then(()=>(jy(),xy));e(t)}return i.result().data}(e);this._data=r;let s=function(e){let t=[];return e.scene.objects.traverse((e,i)=>{"Mesh"===i.type&&"NonParametricGeometry"===i.geometry.type&&void 0!==i.geometry.data.draco&&t.push(i)}),t}(r);r.version&&(0,Xae.default)(r.version,"2.0.2")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),void 0!==this._wasmPath&&(this.setUIWasmUrl(`${this._wasmPath}/hana-ui.wasm`),function(e){RN=e}(this._wasmPath));let a=async function(){}();await Promise.all([a,s.length&&dae(this._wasmPath),rC(r)&&Sx(this._wasmPath),aA(r)&&MM(this._wasmPath),Yf.physicsEnabled(r.scene.objects)&&yae(this._wasmPath),Rw(r)&&tae(),rN(r)&&oN(),Cw(r)&&bw(),Tne(r)&&a.then(()=>ib()?.loadHanaUIRUNTIME()),vae(r)&&Gae(this._wasmPath)].filter(Boolean)),s.length&&await pae(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let n=r.scene.publish.renderer;if(this._rendererAuto&&"webgl"===n)this._rendererBackend="webgl";else if(this._rendererAuto&&"webgpu"===n){if("webgpu"!==this._rendererBackend||!await(navigator.gpu?.requestAdapter().catch(()=>null)))return void this._failWebGPURequired();this._rendererAuto=!1}let o=function(e){let t=new Set;return e.scene.objects.traverse((e,i)=>{if("Page"!==i.type)return;let r=i.postprocessing;if(r&&"object"==typeof r&&!0===r.enabled)for(let[e,i]of Object.entries(r))"enabled"!==e&&i&&"object"==typeof i&&!0===i.enabled&&t.add(e)}),[...t]}(r);if("webgpu"===this._rendererBackend)try{await Promise.all([Promise.resolve().then(()=>(sre(),ere)),Yae(o)]),this._renderer||(this._renderer=await this._createRenderer())}catch(e){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",e),this._rendererBackend="webgl"}if("webgpu"!==this._rendererBackend)return void this._failWebGPURequired();!function(e){lT=e}("webgpu"===this._rendererBackend?"webgpu":"webgl");let l=new aae(r);if(l.resetPersonalCameraFromDocumentData(),this._scene=l.scene,this._sharedAssetsManager=l.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:e}=await Promise.resolve().then(()=>(hre(),are)),t=performance.now();e(r,l.scene);let i=performance.now();console.log("Merged geometries in ",i-t," ms")}rC(r)&&this._scene.traverse(e=>{uC(e)&&e.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(e=>{qv(e)&&e.pendingMediaLoad&&e.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(e=>{"ParticleSystem"===e.type&&(e.wakeUp(),e.data.autoPlay?e.start():e.stop()),Fv(e)&&e.setPlayMode(!0)});let h=Object.keys(r.shared.fonts).map(e=>this._sharedAssetsManager.getFont(e).loadingPromise);if(Promise.all(h).then(()=>{this.disposed||(l.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),Rw(r)&&function(e){if(Yf.physicsEnabled(e.scene.objects))return!0;let t=!1;return e.scene.objects.traverse((e,i)=>{if(i.events)if(Array.isArray(i.events)){for(let e of i.events)if(!0!==e.data.disabled&&"GameControl"===e.data.type&&e.data.collisionEnabled){t=!0;break}}else for(let e of Object.values(i.events))if(!0!==e.disabled&&"GameControl"===e.type&&e.collisionEnabled){t=!0;break}}),t}(r)&&await Promise.all(h),Tne(r)){let e=[];this._scene.traverseEntity(t=>{(Wv(t)||t instanceof FC)&&t.uiCanvas&&e.push(t.uiCanvas)}),await Promise.all(e.map(e=>e.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),function(e,t,i=!1){let r=[],s=i=>{let r=i.data;delete i.states,i.currentState=null,i.reversibleToState=null,i.currentTransitionEvent=null;for(let e of r.states){let t={...e.data};i.states||(i.states={}),i.states[e.id]=Py.patch(r,t)}uae(e.scene,i,null,t,void 0!==r.events.find(e=>"Follow"===e.data.type||"LookAt"===e.data.type)),hae(e)};e.scene.traverse2D(s),e.traverseChildren(a=>{if(i&&(a.rigidBody?.setTranslation(a.position0,!0),a.rigidBody?.setRotation(a.rotation0,!0),a.rigidBody?.setLinvel(lae,!0),a.rigidBody?.setAngvel(lae,!0)),!Lb.is(a))return;let n=a.uuid,o=a.data;if(delete a.states,a.uuid===mm)return;let l=!1;r.some(t=>e.scene.find(n)?.isDescendantOf(t))?l=!0:!0===o.physics?.fusedBody&&"dynamic"===o.physics.rigidBody&&r.push(n),a.data=o,a.currentState=null,a.reversibleToState=null,a.currentTransitionEvent=null;for(let t of o.states){let i={...t.data};!0===e.data.globalPhysics.usePhysics&&o.physics&&("dynamic"===o.physics.rigidBody||l)&&(void 0!==t.data.position&&delete i.position,void 0!==t.data.rotation&&delete i.rotation,void 0!==t.data.hiddenMatrix&&delete i.hiddenMatrix),a.states||(a.states={}),a.states[t.id]=jf.patch(o,i)}uae(e.scene,a,null,t,void 0!==o.events.find(e=>"Follow"===e.data.type||"LookAt"===e.data.type)),Wv(a)&&a.frame&&(a.frame.traverse(e=>s(e)),a.uiCanvas?.applySize())}),hae(e),e.frame&&(e.frame.traverse(e=>s(e)),e.uiCanvas?.applySize())}(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=await this._createRenderer()),!this._rendererConfigured){this._rendererConfigured=!0,this._renderer.hdTransmission=!0===r.scene.publish.hdTransmission;let e=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t=this._getPixelRatio(e()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(t),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let e=this._sharedAssetsManager.getImage("SplineWatermark");await e.loadPromise;let t=e.getTexture(1001);this._renderer.pipeline.setWatermark(t)}}rN(r)&&this._scene.initializeSplatViewer(),void 0!==r.scene.blueNoiseTextureData&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let u=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):("fullscreen"===u.preset?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=u.size[0],this._viewportHeight=u.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Gse(this._renderer,this._camera,new rs(this._viewportWidth,this._viewportHeight),new rs(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(u.allowResponsive??!1)&&"fullscreen"===u.preset),t){let e=new ise(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,u);this._scene.updateMatrixWorld(!0),this._controls=new jae(e),this._animationControls=new Hae(this._scene,this._requestRenderAutoMode),this._eventManager=new Sse(r.scene.publish,this._controls,this._animationControls,e,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this.disposed||this._resize(!0)}),void 0!==i&&this.setVariables(i),0===this.dt&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll),this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0;let d=r.scene.publish.htmlContent?.html;if(t&&d&&"none"!==this._htmlContentMode){let e={shared:this._sharedAssetsManager,findEntity:e=>this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e)};this._htmlContentOverlay=("inline"===this._htmlContentMode?rne.mount(this,this.canvas,d,e):ene.mount(this,this.canvas,d,e))??void 0}}setVariables(e){if(void 0!==this._data){let t=Object.entries(e);for(let[e,i]of t)this.setVariable(e,i)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let e=t;"number"==typeof i.data.value?e="number"==typeof t?t:"boolean"==typeof t?!0===t?1:0:parseFloat(t):"boolean"==typeof i.data.value?e="number"==typeof t?!!t:"boolean"==typeof t?t:"false"!==t.toLocaleLowerCase()&&!!t:"string"!=typeof i.data.value&&void 0!==i.data.value.textValue&&(e=t.toString());let r="string"==typeof e?{textValue:e}:e;this._sharedAssetsManager?.updateVariable(i.id,r),this.requestRender(),this._requestRenderAutoMode()}else void 0===i?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{void 0===e[t.data.name]&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let e=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(e)}}_getVariableValue(e){return"string"!=typeof e&&Qf.isTextValue(e)?Qf.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(t=>t.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(!(t.uuid===mm||this._scene.isInvisibleObjects(t)||t instanceof FC)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof Use&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=Boe(e);this._scene?.activePage.setBackgroundColor(t),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,Jx&&Jx.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(e=>{Hre.unsubscribe(e)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),void 0!==this._resizeObserverTimeout&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,function(e){e.removeEventListener("pointerdown",Ou,!0),e.removeEventListener("pointerdown",Vu,!0),e.removeEventListener("pointermove",Vu,!0),e.removeEventListener("pointerup",Bu,!0),e.removeEventListener("pointercancel",Bu,!0),e.removeEventListener("pointerleave",Bu,!0),window.removeEventListener("keydown",Iu,!0),window.removeEventListener("keyup",Lu,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Aoe.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene)return;let t;this._scene;if(null==e)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);e.traverseAncestors(e=>{e instanceof FC&&(t=e.name)});let i=this._sharedAssetsManager,r={shared:i,scene:this._scene},s=t=>{if(null===t||"Base State"===t)return null;if(t&&e.data.states){let i=e.data.states.find(e=>e.data.name===t);return i?i.id:void 0}},a="material"in e?e.material:void 0,n=e.materialOverride,o={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,material:n??(a?Noe(a):void 0),parentUuid:e.parent instanceof FC||e instanceof fN?void 0:e.parent?.uuid,emitEvent(t){e.dispatchEvent({type:"userEvent",eventName:t})},emitEventReverse(t){e.dispatchEvent({type:"userEvent",eventName:t,reverse:!0})},hide(){e.visible&&(e.visible=!1,r.shared.requestRender())},show(){e.visible||(e.visible=!0,r.shared.requestRender())},get state(){let t=e.stateSelection;if(null!==t)return e.data.states.find(({id:e})=>e===t)?.data.name},set state(t){let i;if(void 0!==t){let r="string"==typeof t?e.data.states.find(({id:e})=>e===t):e.data.states[t];if(r)i=r.id;else{let e="string"==typeof t?s(t):void 0;e&&(i=e)}}e.changeSelectedState(i??null,r),e.currentState=i??null,e.dispatchEvent({type:"completeState",state:i??null}),r.shared.requestRender()},transition:e=>(Kv("transitions","obj.transition()"),{transition(e){return this},play(){return this},pause(){return this},reset(){return this},seek(e){return this}}),set color(t){let i=Boe(t);if(oC.is(e))return void(e.color=i);if(!("Mesh"===e.type&&"material"in e&&e instanceof jT))return;let s={r:i.r,g:i.g,b:i.b,a:i.a},a=e.materialOverride;if(void 0!==a){let e=a.color;return void(!0===e?.isColor&&"function"==typeof e.setStyle&&(e.setStyle(t),r.shared.requestRender()))}let n=Array.isArray(e.material)?e.material[0]:e.material,o=n.data.layers.find(e=>"color"===e.data.type)?.id;if(o)n.updateByOp({type:0,path:["layers",o],props:{color:{...s}}},n.data,r);else{let e=n.data,t=e.layers.find(e=>"light"===e.data.type);if(!t)return;let i=0===e.layers.indexOf(t)?t:null,a=e.layers.at(i?e.layers.indexOf(i)+1:0),o={type:4,fi:i?i.fi+(a?(a.fi-i.fi)/2:1):a?a.fi/2:1,id:ts.generateUUID(),data:{...Ig.defaultData("color"),color:s},localIndex:0},l=e.layers.insertAfterHelper(i?.id??null,1),h=e.layers.runOp({...o,fi:l[0]}).data;Object.assign(n.data,{layers:h}),n.updateByOp({...o,path:["layers"]},n.data,r)}}},l=Hre(o,(t,i)=>{let r=e[t],s=function(e){return e.split(".")}(t);"material"===s[0]&&a&&void 0===n&&function(e,t,i){let r=Array.isArray(i)?i[0]:i;if("layers"===e[0]){let i=parseInt(e[1]),s=r.layers[i],a=e[2];s&&a&&function(e,t,i){let r=e[0];try{if(function(e,t){return!!Eoe[t]?.includes(e)}(r,i.type,e.slice(1)))if("colors"===r){if(e.length<2)throw new Error("You cannot mutate the colors array, only its items");let s=parseInt(e[1]),a=i.getValue(r)?.[s];if(!a)throw new Error("Color index out of range");Roe.setStyle(t),a.set(Roe.r,Roe.g,Roe.b,Roe.a)}else i.getValue(r)?.setStyle(t);else if("texture"===r||"video"===r){let r=i.color;!function(e,t,i){let r=e[0];if("repeat"===r||"offset"===r){let s=e[1];if(void 0===s)t instanceof Array&&2===t.length&&Object.assign(i.mat,{[r]:t});else{let e=i.mat[r],a=0===parseInt(s)?[parseFloat(t),e[1]]:[e[0],parseFloat(t)];Object.assign(i.mat,{[r]:a})}i.mat.updateMatrix()}else"rotation"===r?(i.mat.rotation=parseFloat(t),i.mat.updateMatrix()):"wrapping"===r||"minFilter"===r||"magFilter"===r?"wrapping"===r?i.texture.wrap=t:i.texture[r]=t:"image"===r&&"data"===e[1]&&i.texture.image.updateSrc(t)}(e.slice(1),t,r)}else{let s=e[1],a=i.getValue(r);a?.isVector3&&void 0!==s||a?.isVector2&&void 0!==s?a.setComponent(parseInt(s),t):i.setValue(r,t)}}catch(e){console.error("Error setting material value",e)}}(e.slice(2),t,s)}else"alpha"===e[0]&&r.layers.forEach(e=>{"light"===e.type&&void 0!==e.node.alphaOverride&&(e.node.alphaOverride.value=t,t<1&&(r.transparent=!0))})}(s.slice(1),i,a),"object"!=typeof r&&Object.getOwnPropertyDescriptor(e,t)?.writable&&(e[t]=i),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,l),l}setUIWasmUrl(e){!function(e){lb?.setHanaUIWasmUrl(e)}(e)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(e,t){let i;if("string"==typeof t){if(!t.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let e=await(await fetch(t)).arrayBuffer();i=new Uint8Array(e)}}else i=t;let r=kp.deserialize(i),s="data"in r&&void 0!==r.data.draco;s&&await dae(this._wasmPath);let a=this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e);if(!a)return void console.warn(`Object ${e} not found`);if("Mesh"!==a.data.type||!(a instanceof jT))return void console.warn(`Object ${e} is not a mesh`);let n=a,o={...n.data,geometry:r};s&&await pae([o]),n.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let e of n.data.states){let t={...e.data};n.states||(n.states={}),n.states[e.id]=jf.patch(o,t)}return i}_applyDocumentTransaction(e){this._data=e.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let t of e.actual){let e=t.path;Array.isArray(e)&&2===e.length&&"scene"===e[0]&&"objects"===e[1]&&this._scene?.updateTreeByOp({...t,path:[]},this._sharedAssetsManager)}}_findEntity(e){return this._scene?.getObjectByProperty("uuid",e)??this._scene?.getObjectByName(e)}_resolveParentId(e){if(void 0===e)return this._scene.activePage.uuid;let t="string"==typeof e?e:e.uuid,i=this._findEntity(t);if(!i)throw new Error(`parent '${t}' — no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(e){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if("function"!=typeof e)throw new Error("createCustomMaterial: expected a factory function — createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let t=oT();if(void 0===t&&("webgpu"===this._rendererBackend&&(await Promise.resolve().then(()=>(sre(),ere)),t=oT()),void 0===t))throw new Error("createCustomMaterial: requires the webgpu backend (the runtime default where WebGPU is available). This Application is on the classic WebGL pipeline — pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let i=e(t);if("object"!=typeof i||null===i||!0!==i.isMaterial)throw new Error("createCustomMaterial: the factory must return a three.js material built from the namespace it receives — e.g. (three) => new three.MeshStandardNodeMaterial().");return i}async setMaterial(e,t){if(this.disposed)throw new Error("setMaterial: this Application was disposed.");let i=this._scene;if(!i)throw new Error("setMaterial: no scene loaded — call load() or start() first.");let r="string"==typeof e?e:e.uuid,s=this._findEntity(r);if(!s)throw new Error(`setMaterial: '${r}' — no object with that name or uuid in the scene.`);if(!(s instanceof jT))throw new Error(`setMaterial: '${r}' is not a mesh — lights, groups, and cameras have no material.`);let a="function"==typeof t?await this.createCustomMaterial(t):t;if("webgpu"!==rT())throw new Error("setMaterial: custom three.js materials require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline — pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let n=ane({material:a});if(void 0===n.material)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return s.setMaterialOverride(n.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(s.uuid),this._requestRenderAutoMode(),n.material}async createObject(e,t={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("createObject: no scene loaded — call load() or start() first.");let s=function(e){if("string"!=typeof e||0===e.length)throw new Error(`createObject: expected a type name string — one of ${one}.`);let t=e.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),i=hne[t];if(i)return{objectType:i};let r=lne[t];if(r)return{objectType:"Mesh",geometryType:r};let s=une[t];throw s?new Error(`createObject: '${e}' is not supported — ${s}`):new Error(`createObject: '${e}' is not a creatable Spline type — use one of ${one}, e.g. createObject('Cube', { width: 200 }).`)}(e);"function"==typeof t.material&&(t={...t,material:await this.createCustomMaterial(t.material)});let a,n,{options:o,material:l}=ane(t);if(void 0!==l){if("Mesh"!==s.objectType)throw new Error("createObject: a three.js material instance only applies to mesh types — lights and groups have no material.");if("webgpu"!==rT())throw new Error("createObject: three.js material instances require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline — pass { renderer: 'webgpu' } to the Application, or drop any ?renderer=webgl2 override.")}if("TextGeometry"===s.geometryType){if(!rb.has("text"))throw new Error("createObject: this runtime build was compiled without the 'text' feature — re-export the scene with a Text object present, or load the full runtime build.");if(await tae(),n=t.font??zg,void 0===r.shared.fonts[n]){if(n!==zg){let e=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${n}' is not in this document — available fonts: ${e||"(none)"}.`)}a={name:zg,url:kg}}}let h=this._resolveParentId(t.parent),u=wne(s,o,r),d=ts.generateUUID(),[c,p]=dc(r);a&&(c.shared.fonts[zg]=a),c.scene.objects.insertAfter(h,null,[{id:d,data:u,children:[]}]);let m=p.result();if(a&&this._sharedAssetsManager.addFont(zg,a),void 0!==n){let e=this._sharedAssetsManager.getFont(n);e&&await e.loadingPromise}this._applyDocumentTransaction(m);let g=i.find(d);return void 0!==l&&g.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(g)}cloneObject(e,t={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("cloneObject: no scene loaded — call load() or start() first.");let s="string"==typeof e?e:e?.uuid,a=s?this._findEntity(s):void 0;if(!a)throw new Error(`cloneObject: '${s}' — no object with that name or uuid in the scene.`);if(a instanceof FC)throw new Error("cloneObject: pages cannot be cloned.");let n=r.scene.objects.get(a.uuid);if(!n)throw new Error(`cloneObject: '${s}' is not part of the document tree (expanded clones and instanced children cannot be cloned — clone their source object instead).`);let o=function(e,t,i){let r={...e.data};return void 0!==t.position&&(r.position=pne(t.position,[0,0,0])),void 0!==t.rotation&&(r.rotation=pne(t.rotation,[0,0,0])),void 0!==t.scale&&(r.scale=mne(t.scale)),void 0!==t.visible&&(r.visible=t.visible),r.name=t.name??_ne(`${e.data.name??"Object"} Copy`,i),{...e,data:r}}(Mne(n),t,r.scene.objects),l=void 0!==t.parent?this._resolveParentId(t.parent):r.scene.objects.parent(a.uuid)??null,h=void 0!==t.parent?null:a.uuid,[u,d]=dc(r);u.scene.objects.insertAfter(l,h,[o]),this._applyDocumentTransaction(d.result());let c=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(c)}removeObject(e){let t=this._scene,i=this._data;if(this.disposed||!t||!i)return!1;let r="string"==typeof e?e:e?.uuid,s=r?this._findEntity(r):void 0;if(!s)return!1;if(s instanceof FC)throw new Error("removeObject: pages cannot be removed.");if("PerspectiveCamera"===s.data.type||"OrthographicCamera"===s.data.type)throw new Error("removeObject: cameras cannot be removed.");if(void 0===i.scene.objects.get(s.uuid))throw new Error(`removeObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let a=[];s.traverseEntity(e=>{a.push(e.uuid)});let[n,o]=dc(i);n.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let e of a){let t=this._proxyObjectCache.get(e);t&&(Hre.unsubscribe(t),this._proxyObjectCache.delete(e))}return this._requestRenderAutoMode(),!0}};export{Voe as Application,vm as Axis,Am as Easing,Ng as GradientType,Og as NoiseType,Dg as PatternStyle,Eg as ProjectionType,vg as Side,Rg as TextureFilter,Vg as ToonType,Bg as VoronoiStyle,Pg as Wrapping};