@vertexvis/viewer 0.15.2-testing.3 → 0.15.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 (274) hide show
  1. package/dist/cjs/_commonjsHelpers-dcc4cf71.js +1 -1
  2. package/dist/cjs/app-globals-2035678d.js +1 -1
  3. package/dist/cjs/browser.esm-5d246754.js +1 -1
  4. package/dist/cjs/bundle.esm-22b6f2d6.js +1 -1
  5. package/dist/cjs/bundle.esm-b43c197a.js +38280 -0
  6. package/dist/cjs/{config-6e330a82.js → config-3fc1c093.js} +2 -2
  7. package/dist/cjs/{cursors-85d403e9.js → cursors-02a06ec9.js} +7 -1
  8. package/dist/cjs/dom-8d90bfaf.js +1 -1
  9. package/dist/cjs/dom-92728e58.js +1 -1
  10. package/dist/cjs/dom-d1bbd67c.js +1 -1
  11. package/dist/cjs/dom-d57d3c3b.js +1 -1
  12. package/dist/cjs/elementRectObserver-9b28f182.js +1 -1
  13. package/dist/cjs/entities-9eb7e608.js +1 -1
  14. package/dist/cjs/{entities-7b2e8c03.js → entities-c1c3c6a3.js} +3 -3
  15. package/dist/cjs/errors-1b37642b.js +97 -0
  16. package/dist/cjs/grpc-web-client.umd-2af20c1b.js +1 -1
  17. package/dist/cjs/index-70db349e.js +1 -1
  18. package/dist/cjs/index-b9d13137.js +1 -1
  19. package/dist/cjs/index.cjs.js +9 -6
  20. package/dist/cjs/loader.cjs.js +2 -2
  21. package/dist/cjs/{mapper-0f2294a6.js → mapper-d4145b72.js} +2 -2
  22. package/dist/cjs/markup-4a2fc281.js +1 -1
  23. package/dist/cjs/{model-b61f4d20.js → model-19fb560a.js} +27 -6
  24. package/dist/cjs/model-20a70d27.js +1 -1
  25. package/dist/cjs/overlays-b03ec80b.js +1 -1
  26. package/dist/cjs/png-decoder-ef097f37.js +1 -1
  27. package/dist/cjs/results-178e89a3.js +1 -1
  28. package/dist/cjs/{scene-56438693.js → scene-a94e6fa5.js} +293 -215
  29. package/dist/cjs/shadow-css-6b9daa41.js +1 -1
  30. package/dist/cjs/stencil-fc92b387.js +1 -1
  31. package/dist/cjs/{streamAttributes-c64aee75.js → streamAttributes-cf0c513d.js} +8424 -41995
  32. package/dist/cjs/templates-e57b3741.js +1 -1
  33. package/dist/cjs/utils-2c8e2aa3.js +1 -1
  34. package/dist/cjs/utils-ea359796.js +1 -1
  35. package/dist/cjs/vertex-scene-tree-search_3.cjs.entry.js +1 -1
  36. package/dist/cjs/vertex-scene-tree-table-cell.cjs.entry.js +1 -1
  37. package/dist/cjs/vertex-scene-tree-table-column.cjs.entry.js +1 -1
  38. package/dist/cjs/vertex-scene-tree-table-header.cjs.entry.js +1 -1
  39. package/dist/cjs/vertex-scene-tree-table-resize-divider.cjs.entry.js +1 -1
  40. package/dist/cjs/vertex-scene-tree-toolbar-group.cjs.entry.js +1 -1
  41. package/dist/cjs/vertex-scene-tree.cjs.entry.js +158 -37
  42. package/dist/cjs/vertex-viewer-box-query-tool.cjs.entry.js +425 -0
  43. package/dist/cjs/vertex-viewer-button_3.cjs.entry.js +1 -1
  44. package/dist/cjs/vertex-viewer-default-toolbar.cjs.entry.js +1 -1
  45. package/dist/cjs/vertex-viewer-dom-element_2.cjs.entry.js +3 -2
  46. package/dist/cjs/vertex-viewer-dom-group.cjs.entry.js +1 -1
  47. package/dist/cjs/vertex-viewer-icon.cjs.entry.js +1 -1
  48. package/dist/cjs/vertex-viewer-layer.cjs.entry.js +1 -1
  49. package/dist/cjs/vertex-viewer-markup-arrow_3.cjs.entry.js +1 -1
  50. package/dist/cjs/vertex-viewer-markup-tool.cjs.entry.js +1 -1
  51. package/dist/cjs/vertex-viewer-markup.cjs.entry.js +1 -1
  52. package/dist/cjs/vertex-viewer-measurement-details.cjs.entry.js +3 -2
  53. package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +5 -4
  54. package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +4 -3
  55. package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +7 -6
  56. package/dist/cjs/vertex-viewer-pin-group.cjs.entry.js +10 -5
  57. package/dist/cjs/vertex-viewer-pin-label_2.cjs.entry.js +15 -13
  58. package/dist/cjs/vertex-viewer-pin-tool.cjs.entry.js +20 -9
  59. package/dist/cjs/vertex-viewer-spinner.cjs.entry.js +1 -1
  60. package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +6 -4
  61. package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +5 -4
  62. package/dist/cjs/vertex-viewer.cjs.entry.js +80 -53
  63. package/dist/cjs/viewer.cjs.js +2 -2
  64. package/dist/cjs/viewport-5ca619f7.js +1 -1
  65. package/dist/collection/collection-manifest.json +1 -0
  66. package/dist/collection/components/scene-tree/lib/controller.js +108 -28
  67. package/dist/collection/components/scene-tree/lib/errors.js +35 -2
  68. package/dist/collection/components/scene-tree/scene-tree.js +12 -5
  69. package/dist/collection/components/viewer/viewer.js +17 -15
  70. package/dist/collection/components/viewer-box-query-tool/viewer-box-query-tool.css +79 -0
  71. package/dist/collection/components/viewer-box-query-tool/viewer-box-query-tool.js +278 -0
  72. package/dist/collection/components/viewer-pin-group/viewer-pin-group.js +5 -1
  73. package/dist/collection/components/viewer-pin-label/viewer-pin-label.css +1 -1
  74. package/dist/collection/components/viewer-pin-label/viewer-pin-label.js +14 -12
  75. package/dist/collection/components/viewer-pin-tool/utils.js +25 -4
  76. package/dist/collection/components/viewer-pin-tool/viewer-pin-tool.css +12 -0
  77. package/dist/collection/components/viewer-pin-tool/viewer-pin-tool.js +9 -2
  78. package/dist/collection/components/viewer-transform-widget/viewer-transform-widget.js +3 -2
  79. package/dist/collection/components/viewer-view-cube/viewer-view-cube.js +5 -5
  80. package/dist/collection/lib/cursors.js +6 -1
  81. package/dist/collection/lib/interactions/baseInteractionHandler.js +12 -2
  82. package/dist/collection/lib/interactions/mouseInteractions.js +5 -4
  83. package/dist/collection/lib/mappers/frameStreaming.js +11 -11
  84. package/dist/collection/lib/pins/interactions.js +9 -5
  85. package/dist/collection/lib/pins/model.js +2 -2
  86. package/dist/collection/lib/rendering/matrices.js +2 -4
  87. package/dist/collection/lib/scenes/camera.js +4 -2
  88. package/dist/collection/lib/scenes/mapper.js +103 -30
  89. package/dist/collection/lib/scenes/queries.js +101 -46
  90. package/dist/collection/lib/scenes/scene.js +15 -7
  91. package/dist/collection/lib/stream/stream.js +24 -12
  92. package/dist/collection/lib/transforms/drawable.js +2 -2
  93. package/dist/collection/lib/types/frame.js +4 -3
  94. package/dist/collection/lib/types/frameCamera.js +6 -1
  95. package/dist/collection/lib/types/index.js +3 -2
  96. package/dist/collection/lib/types/loadableResource.js +24 -4
  97. package/dist/collection/lib/types/sceneViewStateIdentifier.js +7 -0
  98. package/dist/collection/lib/volume-intersection/controller.js +104 -0
  99. package/dist/collection/lib/volume-intersection/interactions.js +82 -0
  100. package/dist/collection/lib/volume-intersection/model.js +84 -0
  101. package/dist/custom-elements/index.d.ts +6 -0
  102. package/dist/custom-elements/index.js +23825 -18358
  103. package/dist/custom-elements/png-decoder.js +1 -1
  104. package/dist/esm/_commonjsHelpers-11ca3be1.js +1 -1
  105. package/dist/esm/app-globals-40df99a0.js +1 -1
  106. package/dist/esm/{browser.esm-ae4ca1f1.js → browser.esm-07e7db8f.js} +2 -2
  107. package/dist/esm/bundle.esm-91404853.js +38273 -0
  108. package/dist/esm/{bundle.esm-ce2c7ad3.js → bundle.esm-92e615bf.js} +2 -2
  109. package/dist/esm/{config-49688db8.js → config-25384fe6.js} +3 -3
  110. package/dist/esm/{cursors-a8d4b3f4.js → cursors-127a3bb7.js} +8 -3
  111. package/dist/esm/dom-0440435d.js +1 -1
  112. package/dist/esm/dom-be140992.js +1 -1
  113. package/dist/esm/dom-e19ee80b.js +1 -1
  114. package/dist/esm/{dom-5b164305.js → dom-e436f0c0.js} +2 -2
  115. package/dist/esm/elementRectObserver-39cf7b95.js +1 -1
  116. package/dist/esm/{entities-a5bfef48.js → entities-0e325765.js} +4 -4
  117. package/dist/esm/entities-ce81dd7f.js +1 -1
  118. package/dist/esm/errors-a4cc9caa.js +85 -0
  119. package/dist/esm/grpc-web-client.umd-5409853c.js +1 -1
  120. package/dist/esm/index-26dfb2d0.js +1 -1
  121. package/dist/esm/index-e841d91b.js +1 -1
  122. package/dist/esm/index.js +15 -13
  123. package/dist/esm/index.mjs +15 -13
  124. package/dist/esm/loader.js +2 -2
  125. package/dist/esm/loader.mjs +2 -2
  126. package/dist/esm/{mapper-5894c2a4.js → mapper-dd937684.js} +3 -3
  127. package/dist/esm/{markup-3c2900f3.js → markup-2dde1f10.js} +3 -3
  128. package/dist/esm/{model-fa9af61a.js → model-3cd8cd47.js} +2 -2
  129. package/dist/esm/{model-40bd1711.js → model-bfe1c4d8.js} +29 -8
  130. package/dist/esm/{overlays-cc3efc30.js → overlays-8f195eb3.js} +3 -3
  131. package/dist/esm/{png-decoder-d4b65417.js → png-decoder-45f38ea3.js} +2 -2
  132. package/dist/esm/{results-3b4df2cf.js → results-38baef59.js} +2 -2
  133. package/dist/esm/{scene-5b919078.js → scene-2543b3bd.js} +254 -168
  134. package/dist/esm/shadow-css-51dd7708.js +1 -1
  135. package/dist/esm/stencil-bfbf099f.js +1 -1
  136. package/dist/esm/{streamAttributes-7e8565be.js → streamAttributes-23270e27.js} +8429 -41994
  137. package/dist/esm/templates-022199c1.js +1 -1
  138. package/dist/esm/{utils-81347571.js → utils-2306c744.js} +2 -2
  139. package/dist/esm/{utils-559e1632.js → utils-f03802ef.js} +2 -2
  140. package/dist/esm/vertex-scene-tree-search_3.entry.js +3 -3
  141. package/dist/esm/vertex-scene-tree-table-cell.entry.js +1 -1
  142. package/dist/esm/vertex-scene-tree-table-column.entry.js +1 -1
  143. package/dist/esm/vertex-scene-tree-table-header.entry.js +1 -1
  144. package/dist/esm/vertex-scene-tree-table-resize-divider.entry.js +1 -1
  145. package/dist/esm/vertex-scene-tree-toolbar-group.entry.js +1 -1
  146. package/dist/esm/vertex-scene-tree.entry.js +160 -39
  147. package/dist/esm/vertex-viewer-box-query-tool.entry.js +421 -0
  148. package/dist/esm/vertex-viewer-button_3.entry.js +1 -1
  149. package/dist/esm/vertex-viewer-default-toolbar.entry.js +1 -1
  150. package/dist/esm/vertex-viewer-dom-element_2.entry.js +6 -5
  151. package/dist/esm/vertex-viewer-dom-group.entry.js +3 -3
  152. package/dist/esm/vertex-viewer-icon.entry.js +1 -1
  153. package/dist/esm/vertex-viewer-layer.entry.js +1 -1
  154. package/dist/esm/vertex-viewer-markup-arrow_3.entry.js +4 -4
  155. package/dist/esm/vertex-viewer-markup-tool.entry.js +5 -5
  156. package/dist/esm/vertex-viewer-markup.entry.js +5 -5
  157. package/dist/esm/vertex-viewer-measurement-details.entry.js +5 -4
  158. package/dist/esm/vertex-viewer-measurement-distance.entry.js +13 -12
  159. package/dist/esm/vertex-viewer-measurement-line_2.entry.js +8 -7
  160. package/dist/esm/vertex-viewer-measurement-precise.entry.js +12 -11
  161. package/dist/esm/vertex-viewer-pin-group.entry.js +13 -8
  162. package/dist/esm/vertex-viewer-pin-label_2.entry.js +18 -16
  163. package/dist/esm/vertex-viewer-pin-tool.entry.js +23 -12
  164. package/dist/esm/vertex-viewer-spinner.entry.js +1 -1
  165. package/dist/esm/vertex-viewer-transform-widget.entry.js +9 -7
  166. package/dist/esm/vertex-viewer-view-cube.entry.js +7 -6
  167. package/dist/esm/vertex-viewer.entry.js +65 -38
  168. package/dist/esm/viewer.js +2 -2
  169. package/dist/esm/{viewport-e39e2eba.js → viewport-f19fc583.js} +2 -2
  170. package/dist/types/components/scene-tree/lib/controller.d.ts +18 -3
  171. package/dist/types/components/scene-tree/lib/errors.d.ts +17 -2
  172. package/dist/types/components/viewer/viewer.d.ts +2 -0
  173. package/dist/types/components/viewer-box-query-tool/viewer-box-query-tool.d.ts +94 -0
  174. package/dist/types/components/viewer-pin-tool/utils.d.ts +1 -1
  175. package/dist/types/components.d.ts +56 -0
  176. package/dist/types/lib/cursors.d.ts +5 -0
  177. package/dist/types/lib/interactions/baseInteractionHandler.d.ts +1 -0
  178. package/dist/types/lib/interactions/mouseInteractions.d.ts +2 -1
  179. package/dist/types/lib/pins/interactions.d.ts +4 -2
  180. package/dist/types/lib/pins/model.d.ts +1 -1
  181. package/dist/types/lib/scenes/camera.d.ts +1 -1
  182. package/dist/types/lib/scenes/mapper.d.ts +5 -1
  183. package/dist/types/lib/scenes/queries.d.ts +55 -28
  184. package/dist/types/lib/scenes/scene.d.ts +10 -1
  185. package/dist/types/lib/types/frame.d.ts +1 -1
  186. package/dist/types/lib/types/index.d.ts +2 -1
  187. package/dist/types/lib/types/loadableResource.d.ts +8 -2
  188. package/dist/types/lib/types/sceneViewStateIdentifier.d.ts +15 -0
  189. package/dist/types/lib/volume-intersection/controller.d.ts +45 -0
  190. package/dist/types/lib/volume-intersection/interactions.d.ts +24 -0
  191. package/dist/types/lib/volume-intersection/model.d.ts +33 -0
  192. package/dist/viewer/index.esm.js +2 -2
  193. package/dist/viewer/{p-ad09c92e.entry.js → p-029fba92.entry.js} +1 -1
  194. package/dist/viewer/p-07aeee89.js +1 -1
  195. package/dist/viewer/{p-29986489.js → p-0a017be7.js} +2 -2
  196. package/dist/viewer/p-0c583cad.entry.js +4 -0
  197. package/dist/viewer/p-0d494d01.js +4 -0
  198. package/dist/viewer/p-0fdad1a5.js +1 -1
  199. package/dist/viewer/{p-3ca4a7c1.js → p-1812c82d.js} +2 -2
  200. package/dist/viewer/{p-7663a603.entry.js → p-191156ad.entry.js} +1 -1
  201. package/dist/viewer/{p-a57dc6e4.entry.js → p-1998284a.entry.js} +2 -2
  202. package/dist/viewer/p-27f715f8.entry.js +4 -0
  203. package/dist/viewer/{p-7f6251da.js → p-283aeac4.js} +2 -2
  204. package/dist/viewer/p-298b63c2.entry.js +4 -0
  205. package/dist/viewer/p-2ace066b.entry.js +4 -0
  206. package/dist/viewer/{p-927b528b.js → p-2b60a8b0.js} +2 -2
  207. package/dist/viewer/{p-050f912b.entry.js → p-2fd123c8.entry.js} +1 -1
  208. package/dist/viewer/p-305a8be6.entry.js +4 -0
  209. package/dist/viewer/p-31724d24.js +4 -0
  210. package/dist/viewer/p-32cc2209.js +4 -0
  211. package/dist/viewer/p-3829dd99.entry.js +4 -0
  212. package/dist/viewer/{p-6da8a28f.entry.js → p-3aae4bf1.entry.js} +2 -2
  213. package/dist/viewer/{p-99352cf0.js → p-42760392.js} +2 -2
  214. package/dist/viewer/p-440c8174.js +4 -0
  215. package/dist/viewer/{p-e422deaf.entry.js → p-4f25e367.entry.js} +2 -2
  216. package/dist/viewer/{p-d64c1e14.entry.js → p-507b5aeb.entry.js} +3 -3
  217. package/dist/viewer/{p-1fc24ec6.js → p-51401063.js} +2 -2
  218. package/dist/viewer/{p-426970b3.entry.js → p-533b1c63.entry.js} +1 -1
  219. package/dist/viewer/{p-dcb9804c.entry.js → p-569ed94a.entry.js} +2 -2
  220. package/dist/viewer/p-5809b400.js +1 -1
  221. package/dist/viewer/p-6072cf84.js +4 -0
  222. package/dist/viewer/{p-e4a26a32.entry.js → p-6406a70a.entry.js} +1 -1
  223. package/dist/viewer/p-6bf0594b.entry.js +4 -0
  224. package/dist/viewer/p-72c59115.entry.js +4 -0
  225. package/dist/viewer/{p-d71652b0.entry.js → p-8ac7290a.entry.js} +1 -1
  226. package/dist/viewer/{p-f184bcab.entry.js → p-8afcbd99.entry.js} +1 -1
  227. package/dist/viewer/p-92fe4417.js +1 -1
  228. package/dist/viewer/{p-5746931d.entry.js → p-952a217d.entry.js} +1 -1
  229. package/dist/viewer/p-98e6a50e.js +1 -1
  230. package/dist/viewer/{p-99fd27e0.entry.js → p-9cb99ea8.entry.js} +1 -1
  231. package/dist/viewer/p-a2e9e8a5.js +4 -0
  232. package/dist/viewer/p-a380f0c2.js +1 -1
  233. package/dist/viewer/{p-661b5234.js → p-acfc5c50.js} +2 -2
  234. package/dist/viewer/{p-82bd25e8.entry.js → p-b3540dce.entry.js} +1 -1
  235. package/dist/viewer/p-b5ca30cd.js +4 -0
  236. package/dist/viewer/p-b74242dc.js +1 -1
  237. package/dist/viewer/p-bc1160cf.entry.js +4 -0
  238. package/dist/viewer/{p-c5e67a1e.entry.js → p-bd5a302c.entry.js} +2 -2
  239. package/dist/viewer/p-c738296e.js +1 -1
  240. package/dist/viewer/p-c8c4343b.js +1 -1
  241. package/dist/viewer/p-cd9ccb9e.entry.js +4 -0
  242. package/dist/viewer/{p-40a9dd7d.js → p-cf689bbd.js} +2 -2
  243. package/dist/viewer/{p-70e5e8a8.js → p-d216a866.js} +2 -2
  244. package/dist/viewer/p-d4ed7b8d.js +4 -0
  245. package/dist/viewer/p-d6d5d5de.entry.js +4 -0
  246. package/dist/viewer/p-d6fce4c1.js +1 -1
  247. package/dist/viewer/p-df8fbe56.js +1 -1
  248. package/dist/viewer/p-dfe5a97d.js +1 -1
  249. package/dist/viewer/{p-00ce31a0.js → p-e1896ce4.js} +2 -2
  250. package/dist/viewer/p-e23af70c.js +4 -0
  251. package/dist/viewer/p-e4aa9cdb.js +1 -1
  252. package/dist/viewer/p-e929dd63.entry.js +4 -0
  253. package/dist/viewer/{p-65af7a89.js → p-fc7d8c03.js} +3 -3
  254. package/dist/viewer/viewer.esm.js +2 -2
  255. package/package.json +9 -9
  256. package/readme.md +4 -4
  257. package/dist/viewer/p-096e60bd.js +0 -4
  258. package/dist/viewer/p-0cf4f05d.entry.js +0 -4
  259. package/dist/viewer/p-0fcafbf9.js +0 -4
  260. package/dist/viewer/p-1abfe4bf.js +0 -4
  261. package/dist/viewer/p-1e0dd2e9.js +0 -4
  262. package/dist/viewer/p-22ae6785.entry.js +0 -4
  263. package/dist/viewer/p-27dbc865.js +0 -4
  264. package/dist/viewer/p-31b87b90.js +0 -4
  265. package/dist/viewer/p-3f6f2457.entry.js +0 -4
  266. package/dist/viewer/p-61e50e11.entry.js +0 -4
  267. package/dist/viewer/p-7579e2a1.entry.js +0 -4
  268. package/dist/viewer/p-920c9a88.entry.js +0 -4
  269. package/dist/viewer/p-990f98c2.js +0 -4
  270. package/dist/viewer/p-9dfe0b43.entry.js +0 -4
  271. package/dist/viewer/p-a6558bb2.entry.js +0 -4
  272. package/dist/viewer/p-b7e170ac.entry.js +0 -4
  273. package/dist/viewer/p-d34ad2b2.entry.js +0 -4
  274. package/dist/viewer/p-f3ea0c2b.entry.js +0 -4
@@ -1,4 +0,0 @@
1
- /**!
2
- * Copyright (c) 2022 Vertex Software LLC. All rights reserved.
3
- */
4
- import{h as i,F as t,r as n}from"./p-d6fce4c1.js";import{p as e,m as o,v as s}from"./p-70e5e8a8.js";import"./p-3ca4a7c1.js";import"./p-1fc24ec6.js";import"./p-92fe4417.js";import"./p-31b87b90.js";import"./p-df8fbe56.js";import{V as r}from"./p-29986489.js";import{g as a,i as l,b as p,P as h,a as d,c as v}from"./p-27dbc865.js";import{c}from"./p-07aeee89.js";import"./p-65af7a89.js";import"./p-dfe5a97d.js";const u=({pin:n,selected:e})=>{const{primaryColor:o}=a(n);return i(t,null,p(n)&&i("div",{id:"pin-anchor",class:c("pin-anchor",{selected:e}),style:{background:o}}),l(n)&&i("vertex-viewer-icon",{name:"pin-fill",size:"lg",class:c("pin",{"pin-selected":e}),style:{color:o}}))};function w(i,t,n){const o=[{x:i.x+n.width/2,y:i.y},{x:i.x+n.width/2,y:i.y+n.height},{x:i.x,y:i.y+n.height/2},{x:i.x+n.width,y:i.y+n.height/2}],s=o.map((i=>e.distance(i,t)));return o[s.indexOf(Math.min(...s))]}const b=class{constructor(i){n(this,i),this.matrix=o.makeIdentity(),this.projectionViewMatrix=o.makeIdentity(),this.pinModel=new h,this.selected=!1,this.invalidateStateCounter=0,this.invalidateState=()=>{this.invalidateStateCounter=this.invalidateStateCounter+1}}componentDidLoad(){this.setLabelObserver(),null==this.pinController&&(this.pinController=new d(this.pinModel))}disconnectedCallback(){var i,t;null===(i=this.labelEl)||void 0===i||i.removeEventListener("labelChanged",this.invalidateState),null===(t=this.resizeObserver)||void 0===t||t.disconnect()}render(){var n;if(null==this.pin)throw new Error("Unable to draw pin");const{pinPoint:e,labelPoint:o}=this.computePinPoints(this.pin);return i(t,null,i("vertex-viewer-dom-element",{"data-testid":`drawn-pin-${this.pin.id}`,position:this.pin.worldPosition,onPointerDown:i=>{2!==i.buttons&&i.stopPropagation(),this.selectPin(),this.handleAnchorPointerDown()}},i(u,{pin:this.pin,selected:this.selected})),p(this.pin)&&i(t,null,i("vertex-viewer-pin-label-line",{id:`pin-label-line-${null===(n=this.pin)||void 0===n?void 0:n.id}`,pinPoint:e,pin:this.pin,labelPoint:o,onPointerDown:()=>this.selectPin()}),i("vertex-viewer-pin-label",{pin:this.pin,ref:i=>this.labelEl=i,elementBounds:this.elementBounds,pinController:this.pinController,onPointerDown:()=>this.selectPin()})))}setLabelObserver(){null!=this.labelEl&&(this.labelEl.addEventListener("labelChanged",this.invalidateState),this.resizeObserver=new ResizeObserver((()=>this.invalidateState())),this.resizeObserver.observe(this.labelEl))}computePinPoints(i){return null!=this.elementBounds&&null!=this.pin?p(this.pin)&&null!=this.pin.label.point?this.computeTextPinPoints(this.pin,this.elementBounds):this.computeDefaultPinPoints(this.pin,this.elementBounds):{pinPoint:i.worldPosition}}computeDefaultPinPoints(i,t){return{pinPoint:this.getFromWorldPosition(i.worldPosition,this.projectionViewMatrix,t)}}computeTextPinPoints(i,t){var n,e,o,s;const{pinPoint:r}=this.computeDefaultPinPoints(i,t);return{pinPoint:r,labelPoint:w(v(i.label.point,t),r,{width:(null===(e=null===(n=this.labelEl)||void 0===n?void 0:n.firstElementChild)||void 0===e?void 0:e.clientWidth)||0,height:(null===(s=null===(o=this.labelEl)||void 0===o?void 0:o.firstElementChild)||void 0===s?void 0:s.clientHeight)||0})}}handleAnchorPointerDown(){var i,t;null!=this.elementBounds&&"edit"===(null===(i=this.pinController)||void 0===i?void 0:i.getToolMode())&&null!=this.pin&&(null===(t=this.pinController)||void 0===t||t.setDraggable({id:this.pin.id}))}selectPin(){var i,t;null===(i=this.pinController)||void 0===i||i.setSelectedPinId(null===(t=this.pin)||void 0===t?void 0:t.id)}getFromWorldPosition(i,t,n){const e=s.transformMatrix(i,t);return r.fromDimensions(n).transformVectorToViewport(e)}};b.style=":host{--viewer-annotations-pin-primary-color:var(--blue-700);--viewer-annotations-pin-accent-color:var(--blue-200);--viewer-annotations-pin-dot-color:var(--viewer-annotations-pin-primary-color);--viewer-annotations-pin-color:var(--viewer-annotations-pin-primary-color);--viewer-annotations-pin-font-size:0.75rem;--viewer-annotations-pin-selected-stroke:var(--white);--viewer-annotations-pin-selected-border:2px solid var(--white);--viewer-annotations-pin-label-border:2px solid var(--black);--viewer-annotations-pin-selected-stroke:var(--white);font-size:var(--viewer-annotations-pin-font-size);position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none}.pin-anchor{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;width:9px;height:9px;box-sizing:border-box;border:var(--viewer-annotations-pin-label-border);background:var(--viewer-annotations-pin-dot-color);pointer-events:auto;cursor:pointer}.selected{width:13px;height:13px;border:var(--viewer-annotations-pin-selected-border)}.pin{color:var(--viewer-annotations-pin-color);cursor:pointer}.pin-selected{stroke-width:1;stroke:var(--viewer-annotations-pin-selected-stroke)}";export{b as vertex_viewer_pin_group}
@@ -1,4 +0,0 @@
1
- /**!
2
- * Copyright (c) 2022 Vertex Software LLC. All rights reserved.
3
- */
4
- import{r as t,c as n,h as e,H as r,g as i}from"./p-d6fce4c1.js";import{m as o,p as a,v as u,r as s,j as f,q as l,i as c,h as d,b as v}from"./p-70e5e8a8.js";import{c as h}from"./p-07aeee89.js";import{w as p,r as m}from"./p-b74242dc.js";import{c as b,E as y}from"./p-65af7a89.js";import{c as g,a as w,g as x,b as A}from"./p-dfe5a97d.js";import"./p-31b87b90.js";import"./p-df8fbe56.js";import{V as C}from"./p-29986489.js";class j{constructor(t){this.stream=t,this.isTransforming=!1,this.currentDelta=o.makeIdentity()}async dispose(){this.isTransforming&&this.endTransform()}async beginTransform(t=o.makeIdentity()){this.isTransforming||(this.currentDelta=t,this.isTransforming=!0,console.debug("Beginning transform interaction"),await this.stream.beginInteraction({transform:{delta:this.toDeltaTransform(t)}}))}async updateTransform(t){this.currentDelta=t,await this.stream.updateInteraction({transform:{delta:this.toDeltaTransform(this.currentDelta,!0)}})}async updateTranslation(t){this.currentDelta=o.makeTranslation(t),await this.stream.updateInteraction({transform:{delta:this.toDeltaTransform(this.currentDelta)}})}getCurrentDelta(){return this.currentDelta}async endTransform(){this.isTransforming&&(console.debug(`Ending transform interaction [delta=${this.currentDelta}]`),await this.stream.endInteraction({transform:{delta:this.toDeltaTransform(this.currentDelta)}}),this.isTransforming=!1,this.currentDelta=o.makeIdentity())}async endInteraction(){this.isTransforming&&(await this.stream.endInteraction(),this.isTransforming=!1,this.currentDelta=o.makeIdentity())}clearTransform(){this.currentDelta=o.makeIdentity(),this.endTransform()}toDeltaTransform(t,n=!1){const e=o.toObject(t);return{basisX:n?{x:e.m11,y:e.m21,z:e.m31}:{x:e.m11,y:e.m12,z:e.m13},basisY:n?{x:e.m12,y:e.m22,z:e.m32}:{x:e.m21,y:e.m22,z:e.m23},basisZ:n?{x:e.m13,y:e.m23,z:e.m33}:{x:e.m31,y:e.m32,z:e.m33},xlate:{x:e.m14,y:e.m24,z:e.m34},scale:e.m44}}}function O(t,n){return null!=n?a.create(t.x-n.left,t.y-n.top):void 0}function k(t,n,e,r){const i=null!=r?u.fromMatrixPosition(r):void 0;if(null!=t&&null!=n&&null!=e&&null!=i){if(n.scene.camera.isOrthographic()){const r=e.transformPointToOrthographicRay(t,n.image,n.scene.camera),o=s.at(s.create({origin:i,direction:n.scene.camera.direction}),2*u.magnitude(n.scene.camera.viewVector));return s.intersectPlane(r,f.fromNormalAndCoplanarPoint(n.scene.camera.direction,o))}{const r=e.transformPointToRay(t,n.image,n.scene.camera);return s.intersectPlane(r,f.fromNormalAndCoplanarPoint(n.scene.camera.direction,i))}}}function T(t,n,e,r){const i=u.transformMatrix(r,o.makeRotation(l.fromMatrixRotation(t))),a=u.multiply(i,u.subtract(e,n));return a.x+a.y+a.z}function _(t,n){return o.multiply(o.multiply(o.multiply(o.makeTranslation(u.fromMatrixPosition(n)),o.makeRotation(t)),o.makeTranslation(u.negate(u.fromMatrixPosition(n)))),n)}var F=g((function(t){t.exports=function(){var t=function(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array||t instanceof Uint8ClampedArray},n=function(t,n){for(var e=Object.keys(n),r=0;r<e.length;++r)t[e[r]]=n[e[r]];return t},e="\n";function r(t){var n=new Error("(regl) "+t);throw console.error(n),n}function i(t,n){t||r(n)}function o(t){return t?": "+t:""}function a(t,n){switch(n){case"number":return"number"==typeof t;case"object":return"object"==typeof t;case"string":return"string"==typeof t;case"boolean":return"boolean"==typeof t;case"function":return"function"==typeof t;case"undefined":return void 0===t;case"symbol":return"symbol"==typeof t}}function u(t,n,e){n.indexOf(t)<0&&r("invalid value"+o(e)+". must be one of: "+n)}var s=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function f(t,n){for(t+="";t.length<n;)t=" "+t;return t}function l(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function c(t,n){this.number=t,this.line=n,this.errors=[]}function d(t,n,e){this.file=t,this.line=n,this.message=e}function v(){var t=new Error,n=(t.stack||t).toString(),e=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(n);if(e)return e[1];var r=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(n);return r?r[1]:"unknown"}function h(){var t=new Error,n=(t.stack||t).toString(),e=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(n);if(e)return e[1];var r=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(n);return r?r[1]:"unknown"}function p(t,n){var e,r=t.split("\n"),i=1,o=0,a={unknown:new l,0:new l};a.unknown.name=a[0].name=n||v(),a.unknown.lines.push(new c(0,""));for(var u=0;u<r.length;++u){var s=r[u],f=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(s);if(f)switch(f[1]){case"line":var d=/(\d+)(\s+\d+)?/.exec(f[2]);d&&(i=0|d[1],d[2]&&((o=0|d[2])in a||(a[o]=new l)));break;case"define":var h=/SHADER_NAME(_B64)?\s+(.*)$/.exec(f[2]);h&&(a[o].name=h[1]?(e=h[2],"undefined"!=typeof atob?atob(e):"base64:"+e):h[2])}a[o].lines.push(new c(i++,s))}return Object.keys(a).forEach((function(t){var n=a[t];n.lines.forEach((function(t){n.index[t.number]=t}))})),a}function m(t){t._commandRef=v()}function b(t,n){var e=h();r(t+" in command "+(n||v())+("unknown"===e?"":" called from "+e))}function y(t,n,e,r){a(t,n)||b("invalid parameter type"+o(e)+". expected "+n+", got "+typeof t,r||v())}var g=33071,w={};function x(t,n){return 32820===t||32819===t||33635===t?2:34042===t?4:w[t]*n}function A(t){return!(t&t-1||!t)}w[5120]=w[5121]=1,w[5122]=w[5123]=w[36193]=w[33635]=w[32819]=w[32820]=2,w[5124]=w[5125]=w[5126]=w[34042]=4;var C=n(i,{optional:function(t){t()},raise:r,commandRaise:b,command:function(t,n,e){t||b(n,e||v())},parameter:function(t,n,e){t in n||r("unknown parameter ("+t+")"+o(e)+". possible values: "+Object.keys(n).join())},commandParameter:function(t,n,e,r){t in n||b("unknown parameter ("+t+")"+o(e)+". possible values: "+Object.keys(n).join(),r||v())},constructor:function(t){Object.keys(t).forEach((function(t){s.indexOf(t)<0&&r('invalid regl constructor argument "'+t+'". must be one of '+s)}))},type:function(t,n,e){a(t,n)||r("invalid parameter type"+o(e)+". expected "+n+", got "+typeof t)},commandType:y,isTypedArray:function(n,e){t(n)||r("invalid parameter type"+o(e)+". must be a typed array")},nni:function(t,n){t>=0&&(0|t)===t||r("invalid parameter type, ("+t+")"+o(n)+". must be a nonnegative integer")},oneOf:u,shaderError:function(t,n,r,o,a){if(!t.getShaderParameter(n,t.COMPILE_STATUS)){var u=t.getShaderInfoLog(n),s=o===t.FRAGMENT_SHADER?"fragment":"vertex";y(r,"string",s+" shader source must be a string",a);var l=p(r,a),c=function(t){var n=[];return t.split("\n").forEach((function(t){if(!(t.length<5)){var e=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(t);e?n.push(new d(0|e[1],0|e[2],e[3].trim())):t.length>0&&n.push(new d("unknown",0,t))}})),n}(u);(function(t,n){n.forEach((function(n){var e=t[n.file];if(e){var r=e.index[n.line];if(r)return r.errors.push(n),void(e.hasErrors=!0)}t.unknown.hasErrors=!0,t.unknown.lines[0].errors.push(n)}))})(l,c),Object.keys(l).forEach((function(t){var n=l[t];if(n.hasErrors){var r=[""],i=[""];o("file number "+t+": "+n.name+"\n","color:red;text-decoration:underline;font-weight:bold"),n.lines.forEach((function(t){if(t.errors.length>0){o(f(t.number,4)+"| ","background-color:yellow; font-weight:bold"),o(t.line+e,"color:red; background-color:yellow; font-weight:bold");var n=0;t.errors.forEach((function(r){var i=r.message,a=/^\s*'(.*)'\s*:\s*(.*)$/.exec(i);if(a){var u=a[1];switch(i=a[2],u){case"assign":u="="}n=Math.max(t.line.indexOf(u,n),0)}else n=0;o(f("| ",6)),o(f("^^^",n+3)+e,"font-weight:bold"),o(f("| ",6)),o(i+e,"font-weight:bold")})),o(f("| ",6)+e)}else o(f(t.number,4)+"| "),o(t.line+e,"color:red")})),"undefined"==typeof document||window.chrome?console.log(r.join("")):(i[0]=r.join("%c"),console.log.apply(console,i))}function o(t,n){r.push(t),i.push(n||"")}})),i.raise("Error compiling "+s+" shader, "+l[0].name)}},linkError:function(t,n,r,o,a){if(!t.getProgramParameter(n,t.LINK_STATUS)){var u=t.getProgramInfoLog(n),s=p(r,a),f='Error linking program with vertex shader, "'+p(o,a)[0].name+'", and fragment shader "'+s[0].name+'"';"undefined"!=typeof document?console.log("%c"+f+"\n%c"+u,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(f+e+u),i.raise(f)}},callSite:h,saveCommandRef:m,saveDrawInfo:function(t,n,e,r){function i(t){return t?r.id(t):0}function o(t,n){Object.keys(n).forEach((function(n){t[r.id(n)]=!0}))}m(t),t._fragId=i(t.static.frag),t._vertId=i(t.static.vert);var a=t._uniformSet={};o(a,n.static),o(a,n.dynamic);var u=t._attributeSet={};o(u,e.static),o(u,e.dynamic),t._hasCount="count"in t.static||"count"in t.dynamic||"elements"in t.static||"elements"in t.dynamic},framebufferFormat:function(t,n,e){t.texture?u(t.texture._texture.internalformat,n,"unsupported texture format for attachment"):u(t.renderbuffer._renderbuffer.format,e,"unsupported renderbuffer format for attachment")},guessCommand:v,texture2D:function(t,n,e){var r,o=n.width,a=n.height,u=n.channels;i(o>0&&o<=e.maxTextureSize&&a>0&&a<=e.maxTextureSize,"invalid texture shape"),t.wrapS===g&&t.wrapT===g||i(A(o)&&A(a),"incompatible wrap mode for texture, both width and height must be power of 2"),1===n.mipmask?1!==o&&1!==a&&i(9984!==t.minFilter&&9986!==t.minFilter&&9985!==t.minFilter&&9987!==t.minFilter,"min filter requires mipmap"):(i(A(o)&&A(a),"texture must be a square power of 2 to support mipmapping"),i(n.mipmask===(o<<1)-1,"missing or incomplete mipmap data")),5126===n.type&&(e.extensions.indexOf("oes_texture_float_linear")<0&&i(9728===t.minFilter&&9728===t.magFilter,"filter not supported, must enable oes_texture_float_linear"),i(!t.genMipmaps,"mipmap generation not supported with float textures"));var s=n.images;for(r=0;r<16;++r)if(s[r]){var f=o>>r,l=a>>r;i(n.mipmask&1<<r,"missing mipmap data");var c=s[r];if(i(c.width===f&&c.height===l,"invalid shape for mip images"),i(c.format===n.format&&c.internalformat===n.internalformat&&c.type===n.type,"incompatible type for mip image"),c.compressed);else if(c.data){var d=Math.ceil(x(c.type,u)*f/c.unpackAlignment)*c.unpackAlignment;i(c.data.byteLength===d*l,"invalid data for image, buffer size is inconsistent with image format")}}else t.genMipmaps||i(0==(n.mipmask&1<<r),"extra mipmap data");n.compressed&&i(!t.genMipmaps,"mipmap generation for compressed images not supported")},textureCube:function(t,n,e,r){var o=t.width,a=t.height,u=t.channels;i(o>0&&o<=r.maxTextureSize&&a>0&&a<=r.maxTextureSize,"invalid texture shape"),i(o===a,"cube map must be square"),i(n.wrapS===g&&n.wrapT===g,"wrap mode not supported by cube map");for(var s=0;s<e.length;++s){var f=e[s];i(f.width===o&&f.height===a,"inconsistent cube map face shape"),n.genMipmaps&&(i(!f.compressed,"can not generate mipmap for compressed textures"),i(1===f.mipmask,"can not specify mipmaps and generate mipmaps"));for(var l=f.images,c=0;c<16;++c){var d=l[c];if(d){var v=o>>c,h=a>>c;i(f.mipmask&1<<c,"missing mipmap data"),i(d.width===v&&d.height===h,"invalid shape for mip images"),i(d.format===t.format&&d.internalformat===t.internalformat&&d.type===t.type,"incompatible type for mip image"),d.compressed||d.data&&i(d.data.byteLength===v*h*Math.max(x(d.type,u),d.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format")}}}}}),j=0;function O(t,n){this.id=j++,this.type=t,this.data=n}function k(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function T(t){if(0===t.length)return[];var n=t.charAt(0),e=t.charAt(t.length-1);if(t.length>1&&n===e&&('"'===n||"'"===n))return['"'+k(t.substr(1,t.length-2))+'"'];var r=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(r)return T(t.substr(0,r.index)).concat(T(r[1])).concat(T(t.substr(r.index+r[0].length)));var i=t.split(".");if(1===i.length)return['"'+k(t)+'"'];for(var o=[],a=0;a<i.length;++a)o=o.concat(T(i[a]));return o}function _(t){return"["+T(t).join("][")+"]"}var F={DynamicVariable:O,define:function(t,n){return new O(t,_(n+""))},isDynamic:function(t){return"function"==typeof t&&!t._reglType||t instanceof O},unbox:function t(n,e){return"function"==typeof n?new O(0,n):"number"==typeof n||"boolean"==typeof n?new O(5,n):Array.isArray(n)?new O(6,n.map((function(n,r){return t(n,e+"["+r+"]")}))):n instanceof O?n:void C(!1,"invalid option type in uniform "+e)},accessor:_},M={next:"function"==typeof requestAnimationFrame?function(t){return requestAnimationFrame(t)}:function(t){return setTimeout(t,16)},cancel:"function"==typeof cancelAnimationFrame?function(t){return cancelAnimationFrame(t)}:clearTimeout},z="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date};function D(t){return"string"==typeof t?t.split():(C(Array.isArray(t),"invalid extension array"),t)}function S(t){return"string"==typeof t?(C("undefined"!=typeof document,"not supported outside of DOM"),document.querySelector(t)):t}function E(t){var e,r,i,o,a,u=t||{},s={},f=[],l=[],c="undefined"==typeof window?1:window.devicePixelRatio,d=!1,v=function(t){t&&C.raise(t)},h=function(){};if("string"==typeof u?(C("undefined"!=typeof document,"selector queries only supported in DOM enviroments"),e=document.querySelector(u),C(e,"invalid query string for element")):"object"==typeof u?"string"==typeof(a=u).nodeName&&"function"==typeof a.appendChild&&"function"==typeof a.getBoundingClientRect?e=u:function(t){return"function"==typeof t.drawArrays||"function"==typeof t.drawElements}(u)?i=(o=u).canvas:(C.constructor(u),"gl"in u?o=u.gl:"canvas"in u?i=S(u.canvas):"container"in u&&(r=S(u.container)),"attributes"in u&&C.type(s=u.attributes,"object","invalid context attributes"),"extensions"in u&&(f=D(u.extensions)),"optionalExtensions"in u&&(l=D(u.optionalExtensions)),"onDone"in u&&(C.type(u.onDone,"function","invalid or missing onDone callback"),v=u.onDone),"profile"in u&&(d=!!u.profile),"pixelRatio"in u&&C((c=+u.pixelRatio)>0,"invalid pixel ratio")):C.raise("invalid arguments to regl"),e&&("canvas"===e.nodeName.toLowerCase()?i=e:r=e),!o){if(!i){C("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var p=function(t,e,r){var i,o=document.createElement("canvas");function a(){var n=window.innerWidth,e=window.innerHeight;if(t!==document.body){var i=o.getBoundingClientRect();n=i.right-i.left,e=i.bottom-i.top}o.width=r*n,o.height=r*e}return n(o.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),t.appendChild(o),t===document.body&&(o.style.position="absolute",n(t.style,{margin:0,padding:0})),t!==document.body&&"function"==typeof ResizeObserver?(i=new ResizeObserver((function(){setTimeout(a)}))).observe(t):window.addEventListener("resize",a,!1),a(),{canvas:o,onDestroy:function(){i?i.disconnect():window.removeEventListener("resize",a),t.removeChild(o)}}}(r||document.body,0,c);if(!p)return null;i=p.canvas,h=p.onDestroy}void 0===s.premultipliedAlpha&&(s.premultipliedAlpha=!0),o=function(t,n){function e(e){try{return t.getContext(e,n)}catch(t){return null}}return e("webgl")||e("experimental-webgl")||e("webgl-experimental")}(i,s)}return o?{gl:o,canvas:i,container:r,extensions:f,optionalExtensions:l,pixelRatio:c,profile:d,onDone:v,onDestroy:h}:(h(),v("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function B(t,n){for(var e=Array(t),r=0;r<t;++r)e[r]=n(r);return e}function R(t){var n,e;return n=(t>65535)<<4,n|=e=((t>>>=n)>255)<<3,n|=e=((t>>>=e)>15)<<2,(n|=e=((t>>>=e)>3)<<1)|(t>>>=e)>>1}function J(){var t=B(8,(function(){return[]}));function n(n){var e=function(t){for(var n=16;n<=1<<28;n*=16)if(t<=n)return n;return 0}(n),r=t[R(e)>>2];return r.length>0?r.pop():new ArrayBuffer(e)}function e(n){t[R(n.byteLength)>>2].push(n)}return{alloc:n,free:e,allocType:function(t,e){var r=null;switch(t){case 5120:r=new Int8Array(n(e),0,e);break;case 5121:r=new Uint8Array(n(e),0,e);break;case 5122:r=new Int16Array(n(2*e),0,e);break;case 5123:r=new Uint16Array(n(2*e),0,e);break;case 5124:r=new Int32Array(n(4*e),0,e);break;case 5125:r=new Uint32Array(n(4*e),0,e);break;case 5126:r=new Float32Array(n(4*e),0,e);break;default:return null}return r.length!==e?r.subarray(0,e):r},freeType:function(t){e(t.buffer)}}}var N=J();N.zero=J();var V=3553,W=6408,I=5126,L=36160;function U(n){return!!n&&"object"==typeof n&&Array.isArray(n.shape)&&Array.isArray(n.stride)&&"number"==typeof n.offset&&n.shape.length===n.stride.length&&(Array.isArray(n.data)||t(n.data))}var P=function(t){return Object.keys(t).map((function(n){return t[n]}))},q={shape:function(t){for(var n=[],e=t;e.length;e=e[0])n.push(e.length);return n},flatten:function(t,n,e,r){var i=1;if(n.length)for(var o=0;o<n.length;++o)i*=n[o];else i=0;var a=r||N.allocType(e,i);switch(n.length){case 0:break;case 1:!function(t,n,e){for(var r=0;r<n;++r)e[r]=t[r]}(t,n[0],a);break;case 2:!function(t,n,e,r){for(var i=0,o=0;o<n;++o)for(var a=t[o],u=0;u<e;++u)r[i++]=a[u]}(t,n[0],n[1],a);break;case 3:G(t,n[0],n[1],n[2],a,0);break;default:H(t,n,0,a,0)}return a}};function G(t,n,e,r,i,o){for(var a=o,u=0;u<n;++u)for(var s=t[u],f=0;f<e;++f)for(var l=s[f],c=0;c<r;++c)i[a++]=l[c]}function H(t,n,e,r,i){for(var o=1,a=e+1;a<n.length;++a)o*=n[a];var u=n[e];if(n.length-e==4){var s=n[e+1],f=n[e+2],l=n[e+3];for(a=0;a<u;++a)G(t[a],s,f,l,r,i),i+=o}else for(a=0;a<u;++a)H(t[a],n,e+1,r,i),i+=o}var $={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Q={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},X={dynamic:35048,stream:35040,static:35044},Y=q.flatten,Z=q.shape,K=5121,tt=5126,nt=[];function et(t){return 0|$[Object.prototype.toString.call(t)]}function rt(t,n){for(var e=0;e<n.length;++e)t[e]=n[e]}function it(t,n,e,r,i,o,a){for(var u=0,s=0;s<e;++s)for(var f=0;f<r;++f)t[u++]=n[i*s+o*f+a]}nt[5120]=1,nt[5122]=2,nt[5124]=4,nt[5121]=1,nt[5123]=2,nt[5125]=4,nt[5126]=4;var ot={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},at=5121,ut=5123,st=5125,ft=34963;var lt=new Float32Array(1),ct=new Uint32Array(lt.buffer);function dt(t){for(var n=N.allocType(5123,t.length),e=0;e<t.length;++e)if(isNaN(t[e]))n[e]=65535;else if(t[e]===1/0)n[e]=31744;else if(t[e]===-1/0)n[e]=64512;else{lt[0]=t[e];var r=ct[0],i=r>>>31<<15,o=(r<<1>>>24)-127,a=r>>13&1023;n[e]=o<-24?i:o<-14?i+(a+1024>>-14-o):o>15?i+31744:i+(o+15<<10)+a}return n}function vt(n){return Array.isArray(n)||t(n)}var ht=function(t){return!(t&t-1||!t)},pt=3553,mt=34067,bt=34069,yt=6408,gt=6406,wt=6407,xt=6409,At=6410,Ct=32855,jt=6402,Ot=34041,kt=35904,Tt=35906,_t=36193,Ft=33776,Mt=33777,zt=33778,Dt=33779,St=5121,Et=5123,Bt=5125,Rt=5126,Jt=33071,Nt=9728,Vt=9984,Wt=9987,It=4352,Lt=33984,Ut=[Vt,9986,9985,Wt],Pt=[0,xt,At,wt,yt],qt={};function Gt(t){return"[object "+t+"]"}qt[6409]=qt[6406]=qt[6402]=1,qt[34041]=qt[6410]=2,qt[6407]=qt[35904]=3,qt[6408]=qt[35906]=4;var Ht=Gt("HTMLCanvasElement"),$t=Gt("OffscreenCanvas"),Qt=Gt("CanvasRenderingContext2D"),Xt=Gt("ImageBitmap"),Yt=Gt("HTMLImageElement"),Zt=Gt("HTMLVideoElement"),Kt=Object.keys($).concat([Ht,$t,Qt,Xt,Yt,Zt]),tn=[];tn[5121]=1,tn[5126]=4,tn[36193]=2,tn[5123]=2,tn[5125]=4;var nn=[];function en(t){return Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function rn(t){return!!Array.isArray(t)&&!(0===t.length||!vt(t[0]))}function on(t){return Object.prototype.toString.call(t)}function an(t){return on(t)===Ht}function un(t){return on(t)===$t}function sn(t){if(!t)return!1;var n=on(t);return Kt.indexOf(n)>=0||en(t)||rn(t)||U(t)}function fn(t){return 0|$[Object.prototype.toString.call(t)]}function ln(t,n){return N.allocType(t.type===_t?Rt:t.type,n)}function cn(t,n){t.type===_t?(t.data=dt(n),N.freeType(n)):t.data=n}function dn(t,n,e,r,i,o){var a;if(a=void 0!==nn[t]?nn[t]:qt[t]*tn[n],o&&(a*=6),i){for(var u=0,s=e;s>=1;)u+=a*s*s,s/=2;return u}return a*e*r}function vn(e,r,i,o,a,u,s){var f={"don't care":It,"dont care":It,nice:4354,fast:4353},l={repeat:10497,clamp:Jt,mirror:33648},c={nearest:Nt,linear:9729},d=n({mipmap:Wt,"nearest mipmap nearest":Vt,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":Wt},c),v={none:0,browser:37444},h={uint8:St,rgba4:32819,rgb565:33635,"rgb5 a1":32820},p={alpha:gt,luminance:xt,"luminance alpha":At,rgb:wt,rgba:yt,rgba4:32854,"rgb5 a1":Ct,rgb565:36194},m={};r.ext_srgb&&(p.srgb=kt,p.srgba=Tt),r.oes_texture_float&&(h.float32=h.float=Rt),r.oes_texture_half_float&&(h.float16=h["half float"]=_t),r.webgl_depth_texture&&(n(p,{depth:jt,"depth stencil":Ot}),n(h,{uint16:Et,uint32:Bt,"depth stencil":34042})),r.webgl_compressed_texture_s3tc&&n(m,{"rgb s3tc dxt1":Ft,"rgba s3tc dxt1":Mt,"rgba s3tc dxt3":zt,"rgba s3tc dxt5":Dt}),r.webgl_compressed_texture_atc&&n(m,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),r.webgl_compressed_texture_pvrtc&&n(m,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),r.webgl_compressed_texture_etc1&&(m["rgb etc1"]=36196);var b=Array.prototype.slice.call(e.getParameter(34467));Object.keys(m).forEach((function(t){var n=m[t];b.indexOf(n)>=0&&(p[t]=n)}));var y=Object.keys(p);i.textureFormats=y;var g=[];Object.keys(p).forEach((function(t){g[p[t]]=t}));var w=[];Object.keys(h).forEach((function(t){w[h[t]]=t}));var x=[];Object.keys(c).forEach((function(t){x[c[t]]=t}));var A=[];Object.keys(d).forEach((function(t){A[d[t]]=t}));var j=[];Object.keys(l).forEach((function(t){j[l[t]]=t}));var O=y.reduce((function(t,n){var e=p[n];return t[e]=e===xt||e===gt||e===xt||e===At||e===jt||e===Ot||r.ext_srgb&&(e===kt||e===Tt)?e:e===Ct||n.indexOf("rgba")>=0?yt:wt,t}),{});function k(){this.internalformat=yt,this.format=yt,this.type=St,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=37444,this.width=0,this.height=0,this.channels=0}function T(t,n){t.internalformat=n.internalformat,t.format=n.format,t.type=n.type,t.compressed=n.compressed,t.premultiplyAlpha=n.premultiplyAlpha,t.flipY=n.flipY,t.unpackAlignment=n.unpackAlignment,t.colorSpace=n.colorSpace,t.width=n.width,t.height=n.height,t.channels=n.channels}function _(t,n){if("object"==typeof n&&n){if("premultiplyAlpha"in n&&(C.type(n.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),t.premultiplyAlpha=n.premultiplyAlpha),"flipY"in n&&(C.type(n.flipY,"boolean","invalid texture flip"),t.flipY=n.flipY),"alignment"in n&&(C.oneOf(n.alignment,[1,2,4,8],"invalid texture unpack alignment"),t.unpackAlignment=n.alignment),"colorSpace"in n&&(C.parameter(n.colorSpace,v,"invalid colorSpace"),t.colorSpace=v[n.colorSpace]),"type"in n){var e=n.type;C(r.oes_texture_float||!("float"===e||"float32"===e),"you must enable the OES_texture_float extension in order to use floating point textures."),C(r.oes_texture_half_float||!("half float"===e||"float16"===e),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),C(r.webgl_depth_texture||!("uint16"===e||"uint32"===e||"depth stencil"===e),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),C.parameter(e,h,"invalid texture type"),t.type=h[e]}var o=t.width,a=t.height,u=t.channels,s=!1;"shape"in n?(C(Array.isArray(n.shape)&&n.shape.length>=2,"shape must be an array"),o=n.shape[0],a=n.shape[1],3===n.shape.length&&(C((u=n.shape[2])>0&&u<=4,"invalid number of channels"),s=!0),C(o>=0&&o<=i.maxTextureSize,"invalid width"),C(a>=0&&a<=i.maxTextureSize,"invalid height")):("radius"in n&&(o=a=n.radius,C(o>=0&&o<=i.maxTextureSize,"invalid radius")),"width"in n&&C((o=n.width)>=0&&o<=i.maxTextureSize,"invalid width"),"height"in n&&C((a=n.height)>=0&&a<=i.maxTextureSize,"invalid height"),"channels"in n&&(C((u=n.channels)>0&&u<=4,"invalid number of channels"),s=!0)),t.width=0|o,t.height=0|a,t.channels=0|u;var f=!1;if("format"in n){var l=n.format;C(r.webgl_depth_texture||!("depth"===l||"depth stencil"===l),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),C.parameter(l,p,"invalid texture format");var c=t.internalformat=p[l];t.format=O[c],l in h&&("type"in n||(t.type=h[l])),l in m&&(t.compressed=!0),f=!0}!s&&f?t.channels=qt[t.format]:s&&!f?t.channels!==Pt[t.format]&&(t.format=t.internalformat=Pt[t.channels]):f&&s&&C(t.channels===qt[t.format],"number of channels inconsistent with specified format")}}function F(t){e.pixelStorei(37440,t.flipY),e.pixelStorei(37441,t.premultiplyAlpha),e.pixelStorei(37443,t.colorSpace),e.pixelStorei(3317,t.unpackAlignment)}function M(){k.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function z(n,e){var r=null;if(sn(e)?r=e:e&&(C.type(e,"object","invalid pixel data type"),_(n,e),"x"in e&&(n.xOffset=0|e.x),"y"in e&&(n.yOffset=0|e.y),sn(e.data)&&(r=e.data)),C(!n.compressed||r instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),e.copy){C(!r,"can not specify copy and data field for the same texture");var o=a.viewportWidth,u=a.viewportHeight;n.width=n.width||o-n.xOffset,n.height=n.height||u-n.yOffset,n.needsCopy=!0,C(n.xOffset>=0&&n.xOffset<o&&n.yOffset>=0&&n.yOffset<u&&n.width>0&&n.width<=o&&n.height>0&&n.height<=u,"copy texture read out of bounds")}else if(r){if(t(r))n.channels=n.channels||4,n.data=r,"type"in e||n.type!==St||(n.type=fn(r));else if(en(r))n.channels=n.channels||4,function(t,n){var e=n.length;switch(t.type){case St:case Et:case Bt:case Rt:var r=N.allocType(t.type,e);r.set(n),t.data=r;break;case _t:t.data=dt(n);break;default:C.raise("unsupported texture type, must specify a typed array")}}(n,r),n.alignment=1,n.needsFree=!0;else if(U(r)){var s=r.data;Array.isArray(s)||n.type!==St||(n.type=fn(s));var f,l,c,d,v,h,p=r.shape,m=r.stride;3===p.length?(c=p[2],h=m[2]):(C(2===p.length,"invalid ndarray pixel data, must be 2 or 3D"),c=1,h=1),f=p[0],l=p[1],d=m[0],v=m[1],n.alignment=1,n.width=f,n.height=l,n.channels=c,n.format=n.internalformat=Pt[c],n.needsFree=!0,function(t,n,e,r,i,o){for(var a=t.width,u=t.height,s=t.channels,f=ln(t,a*u*s),l=0,c=0;c<u;++c)for(var d=0;d<a;++d)for(var v=0;v<s;++v)f[l++]=n[e*d+r*c+i*v+o];cn(t,f)}(n,s,d,v,h,r.offset)}else if(an(r)||un(r)||on(r)===Qt)n.element=an(r)||un(r)?r:r.canvas,n.width=n.element.width,n.height=n.element.height,n.channels=4;else if(function(t){return on(t)===Xt}(r))n.element=r,n.width=r.width,n.height=r.height,n.channels=4;else if(function(t){return on(t)===Yt}(r))n.element=r,n.width=r.naturalWidth,n.height=r.naturalHeight,n.channels=4;else if(function(t){return on(t)===Zt}(r))n.element=r,n.width=r.videoWidth,n.height=r.videoHeight,n.channels=4;else if(rn(r)){var b=n.width||r[0].length,y=n.height||r.length,g=n.channels;g=vt(r[0][0])?g||r[0][0].length:g||1;for(var w=q.shape(r),x=1,A=0;A<w.length;++A)x*=w[A];var j=ln(n,x);q.flatten(r,w,"",j),cn(n,j),n.alignment=1,n.width=b,n.height=y,n.channels=g,n.format=n.internalformat=Pt[g],n.needsFree=!0}}else n.width=n.width||1,n.height=n.height||1,n.channels=n.channels||4;n.type===Rt?C(i.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):n.type===_t&&C(i.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function D(t,n,r){var i=t.element,a=t.data,u=t.internalformat,s=t.format,f=t.type,l=t.width,c=t.height;F(t),i?e.texImage2D(n,r,s,s,f,i):t.compressed?e.compressedTexImage2D(n,r,u,l,c,0,a):t.needsCopy?(o(),e.copyTexImage2D(n,r,s,t.xOffset,t.yOffset,l,c,0)):e.texImage2D(n,r,s,l,c,0,s,f,a||null)}function S(t,n,r,i,a){var u=t.element,s=t.data,f=t.internalformat,l=t.format,c=t.type,d=t.width,v=t.height;F(t),u?e.texSubImage2D(n,a,r,i,l,c,u):t.compressed?e.compressedTexSubImage2D(n,a,r,i,f,d,v,s):t.needsCopy?(o(),e.copyTexSubImage2D(n,a,r,i,t.xOffset,t.yOffset,d,v)):e.texSubImage2D(n,a,r,i,d,v,l,c,s)}var E=[];function B(){return E.pop()||new M}function R(t){t.needsFree&&N.freeType(t.data),M.call(t),E.push(t)}function J(){k.call(this),this.genMipmaps=!1,this.mipmapHint=It,this.mipmask=0,this.images=Array(16)}function V(t,n,e){var r=t.images[0]=B();t.mipmask=1,r.width=t.width=n,r.height=t.height=e,r.channels=t.channels=4}function W(t,n){var e=null;if(sn(n))T(e=t.images[0]=B(),t),z(e,n),t.mipmask=1;else if(_(t,n),Array.isArray(n.mipmap))for(var r=n.mipmap,i=0;i<r.length;++i)T(e=t.images[i]=B(),t),e.width>>=i,e.height>>=i,z(e,r[i]),t.mipmask|=1<<i;else T(e=t.images[0]=B(),t),z(e,n),t.mipmask=1;T(t,t.images[0]),!t.compressed||t.internalformat!==Ft&&t.internalformat!==Mt&&t.internalformat!==zt&&t.internalformat!==Dt||C(t.width%4==0&&t.height%4==0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function I(t,n){for(var e=t.images,r=0;r<e.length;++r){if(!e[r])return;D(e[r],n,r)}}var L=[];function G(){var t=L.pop()||new J;k.call(t),t.mipmask=0;for(var n=0;n<16;++n)t.images[n]=null;return t}function H(t){for(var n=t.images,e=0;e<n.length;++e)n[e]&&R(n[e]),n[e]=null;L.push(t)}function $(){this.minFilter=Nt,this.magFilter=Nt,this.wrapS=Jt,this.wrapT=Jt,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=It}function Q(t,n){if("min"in n){var e=n.min;C.parameter(e,d),t.minFilter=d[e],Ut.indexOf(t.minFilter)>=0&&!("faces"in n)&&(t.genMipmaps=!0)}if("mag"in n){var r=n.mag;C.parameter(r,c),t.magFilter=c[r]}var o=t.wrapS,a=t.wrapT;if("wrap"in n){var u=n.wrap;"string"==typeof u?(C.parameter(u,l),o=a=l[u]):Array.isArray(u)&&(C.parameter(u[0],l),C.parameter(u[1],l),o=l[u[0]],a=l[u[1]])}else{if("wrapS"in n){var s=n.wrapS;C.parameter(s,l),o=l[s]}if("wrapT"in n){var v=n.wrapT;C.parameter(v,l),a=l[v]}}if(t.wrapS=o,t.wrapT=a,"anisotropic"in n){var h=n.anisotropic;C("number"==typeof h&&h>=1&&h<=i.maxAnisotropic,"aniso samples must be between 1 and "),t.anisotropic=n.anisotropic}if("mipmap"in n){var p=!1;switch(typeof n.mipmap){case"string":C.parameter(n.mipmap,f,"invalid mipmap hint"),t.mipmapHint=f[n.mipmap],t.genMipmaps=!0,p=!0;break;case"boolean":p=t.genMipmaps=n.mipmap;break;case"object":C(Array.isArray(n.mipmap),"invalid mipmap type"),t.genMipmaps=!1,p=!0;break;default:C.raise("invalid mipmap type")}p&&!("min"in n)&&(t.minFilter=Vt)}}function X(t,n){e.texParameteri(n,10241,t.minFilter),e.texParameteri(n,10240,t.magFilter),e.texParameteri(n,10242,t.wrapS),e.texParameteri(n,10243,t.wrapT),r.ext_texture_filter_anisotropic&&e.texParameteri(n,34046,t.anisotropic),t.genMipmaps&&(e.hint(33170,t.mipmapHint),e.generateMipmap(n))}var Y=0,Z={},K=i.maxTextureUnits,tt=Array(K).map((function(){return null}));function nt(t){k.call(this),this.mipmask=0,this.internalformat=yt,this.id=Y++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new $,s.profile&&(this.stats={size:0})}function et(t){e.activeTexture(Lt),e.bindTexture(t.target,t.texture)}function rt(){var t=tt[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(pt,null)}function it(t){var n=t.texture;C(n,"must not double destroy texture");var r=t.unit,i=t.target;r>=0&&(e.activeTexture(Lt+r),e.bindTexture(i,null),tt[r]=null),e.deleteTexture(n),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete Z[t.id],u.textureCount--}return n(nt.prototype,{bind:function(){var t=this;t.bindCount+=1;var n=t.unit;if(n<0){for(var r=0;r<K;++r){var i=tt[r];if(i){if(i.bindCount>0)continue;i.unit=-1}tt[r]=t,n=r;break}n>=K&&C.raise("insufficient number of texture units"),s.profile&&u.maxTextureUnits<n+1&&(u.maxTextureUnits=n+1),t.unit=n,e.activeTexture(Lt+n),e.bindTexture(t.target,t.texture)}return n},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&it(this)}}),s.profile&&(u.getTotalTextureSize=function(){var t=0;return Object.keys(Z).forEach((function(n){t+=Z[n].stats.size})),t}),{create2D:function(t,n){var r=new nt(pt);function o(t,n){var e=r.texInfo;$.call(e);var a=G();return"number"==typeof t?V(a,0|t,"number"==typeof n?0|n:0|t):t?(C.type(t,"object","invalid arguments to regl.texture"),Q(e,t),W(a,t)):V(a,1,1),e.genMipmaps&&(a.mipmask=(a.width<<1)-1),r.mipmask=a.mipmask,T(r,a),C.texture2D(e,a,i),r.internalformat=a.internalformat,o.width=a.width,o.height=a.height,et(r),I(a,pt),X(e,pt),rt(),H(a),s.profile&&(r.stats.size=dn(r.internalformat,r.type,a.width,a.height,e.genMipmaps,!1)),o.format=g[r.internalformat],o.type=w[r.type],o.mag=x[e.magFilter],o.min=A[e.minFilter],o.wrapS=j[e.wrapS],o.wrapT=j[e.wrapT],o}return Z[r.id]=r,u.textureCount++,o(t,n),o.subimage=function(t,n,e,i){C(!!t,"must specify image data");var a=0|n,u=0|e,s=0|i,f=B();return T(f,r),f.width=0,f.height=0,z(f,t),f.width=f.width||(r.width>>s)-a,f.height=f.height||(r.height>>s)-u,C(r.type===f.type&&r.format===f.format&&r.internalformat===f.internalformat,"incompatible format for texture.subimage"),C(a>=0&&u>=0&&a+f.width<=r.width&&u+f.height<=r.height,"texture.subimage write out of bounds"),C(r.mipmask&1<<s,"missing mipmap data"),C(f.data||f.element||f.needsCopy,"missing image data"),et(r),S(f,pt,a,u,s),rt(),R(f),o},o.resize=function(t,n){var i=0|t,a=0|n||i;if(i===r.width&&a===r.height)return o;o.width=r.width=i,o.height=r.height=a,et(r);for(var u=0;r.mipmask>>u;++u){var f=i>>u,l=a>>u;if(!f||!l)break;e.texImage2D(pt,u,r.format,f,l,0,r.format,r.type,null)}return rt(),s.profile&&(r.stats.size=dn(r.internalformat,r.type,i,a,!1,!1)),o},o._reglType="texture2d",o._texture=r,s.profile&&(o.stats=r.stats),o.destroy=function(){r.decRef()},o},createCube:function(t,n,r,o,a,f){var l=new nt(mt);Z[l.id]=l,u.cubeCount++;var c=new Array(6);function d(t,n,e,r,o,a){var u,f=l.texInfo;for($.call(f),u=0;u<6;++u)c[u]=G();if("number"!=typeof t&&t)if("object"==typeof t)if(n)W(c[0],t),W(c[1],n),W(c[2],e),W(c[3],r),W(c[4],o),W(c[5],a);else if(Q(f,t),_(l,t),"faces"in t){var v=t.faces;for(C(Array.isArray(v)&&6===v.length,"cube faces must be a length 6 array"),u=0;u<6;++u)C("object"==typeof v[u]&&!!v[u],"invalid input for cube map face"),T(c[u],l),W(c[u],v[u])}else for(u=0;u<6;++u)W(c[u],t);else C.raise("invalid arguments to cube map");else{var h=0|t||1;for(u=0;u<6;++u)V(c[u],h,h)}for(T(l,c[0]),C.optional((function(){i.npotTextureCube||C(ht(l.width)&&ht(l.height),"your browser does not support non power or two texture dimensions")})),l.mipmask=f.genMipmaps?(c[0].width<<1)-1:c[0].mipmask,C.textureCube(l,f,c,i),l.internalformat=c[0].internalformat,d.width=c[0].width,d.height=c[0].height,et(l),u=0;u<6;++u)I(c[u],bt+u);for(X(f,mt),rt(),s.profile&&(l.stats.size=dn(l.internalformat,l.type,d.width,d.height,f.genMipmaps,!0)),d.format=g[l.internalformat],d.type=w[l.type],d.mag=x[f.magFilter],d.min=A[f.minFilter],d.wrapS=j[f.wrapS],d.wrapT=j[f.wrapT],u=0;u<6;++u)H(c[u]);return d}return d(t,n,r,o,a,f),d.subimage=function(t,n,e,r,i){C(!!n,"must specify image data"),C("number"==typeof t&&t===(0|t)&&t>=0&&t<6,"invalid face");var o=0|e,a=0|r,u=0|i,s=B();return T(s,l),s.width=0,s.height=0,z(s,n),s.width=s.width||(l.width>>u)-o,s.height=s.height||(l.height>>u)-a,C(l.type===s.type&&l.format===s.format&&l.internalformat===s.internalformat,"incompatible format for texture.subimage"),C(o>=0&&a>=0&&o+s.width<=l.width&&a+s.height<=l.height,"texture.subimage write out of bounds"),C(l.mipmask&1<<u,"missing mipmap data"),C(s.data||s.element||s.needsCopy,"missing image data"),et(l),S(s,bt+t,o,a,u),rt(),R(s),d},d.resize=function(t){var n=0|t;if(n!==l.width){d.width=l.width=n,d.height=l.height=n,et(l);for(var r=0;r<6;++r)for(var i=0;l.mipmask>>i;++i)e.texImage2D(bt+r,i,l.format,n>>i,n>>i,0,l.format,l.type,null);return rt(),s.profile&&(l.stats.size=dn(l.internalformat,l.type,d.width,d.height,!1,!0)),d}},d._reglType="textureCube",d._texture=l,s.profile&&(d.stats=l.stats),d.destroy=function(){l.decRef()},d},clear:function(){for(var t=0;t<K;++t)e.activeTexture(Lt+t),e.bindTexture(pt,null),tt[t]=null;P(Z).forEach(it),u.cubeCount=0,u.textureCount=0},getTexture:function(){return null},restore:function(){for(var t=0;t<K;++t){var n=tt[t];n&&(n.bindCount=0,n.unit=-1,tt[t]=null)}P(Z).forEach((function(t){t.texture=e.createTexture(),e.bindTexture(t.target,t.texture);for(var n=0;n<32;++n)if(0!=(t.mipmask&1<<n))if(t.target===pt)e.texImage2D(pt,n,t.internalformat,t.width>>n,t.height>>n,0,t.internalformat,t.type,null);else for(var r=0;r<6;++r)e.texImage2D(bt+r,n,t.internalformat,t.width>>n,t.height>>n,0,t.internalformat,t.type,null);X(t.texInfo,t.target)}))},refresh:function(){for(var t=0;t<K;++t){var n=tt[t];n&&(n.bindCount=0,n.unit=-1,tt[t]=null),e.activeTexture(Lt+t),e.bindTexture(pt,null),e.bindTexture(mt,null)}}}}nn[32854]=2,nn[32855]=2,nn[36194]=2,nn[34041]=4,nn[33776]=.5,nn[33777]=.5,nn[33778]=1,nn[33779]=1,nn[35986]=.5,nn[35987]=1,nn[34798]=1,nn[35840]=.5,nn[35841]=.25,nn[35842]=.5,nn[35843]=.25,nn[36196]=.5;var hn=36161,pn=32854,mn=[];function bn(t,n,e){return mn[t]*n*e}mn[32854]=2,mn[32855]=2,mn[36194]=2,mn[33189]=2,mn[36168]=1,mn[34041]=4,mn[35907]=4,mn[34836]=16,mn[34842]=8,mn[34843]=6;var yn=36160,gn=36161,wn=3553,xn=34069,An=[6407,6408],Cn=[];Cn[6408]=4,Cn[6407]=3;var jn=[];jn[5121]=1,jn[5126]=4,jn[36193]=2;var On=[32854,32855,36194,35907,34842,34843,34836],kn={};kn[36053]="complete",kn[36054]="incomplete attachment",kn[36057]="incomplete dimensions",kn[36055]="incomplete, missing attachment",kn[36061]="unsupported";var Tn=["attributes","elements","offset","count","primitive","instances"];function _n(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.offset=0,this.stride=0,this.divisor=0}var Fn=5121,Mn=5126;function zn(n,e,r,i,o,a,u){function s(s){var f;null===e.next?(C(o.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),f=Fn):(C(null!==e.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),f=e.next.colorAttachments[0].texture._texture.type,C.optional((function(){a.oes_texture_float?(C(f===Fn||f===Mn,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),f===Mn&&C(u.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):C(f===Fn,"Reading from a framebuffer is only allowed for the type 'uint8'")})));var l=0,c=0,d=i.framebufferWidth,v=i.framebufferHeight,h=null;t(s)?h=s:s&&(C.type(s,"object","invalid arguments to regl.read()"),c=0|s.y,C((l=0|s.x)>=0&&l<i.framebufferWidth,"invalid x offset for regl.read"),C(c>=0&&c<i.framebufferHeight,"invalid y offset for regl.read"),d=0|(s.width||i.framebufferWidth-l),v=0|(s.height||i.framebufferHeight-c),h=s.data||null),h&&(f===Fn?C(h instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):f===Mn&&C(h instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),C(d>0&&d+l<=i.framebufferWidth,"invalid width for read pixels"),C(v>0&&v+c<=i.framebufferHeight,"invalid height for read pixels"),r();var p=d*v*4;return h||(f===Fn?h=new Uint8Array(p):f===Mn&&(h=h||new Float32Array(p))),C.isTypedArray(h,"data buffer for regl.read() must be a typedarray"),C(h.byteLength>=p,"data buffer for regl.read() too small"),n.pixelStorei(3333,4),n.readPixels(l,c,d,v,6408,f,h),h}return function(t){return t&&"framebuffer"in t?function(t){var n;return e.setFBO({framebuffer:t.framebuffer},(function(){n=s(t)})),n}(t):s(t)}}function Dn(t){return Array.prototype.slice.call(t)}function Sn(t){return Dn(t).join("")}var En="xyzw".split(""),Bn="dither",Rn="blend.enable",Jn="blend.color",Nn="blend.equation",Vn="blend.func",Wn="depth.enable",In="depth.func",Ln="depth.range",Un="depth.mask",Pn="colorMask",qn="cull.enable",Gn="cull.face",Hn="frontFace",$n="lineWidth",Qn="polygonOffset.enable",Xn="polygonOffset.offset",Yn="sample.alpha",Zn="sample.enable",Kn="sample.coverage",te="stencil.enable",ne="stencil.mask",ee="stencil.func",re="stencil.opFront",ie="stencil.opBack",oe="scissor.enable",ae="scissor.box",ue="viewport",se="profile",fe="framebuffer",le="vert",ce="frag",de="elements",ve="primitive",he="count",pe="offset",me="instances",be="vao",ye="Width",ge="Height",we=fe+ye,xe=fe+ge,Ae="drawingBufferWidth",Ce="drawingBufferHeight",je=[Vn,Nn,ee,re,ie,Kn,ue,ae,Xn],Oe=34962,ke=34963,Te=5126,_e=35664,Fe=35665,Me=35666,ze=5124,De=35667,Se=35668,Ee=35669,Be=35670,Re=35671,Je=35672,Ne=35673,Ve=35674,We=35675,Ie=35676,Le=35678,Ue=35680,Pe=1028,qe=1029,Ge=2305,He=7680,$e={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Qe=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],Xe={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Ye={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Ze={frag:35632,vert:35633},Ke={cw:2304,ccw:Ge};function tr(n){return Array.isArray(n)||t(n)||U(n)}function nr(t){return t.sort((function(t,n){return t===ue?-1:n===ue?1:t<n?-1:1}))}function er(t,n,e,r){this.thisDep=t,this.contextDep=n,this.propDep=e,this.append=r}function rr(t){return t&&!(t.thisDep||t.contextDep||t.propDep)}function ir(t){return new er(!1,!1,!1,t)}function or(t,n){var e=t.type;if(0===e){var r=t.data.length;return new er(!0,r>=1,r>=2,n)}if(4===e){var i=t.data;return new er(i.thisDep,i.contextDep,i.propDep,n)}if(5===e)return new er(!1,!1,!1,n);if(6===e){for(var o=!1,a=!1,u=!1,s=0;s<t.data.length;++s){var f=t.data[s];if(1===f.type)u=!0;else if(2===f.type)a=!0;else if(3===f.type)o=!0;else if(0===f.type){o=!0;var l=f.data;l>=1&&(a=!0),l>=2&&(u=!0)}else 4===f.type&&(o=o||f.data.thisDep,a=a||f.data.contextDep,u=u||f.data.propDep)}return new er(o,a,u,n)}return new er(3===e,2===e,1===e,n)}var ar=new er(!1,!1,!1,(function(){}));function ur(t,e,r,i,o,a,u,s,f,l,c,d,v,h,p){var m=l.Record,b={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&(b.min=32775,b.max=32776);var y=r.angle_instanced_arrays,g=r.webgl_draw_buffers,w=r.oes_vertex_array_object,x={dirty:!0,profile:p.profile},A={},j=[],O={},k={};function T(t){return t.replace(".","_")}function _(t,n,e){var r=T(t);j.push(t),A[r]=x[r]=!!e,O[r]=n}function M(t,n,e){var r=T(t);j.push(t),Array.isArray(e)?(x[r]=e.slice(),A[r]=e.slice()):x[r]=A[r]=e,k[r]=n}_(Bn,3024),_(Rn,3042),M(Jn,"blendColor",[0,0,0,0]),M(Nn,"blendEquationSeparate",[32774,32774]),M(Vn,"blendFuncSeparate",[1,0,1,0]),_(Wn,2929,!0),M(In,"depthFunc",513),M(Ln,"depthRange",[0,1]),M(Un,"depthMask",!0),M(Pn,Pn,[!0,!0,!0,!0]),_(qn,2884),M(Gn,"cullFace",qe),M(Hn,Hn,Ge),M($n,$n,1),_(Qn,32823),M(Xn,"polygonOffset",[0,0]),_(Yn,32926),_(Zn,32928),M(Kn,"sampleCoverage",[1,!1]),_(te,2960),M(ne,"stencilMask",-1),M(ee,"stencilFunc",[519,0,-1]),M(re,"stencilOpSeparate",[Pe,He,He,He]),M(ie,"stencilOpSeparate",[qe,He,He,He]),_(oe,3089),M(ae,"scissor",[0,0,t.drawingBufferWidth,t.drawingBufferHeight]),M(ue,ue,[0,0,t.drawingBufferWidth,t.drawingBufferHeight]);var z={gl:t,context:v,strings:e,next:A,current:x,draw:d,elements:a,buffer:o,shader:c,attributes:l.state,vao:l,uniforms:f,framebuffer:s,extensions:r,timer:h,isBufferArgs:tr},D={primTypes:ot,compareFuncs:Xe,blendFuncs:$e,blendEquations:b,stencilOps:Ye,glTypes:Q,orientationType:Ke};C.optional((function(){z.isArrayLike=vt})),g&&(D.backBuffer=[qe],D.drawBuffer=B(i.maxDrawbuffers,(function(t){return 0===t?[0]:B(t,(function(t){return 36064+t}))})));var S=0;function E(){var t=function(){var t=0,e=[],r=[];function i(){var e=[],r=[];return n((function(){e.push.apply(e,Dn(arguments))}),{def:function(){var n="v"+t++;return r.push(n),arguments.length>0&&(e.push(n,"="),e.push.apply(e,Dn(arguments)),e.push(";")),n},toString:function(){return Sn([r.length>0?"var "+r.join(",")+";":"",Sn(e)])}})}function o(){var t=i(),e=i(),r=t.toString,o=e.toString;function a(n,r){e(n,r,"=",t.def(n,r),";")}return n((function(){t.apply(t,Dn(arguments))}),{def:t.def,entry:t,exit:e,save:a,set:function(n,e,r){a(n,e),t(n,e,"=",r,";")},toString:function(){return r()+o()}})}var a=i(),u={};return{global:a,link:function(n){for(var i=0;i<r.length;++i)if(r[i]===n)return e[i];var o="g"+t++;return e.push(o),r.push(n),o},block:i,proc:function(t,e){var r=[];function i(){var t="a"+r.length;return r.push(t),t}e=e||0;for(var a=0;a<e;++a)i();var s=o(),f=s.toString;return u[t]=n(s,{arg:i,toString:function(){return Sn(["function(",r.join(),"){",f(),"}"])}})},scope:o,cond:function(){var t=Sn(arguments),e=o(),r=o(),i=e.toString,a=r.toString;return n(e,{then:function(){return e.apply(e,Dn(arguments)),this},else:function(){return r.apply(r,Dn(arguments)),this},toString:function(){var n=a();return n&&(n="else{"+n+"}"),Sn(["if(",t,"){",i(),"}",n])}})},compile:function(){var t=['"use strict";',a,"return {"];Object.keys(u).forEach((function(n){t.push('"',n,'":',u[n].toString(),",")})),t.push("}");var n=Sn(t).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,e.concat(n)).apply(null,r)}}}(),r=t.link,i=t.global;t.id=S++,t.batchId="0";var o=r(z),a=t.shared={props:"a0"};Object.keys(z).forEach((function(t){a[t]=i.def(o,".",t)})),C.optional((function(){t.CHECK=r(C),t.commandStr=C.guessCommand(),t.command=r(t.commandStr),t.assert=function(t,n,e){t("if(!(",n,"))",this.CHECK,".commandRaise(",r(e),",",this.command,");")},D.invalidBlendCombinations=Qe}));var u=t.next={},s=t.current={};Object.keys(k).forEach((function(t){Array.isArray(x[t])&&(u[t]=i.def(a.next,".",t),s[t]=i.def(a.current,".",t))}));var f=t.constants={};Object.keys(D).forEach((function(t){f[t]=i.def(JSON.stringify(D[t]))})),t.invoke=function(n,e){switch(e.type){case 0:var i=["this",a.context,a.props,t.batchId];return n.def(r(e.data),".call(",i.slice(0,Math.max(e.data.length+1,4)),")");case 1:return n.def(a.props,e.data);case 2:return n.def(a.context,e.data);case 3:return n.def("this",e.data);case 4:return e.data.append(t,n),e.data.ref;case 5:return e.data.toString();case 6:return e.data.map((function(e){return t.invoke(n,e)}))}},t.attribCache={};var c={};return t.scopeAttrib=function(t){var n=e.id(t);if(n in c)return c[n];var i=l.scope[n];return i||(i=l.scope[n]=new m),c[n]=r(i)},t}function R(t,n,u,f,d){var v=t.static,h=t.dynamic;C.optional((function(){var t=[fe,le,ce,de,ve,pe,he,me,se,be].concat(j);function n(n){Object.keys(n).forEach((function(n){C.command(t.indexOf(n)>=0,'unknown parameter "'+n+'"',d.commandStr)}))}n(v),n(h)}));var p=function(t,n){var e=t.static;if("string"==typeof e[ce]&&"string"==typeof e[le]){if(Object.keys(n.dynamic).length>0)return null;var r=n.static,i=Object.keys(r);if(i.length>0&&"number"==typeof r[i[0]]){for(var o=[],a=0;a<i.length;++a)C("number"==typeof r[i[a]],"must specify all vertex attribute locations when using vaos"),o.push([0|r[i[a]],i[a]]);return o}}return null}(t,n),g=function(t){var n=t.static,e=t.dynamic;if(fe in n){var r=n[fe];return r?(r=s.getFramebuffer(r),C.command(r,"invalid framebuffer object"),ir((function(t,n){var e=t.link(r),i=t.shared;n.set(i.framebuffer,".next",e);var o=i.context;return n.set(o,"."+we,e+".width"),n.set(o,"."+xe,e+".height"),e}))):ir((function(t,n){var e=t.shared;n.set(e.framebuffer,".next","null");var r=e.context;return n.set(r,"."+we,r+"."+Ae),n.set(r,"."+xe,r+"."+Ce),"null"}))}if(fe in e){var i=e[fe];return or(i,(function(t,n){var e=t.invoke(n,i),r=t.shared,o=r.framebuffer,a=n.def(o,".getFramebuffer(",e,")");C.optional((function(){t.assert(n,"!"+e+"||"+a,"invalid framebuffer object")})),n.set(o,".next",a);var u=r.context;return n.set(u,"."+we,a+"?"+a+".width:"+u+"."+Ae),n.set(u,"."+xe,a+"?"+a+".height:"+u+"."+Ce),a}))}return null}(t),w=function(t,n,e){var r=t.static,i=t.dynamic;function o(t){if(t in r){var o=r[t];C.commandType(o,"object","invalid "+t,e.commandStr);var a,u,s=!0,f=0|o.x,l=0|o.y;return"width"in o?C.command((a=0|o.width)>=0,"invalid "+t,e.commandStr):s=!1,"height"in o?C.command((u=0|o.height)>=0,"invalid "+t,e.commandStr):s=!1,new er(!s&&n&&n.thisDep,!s&&n&&n.contextDep,!s&&n&&n.propDep,(function(t,n){var e=t.shared.context,r=a;"width"in o||(r=n.def(e,".",we,"-",f));var i=u;return"height"in o||(i=n.def(e,".",xe,"-",l)),[f,l,r,i]}))}if(t in i){var c=i[t],d=or(c,(function(n,e){var r=n.invoke(e,c);C.optional((function(){n.assert(e,r+"&&typeof "+r+'==="object"',"invalid "+t)}));var i=n.shared.context,o=e.def(r,".x|0"),a=e.def(r,".y|0"),u=e.def('"width" in ',r,"?",r,".width|0:","(",i,".",we,"-",o,")"),s=e.def('"height" in ',r,"?",r,".height|0:","(",i,".",xe,"-",a,")");return C.optional((function(){n.assert(e,u+">=0&&"+s+">=0","invalid "+t)})),[o,a,u,s]}));return n&&(d.thisDep=d.thisDep||n.thisDep,d.contextDep=d.contextDep||n.contextDep,d.propDep=d.propDep||n.propDep),d}return n?new er(n.thisDep,n.contextDep,n.propDep,(function(t,n){var e=t.shared.context;return[0,0,n.def(e,".",we),n.def(e,".",xe)]})):null}var a=o(ue);if(a){var u=a;a=new er(a.thisDep,a.contextDep,a.propDep,(function(t,n){var e=u.append(t,n),r=t.shared.context;return n.set(r,".viewportWidth",e[2]),n.set(r,".viewportHeight",e[3]),e}))}return{viewport:a,scissor_box:o(ae)}}(t,g,d),x=function(t,n){var e=t.static,r=t.dynamic,i={},o=!1,u=function(){if(be in e){var t=e[be];return null!==t&&null===l.getVAO(t)&&(t=l.createVAO(t)),o=!0,i.vao=t,ir((function(n){var e=l.getVAO(t);return e?n.link(e):"null"}))}if(be in r){o=!0;var n=r[be];return or(n,(function(t,e){var r=t.invoke(e,n);return e.def(t.shared.vao+".getVAO("+r+")")}))}return null}(),s=!1,f=function(){if(de in e){var t=e[de];if(i.elements=t,tr(t)){var f=i.elements=a.create(t,!0);t=a.getElements(f),s=!0}else t&&(t=a.getElements(t),s=!0,C.command(t,"invalid elements",n.commandStr));var l=ir((function(n){if(t){var e=n.link(t);return n.ELEMENTS=e,e}return n.ELEMENTS=null,null}));return l.value=t,l}if(de in r){s=!0;var c=r[de];return or(c,(function(t,n){var e=t.shared,r=e.isBufferArgs,i=e.elements,o=t.invoke(n,c),a=n.def("null"),u=n.def(r,"(",o,")"),s=t.cond(u).then(a,"=",i,".createStream(",o,");").else(a,"=",i,".getElements(",o,");");return C.optional((function(){t.assert(s.else,"!"+o+"||"+a,"invalid elements")})),n.entry(s),n.exit(t.cond(u).then(i,".destroyStream(",a,");")),t.ELEMENTS=a,a}))}return o?new er(u.thisDep,u.contextDep,u.propDep,(function(t,n){return n.def(t.shared.vao+".currentVAO?"+t.shared.elements+".getElements("+t.shared.vao+".currentVAO.elements):null")})):null}();function c(t,a){if(t in e){var f=0|e[t];return a?i.offset=f:i.instances=f,C.command(!a||f>=0,"invalid "+t,n.commandStr),ir((function(t){return a&&(t.OFFSET=f),f}))}if(t in r){var l=r[t];return or(l,(function(n,e){var r=n.invoke(e,l);return a&&(n.OFFSET=r,C.optional((function(){n.assert(e,r+">=0","invalid "+t)}))),r}))}if(a){if(s)return ir((function(t){return t.OFFSET=0,0}));if(o)return new er(u.thisDep,u.contextDep,u.propDep,(function(t,n){return n.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.offset:0")}))}else if(o)return new er(u.thisDep,u.contextDep,u.propDep,(function(t,n){return n.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.instances:-1")}));return null}var d=c(pe,!0),v=function(){if(ve in e){var t=e[ve];return i.primitive=t,C.commandParameter(t,ot,"invalid primitve",n.commandStr),ir((function(){return ot[t]}))}if(ve in r){var a=r[ve];return or(a,(function(t,n){var e=t.constants.primTypes,r=t.invoke(n,a);return C.optional((function(){t.assert(n,r+" in "+e,"invalid primitive, must be one of "+Object.keys(ot))})),n.def(e,"[",r,"]")}))}return s?rr(f)?ir(f.value?function(t,n){return n.def(t.ELEMENTS,".primType")}:function(){return 4}):new er(f.thisDep,f.contextDep,f.propDep,(function(t,n){var e=t.ELEMENTS;return n.def(e,"?",e,".primType:",4)})):o?new er(u.thisDep,u.contextDep,u.propDep,(function(t,n){return n.def(t.shared.vao+".currentVAO?"+t.shared.vao+".currentVAO.primitive:4")})):null}(),h=function(){if(he in e){var t=0|e[he];return i.count=t,C.command("number"==typeof t&&t>=0,"invalid vertex count",n.commandStr),ir((function(){return t}))}if(he in r){var a=r[he];return or(a,(function(t,n){var e=t.invoke(n,a);return C.optional((function(){t.assert(n,"typeof "+e+'==="number"&&'+e+">=0&&"+e+"===("+e+"|0)","invalid vertex count")})),e}))}if(s){if(rr(f)){if(f)return d?new er(d.thisDep,d.contextDep,d.propDep,(function(t,n){var e=n.def(t.ELEMENTS,".vertCount-",t.OFFSET);return C.optional((function(){t.assert(n,e+">=0","invalid vertex offset/element buffer too small")})),e})):ir((function(t,n){return n.def(t.ELEMENTS,".vertCount")}));var l=ir((function(){return-1}));return C.optional((function(){l.MISSING=!0})),l}var c=new er(f.thisDep||d.thisDep,f.contextDep||d.contextDep,f.propDep||d.propDep,(function(t,n){var e=t.ELEMENTS;return t.OFFSET?n.def(e,"?",e,".vertCount-",t.OFFSET,":-1"):n.def(e,"?",e,".vertCount:-1")}));return C.optional((function(){c.DYNAMIC=!0})),c}return o?new er(u.thisDep,u.contextDep,u.propDep,(function(t,n){return n.def(t.shared.vao,".currentVAO?",t.shared.vao,".currentVAO.count:-1")})):null}(),p=c(me,!1);return{elements:f,primitive:v,count:h,instances:p,offset:d,vao:u,vaoActive:o,elementsActive:s,static:i}}(t,d),A=function(t,n){var e=t.static,r=t.dynamic,o={};return j.forEach((function(t){var a=T(t);function u(n,i){if(t in e){var u=n(e[t]);o[a]=ir((function(){return u}))}else if(t in r){var s=r[t];o[a]=or(s,(function(t,n){return i(t,n,t.invoke(n,s))}))}}switch(t){case qn:case Rn:case Bn:case te:case Wn:case oe:case Qn:case Yn:case Zn:case Un:return u((function(e){return C.commandType(e,"boolean",t,n.commandStr),e}),(function(n,e,r){return C.optional((function(){n.assert(e,"typeof "+r+'==="boolean"',"invalid flag "+t,n.commandStr)})),r}));case In:return u((function(e){return C.commandParameter(e,Xe,"invalid "+t,n.commandStr),Xe[e]}),(function(n,e,r){var i=n.constants.compareFuncs;return C.optional((function(){n.assert(e,r+" in "+i,"invalid "+t+", must be one of "+Object.keys(Xe))})),e.def(i,"[",r,"]")}));case Ln:return u((function(t){return C.command(vt(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&t[0]<=t[1],"depth range is 2d array",n.commandStr),t}),(function(t,n,e){return C.optional((function(){t.assert(n,t.shared.isArrayLike+"("+e+")&&"+e+".length===2&&typeof "+e+'[0]==="number"&&typeof '+e+'[1]==="number"&&'+e+"[0]<="+e+"[1]","depth range must be a 2d array")})),[n.def("+",e,"[0]"),n.def("+",e,"[1]")]}));case Vn:return u((function(t){C.commandType(t,"object","blend.func",n.commandStr);var e="srcRGB"in t?t.srcRGB:t.src,r="srcAlpha"in t?t.srcAlpha:t.src,i="dstRGB"in t?t.dstRGB:t.dst,o="dstAlpha"in t?t.dstAlpha:t.dst;return C.commandParameter(e,$e,a+".srcRGB",n.commandStr),C.commandParameter(r,$e,a+".srcAlpha",n.commandStr),C.commandParameter(i,$e,a+".dstRGB",n.commandStr),C.commandParameter(o,$e,a+".dstAlpha",n.commandStr),C.command(-1===Qe.indexOf(e+", "+i),"unallowed blending combination (srcRGB, dstRGB) = ("+e+", "+i+")",n.commandStr),[$e[e],$e[i],$e[r],$e[o]]}),(function(n,e,r){var i=n.constants.blendFuncs;function o(o,a){var u=e.def('"',o,a,'" in ',r,"?",r,".",o,a,":",r,".",o);return C.optional((function(){n.assert(e,u+" in "+i,"invalid "+t+"."+o+a+", must be one of "+Object.keys($e))})),u}C.optional((function(){n.assert(e,r+"&&typeof "+r+'==="object"',"invalid blend func, must be an object")}));var a=o("src","RGB"),u=o("dst","RGB");C.optional((function(){n.assert(e,n.constants.invalidBlendCombinations+".indexOf("+a+'+", "+'+u+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")}));var s=e.def(i,"[",a,"]"),f=e.def(i,"[",o("src","Alpha"),"]");return[s,e.def(i,"[",u,"]"),f,e.def(i,"[",o("dst","Alpha"),"]")]}));case Nn:return u((function(e){return"string"==typeof e?(C.commandParameter(e,b,"invalid "+t,n.commandStr),[b[e],b[e]]):"object"==typeof e?(C.commandParameter(e.rgb,b,t+".rgb",n.commandStr),C.commandParameter(e.alpha,b,t+".alpha",n.commandStr),[b[e.rgb],b[e.alpha]]):void C.commandRaise("invalid blend.equation",n.commandStr)}),(function(n,e,r){var i=n.constants.blendEquations,o=e.def(),a=e.def(),u=n.cond("typeof ",r,'==="string"');return C.optional((function(){function e(t,e,r){n.assert(t,r+" in "+i,"invalid "+e+", must be one of "+Object.keys(b))}e(u.then,t,r),n.assert(u.else,r+"&&typeof "+r+'==="object"',"invalid "+t),e(u.else,t+".rgb",r+".rgb"),e(u.else,t+".alpha",r+".alpha")})),u.then(o,"=",a,"=",i,"[",r,"];"),u.else(o,"=",i,"[",r,".rgb];",a,"=",i,"[",r,".alpha];"),e(u),[o,a]}));case Jn:return u((function(t){return C.command(vt(t)&&4===t.length,"blend.color must be a 4d array",n.commandStr),B(4,(function(n){return+t[n]}))}),(function(t,n,e){return C.optional((function(){t.assert(n,t.shared.isArrayLike+"("+e+")&&"+e+".length===4","blend.color must be a 4d array")})),B(4,(function(t){return n.def("+",e,"[",t,"]")}))}));case ne:return u((function(t){return C.commandType(t,"number",a,n.commandStr),0|t}),(function(t,n,e){return C.optional((function(){t.assert(n,"typeof "+e+'==="number"',"invalid stencil.mask")})),n.def(e,"|0")}));case ee:return u((function(e){C.commandType(e,"object",a,n.commandStr);var r=e.cmp||"keep",i=e.ref||0,o="mask"in e?e.mask:-1;return C.commandParameter(r,Xe,t+".cmp",n.commandStr),C.commandType(i,"number",t+".ref",n.commandStr),C.commandType(o,"number",t+".mask",n.commandStr),[Xe[r],i,o]}),(function(t,n,e){var r=t.constants.compareFuncs;return C.optional((function(){function i(){t.assert(n,Array.prototype.join.call(arguments,""),"invalid stencil.func")}i(e+"&&typeof ",e,'==="object"'),i('!("cmp" in ',e,")||(",e,".cmp in ",r,")")})),[n.def('"cmp" in ',e,"?",r,"[",e,".cmp]",":",He),n.def(e,".ref|0"),n.def('"mask" in ',e,"?",e,".mask|0:-1")]}));case re:case ie:return u((function(e){C.commandType(e,"object",a,n.commandStr);var r=e.fail||"keep",i=e.zfail||"keep",o=e.zpass||"keep";return C.commandParameter(r,Ye,t+".fail",n.commandStr),C.commandParameter(i,Ye,t+".zfail",n.commandStr),C.commandParameter(o,Ye,t+".zpass",n.commandStr),[t===ie?qe:Pe,Ye[r],Ye[i],Ye[o]]}),(function(n,e,r){var i=n.constants.stencilOps;function o(o){return C.optional((function(){n.assert(e,'!("'+o+'" in '+r+")||("+r+"."+o+" in "+i+")","invalid "+t+"."+o+", must be one of "+Object.keys(Ye))})),e.def('"',o,'" in ',r,"?",i,"[",r,".",o,"]:",He)}return C.optional((function(){n.assert(e,r+"&&typeof "+r+'==="object"',"invalid "+t)})),[t===ie?qe:Pe,o("fail"),o("zfail"),o("zpass")]}));case Xn:return u((function(t){C.commandType(t,"object",a,n.commandStr);var e=0|t.factor,r=0|t.units;return C.commandType(e,"number",a+".factor",n.commandStr),C.commandType(r,"number",a+".units",n.commandStr),[e,r]}),(function(n,e,r){return C.optional((function(){n.assert(e,r+"&&typeof "+r+'==="object"',"invalid "+t)})),[e.def(r,".factor|0"),e.def(r,".units|0")]}));case Gn:return u((function(t){var e=0;return"front"===t?e=Pe:"back"===t&&(e=qe),C.command(!!e,a,n.commandStr),e}),(function(t,n,e){return C.optional((function(){t.assert(n,e+'==="front"||'+e+'==="back"',"invalid cull.face")})),n.def(e,'==="front"?',Pe,":",qe)}));case $n:return u((function(t){return C.command("number"==typeof t&&t>=i.lineWidthDims[0]&&t<=i.lineWidthDims[1],"invalid line width, must be a positive number between "+i.lineWidthDims[0]+" and "+i.lineWidthDims[1],n.commandStr),t}),(function(t,n,e){return C.optional((function(){t.assert(n,"typeof "+e+'==="number"&&'+e+">="+i.lineWidthDims[0]+"&&"+e+"<="+i.lineWidthDims[1],"invalid line width")})),e}));case Hn:return u((function(t){return C.commandParameter(t,Ke,a,n.commandStr),Ke[t]}),(function(t,n,e){return C.optional((function(){t.assert(n,e+'==="cw"||'+e+'==="ccw"',"invalid frontFace, must be one of cw,ccw")})),n.def(e+'==="cw"?2304:'+Ge)}));case Pn:return u((function(t){return C.command(vt(t)&&4===t.length,"color.mask must be length 4 array",n.commandStr),t.map((function(t){return!!t}))}),(function(t,n,e){return C.optional((function(){t.assert(n,t.shared.isArrayLike+"("+e+")&&"+e+".length===4","invalid color.mask")})),B(4,(function(t){return"!!"+e+"["+t+"]"}))}));case Kn:return u((function(t){C.command("object"==typeof t&&t,a,n.commandStr);var e="value"in t?t.value:1,r=!!t.invert;return C.command("number"==typeof e&&e>=0&&e<=1,"sample.coverage.value must be a number between 0 and 1",n.commandStr),[e,r]}),(function(t,n,e){return C.optional((function(){t.assert(n,e+"&&typeof "+e+'==="object"',"invalid sample.coverage")})),[n.def('"value" in ',e,"?+",e,".value:1"),n.def("!!",e,".invert")]}))}})),o}(t,d),O=function(t,n,r){var i=t.static,o=t.dynamic;function a(t){if(t in i){var n=e.id(i[t]);C.optional((function(){c.shader(Ze[t],n,C.guessCommand())}));var r=ir((function(){return n}));return r.id=n,r}if(t in o){var a=o[t];return or(a,(function(n,e){var r=n.invoke(e,a),i=e.def(n.shared.strings,".id(",r,")");return C.optional((function(){e(n.shared.shader,".shader(",Ze[t],",",i,",",n.command,");")})),i}))}return null}var u,s=a(ce),f=a(le),l=null;return rr(s)&&rr(f)?(l=c.program(f.id,s.id,null,r),u=ir((function(t){return t.link(l)}))):u=new er(s&&s.thisDep||f&&f.thisDep,s&&s.contextDep||f&&f.contextDep,s&&s.propDep||f&&f.propDep,(function(t,n){var e,r=t.shared.shader;e=s?s.append(t,n):n.def(r,".",ce);var i=r+".program("+(f?f.append(t,n):n.def(r,".",le))+","+e;return C.optional((function(){i+=","+t.command})),n.def(i+")")})),{frag:s,vert:f,progVar:u,program:l}}(t,0,p);function k(t){var n=w[t];n&&(A[t]=n)}k(ue),k(T(ae));var _=Object.keys(A).length>0,F={framebuffer:g,draw:x,shader:O,state:A,dirty:_,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(F.profile=function(t){var n,e=t.static,r=t.dynamic;if(se in e){var i=!!e[se];(n=ir((function(){return i}))).enable=i}else if(se in r){var o=r[se];n=or(o,(function(t,n){return t.invoke(n,o)}))}return n}(t),F.uniforms=function(t,n){var e=t.static,r=t.dynamic,i={};return Object.keys(e).forEach((function(t){var r,o=e[t];if("number"==typeof o||"boolean"==typeof o)r=ir((function(){return o}));else if("function"==typeof o){var a=o._reglType;"texture2d"===a||"textureCube"===a?r=ir((function(t){return t.link(o)})):"framebuffer"===a||"framebufferCube"===a?(C.command(o.color.length>0,'missing color attachment for framebuffer sent to uniform "'+t+'"',n.commandStr),r=ir((function(t){return t.link(o.color[0])}))):C.commandRaise('invalid data for uniform "'+t+'"',n.commandStr)}else vt(o)?r=ir((function(n){return n.global.def("[",B(o.length,(function(e){return C.command("number"==typeof o[e]||"boolean"==typeof o[e],"invalid uniform "+t,n.commandStr),o[e]})),"]")})):C.commandRaise('invalid or missing data for uniform "'+t+'"',n.commandStr);r.value=o,i[t]=r})),Object.keys(r).forEach((function(t){var n=r[t];i[t]=or(n,(function(t,e){return t.invoke(e,n)}))})),i}(u,d),F.drawVAO=F.scopeVAO=x.vao,!F.drawVAO&&O.program&&!p&&r.angle_instanced_arrays&&x.static.elements){var M=!0,z=O.program.attributes.map((function(t){var e=n.static[t];return M=M&&!!e,e}));if(M&&z.length>0){var D=l.getVAO(l.createVAO({attributes:z,elements:x.static.elements}));F.drawVAO=new er(null,null,null,(function(t){return t.link(D)})),F.useVAO=!0}}return p?F.useVAO=!0:F.attributes=function(t,n){var r=t.static,i=t.dynamic,a={};return Object.keys(r).forEach((function(t){var i=r[t],u=e.id(t),s=new m;if(tr(i))s.state=1,s.buffer=o.getBuffer(o.create(i,Oe,!1,!0)),s.type=0;else{var f=o.getBuffer(i);if(f)s.state=1,s.buffer=f,s.type=0;else if(C.command("object"==typeof i&&i,"invalid data for attribute "+t,n.commandStr),"constant"in i){var l=i.constant;s.buffer="null",s.state=2,"number"==typeof l?s.x=l:(C.command(vt(l)&&l.length>0&&l.length<=4,"invalid constant for attribute "+t,n.commandStr),En.forEach((function(t,n){n<l.length&&(s[t]=l[n])})))}else{f=tr(i.buffer)?o.getBuffer(o.create(i.buffer,Oe,!1,!0)):o.getBuffer(i.buffer),C.command(!!f,'missing buffer for attribute "'+t+'"',n.commandStr);var c=0|i.offset;C.command(c>=0,'invalid offset for attribute "'+t+'"',n.commandStr);var d=0|i.stride;C.command(d>=0&&d<256,'invalid stride for attribute "'+t+'", must be integer betweeen [0, 255]',n.commandStr);var v=0|i.size;C.command(!("size"in i)||v>0&&v<=4,'invalid size for attribute "'+t+'", must be 1,2,3,4',n.commandStr);var h=!!i.normalized,p=0;"type"in i&&(C.commandParameter(i.type,Q,"invalid type for attribute "+t,n.commandStr),p=Q[i.type]);var b=0|i.divisor;C.optional((function(){"divisor"in i&&(C.command(0===b||y,'cannot specify divisor for attribute "'+t+'", instancing not supported',n.commandStr),C.command(b>=0,'invalid divisor for attribute "'+t+'"',n.commandStr));var e=n.commandStr,r=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach((function(n){C.command(r.indexOf(n)>=0,'unknown parameter "'+n+'" for attribute pointer "'+t+'" (valid parameters are '+r+")",e)}))})),s.buffer=f,s.state=1,s.size=v,s.normalized=h,s.type=p||f.dtype,s.offset=c,s.stride=d,s.divisor=b}}a[t]=ir((function(t){var n=t.attribCache;if(u in n)return n[u];var e={isStream:!1};return Object.keys(s).forEach((function(t){e[t]=s[t]})),s.buffer&&(e.buffer=t.link(s.buffer),e.type=e.type||e.buffer+".dtype"),n[u]=e,e}))})),Object.keys(i).forEach((function(t){var n=i[t];a[t]=or(n,(function(e,r){var i=e.invoke(r,n),o=e.shared,a=e.constants,u=o.isBufferArgs,s=o.buffer;C.optional((function(){e.assert(r,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+u+"("+i+")||"+s+".getBuffer("+i+")||"+s+".getBuffer("+i+".buffer)||"+u+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+o.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+t+'"')}));var f={isStream:r.def(!1)},l=new m;l.state=1,Object.keys(l).forEach((function(t){f[t]=r.def(""+l[t])}));var c=f.buffer,d=f.type;function v(t){r(f[t],"=",i,".",t,"|0;")}return r("if(",u,"(",i,")){",f.isStream,"=true;",c,"=",s,".createStream(",Oe,",",i,");",d,"=",c,".dtype;","}else{",c,"=",s,".getBuffer(",i,");","if(",c,"){",d,"=",c,".dtype;",'}else if("constant" in ',i,"){",f.state,"=",2,";","if(typeof "+i+'.constant === "number"){',f[En[0]],"=",i,".constant;",En.slice(1).map((function(t){return f[t]})).join("="),"=0;","}else{",En.map((function(t,n){return f[t]+"="+i+".constant.length>"+n+"?"+i+".constant["+n+"]:0;"})).join(""),"}}else{","if(",u,"(",i,".buffer)){",c,"=",s,".createStream(",Oe,",",i,".buffer);","}else{",c,"=",s,".getBuffer(",i,".buffer);","}",d,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",c,".dtype;",f.normalized,"=!!",i,".normalized;"),v("size"),v("offset"),v("stride"),v("divisor"),r("}}"),r.exit("if(",f.isStream,"){",s,".destroyStream(",c,");","}"),f}))})),a}(n,d),F.context=function(t){var n=t.static,e=t.dynamic,r={};return Object.keys(n).forEach((function(t){var e=n[t];r[t]=ir((function(t){return"number"==typeof e||"boolean"==typeof e?""+e:t.link(e)}))})),Object.keys(e).forEach((function(t){var n=e[t];r[t]=or(n,(function(t,e){return t.invoke(e,n)}))})),r}(f),F}function J(t,n,e){var r=t.shared.context,i=t.scope();Object.keys(e).forEach((function(o){n.save(r,"."+o);var a=e[o].append(t,n);Array.isArray(a)?i(r,".",o,"=[",a.join(),"];"):i(r,".",o,"=",a,";")})),n(i)}function N(t,n,e,r){var i,o=t.shared,a=o.gl,u=o.framebuffer;g&&(i=n.def(o.extensions,".webgl_draw_buffers"));var s,f=t.constants,l=f.drawBuffer,c=f.backBuffer;s=e?e.append(t,n):n.def(u,".next"),r||n("if(",s,"!==",u,".cur){"),n("if(",s,"){",a,".bindFramebuffer(",36160,",",s,".framebuffer);"),g&&n(i,".drawBuffersWEBGL(",l,"[",s,".colorAttachments.length]);"),n("}else{",a,".bindFramebuffer(",36160,",null);"),g&&n(i,".drawBuffersWEBGL(",c,");"),n("}",u,".cur=",s,";"),r||n("}")}function V(t,n,e){var r=t.shared,i=r.gl,o=t.current,a=t.next,u=r.current,s=r.next,f=t.cond(u,".dirty");j.forEach((function(n){var r,l,c=T(n);if(!(c in e.state))if(c in a){r=a[c],l=o[c];var d=B(x[c].length,(function(t){return f.def(r,"[",t,"]")}));f(t.cond(d.map((function(t,n){return t+"!=="+l+"["+n+"]"})).join("||")).then(i,".",k[c],"(",d,");",d.map((function(t,n){return l+"["+n+"]="+t})).join(";"),";"))}else{r=f.def(s,".",c);var v=t.cond(r,"!==",u,".",c);f(v),c in O?v(t.cond(r).then(i,".enable(",O[c],");").else(i,".disable(",O[c],");"),u,".",c,"=",r,";"):v(i,".",k[c],"(",r,");",u,".",c,"=",r,";")}})),0===Object.keys(e.state).length&&f(u,".dirty=false;"),n(f)}function W(t,n,e,r){var i=t.shared,o=t.current,a=i.current,u=i.gl;nr(Object.keys(e)).forEach((function(i){var s=e[i];if(!r||r(s)){var f=s.append(t,n);if(O[i]){var l=O[i];rr(s)?n(u,f?".enable(":".disable(",l,");"):n(t.cond(f).then(u,".enable(",l,");").else(u,".disable(",l,");")),n(a,".",i,"=",f,";")}else if(vt(f)){var c=o[i];n(u,".",k[i],"(",f,");",f.map((function(t,n){return c+"["+n+"]="+t})).join(";"),";")}else n(u,".",k[i],"(",f,");",a,".",i,"=",f,";")}}))}function I(t,n){y&&(t.instancing=n.def(t.shared.extensions,".angle_instanced_arrays"))}function L(t,n,e,r,i){var o,a,u,s=t.shared,f=t.stats,l=s.current,c=s.timer,d=e.profile;function v(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function p(t){t(o=n.def(),"=",v(),";"),"string"==typeof i?t(f,".count+=",i,";"):t(f,".count++;"),h&&(r?t(a=n.def(),"=",c,".getNumPendingQueries();"):t(c,".beginQuery(",f,");"))}function m(t){t(f,".cpuTime+=",v(),"-",o,";"),h&&(r?t(c,".pushScopeStats(",a,",",c,".getNumPendingQueries(),",f,");"):t(c,".endQuery();"))}function b(t){var e=n.def(l,".profile");n(l,".profile=",t,";"),n.exit(l,".profile=",e,";")}if(d){if(rr(d))return void(d.enable?(p(n),m(n.exit),b("true")):b("false"));b(u=d.append(t,n))}else u=n.def(l,".profile");var y=t.block();p(y),n("if(",u,"){",y,"}");var g=t.block();m(g),n.exit("if(",u,"){",g,"}")}function U(t,n,e,r,i){var o=t.shared;r.forEach((function(r){var a,u=r.name,s=e.attributes[u];if(s){if(!i(s))return;a=s.append(t,n)}else{if(!i(ar))return;var f=t.scopeAttrib(u);C.optional((function(){t.assert(n,f+".state","missing attribute "+u)})),a={},Object.keys(new m).forEach((function(t){a[t]=n.def(f,".",t)}))}!function(e,r,i){var a=o.gl,u=n.def(e,".location"),s=n.def(o.attributes,"[",u,"]"),f=i.state,l=i.buffer,c=[i.x,i.y,i.z,i.w],d=["buffer","normalized","offset","stride"];function v(){n("if(!",s,".buffer){",a,".enableVertexAttribArray(",u,");}");var e,o=i.type;if(e=i.size?n.def(i.size,"||",r):r,n("if(",s,".type!==",o,"||",s,".size!==",e,"||",d.map((function(t){return s+"."+t+"!=="+i[t]})).join("||"),"){",a,".bindBuffer(",Oe,",",l,".buffer);",a,".vertexAttribPointer(",[u,e,o,i.normalized,i.stride,i.offset],");",s,".type=",o,";",s,".size=",e,";",d.map((function(t){return s+"."+t+"="+i[t]+";"})).join(""),"}"),y){var f=i.divisor;n("if(",s,".divisor!==",f,"){",t.instancing,".vertexAttribDivisorANGLE(",[u,f],");",s,".divisor=",f,";}")}}function h(){n("if(",s,".buffer){",a,".disableVertexAttribArray(",u,");",s,".buffer=null;","}if(",En.map((function(t,n){return s+"."+t+"!=="+c[n]})).join("||"),"){",a,".vertexAttrib4f(",u,",",c,");",En.map((function(t,n){return s+"."+t+"="+c[n]+";"})).join(""),"}")}1===f?v():2===f?h():(n("if(",f,"===",1,"){"),v(),n("}else{"),h(),n("}"))}(t.link(r),function(t){switch(t){case _e:case De:case Re:return 2;case Fe:case Se:case Je:return 3;case Me:case Ee:case Ne:return 4;default:return 1}}(r.info.type),a)}))}function P(t,n,r,i,o,a){for(var u,s=t.shared,f=s.gl,l={},c=0;c<i.length;++c){var d=i[c],v=d.name,h=d.info.type,p=d.info.size,m=r.uniforms[v];if(p>1){if(!m)continue;var b=v.replace("[0]","");if(l[b])continue;l[b]=1}var y,g=t.link(d)+".location";if(m){if(!o(m))continue;if(rr(m)){var w=m.value;if(C.command(null!=w,'missing uniform "'+v+'"',t.commandStr),h===Le||h===Ue){C.command("function"==typeof w&&(h===Le&&("texture2d"===w._reglType||"framebuffer"===w._reglType)||h===Ue&&("textureCube"===w._reglType||"framebufferCube"===w._reglType)),"invalid texture for uniform "+v,t.commandStr);var x=t.link(w._texture||w.color[0]._texture);n(f,".uniform1i(",g,",",x+".bind());"),n.exit(x,".unbind();")}else if(h===Ve||h===We||h===Ie){C.optional((function(){C.command(vt(w),"invalid matrix for uniform "+v,t.commandStr),C.command(h===Ve&&4===w.length||h===We&&9===w.length||h===Ie&&16===w.length,"invalid length for matrix uniform "+v,t.commandStr)}));var A=t.global.def("new Float32Array(["+Array.prototype.slice.call(w)+"])"),j=2;h===We?j=3:h===Ie&&(j=4),n(f,".uniformMatrix",j,"fv(",g,",false,",A,");")}else{switch(h){case Te:1===p?C.commandType(w,"number","uniform "+v,t.commandStr):C.command(vt(w)&&w.length===p,"uniform "+v,t.commandStr),u="1f";break;case _e:C.command(vt(w)&&w.length&&w.length%2==0&&w.length<=2*p,"uniform "+v,t.commandStr),u="2f";break;case Fe:C.command(vt(w)&&w.length&&w.length%3==0&&w.length<=3*p,"uniform "+v,t.commandStr),u="3f";break;case Me:C.command(vt(w)&&w.length&&w.length%4==0&&w.length<=4*p,"uniform "+v,t.commandStr),u="4f";break;case Be:1===p?C.commandType(w,"boolean","uniform "+v,t.commandStr):C.command(vt(w)&&w.length===p,"uniform "+v,t.commandStr),u="1i";break;case ze:1===p?C.commandType(w,"number","uniform "+v,t.commandStr):C.command(vt(w)&&w.length===p,"uniform "+v,t.commandStr),u="1i";break;case Re:case De:C.command(vt(w)&&w.length&&w.length%2==0&&w.length<=2*p,"uniform "+v,t.commandStr),u="2i";break;case Je:case Se:C.command(vt(w)&&w.length&&w.length%3==0&&w.length<=3*p,"uniform "+v,t.commandStr),u="3i";break;case Ne:case Ee:C.command(vt(w)&&w.length&&w.length%4==0&&w.length<=4*p,"uniform "+v,t.commandStr),u="4i"}p>1?(u+="v",w=t.global.def("["+Array.prototype.slice.call(w)+"]")):w=vt(w)?Array.prototype.slice.call(w):w,n(f,".uniform",u,"(",g,",",w,");")}continue}y=m.append(t,n)}else{if(!o(ar))continue;y=n.def(s.uniforms,"[",e.id(v),"]")}h===Le?(C(!Array.isArray(y),"must specify a scalar prop for textures"),n("if(",y,"&&",y,'._reglType==="framebuffer"){',y,"=",y,".color[0];","}")):h===Ue&&(C(!Array.isArray(y),"must specify a scalar prop for cube maps"),n("if(",y,"&&",y,'._reglType==="framebufferCube"){',y,"=",y,".color[0];","}")),C.optional((function(){function e(e,r){t.assert(n,e,'bad data or missing for uniform "'+v+'". '+r)}function r(t,n){1===n&&C(!Array.isArray(y),"must not specify an array type for uniform"),e("Array.isArray("+y+") && typeof "+y+'[0]===" '+t+'" || typeof '+y+'==="'+t+'"',"invalid type, expected "+t)}function i(t,n,r){Array.isArray(y)?C(y.length&&y.length%t==0&&y.length<=t*r,"must have length of "+(1===r?"":"n * ")+t):e(s.isArrayLike+"("+y+")&&"+y+".length && "+y+".length % "+t+" === 0 && "+y+".length<="+t*r,"invalid vector, should have length of "+(1===r?"":"n * ")+t)}function o(t){C(!Array.isArray(y),"must not specify a value type"),e("typeof "+y+'==="function"&&'+y+'._reglType==="texture'+(3553===t?"2d":"Cube")+'"',"invalid texture type")}switch(h){case ze:r("number",p);break;case De:i(2,0,p);break;case Se:i(3,0,p);break;case Ee:i(4,0,p);break;case Te:r("number",p);break;case _e:i(2,0,p);break;case Fe:i(3,0,p);break;case Me:i(4,0,p);break;case Be:r("boolean",p);break;case Re:i(2,0,p);break;case Je:i(3,0,p);break;case Ne:case Ve:i(4,0,p);break;case We:i(9,0,p);break;case Ie:i(16,0,p);break;case Le:o(3553);break;case Ue:o(34067)}}));var O=1;switch(h){case Le:case Ue:var k=n.def(y,"._texture");n(f,".uniform1i(",g,",",k,".bind());"),n.exit(k,".unbind();");continue;case ze:case Be:u="1i";break;case De:case Re:u="2i",O=2;break;case Se:case Je:u="3i",O=3;break;case Ee:case Ne:u="4i",O=4;break;case Te:u="1f";break;case _e:u="2f",O=2;break;case Fe:u="3f",O=3;break;case Me:u="4f",O=4;break;case Ve:u="Matrix2fv";break;case We:u="Matrix3fv";break;case Ie:u="Matrix4fv"}if(-1===u.indexOf("Matrix")&&p>1&&(u+="v",O=1),"M"===u.charAt(0)){n(f,".uniform",u,"(",g,",");var T=Math.pow(h-Ve+2,2),_=t.global.def("new Float32Array(",T,")");Array.isArray(y)?n("false,(",B(T,(function(t){return _+"["+t+"]="+y[t]})),",",_,")"):n("false,(Array.isArray(",y,")||",y," instanceof Float32Array)?",y,":(",B(T,(function(t){return _+"["+t+"]="+y+"["+t+"]"})),",",_,")"),n(");")}else if(O>1){for(var F=[],M=[],z=0;z<O;++z)Array.isArray(y)?M.push(y[z]):M.push(n.def(y+"["+z+"]")),a&&F.push(n.def());a&&n("if(!",t.batchId,"||",F.map((function(t,n){return t+"!=="+M[n]})).join("||"),"){",F.map((function(t,n){return t+"="+M[n]+";"})).join("")),n(f,".uniform",u,"(",g,",",M.join(","),");"),a&&n("}")}else{if(C(!Array.isArray(y),"uniform value must not be an array"),a){var D=n.def();n("if(!",t.batchId,"||",D,"!==",y,"){",D,"=",y,";")}n(f,".uniform",u,"(",g,",",y,");"),a&&n("}")}}}function q(t,n,e,r){var i=t.shared,o=i.gl,a=i.draw,u=r.draw;var s=function(){var s,f=u.elements,l=n;return f?((f.contextDep&&r.contextDynamic||f.propDep)&&(l=e),s=f.append(t,l),u.elementsActive&&l("if("+s+")"+o+".bindBuffer("+"34963,"+s+".buffer.buffer);")):(s=l.def(),l(s,"=",a,".",de,";","if(",s,"){",o,".bindBuffer(",ke,",",s,".buffer.buffer);}","else if(",i.vao,".currentVAO){",s,"=",t.shared.elements+".getElements("+i.vao,".currentVAO.elements);",w?"":"if("+s+")"+o+".bindBuffer("+"34963,"+s+".buffer.buffer);","}")),s}();function f(i){var o=u[i];return o?o.append(t,o.contextDep&&r.contextDynamic||o.propDep?e:n):n.def(a,".",i)}var l,c,d=f(ve),v=f(pe),h=function(){var i,o=u.count,s=n;return o?((o.contextDep&&r.contextDynamic||o.propDep)&&(s=e),i=o.append(t,s),C.optional((function(){o.MISSING&&t.assert(n,"false","missing vertex count"),o.DYNAMIC&&t.assert(s,i+">=0","missing vertex count")}))):(i=s.def(a,".",he),C.optional((function(){t.assert(s,i+">=0","missing vertex count")}))),i}();if("number"==typeof h){if(0===h)return}else e("if(",h,"){"),e.exit("}");y&&(l=f(me),c=t.instancing);var p=s+".type",m=u.elements&&rr(u.elements)&&!u.vaoActive;function b(){function t(){e(c,".drawElementsInstancedANGLE(",[d,h,p,v+"<<(("+p+"-5121)>>1)",l],");")}function n(){e(c,".drawArraysInstancedANGLE(",[d,v,h,l],");")}s&&"null"!==s?m?t():(e("if(",s,"){"),t(),e("}else{"),n(),e("}")):n()}function g(){function t(){e(o+".drawElements("+[d,h,p,v+"<<(("+p+"-5121)>>1)"]+");")}function n(){e(o+".drawArrays("+[d,v,h]+");")}s&&"null"!==s?m?t():(e("if(",s,"){"),t(),e("}else{"),n(),e("}")):n()}y&&("number"!=typeof l||l>=0)?"string"==typeof l?(e("if(",l,">0){"),b(),e("}else if(",l,"<0){"),g(),e("}")):b():g()}function G(t,n,e,r,i){var o=E(),a=o.proc("body",i);return C.optional((function(){o.commandStr=n.commandStr,o.command=o.link(n.commandStr)})),y&&(o.instancing=a.def(o.shared.extensions,".angle_instanced_arrays")),t(o,a,e,r),o.compile().body}function H(t,n,e,r){I(t,n),e.useVAO?e.drawVAO?n(t.shared.vao,".setVAO(",e.drawVAO.append(t,n),");"):n(t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"):(n(t.shared.vao,".setVAO(null);"),U(t,n,e,r.attributes,(function(){return!0}))),P(t,n,e,r.uniforms,(function(){return!0}),!1),q(t,n,n,e)}function $(t,n,e,r){function i(){return!0}t.batchId="a1",I(t,n),U(t,n,e,r.attributes,i),P(t,n,e,r.uniforms,i,!1),q(t,n,n,e)}function X(t,n,e,r){I(t,n);var i=e.contextDep,o=n.def(),a=n.def();t.shared.props=a,t.batchId=o;var u=t.scope(),s=t.scope();function f(t){return t.contextDep&&i||t.propDep}function l(t){return!f(t)}if(n(u.entry,"for(",o,"=0;",o,"<","a1",";++",o,"){",a,"=","a0","[",o,"];",s,"}",u.exit),e.needsContext&&J(t,s,e.context),e.needsFramebuffer&&N(t,s,e.framebuffer),W(t,s,e.state,f),e.profile&&f(e.profile)&&L(t,s,e,!1,!0),r)e.useVAO?e.drawVAO?f(e.drawVAO)?s(t.shared.vao,".setVAO(",e.drawVAO.append(t,s),");"):u(t.shared.vao,".setVAO(",e.drawVAO.append(t,u),");"):u(t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"):(u(t.shared.vao,".setVAO(null);"),U(t,u,e,r.attributes,l),U(t,s,e,r.attributes,f)),P(t,u,e,r.uniforms,l,!1),P(t,s,e,r.uniforms,f,!0),q(t,u,s,e);else{var c=t.global.def("{}"),d=e.shader.progVar.append(t,s),v=s.def(d,".id"),h=s.def(c,"[",v,"]");s(t.shared.gl,".useProgram(",d,".program);","if(!",h,"){",h,"=",c,"[",v,"]=",t.link((function(n){return G($,t,e,n,2)})),"(",d,");}",h,".call(this,a0[",o,"],",o,");")}}function Y(t,n,e){var r=n.static[e];if(r&&function(t){if("object"==typeof t&&!vt(t)){for(var n=Object.keys(t),e=0;e<n.length;++e)if(F.isDynamic(t[n[e]]))return!0;return!1}}(r)){var i=t.global,o=Object.keys(r),a=!1,u=!1,s=!1,f=t.global.def("{}");o.forEach((function(n){var e=r[n];if(F.isDynamic(e)){"function"==typeof e&&(e=r[n]=F.unbox(e));var o=or(e,null);a=a||o.thisDep,s=s||o.propDep,u=u||o.contextDep}else{switch(i(f,".",n,"="),typeof e){case"number":i(e);break;case"string":i('"',e,'"');break;case"object":Array.isArray(e)&&i("[",e.join(),"]");break;default:i(t.link(e))}i(";")}})),n.dynamic[e]=new F.DynamicVariable(4,{thisDep:a,contextDep:u,propDep:s,ref:f,append:function(t,n){o.forEach((function(e){var i=r[e];if(F.isDynamic(i)){var o=t.invoke(n,i);n(f,".",e,"=",o,";")}}))}}),delete n.static[e]}}return{next:A,current:x,procs:function(){var t=E(),n=t.proc("poll"),e=t.proc("refresh"),o=t.block();n(o),e(o);var a,u=t.shared,s=u.gl,f=u.next,l=u.current;o(l,".dirty=false;"),N(t,n),N(t,e,null,!0),y&&(a=t.link(y)),r.oes_vertex_array_object&&e(t.link(r.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var c=0;c<i.maxAttributes;++c){var d=e.def(u.attributes,"[",c,"]"),v=t.cond(d,".buffer");v.then(s,".enableVertexAttribArray(",c,");",s,".bindBuffer(",Oe,",",d,".buffer.buffer);",s,".vertexAttribPointer(",c,",",d,".size,",d,".type,",d,".normalized,",d,".stride,",d,".offset);").else(s,".disableVertexAttribArray(",c,");",s,".vertexAttrib4f(",c,",",d,".x,",d,".y,",d,".z,",d,".w);",d,".buffer=null;"),e(v),y&&e(a,".vertexAttribDivisorANGLE(",c,",",d,".divisor);")}return e(t.shared.vao,".currentVAO=null;",t.shared.vao,".setVAO(",t.shared.vao,".targetVAO);"),Object.keys(O).forEach((function(r){var i=O[r],a=o.def(f,".",r),u=t.block();u("if(",a,"){",s,".enable(",i,")}else{",s,".disable(",i,")}",l,".",r,"=",a,";"),e(u),n("if(",a,"!==",l,".",r,"){",u,"}")})),Object.keys(k).forEach((function(r){var i,a,u=k[r],c=x[r],d=t.block();if(d(s,".",u,"("),vt(c)){var v=c.length;i=t.global.def(f,".",r),a=t.global.def(l,".",r),d(B(v,(function(t){return i+"["+t+"]"})),");",B(v,(function(t){return a+"["+t+"]="+i+"["+t+"];"})).join("")),n("if(",B(v,(function(t){return i+"["+t+"]!=="+a+"["+t+"]"})).join("||"),"){",d,"}")}else i=o.def(f,".",r),a=o.def(l,".",r),d(i,");",l,".",r,"=",i,";"),n("if(",i,"!==",a,"){",d,"}");e(d)})),t.compile()}(),compile:function(t,r,i,o,a){var u=E();u.stats=u.link(a),Object.keys(r.static).forEach((function(t){Y(u,r,t)})),je.forEach((function(n){Y(u,t,n)}));var s=R(t,r,i,o,u);return function(t,n){var e=t.proc("draw",1);I(t,e),J(t,e,n.context),N(t,e,n.framebuffer),V(t,e,n),W(t,e,n.state),L(t,e,n,!1,!0);var r=n.shader.progVar.append(t,e);if(e(t.shared.gl,".useProgram(",r,".program);"),n.shader.program)H(t,e,n,n.shader.program);else{e(t.shared.vao,".setVAO(null);");var i=t.global.def("{}"),o=e.def(r,".id"),a=e.def(i,"[",o,"]");e(t.cond(a).then(a,".call(this,a0);").else(a,"=",i,"[",o,"]=",t.link((function(e){return G(H,t,n,e,1)})),"(",r,");",a,".call(this,a0);"))}Object.keys(n.state).length>0&&e(t.shared.current,".dirty=true;"),t.shared.vao&&e(t.shared.vao,".setVAO(null);")}(u,s),function(t,n){var r=t.proc("scope",3);t.batchId="a2";var i=t.shared,o=i.current;function a(e){var o=n.shader[e];o&&r.set(i.shader,"."+e,o.append(t,r))}J(t,r,n.context),n.framebuffer&&n.framebuffer.append(t,r),nr(Object.keys(n.state)).forEach((function(e){var o=n.state[e].append(t,r);vt(o)?o.forEach((function(n,i){r.set(t.next[e],"["+i+"]",n)})):r.set(i.next,"."+e,o)})),L(t,r,n,!0,!0),[de,pe,he,me,ve].forEach((function(e){var o=n.draw[e];o&&r.set(i.draw,"."+e,""+o.append(t,r))})),Object.keys(n.uniforms).forEach((function(o){var a=n.uniforms[o].append(t,r);Array.isArray(a)&&(a="["+a.join()+"]"),r.set(i.uniforms,"["+e.id(o)+"]",a)})),Object.keys(n.attributes).forEach((function(e){var i=n.attributes[e].append(t,r),o=t.scopeAttrib(e);Object.keys(new m).forEach((function(t){r.set(o,"."+t,i[t])}))})),n.scopeVAO&&r.set(i.vao,".targetVAO",n.scopeVAO.append(t,r)),a(le),a(ce),Object.keys(n.state).length>0&&(r(o,".dirty=true;"),r.exit(o,".dirty=true;")),r("a1(",t.shared.context,",a0,",t.batchId,");")}(u,s),function(t,n){var e=t.proc("batch",2);t.batchId="0",I(t,e);var r=!1,i=!0;Object.keys(n.context).forEach((function(t){r=r||n.context[t].propDep})),r||(J(t,e,n.context),i=!1);var o=n.framebuffer,a=!1;function u(t){return t.contextDep&&r||t.propDep}o?(o.propDep?r=a=!0:o.contextDep&&r&&(a=!0),a||N(t,e,o)):N(t,e,null),n.state.viewport&&n.state.viewport.propDep&&(r=!0),V(t,e,n),W(t,e,n.state,(function(t){return!u(t)})),n.profile&&u(n.profile)||L(t,e,n,!1,"a1"),n.contextDep=r,n.needsContext=i,n.needsFramebuffer=a;var s=n.shader.progVar;if(s.contextDep&&r||s.propDep)X(t,e,n,null);else{var f=s.append(t,e);if(e(t.shared.gl,".useProgram(",f,".program);"),n.shader.program)X(t,e,n,n.shader.program);else{e(t.shared.vao,".setVAO(null);");var l=t.global.def("{}"),c=e.def(f,".id"),d=e.def(l,"[",c,"]");e(t.cond(d).then(d,".call(this,a0,a1);").else(d,"=",l,"[",c,"]=",t.link((function(e){return G(X,t,n,e,2)})),"(",f,");",d,".call(this,a0,a1);"))}}Object.keys(n.state).length>0&&e(t.shared.current,".dirty=true;"),t.shared.vao&&e(t.shared.vao,".setVAO(null);")}(u,s),n(u.compile(),{destroy:function(){s.shader.program.destroy()}})}}}var sr=function(t,n){if(!n.ext_disjoint_timer_query)return null;var e=[];function r(t){e.push(t)}var i=[];function o(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var a=[];function u(t){a.push(t)}var s=[];function f(t,n,e){var r=a.pop()||new o;r.startQueryIndex=t,r.endQueryIndex=n,r.sum=0,r.stats=e,s.push(r)}var l=[],c=[];return{beginQuery:function(t){var r=e.pop()||n.ext_disjoint_timer_query.createQueryEXT();n.ext_disjoint_timer_query.beginQueryEXT(35007,r),i.push(r),f(i.length-1,i.length,t)},endQuery:function(){n.ext_disjoint_timer_query.endQueryEXT(35007)},pushScopeStats:f,update:function(){var t,e,o=i.length;if(0!==o){c.length=Math.max(c.length,o+1),l.length=Math.max(l.length,o+1),l[0]=0,c[0]=0;var a=0;for(t=0,e=0;e<i.length;++e){var f=i[e];n.ext_disjoint_timer_query.getQueryObjectEXT(f,34919)?(a+=n.ext_disjoint_timer_query.getQueryObjectEXT(f,34918),r(f)):i[t++]=f,l[e+1]=a,c[e+1]=t}for(i.length=t,t=0,e=0;e<s.length;++e){var d=s[e],v=d.startQueryIndex,h=d.endQueryIndex;d.sum+=l[h]-l[v];var p=c[v],m=c[h];m===p?(d.stats.gpuTime+=d.sum/1e6,u(d)):(d.startQueryIndex=p,d.endQueryIndex=m,s[t++]=d)}s.length=t}},getNumPendingQueries:function(){return i.length},clear:function(){e.push.apply(e,i);for(var t=0;t<e.length;t++)n.ext_disjoint_timer_query.deleteQueryEXT(e[t]);i.length=0,e.length=0},restore:function(){i.length=0,e.length=0}}},fr="webglcontextlost",lr="webglcontextrestored";function cr(t,n){for(var e=0;e<t.length;++e)if(t[e]===n)return e;return-1}return function(e){var r=E(e);if(!r)return null;var i=r.gl,o=i.getContextAttributes(),a=i.isContextLost(),u=function(t,n){var e={};function r(n){C.type(n,"string","extension name must be string");var r,i=n.toLowerCase();try{r=e[i]=t.getExtension(i)}catch(t){}return!!r}for(var i=0;i<n.extensions.length;++i){var o=n.extensions[i];if(!r(o))return n.onDestroy(),n.onDone('"'+o+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return n.optionalExtensions.forEach(r),{extensions:e,restore:function(){Object.keys(e).forEach((function(t){if(e[t]&&!r(t))throw new Error("(regl): error restoring extension "+t)}))}}}(i,r);if(!u)return null;var s,f,l=(s={"":0},f=[""],{id:function(t){var n=s[t];return n||(n=s[t]=f.length,f.push(t),n)},str:function(t){return f[t]}}),c={vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},d=u.extensions,v=sr(0,d),h=z(),p=i.drawingBufferWidth,m=i.drawingBufferHeight,b={tick:0,time:0,viewportWidth:p,viewportHeight:m,framebufferWidth:p,framebufferHeight:m,drawingBufferWidth:p,drawingBufferHeight:m,pixelRatio:r.pixelRatio},y={elements:null,primitive:4,count:-1,offset:0,instances:-1},g=function(t,n){var e=1;n.ext_texture_filter_anisotropic&&(e=t.getParameter(34047));var r=1,i=1;n.webgl_draw_buffers&&(r=t.getParameter(34852),i=t.getParameter(36063));var o=!!n.oes_texture_float;if(o){var a=t.createTexture();t.bindTexture(V,a),t.texImage2D(V,0,W,1,1,0,W,I,null);var u=t.createFramebuffer();if(t.bindFramebuffer(L,u),t.framebufferTexture2D(L,36064,V,a,0),t.bindTexture(V,null),36053!==t.checkFramebufferStatus(L))o=!1;else{t.viewport(0,0,1,1),t.clearColor(1,0,0,1),t.clear(16384);var s=N.allocType(I,4);t.readPixels(0,0,1,1,W,I,s),t.getError()?o=!1:(t.deleteFramebuffer(u),t.deleteTexture(a),o=1===s[0]),N.freeType(s)}}var f=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var l=t.createTexture(),c=N.allocType(5121,36);t.activeTexture(33984),t.bindTexture(34067,l),t.texImage2D(34069,0,W,3,3,0,W,5121,c),N.freeType(c),t.bindTexture(34067,null),t.deleteTexture(l),f=!t.getError()}return{colorBits:[t.getParameter(3410),t.getParameter(3411),t.getParameter(3412),t.getParameter(3413)],depthBits:t.getParameter(3414),stencilBits:t.getParameter(3415),subpixelBits:t.getParameter(3408),extensions:Object.keys(n).filter((function(t){return!!n[t]})),maxAnisotropic:e,maxDrawbuffers:r,maxColorAttachments:i,pointSizeDims:t.getParameter(33901),lineWidthDims:t.getParameter(33902),maxViewportDims:t.getParameter(3386),maxCombinedTextureUnits:t.getParameter(35661),maxCubeMapSize:t.getParameter(34076),maxRenderbufferSize:t.getParameter(34024),maxTextureUnits:t.getParameter(34930),maxTextureSize:t.getParameter(3379),maxAttributes:t.getParameter(34921),maxVertexUniforms:t.getParameter(36347),maxVertexTextureUnits:t.getParameter(35660),maxVaryingVectors:t.getParameter(36348),maxFragmentUniforms:t.getParameter(36349),glsl:t.getParameter(35724),renderer:t.getParameter(7937),vendor:t.getParameter(7936),version:t.getParameter(7938),readFloat:o,npotTextureCube:f}}(i,d),w=function(n,e,r,i){var o=0,a={};function u(t){this.id=o++,this.buffer=n.createBuffer(),this.type=t,this.usage=35044,this.byteLength=0,this.dimension=1,this.dtype=K,this.persistentData=null,r.profile&&(this.stats={size:0})}u.prototype.bind=function(){n.bindBuffer(this.type,this.buffer)},u.prototype.destroy=function(){c(this)};var s=[];function f(t,e,r){t.byteLength=e.byteLength,n.bufferData(t.type,e,r)}function l(n,e,r,i,o,a){var u,s;if(n.usage=r,Array.isArray(e)){if(n.dtype=i||tt,e.length>0)if(Array.isArray(e[0])){u=Z(e);for(var l=1,c=1;c<u.length;++c)l*=u[c];n.dimension=l,f(n,s=Y(e,u,n.dtype),r),a?n.persistentData=s:N.freeType(s)}else if("number"==typeof e[0]){n.dimension=o;var d=N.allocType(n.dtype,e.length);rt(d,e),f(n,d,r),a?n.persistentData=d:N.freeType(d)}else t(e[0])?(n.dimension=e[0].length,n.dtype=i||et(e[0])||tt,f(n,s=Y(e,[e.length,e[0].length],n.dtype),r),a?n.persistentData=s:N.freeType(s)):C.raise("invalid buffer data")}else if(t(e))n.dtype=i||et(e),n.dimension=o,f(n,e,r),a&&(n.persistentData=new Uint8Array(new Uint8Array(e.buffer)));else if(U(e)){var v=e.stride,h=e.offset,p=0,m=0,b=0,y=0;1===(u=e.shape).length?(p=u[0],m=1,b=v[0],y=0):2===u.length?(p=u[0],m=u[1],b=v[0],y=v[1]):C.raise("invalid shape"),n.dtype=i||et(e.data)||tt,n.dimension=m;var g=N.allocType(n.dtype,p*m);it(g,e.data,p,m,b,y,h),f(n,g,r),a?n.persistentData=g:N.freeType(g)}else e instanceof ArrayBuffer?(n.dtype=K,n.dimension=o,f(n,e,r),a&&(n.persistentData=new Uint8Array(new Uint8Array(e)))):C.raise("invalid buffer data")}function c(t){e.bufferCount--,i(t);var r=t.buffer;C(r,"buffer must not be deleted already"),n.deleteBuffer(r),t.buffer=null,delete a[t.id]}return r.profile&&(e.getTotalBufferSize=function(){var t=0;return Object.keys(a).forEach((function(n){t+=a[n].stats.size})),t}),{create:function(i,o,s,f){e.bufferCount++;var d=new u(o);function v(e){var i=35044,o=null,a=0,u=0,s=1;return Array.isArray(e)||t(e)||U(e)||e instanceof ArrayBuffer?o=e:"number"==typeof e?a=0|e:e&&(C.type(e,"object","buffer arguments must be an object, a number or an array"),"data"in e&&(C(null===o||Array.isArray(o)||t(o)||U(o),"invalid data for buffer"),o=e.data),"usage"in e&&(C.parameter(e.usage,X,"invalid buffer usage"),i=X[e.usage]),"type"in e&&(C.parameter(e.type,Q,"invalid buffer type"),u=Q[e.type]),"dimension"in e&&(C.type(e.dimension,"number","invalid dimension"),s=0|e.dimension),"length"in e&&(C.nni(a,"buffer length must be a nonnegative integer"),a=0|e.length)),d.bind(),o?l(d,o,i,u,s,f):(a&&n.bufferData(d.type,a,i),d.dtype=u||K,d.usage=i,d.dimension=s,d.byteLength=a),r.profile&&(d.stats.size=d.byteLength*nt[d.dtype]),v}function h(t,e){C(e+t.byteLength<=d.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+t.byteLength+" starting from offset "+e+" to a buffer of size "+d.byteLength),n.bufferSubData(d.type,e,t)}return a[d.id]=d,s||v(i),v._reglType="buffer",v._buffer=d,v.subdata=function(n,e){var r,i=0|(e||0);if(d.bind(),t(n)||n instanceof ArrayBuffer)h(n,i);else if(Array.isArray(n)){if(n.length>0)if("number"==typeof n[0]){var o=N.allocType(d.dtype,n.length);rt(o,n),h(o,i),N.freeType(o)}else if(Array.isArray(n[0])||t(n[0])){r=Z(n);var a=Y(n,r,d.dtype);h(a,i),N.freeType(a)}else C.raise("invalid buffer data")}else if(U(n)){var u=n.stride,s=0,f=0,l=0,c=0;1===(r=n.shape).length?(s=r[0],f=1,l=u[0],c=0):2===r.length?(s=r[0],f=r[1],l=u[0],c=u[1]):C.raise("invalid shape");var p=Array.isArray(n.data)?d.dtype:et(n.data),m=N.allocType(p,s*f);it(m,n.data,s,f,l,c,n.offset),h(m,i),N.freeType(m)}else C.raise("invalid data for buffer subdata");return v},r.profile&&(v.stats=d.stats),v.destroy=function(){c(d)},v},createStream:function(t,n){var e=s.pop();return e||(e=new u(t)),e.bind(),l(e,n,35040,0,1,!1),e},destroyStream:function(t){s.push(t)},clear:function(){P(a).forEach(c),s.forEach(c)},getBuffer:function(t){return t&&t._buffer instanceof u?t._buffer:null},restore:function(){P(a).forEach((function(t){t.buffer=n.createBuffer(),n.bindBuffer(t.type,t.buffer),n.bufferData(t.type,t.persistentData||t.byteLength,t.usage)}))},_initBuffer:l}}(i,c,r,(function(t){return A.destroyBuffer(t)})),x=function(n,e,r,i){var o={},a=0,u={uint8:at,uint16:ut};function s(t){this.id=a++,o[this.id]=this,this.buffer=t,this.primType=4,this.vertCount=0,this.type=0}e.oes_element_index_uint&&(u.uint32=st),s.prototype.bind=function(){this.buffer.bind()};var f=[];function l(i,o,a,u,s,f,l){var c;if(i.buffer.bind(),o){var d=l;l||t(o)&&(!U(o)||t(o.data))||(d=e.oes_element_index_uint?st:ut),r._initBuffer(i.buffer,o,a,d,3)}else n.bufferData(ft,f,a),i.buffer.dtype=c||at,i.buffer.usage=a,i.buffer.dimension=3,i.buffer.byteLength=f;if(c=l,!l){switch(i.buffer.dtype){case at:case 5120:c=at;break;case ut:case 5122:c=ut;break;case st:case 5124:c=st;break;default:C.raise("unsupported type for element array")}i.buffer.dtype=c}i.type=c,C(c!==st||!!e.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var v=s;v<0&&(v=i.buffer.byteLength,c===ut?v>>=1:c===st&&(v>>=2)),i.vertCount=v;var h=u;if(u<0){h=4;var p=i.buffer.dimension;1===p&&(h=0),2===p&&(h=1),3===p&&(h=4)}i.primType=h}function c(t){i.elementsCount--,C(null!==t.buffer,"must not double destroy elements"),delete o[t.id],t.buffer.destroy(),t.buffer=null}return{create:function(n){var e=r.create(null,ft,!0),o=new s(e._buffer);function a(n){if(n)if("number"==typeof n)e(n),o.primType=4,o.vertCount=0|n,o.type=at;else{var r=null,i=35044,s=-1,f=-1,c=0,d=0;Array.isArray(n)||t(n)||U(n)?r=n:(C.type(n,"object","invalid arguments for elements"),"data"in n&&(r=n.data,C(Array.isArray(r)||t(r)||U(r),"invalid data for element buffer")),"usage"in n&&(C.parameter(n.usage,X,"invalid element buffer usage"),i=X[n.usage]),"primitive"in n&&(C.parameter(n.primitive,ot,"invalid element buffer primitive"),s=ot[n.primitive]),"count"in n&&(C("number"==typeof n.count&&n.count>=0,"invalid vertex count for elements"),f=0|n.count),"type"in n&&(C.parameter(n.type,u,"invalid buffer type"),d=u[n.type]),"length"in n?c=0|n.length:(c=f,d===ut||5122===d?c*=2:d!==st&&5124!==d||(c*=4))),l(o,r,i,s,f,c,d)}else e(),o.primType=4,o.vertCount=0,o.type=at;return a}return i.elementsCount++,a(n),a._reglType="elements",a._elements=o,a.subdata=function(t,n){return e.subdata(t,n),a},a.destroy=function(){c(o)},a},createStream:function(t){var n=f.pop();return n||(n=new s(r.create(null,ft,!0,!1)._buffer)),l(n,t,35040,-1,-1,0,0),n},destroyStream:function(t){f.push(t)},getElements:function(t){return"function"==typeof t&&t._elements instanceof s?t._elements:null},clear:function(){P(o).forEach(c)}}}(i,d,w,c),A=function(n,e,r,i,o,a,u){for(var s=r.maxAttributes,f=new Array(s),l=0;l<s;++l)f[l]=new _n;var c=0,d={},v={Record:_n,scope:{},state:f,currentVAO:null,targetVAO:null,restore:h()?function(){h()&&P(d).forEach((function(t){t.refresh()}))}:function(){},createVAO:function(n){var r=new m;function u(n){var i;if(Array.isArray(n))i=n,r.elements&&r.ownsElements&&r.elements.destroy(),r.elements=null,r.ownsElements=!1,r.offset=0,r.count=0,r.instances=-1,r.primitive=4;else{if(C("object"==typeof n,"invalid arguments for create vao"),C("attributes"in n,"must specify attributes for vao"),n.elements){var f=n.elements;r.ownsElements?"function"==typeof f&&"elements"===f._reglType?(r.elements.destroy(),r.ownsElements=!1):(r.elements(f),r.ownsElements=!1):a.getElements(n.elements)?(r.elements=n.elements,r.ownsElements=!1):(r.elements=a.create(n.elements),r.ownsElements=!0)}else r.elements=null,r.ownsElements=!1;i=n.attributes,r.offset=0,r.count=-1,r.instances=-1,r.primitive=4,r.elements&&(r.count=r.elements._elements.vertCount,r.primitive=r.elements._elements.primType),"offset"in n&&(r.offset=0|n.offset),"count"in n&&(r.count=0|n.count),"instances"in n&&(r.instances=0|n.instances),"primitive"in n&&(C(n.primitive in ot,"bad primitive type: "+n.primitive),r.primitive=ot[n.primitive]),C.optional((()=>{for(var t=Object.keys(n),e=0;e<t.length;++e)C(Tn.indexOf(t[e])>=0,'invalid option for vao: "'+t[e]+'" valid options are '+Tn)})),C(Array.isArray(i),"attributes must be an array")}C(i.length<s,"too many attributes"),C(i.length>0,"must specify at least one attribute");var l={},c=r.attributes;c.length=i.length;for(var d=0;d<i.length;++d){var v,h=i[d],p=c[d]=new _n,m=h.data||h;Array.isArray(m)||t(m)||U(m)?(r.buffers[d]&&(v=r.buffers[d],t(m)&&v._buffer.byteLength>=m.byteLength?v.subdata(m):(v.destroy(),r.buffers[d]=null)),r.buffers[d]||(v=r.buffers[d]=o.create(h,34962,!1,!0)),p.buffer=o.getBuffer(v),p.size=0|p.buffer.dimension,p.normalized=!1,p.type=p.buffer.dtype,p.offset=0,p.stride=0,p.divisor=0,p.state=1,l[d]=1):o.getBuffer(h)?(p.buffer=o.getBuffer(h),p.size=0|p.buffer.dimension,p.normalized=!1,p.type=p.buffer.dtype,p.offset=0,p.stride=0,p.divisor=0,p.state=1):o.getBuffer(h.buffer)?(p.buffer=o.getBuffer(h.buffer),p.size=0|(+h.size||p.buffer.dimension),p.normalized=!!h.normalized||!1,"type"in h?(C.parameter(h.type,Q,"invalid buffer type"),p.type=Q[h.type]):p.type=p.buffer.dtype,p.offset=0|(h.offset||0),p.stride=0|(h.stride||0),p.divisor=0|(h.divisor||0),p.state=1,C(p.size>=1&&p.size<=4,"size must be between 1 and 4"),C(p.offset>=0,"invalid offset"),C(p.stride>=0&&p.stride<=255,"stride must be between 0 and 255"),C(p.divisor>=0,"divisor must be positive"),C(!p.divisor||!!e.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in h?(C(d>0,"first attribute must not be a constant"),p.x=+h.x||0,p.y=+h.y||0,p.z=+h.z||0,p.w=+h.w||0,p.state=2):C(!1,"invalid attribute spec for location "+d)}for(var b=0;b<r.buffers.length;++b)!l[b]&&r.buffers[b]&&(r.buffers[b].destroy(),r.buffers[b]=null);return r.refresh(),u}return i.vaoCount+=1,u.destroy=function(){for(var t=0;t<r.buffers.length;++t)r.buffers[t]&&r.buffers[t].destroy();r.buffers.length=0,r.ownsElements&&(r.elements.destroy(),r.elements=null,r.ownsElements=!1),r.destroy()},u._vao=r,u._reglType="vao",u(n)},getVAO:function(t){return"function"==typeof t&&t._vao?t._vao:null},destroyBuffer:function(t){for(var e=0;e<f.length;++e){var r=f[e];r.buffer===t&&(n.disableVertexAttribArray(e),r.buffer=null)}},setVAO:h()?function(t){t!==v.currentVAO&&(h().bindVertexArrayOES(t?t.vao:null),v.currentVAO=t)}:function(t){if(t!==v.currentVAO){if(t)t.bindAttrs();else{for(var e=p(),r=0;r<f.length;++r){var i=f[r];i.buffer?(n.enableVertexAttribArray(r),i.buffer.bind(),n.vertexAttribPointer(r,i.size,i.type,i.normalized,i.stride,i.offfset),e&&i.divisor&&e.vertexAttribDivisorANGLE(r,i.divisor)):(n.disableVertexAttribArray(r),n.vertexAttrib4f(r,i.x,i.y,i.z,i.w))}n.bindBuffer(34963,u.elements?u.elements.buffer.buffer:null)}v.currentVAO=t}},clear:h()?function(){P(d).forEach((function(t){t.destroy()}))}:function(){}};function h(){return e.oes_vertex_array_object}function p(){return e.angle_instanced_arrays}function m(){this.id=++c,this.attributes=[],this.elements=null,this.ownsElements=!1,this.count=0,this.offset=0,this.instances=-1,this.primitive=4;var t=h();this.vao=t?t.createVertexArrayOES():null,d[this.id]=this,this.buffers=[]}return m.prototype.bindAttrs=function(){for(var t=p(),e=this.attributes,r=0;r<e.length;++r){var i=e[r];i.buffer?(n.enableVertexAttribArray(r),n.bindBuffer(34962,i.buffer.buffer),n.vertexAttribPointer(r,i.size,i.type,i.normalized,i.stride,i.offset),t&&i.divisor&&t.vertexAttribDivisorANGLE(r,i.divisor)):(n.disableVertexAttribArray(r),n.vertexAttrib4f(r,i.x,i.y,i.z,i.w))}for(var o=e.length;o<s;++o)n.disableVertexAttribArray(o);var u=a.getElements(this.elements);n.bindBuffer(34963,u?u.buffer.buffer:null)},m.prototype.refresh=function(){var t=h();t&&(t.bindVertexArrayOES(this.vao),this.bindAttrs(),v.currentVAO=null,t.bindVertexArrayOES(null))},m.prototype.destroy=function(){if(this.vao){var t=h();this===v.currentVAO&&(v.currentVAO=null,t.bindVertexArrayOES(null)),t.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),d[this.id]&&(delete d[this.id],i.vaoCount-=1)},v}(i,d,g,c,w,x,y),j=function(t,e,r,i){var o={},a={};function u(t,n,e,r){this.name=t,this.id=n,this.location=e,this.info=r}function s(t,n){for(var e=0;e<t.length;++e)if(t[e].id===n.id)return void(t[e].location=n.location);t.push(n)}function f(n,r,i){var u=35632===n?o:a,s=u[r];if(!s){var f=e.str(r);s=t.createShader(n),t.shaderSource(s,f),t.compileShader(s),C.shaderError(t,s,f,n,i),u[r]=s}return s}var l={},c=[],d=0;function v(t,n){this.id=d++,this.fragId=t,this.vertId=n,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,i.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function h(n,r,o){var a,l,c=f(35632,n.fragId),d=f(35633,n.vertId),v=n.program=t.createProgram();if(t.attachShader(v,c),t.attachShader(v,d),o)for(a=0;a<o.length;++a){var h=o[a];t.bindAttribLocation(v,h[0],h[1])}t.linkProgram(v),C.linkError(t,v,e.str(n.fragId),e.str(n.vertId),r);var p=t.getProgramParameter(v,35718);i.profile&&(n.stats.uniformsCount=p);var m=n.uniforms;for(a=0;a<p;++a)if(l=t.getActiveUniform(v,a)){if(l.size>1)for(var b=0;b<l.size;++b){var y=l.name.replace("[0]","["+b+"]");s(m,new u(y,e.id(y),t.getUniformLocation(v,y),l))}var g=l.name;l.size>1&&(g=g.replace("[0]","")),s(m,new u(g,e.id(g),t.getUniformLocation(v,g),l))}var w=t.getProgramParameter(v,35721);i.profile&&(n.stats.attributesCount=w);var x=n.attributes;for(a=0;a<w;++a)(l=t.getActiveAttrib(v,a))&&s(x,new u(l.name,e.id(l.name),t.getAttribLocation(v,l.name),l))}return i.profile&&(r.getMaxUniformsCount=function(){var t=0;return c.forEach((function(n){n.stats.uniformsCount>t&&(t=n.stats.uniformsCount)})),t},r.getMaxAttributesCount=function(){var t=0;return c.forEach((function(n){n.stats.attributesCount>t&&(t=n.stats.attributesCount)})),t}),{clear:function(){var n=t.deleteShader.bind(t);P(o).forEach(n),o={},P(a).forEach(n),a={},c.forEach((function(n){t.deleteProgram(n.program)})),c.length=0,l={},r.shaderCount=0},program:function(e,i,u,s){C.command(e>=0,"missing vertex shader",u),C.command(i>=0,"missing fragment shader",u);var f=l[i];f||(f=l[i]={});var d=f[e];if(d&&(d.refCount++,!s))return d;var p=new v(i,e);return r.shaderCount++,h(p,u,s),d||(f[e]=p),c.push(p),n(p,{destroy:function(){if(p.refCount--,p.refCount<=0){t.deleteProgram(p.program);var n=c.indexOf(p);c.splice(n,1),r.shaderCount--}f[p.vertId].refCount<=0&&(t.deleteShader(a[p.vertId]),delete a[p.vertId],delete l[p.fragId][p.vertId]),Object.keys(l[p.fragId]).length||(t.deleteShader(o[p.fragId]),delete o[p.fragId],delete l[p.fragId])}})},restore:function(){o={},a={};for(var t=0;t<c.length;++t)h(c[t],null,c[t].attributes.map((function(t){return[t.location,t.name]})))},shader:f,frag:-1,vert:-1}}(i,l,c,r),O=vn(i,d,g,(function(){_.procs.poll()}),b,c,r),k=function(t,n,e,r,i){var o={rgba4:pn,rgb565:36194,"rgb5 a1":32855,depth:33189,stencil:36168,"depth stencil":34041};n.ext_srgb&&(o.srgba=35907),n.ext_color_buffer_half_float&&(o.rgba16f=34842,o.rgb16f=34843),n.webgl_color_buffer_float&&(o.rgba32f=34836);var a=[];Object.keys(o).forEach((function(t){a[o[t]]=t}));var u=0,s={};function f(t){this.id=u++,this.refCount=1,this.renderbuffer=t,this.format=pn,this.width=0,this.height=0,i.profile&&(this.stats={size:0})}function l(n){var e=n.renderbuffer;C(e,"must not double destroy renderbuffer"),t.bindRenderbuffer(hn,null),t.deleteRenderbuffer(e),n.renderbuffer=null,n.refCount=0,delete s[n.id],r.renderbufferCount--}return f.prototype.decRef=function(){--this.refCount<=0&&l(this)},i.profile&&(r.getTotalRenderbufferSize=function(){var t=0;return Object.keys(s).forEach((function(n){t+=s[n].stats.size})),t}),{create:function(n,u){var l=new f(t.createRenderbuffer());function c(n,r){var u=0,s=0,f=pn;if("object"==typeof n&&n){var d=n;if("shape"in d){var v=d.shape;C(Array.isArray(v)&&v.length>=2,"invalid renderbuffer shape"),u=0|v[0],s=0|v[1]}else"radius"in d&&(u=s=0|d.radius),"width"in d&&(u=0|d.width),"height"in d&&(s=0|d.height);"format"in d&&(C.parameter(d.format,o,"invalid renderbuffer format"),f=o[d.format])}else"number"==typeof n?(u=0|n,s="number"==typeof r?0|r:u):n?C.raise("invalid arguments to renderbuffer constructor"):u=s=1;if(C(u>0&&s>0&&u<=e.maxRenderbufferSize&&s<=e.maxRenderbufferSize,"invalid renderbuffer size"),u!==l.width||s!==l.height||f!==l.format)return c.width=l.width=u,c.height=l.height=s,l.format=f,t.bindRenderbuffer(hn,l.renderbuffer),t.renderbufferStorage(hn,f,u,s),C(0===t.getError(),"invalid render buffer format"),i.profile&&(l.stats.size=bn(l.format,l.width,l.height)),c.format=a[l.format],c}return s[l.id]=l,r.renderbufferCount++,c(n,u),c.resize=function(n,r){var o=0|n,a=0|r||o;return o===l.width&&a===l.height||(C(o>0&&a>0&&o<=e.maxRenderbufferSize&&a<=e.maxRenderbufferSize,"invalid renderbuffer size"),c.width=l.width=o,c.height=l.height=a,t.bindRenderbuffer(hn,l.renderbuffer),t.renderbufferStorage(hn,l.format,o,a),C(0===t.getError(),"invalid render buffer format"),i.profile&&(l.stats.size=bn(l.format,l.width,l.height))),c},c._reglType="renderbuffer",c._renderbuffer=l,i.profile&&(c.stats=l.stats),c.destroy=function(){l.decRef()},c},clear:function(){P(s).forEach(l)},restore:function(){P(s).forEach((function(n){n.renderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(hn,n.renderbuffer),t.renderbufferStorage(hn,n.format,n.width,n.height)})),t.bindRenderbuffer(hn,null)}}}(i,d,g,c,r),T=function(t,e,r,i,o,a){var u={cur:null,next:null,dirty:!1,setFBO:null},s=["rgba"],f=["rgba4","rgb565","rgb5 a1"];e.ext_srgb&&f.push("srgba"),e.ext_color_buffer_half_float&&f.push("rgba16f","rgb16f"),e.webgl_color_buffer_float&&f.push("rgba32f");var l=["uint8"];function c(t,n,e){this.target=t,this.texture=n,this.renderbuffer=e;var r=0,i=0;n?(r=n.width,i=n.height):e&&(r=e.width,i=e.height),this.width=r,this.height=i}function d(t){t&&(t.texture&&t.texture._texture.decRef(),t.renderbuffer&&t.renderbuffer._renderbuffer.decRef())}function v(t,n,e){if(t)if(t.texture){var r=t.texture._texture,i=Math.max(1,r.width),o=Math.max(1,r.height);C(i===n&&o===e,"inconsistent width/height for supplied texture"),r.refCount+=1}else{var a=t.renderbuffer._renderbuffer;C(a.width===n&&a.height===e,"inconsistent width/height for renderbuffer"),a.refCount+=1}}function h(n,e){e&&(e.texture?t.framebufferTexture2D(yn,n,e.target,e.texture._texture.texture,0):t.framebufferRenderbuffer(yn,n,gn,e.renderbuffer._renderbuffer.renderbuffer))}function p(t){var n=wn,e=null,r=null,i=t;"object"==typeof t&&(i=t.data,"target"in t&&(n=0|t.target)),C.type(i,"function","invalid attachment data");var o=i._reglType;return"texture2d"===o?(e=i,C(n===wn)):"textureCube"===o?(e=i,C(n>=xn&&n<34075,"invalid cube map target")):"renderbuffer"===o?(r=i,n=gn):C.raise("invalid regl object for attachment"),new c(n,e,r)}function m(t,n,e,r,a){if(e){var u=i.create2D({width:t,height:n,format:r,type:a});return u._texture.refCount=0,new c(wn,u,null)}var s=o.create({width:t,height:n,format:r});return s._renderbuffer.refCount=0,new c(gn,null,s)}function b(t){return t&&(t.texture||t.renderbuffer)}function y(t,n,e){t&&(t.texture?t.texture.resize(n,e):t.renderbuffer&&t.renderbuffer.resize(n,e),t.width=n,t.height=e)}e.oes_texture_half_float&&l.push("half float","float16"),e.oes_texture_float&&l.push("float","float32");var g=0,w={};function x(){this.id=g++,w[this.id]=this,this.framebuffer=t.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function A(t){t.colorAttachments.forEach(d),d(t.depthAttachment),d(t.stencilAttachment),d(t.depthStencilAttachment)}function j(n){var e=n.framebuffer;C(e,"must not double destroy framebuffer"),t.deleteFramebuffer(e),n.framebuffer=null,a.framebufferCount--,delete w[n.id]}function O(n){var e;t.bindFramebuffer(yn,n.framebuffer);var i=n.colorAttachments;for(e=0;e<i.length;++e)h(36064+e,i[e]);for(e=i.length;e<r.maxColorAttachments;++e)t.framebufferTexture2D(yn,36064+e,wn,null,0);t.framebufferTexture2D(yn,33306,wn,null,0),t.framebufferTexture2D(yn,36096,wn,null,0),t.framebufferTexture2D(yn,36128,wn,null,0),h(36096,n.depthAttachment),h(36128,n.stencilAttachment),h(33306,n.depthStencilAttachment);var o=t.checkFramebufferStatus(yn);t.isContextLost()||36053===o||C.raise("framebuffer configuration not supported, status = "+kn[o]),t.bindFramebuffer(yn,u.next?u.next.framebuffer:null),u.cur=u.next,t.getError()}function k(t,i){var o=new x;function c(t,n){var i;C(u.next!==o,"can not update framebuffer which is currently in use");var a=0,d=0,h=!0,y=!0,g=null,w=!0,x="rgba",j="uint8",k=1,T=null,_=null,F=null,M=!1;if("number"==typeof t)a=0|t,d=0|n||a;else if(t){C.type(t,"object","invalid arguments for framebuffer");var z=t;if("shape"in z){var D=z.shape;C(Array.isArray(D)&&D.length>=2,"invalid shape for framebuffer"),a=D[0],d=D[1]}else"radius"in z&&(a=d=z.radius),"width"in z&&(a=z.width),"height"in z&&(d=z.height);("color"in z||"colors"in z)&&(g=z.color||z.colors,Array.isArray(g)&&C(1===g.length||e.webgl_draw_buffers,"multiple render targets not supported")),g||("colorCount"in z&&C((k=0|z.colorCount)>0,"invalid color buffer count"),"colorTexture"in z&&(w=!!z.colorTexture,x="rgba4"),"colorType"in z&&(j=z.colorType,w?(C(e.oes_texture_float||!("float"===j||"float32"===j),"you must enable OES_texture_float in order to use floating point framebuffer objects"),C(e.oes_texture_half_float||!("half float"===j||"float16"===j),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===j||"float16"===j?(C(e.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),x="rgba16f"):"float"!==j&&"float32"!==j||(C(e.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),x="rgba32f"),C.oneOf(j,l,"invalid color type")),"colorFormat"in z&&(s.indexOf(x=z.colorFormat)>=0?w=!0:f.indexOf(x)>=0?w=!1:C.optional((function(){w?C.oneOf(z.colorFormat,s,"invalid color format for texture"):C.oneOf(z.colorFormat,f,"invalid color format for renderbuffer")})))),("depthTexture"in z||"depthStencilTexture"in z)&&C(!(M=!(!z.depthTexture&&!z.depthStencilTexture))||e.webgl_depth_texture,"webgl_depth_texture extension not supported"),"depth"in z&&("boolean"==typeof z.depth?h=z.depth:(T=z.depth,y=!1)),"stencil"in z&&("boolean"==typeof z.stencil?y=z.stencil:(_=z.stencil,h=!1)),"depthStencil"in z&&("boolean"==typeof z.depthStencil?h=y=z.depthStencil:(F=z.depthStencil,h=!1,y=!1))}else a=d=1;var S=null,E=null,B=null,R=null;if(Array.isArray(g))S=g.map(p);else if(g)S=[p(g)];else for(S=new Array(k),i=0;i<k;++i)S[i]=m(a,d,w,x,j);C(e.webgl_draw_buffers||S.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),C(S.length<=r.maxColorAttachments,"too many color attachments, not supported"),a=a||S[0].width,d=d||S[0].height,T?E=p(T):h&&!y&&(E=m(a,d,M,"depth","uint32")),_?B=p(_):y&&!h&&(B=m(a,d,!1,"stencil","uint8")),F?R=p(F):!T&&!_&&y&&h&&(R=m(a,d,M,"depth stencil","depth stencil")),C(!!T+!!_+!!F<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var J=null;for(i=0;i<S.length;++i)if(v(S[i],a,d),C(!S[i]||S[i].texture&&An.indexOf(S[i].texture._texture.format)>=0||S[i].renderbuffer&&On.indexOf(S[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),S[i]&&S[i].texture){var N=Cn[S[i].texture._texture.format]*jn[S[i].texture._texture.type];null===J?J=N:C(J===N,"all color attachments much have the same number of bits per pixel.")}return v(E,a,d),C(!E||E.texture&&6402===E.texture._texture.format||E.renderbuffer&&33189===E.renderbuffer._renderbuffer.format,"invalid depth attachment for framebuffer object"),v(B,a,d),C(!B||B.renderbuffer&&36168===B.renderbuffer._renderbuffer.format,"invalid stencil attachment for framebuffer object"),v(R,a,d),C(!R||R.texture&&34041===R.texture._texture.format||R.renderbuffer&&34041===R.renderbuffer._renderbuffer.format,"invalid depth-stencil attachment for framebuffer object"),A(o),o.width=a,o.height=d,o.colorAttachments=S,o.depthAttachment=E,o.stencilAttachment=B,o.depthStencilAttachment=R,c.color=S.map(b),c.depth=b(E),c.stencil=b(B),c.depthStencil=b(R),c.width=o.width,c.height=o.height,O(o),c}return a.framebufferCount++,c(t,i),n(c,{resize:function(t,n){C(u.next!==o,"can not resize a framebuffer which is currently in use");var e=Math.max(0|t,1),r=Math.max(0|n||e,1);if(e===o.width&&r===o.height)return c;for(var i=o.colorAttachments,a=0;a<i.length;++a)y(i[a],e,r);return y(o.depthAttachment,e,r),y(o.stencilAttachment,e,r),y(o.depthStencilAttachment,e,r),o.width=c.width=e,o.height=c.height=r,O(o),c},_reglType:"framebuffer",_framebuffer:o,destroy:function(){j(o),A(o)},use:function(t){u.setFBO({framebuffer:c},t)}})}return n(u,{getFramebuffer:function(t){if("function"==typeof t&&"framebuffer"===t._reglType){var n=t._framebuffer;if(n instanceof x)return n}return null},create:k,createCube:function(t){var o=Array(6);function a(t){var r;C(o.indexOf(u.next)<0,"can not update framebuffer which is currently in use");var f,c={color:null},d=0,v=null,h="rgba",p="uint8",m=1;if("number"==typeof t)d=0|t;else if(t){C.type(t,"object","invalid arguments for framebuffer");var b=t;if("shape"in b){var y=b.shape;C(Array.isArray(y)&&y.length>=2,"invalid shape for framebuffer"),C(y[0]===y[1],"cube framebuffer must be square"),d=y[0]}else"radius"in b&&(d=0|b.radius),"width"in b?(d=0|b.width,"height"in b&&C(b.height===d,"must be square")):"height"in b&&(d=0|b.height);("color"in b||"colors"in b)&&(v=b.color||b.colors,Array.isArray(v)&&C(1===v.length||e.webgl_draw_buffers,"multiple render targets not supported")),v||("colorCount"in b&&C((m=0|b.colorCount)>0,"invalid color buffer count"),"colorType"in b&&(C.oneOf(b.colorType,l,"invalid color type"),p=b.colorType),"colorFormat"in b&&(h=b.colorFormat,C.oneOf(b.colorFormat,s,"invalid color format for texture"))),"depth"in b&&(c.depth=b.depth),"stencil"in b&&(c.stencil=b.stencil),"depthStencil"in b&&(c.depthStencil=b.depthStencil)}else d=1;if(v)if(Array.isArray(v))for(f=[],r=0;r<v.length;++r)f[r]=v[r];else f=[v];else{f=Array(m);var g={radius:d,format:h,type:p};for(r=0;r<m;++r)f[r]=i.createCube(g)}for(c.color=Array(f.length),r=0;r<f.length;++r){var w=f[r];C("function"==typeof w&&"textureCube"===w._reglType,"invalid cube map"),C(w.width===(d=d||w.width)&&w.height===d,"invalid cube map shape"),c.color[r]={target:xn,data:f[r]}}for(r=0;r<6;++r){for(var x=0;x<f.length;++x)c.color[x].target=xn+r;r>0&&(c.depth=o[0].depth,c.stencil=o[0].stencil,c.depthStencil=o[0].depthStencil),o[r]?o[r](c):o[r]=k(c)}return n(a,{width:d,height:d,color:f})}return a(t),n(a,{faces:o,resize:function(t){var n,e=0|t;if(C(e>0&&e<=r.maxCubeMapSize,"invalid radius for cube fbo"),e===a.width)return a;var i=a.color;for(n=0;n<i.length;++n)i[n].resize(e);for(n=0;n<6;++n)o[n].resize(e);return a.width=a.height=e,a},_reglType:"framebufferCube",destroy:function(){o.forEach((function(t){t.destroy()}))}})},clear:function(){P(w).forEach(j)},restore:function(){u.cur=null,u.next=null,u.dirty=!0,P(w).forEach((function(n){n.framebuffer=t.createFramebuffer(),O(n)}))}})}(i,d,g,O,k,c),_=ur(i,l,d,g,w,x,0,T,{},A,j,y,b,v,r),D=zn(i,T,_.procs.poll,b,o,d,g),S=_.next,B=i.canvas,R=[],J=[],q=[],G=[r.onDestroy],H=null;function $(){if(0===R.length)return v&&v.update(),void(H=null);H=M.next($),gt();for(var t=R.length-1;t>=0;--t){var n=R[t];n&&n(b,null,0)}i.flush(),v&&v.update()}function lt(){!H&&R.length>0&&(H=M.next($))}function ct(){H&&(M.cancel($),H=null)}function dt(t){t.preventDefault(),a=!0,ct(),J.forEach((function(t){t()}))}function vt(){i.getError(),a=!1,u.restore(),j.restore(),w.restore(),O.restore(),k.restore(),T.restore(),A.restore(),v&&v.restore(),_.procs.refresh(),lt(),q.forEach((function(t){t()}))}function ht(t){function e(t,n){var e={},r={};return Object.keys(t).forEach((function(i){var o=t[i];if(F.isDynamic(o))r[i]=F.unbox(o,i);else{if(n&&Array.isArray(o))for(var a=0;a<o.length;++a)if(F.isDynamic(o[a]))return void(r[i]=F.unbox(o,i));e[i]=o}})),{dynamic:r,static:e}}C(!!t,"invalid args to regl({...})"),C.type(t,"object","invalid args to regl({...})");var r=e(t.context||{},!0),i=e(t.uniforms||{},!0),o=e(t.attributes||{},!1),u=e(function(t){var e=n({},t);function r(t){if(t in e){var n=e[t];delete e[t],Object.keys(n).forEach((function(r){e[t+"."+r]=n[r]}))}}return delete e.uniforms,delete e.attributes,delete e.context,delete e.vao,"stencil"in e&&e.stencil.op&&(e.stencil.opBack=e.stencil.opFront=e.stencil.op,delete e.stencil.op),r("blend"),r("depth"),r("cull"),r("stencil"),r("polygonOffset"),r("scissor"),r("sample"),"vao"in t&&(e.vao=t.vao),e}(t),!1),s={gpuTime:0,cpuTime:0,count:0},f=_.compile(u,o,i,r,s),l=f.draw,c=f.batch,d=f.scope,v=[];return n((function(t,n){var e;if(a&&C.raise("context lost"),"function"==typeof t)return d.call(this,null,t,0);if("function"==typeof n)if("number"==typeof t)for(e=0;e<t;++e)d.call(this,null,n,e);else{if(!Array.isArray(t))return d.call(this,t,n,0);for(e=0;e<t.length;++e)d.call(this,t[e],n,e)}else if("number"==typeof t){if(t>0)return c.call(this,function(t){for(;v.length<t;)v.push(null);return v}(0|t),0|t)}else{if(!Array.isArray(t))return l.call(this,t);if(t.length)return c.call(this,t,t.length)}}),{stats:s,destroy:function(){f.destroy()}})}B&&(B.addEventListener(fr,dt,!1),B.addEventListener(lr,vt,!1));var pt=T.setFBO=ht({framebuffer:F.define.call(null,1,"framebuffer")});function mt(t,n){var e=0;_.procs.poll();var r=n.color;r&&(i.clearColor(+r[0]||0,+r[1]||0,+r[2]||0,+r[3]||0),e|=16384),"depth"in n&&(i.clearDepth(+n.depth),e|=256),"stencil"in n&&(i.clearStencil(0|n.stencil),e|=1024),C(!!e,"called regl.clear with no buffer specified"),i.clear(e)}function bt(t){return C.type(t,"function","regl.frame() callback must be a function"),R.push(t),lt(),{cancel:function(){var n=cr(R,t);C(n>=0,"cannot cancel a frame twice"),R[n]=function t(){var n=cr(R,t);R[n]=R[R.length-1],R.length-=1,R.length<=0&&ct()}}}}function yt(){var t=S.viewport,n=S.scissor_box;t[0]=t[1]=n[0]=n[1]=0,b.viewportWidth=b.framebufferWidth=b.drawingBufferWidth=t[2]=n[2]=i.drawingBufferWidth,b.viewportHeight=b.framebufferHeight=b.drawingBufferHeight=t[3]=n[3]=i.drawingBufferHeight}function gt(){b.tick+=1,b.time=xt(),yt(),_.procs.poll()}function wt(){O.refresh(),yt(),_.procs.refresh(),v&&v.update()}function xt(){return(z()-h)/1e3}wt();var At=n(ht,{clear:function(t){if(C("object"==typeof t&&t,"regl.clear() takes an object as input"),"framebuffer"in t)if(t.framebuffer&&"framebufferCube"===t.framebuffer_reglType)for(var e=0;e<6;++e)pt(n({framebuffer:t.framebuffer.faces[e]},t),mt);else pt(t,mt);else mt(0,t)},prop:F.define.bind(null,1),context:F.define.bind(null,2),this:F.define.bind(null,3),draw:ht({}),buffer:function(t){return w.create(t,34962,!1,!1)},elements:function(t){return x.create(t,!1)},texture:O.create2D,cube:O.createCube,renderbuffer:k.create,framebuffer:T.create,framebufferCube:T.createCube,vao:A.createVAO,attributes:o,frame:bt,on:function(t,n){var e;switch(C.type(n,"function","listener callback must be a function"),t){case"frame":return bt(n);case"lost":e=J;break;case"restore":e=q;break;case"destroy":e=G;break;default:C.raise("invalid event, must be one of frame,lost,restore,destroy")}return e.push(n),{cancel:function(){for(var t=0;t<e.length;++t)if(e[t]===n)return e[t]=e[e.length-1],void e.pop()}}},limits:g,hasExtension:function(t){return g.extensions.indexOf(t.toLowerCase())>=0},read:D,destroy:function(){R.length=0,ct(),B&&(B.removeEventListener(fr,dt),B.removeEventListener(lr,vt)),j.clear(),T.clear(),k.clear(),A.clear(),O.clear(),x.clear(),w.clear(),v&&v.clear(),G.forEach((function(t){t()}))},_gl:i,_refresh:wt,poll:function(){gt(),v&&v.update()},now:xt,stats:c});return r.onDone(null,At),At}}()})),M=function(t,n){if(!t||null==t.length)throw Error("Argument should be an array");n=null==n?1:Math.floor(n);for(var e=Array(2*n),r=0;r<n;r++){for(var i=-1/0,o=1/0,a=r,u=t.length;a<u;a+=n)t[a]>i&&(i=t[a]),t[a]<o&&(o=t[a]);e[r]=o,e[n+r]=i}return e},z=function(t,n,e){if(!t||null==t.length)throw Error("Argument should be an array");null==n&&(n=1),null==e&&(e=M(t,n));for(var r=0;r<n;r++){var i=e[n+r],o=e[r],a=r,u=t.length;if(i===1/0&&o===-1/0)for(a=r;a<u;a+=n)t[a]=t[a]===i?1:t[a]===o?0:.5;else if(i===1/0)for(a=r;a<u;a+=n)t[a]=t[a]===i?1:0;else if(o===-1/0)for(a=r;a<u;a+=n)t[a]=t[a]===o?0:1;else{var s=i-o;for(a=r;a<u;a+=n)isNaN(t[a])||(t[a]=0===s?.5:(t[a]-o)/s)}}return t},D={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},S=function(t){var n,e,r=[],i=1;if("string"==typeof t)if(D[t])r=D[t].slice(),e="rgb";else if("transparent"===t)i=0,e="rgb",r=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(t)){var o=t.slice(1);i=1,(s=o.length)<=4?(r=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],4===s&&(i=parseInt(o[3]+o[3],16)/255)):(r=[parseInt(o[0]+o[1],16),parseInt(o[2]+o[3],16),parseInt(o[4]+o[5],16)],8===s&&(i=parseInt(o[6]+o[7],16)/255)),r[0]||(r[0]=0),r[1]||(r[1]=0),r[2]||(r[2]=0),e="rgb"}else if(n=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(t)){var a=n[1],u="rgb"===a;e=o=a.replace(/a$/,"");var s="cmyk"===o?4:"gray"===o?1:3;r=n[2].trim().split(/\s*[,\/]\s*|\s+/).map((function(t,n){if(/%$/.test(t))return n===s?parseFloat(t)/100:"rgb"===o?255*parseFloat(t)/100:parseFloat(t);if("h"===o[n]){if(/deg$/.test(t))return parseFloat(t);if(void 0!==E[t])return E[t]}return parseFloat(t)})),a===o&&r.push(1),i=u||void 0===r[s]?1:r[s],r=r.slice(0,s)}else t.length>10&&/[0-9](?:\s|\/)/.test(t)&&(r=t.match(/([0-9]+)/g).map((function(t){return parseFloat(t)})),e=t.match(/([a-z])/gi).join("").toLowerCase());else isNaN(t)?Array.isArray(t)||t.length?(r=[t[0],t[1],t[2]],e="rgb",i=4===t.length?t[3]:1):t instanceof Object&&(null!=t.r||null!=t.red||null!=t.R?(e="rgb",r=[t.r||t.red||t.R||0,t.g||t.green||t.G||0,t.b||t.blue||t.B||0]):(e="hsl",r=[t.h||t.hue||t.H||0,t.s||t.saturation||t.S||0,t.l||t.lightness||t.L||t.b||t.brightness]),i=t.a||t.alpha||t.opacity||1,null!=t.opacity&&(i/=100)):(e="rgb",r=[t>>>16,(65280&t)>>>8,255&t]);return{space:e,values:r,alpha:i}},E={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function B(t){var n,e,r,i,o,a=t[0]/360,u=t[1]/100,s=t[2]/100,f=0;if(0===u)return[o=255*s,o,o];for(n=2*s-(e=s<.5?s*(1+u):s+u-s*u),i=[0,0,0];f<3;)(r=a+1/3*-(f-1))<0?r++:r>1&&r--,i[f++]=255*(o=6*r<1?n+6*(e-n)*r:2*r<1?e:3*r<2?n+(e-n)*(2/3-r)*6:n);return i}var R=function(t,n){"float"!==n&&n||(n="array"),"uint"===n&&(n="uint8"),"uint_clamped"===n&&(n="uint8_clamped");var e=new(function(t){switch(t){case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;case"array":return Array;case"uint8_clamped":return Uint8ClampedArray}}(n))(4),r="uint8"!==n&&"uint8_clamped"!==n;return t.length&&"string"!=typeof t||((t=function(t){var n;Array.isArray(t)&&t.raw&&(t=String.raw.apply(null,arguments));var e=S(t);if(!e.space)return[];var r=[0,0,0],i="h"===e.space[0]?[360,100,100]:[255,255,255];return(n=Array(3))[0]=Math.min(Math.max(e.values[0],r[0]),i[0]),n[1]=Math.min(Math.max(e.values[1],r[1]),i[1]),n[2]=Math.min(Math.max(e.values[2],r[2]),i[2]),"h"===e.space[0]&&(n=B(n)),n.push(Math.min(Math.max(e.alpha,0),1)),n}(t))[0]/=255,t[1]/=255,t[2]/=255),function(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||!!(Array.isArray(t)&&(t[0]>1||0===t[0])&&(t[1]>1||0===t[1])&&(t[2]>1||0===t[2])&&(!t[3]||t[3]>1))}(t)?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=null!=t[3]?t[3]:255,r&&(e[0]/=255,e[1]/=255,e[2]/=255,e[3]/=255),e):(r?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=null!=t[3]?t[3]:1):(e[0]=Math.min(Math.max(Math.floor(255*t[0]),0),255),e[1]=Math.min(Math.max(Math.floor(255*t[1]),0),255),e[2]=Math.min(Math.max(Math.floor(255*t[2]),0),255),e[3]=null==t[3]?255:Math.min(Math.max(Math.floor(255*t[3]),0),255)),e)},J=V,N=V;function V(t,n,e){e=e||2;var r,i,o,a,u,s,f,l=n&&n.length,c=l?n[0]*e:t.length,d=W(t,0,c,e,!0),v=[];if(!d||d.next===d.prev)return v;if(l&&(d=function(t,n,e,r){var i,o,a,u=[];for(i=0,o=n.length;i<o;i++)(a=W(t,n[i]*r,i<o-1?n[i+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),u.push(Y(a));for(u.sort(H),i=0;i<u.length;i++)e=I(e=$(u[i],e),e.next);return e}(t,n,d,e)),t.length>80*e){r=o=t[0],i=a=t[1];for(var h=e;h<c;h+=e)(u=t[h])<r&&(r=u),(s=t[h+1])<i&&(i=s),u>o&&(o=u),s>a&&(a=s);f=0!==(f=Math.max(o-r,a-i))?1/f:0}return L(d,v,e,r,i,f),v}function W(t,n,e,r,i){var o,a;if(i===lt(t,n,e,r)>0)for(o=n;o<e;o+=r)a=ut(o,t[o],t[o+1],a);else for(o=e-r;o>=n;o-=r)a=ut(o,t[o],t[o+1],a);return a&&nt(a,a.next)&&(st(a),a=a.next),a}function I(t,n){if(!t)return t;n||(n=t);var e,r=t;do{if(e=!1,r.steiner||!nt(r,r.next)&&0!==tt(r.prev,r,r.next))r=r.next;else{if(st(r),(r=n=r.prev)===r.next)break;e=!0}}while(e||r!==n);return n}function L(t,n,e,r,i,o,a){if(t){!a&&o&&function(t,n,e,r){var i=t;do{null===i.z&&(i.z=X(i.x,i.y,n,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var n,e,r,i,o,a,u,s,f=1;do{for(e=t,t=null,o=null,a=0;e;){for(a++,r=e,u=0,n=0;n<f&&(u++,r=r.nextZ);n++);for(s=f;u>0||s>0&&r;)0!==u&&(0===s||!r||e.z<=r.z)?(i=e,e=e.nextZ,u--):(i=r,r=r.nextZ,s--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;e=r}o.nextZ=null,f*=2}while(a>1)}(i)}(t,r,i,o);for(var u,s,f=t;t.prev!==t.next;)if(u=t.prev,s=t.next,o?P(t,r,i,o):U(t))n.push(u.i/e),n.push(t.i/e),n.push(s.i/e),st(t),t=s.next,f=s.next;else if((t=s)===f){a?1===a?L(t=q(I(t),n,e),n,e,r,i,o,2):2===a&&G(t,n,e,r,i,o):L(I(t),n,e,r,i,o,1);break}}}function U(t){var n=t.prev,e=t,r=t.next;if(tt(n,e,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Z(n.x,n.y,e.x,e.y,r.x,r.y,i.x,i.y)&&tt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function P(t,n,e,r){var i=t.prev,o=t,a=t.next;if(tt(i,o,a)>=0)return!1;for(var u=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,s=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,f=X(i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,n,e,r),l=X(u,s,n,e,r),c=t.prevZ,d=t.nextZ;c&&c.z>=f&&d&&d.z<=l;){if(c!==t.prev&&c!==t.next&&Z(i.x,i.y,o.x,o.y,a.x,a.y,c.x,c.y)&&tt(c.prev,c,c.next)>=0)return!1;if(c=c.prevZ,d!==t.prev&&d!==t.next&&Z(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&tt(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;c&&c.z>=f;){if(c!==t.prev&&c!==t.next&&Z(i.x,i.y,o.x,o.y,a.x,a.y,c.x,c.y)&&tt(c.prev,c,c.next)>=0)return!1;c=c.prevZ}for(;d&&d.z<=l;){if(d!==t.prev&&d!==t.next&&Z(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&tt(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function q(t,n,e){var r=t;do{var i=r.prev,o=r.next.next;!nt(i,o)&&et(i,r,r.next,o)&&ot(i,o)&&ot(o,i)&&(n.push(i.i/e),n.push(r.i/e),n.push(o.i/e),st(r),st(r.next),r=t=o),r=r.next}while(r!==t);return I(r)}function G(t,n,e,r,i,o){var a=t;do{for(var u=a.next.next;u!==a.prev;){if(a.i!==u.i&&K(a,u)){var s=at(a,u);return a=I(a,a.next),s=I(s,s.next),L(a,n,e,r,i,o),void L(s,n,e,r,i,o)}u=u.next}a=a.next}while(a!==t)}function H(t,n){return t.x-n.x}function $(t,n){var e=function(t,n){var e,r=n,i=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var u=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(u<=i&&u>a){if(a=u,u===i){if(o===r.y)return r;if(o===r.next.y)return r.next}e=r.x<r.next.x?r:r.next}}r=r.next}while(r!==n);if(!e)return null;if(i===a)return e;var s,f=e,l=e.x,c=e.y,d=1/0;r=e;do{i>=r.x&&r.x>=l&&i!==r.x&&Z(o<c?i:a,o,l,c,o<c?a:i,o,r.x,r.y)&&(s=Math.abs(o-r.y)/(i-r.x),ot(r,t)&&(s<d||s===d&&(r.x>e.x||r.x===e.x&&Q(e,r)))&&(e=r,d=s)),r=r.next}while(r!==f);return e}(t,n);if(!e)return n;var r=at(e,t),i=I(e,e.next);return I(r,r.next),n===e?i:n}function Q(t,n){return tt(t.prev,t,n.prev)<0&&tt(n.next,t,t.next)<0}function X(t,n,e,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-e)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-r)*i)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function Y(t){var n=t,e=t;do{(n.x<e.x||n.x===e.x&&n.y<e.y)&&(e=n),n=n.next}while(n!==t);return e}function Z(t,n,e,r,i,o,a,u){return(i-a)*(n-u)-(t-a)*(o-u)>=0&&(t-a)*(r-u)-(e-a)*(n-u)>=0&&(e-a)*(o-u)-(i-a)*(r-u)>=0}function K(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==n.i&&e.next.i!==n.i&&et(e,e.next,t,n))return!0;e=e.next}while(e!==t);return!1}(t,n)&&(ot(t,n)&&ot(n,t)&&function(t,n){var e=t,r=!1,i=(t.x+n.x)/2,o=(t.y+n.y)/2;do{e.y>o!=e.next.y>o&&e.next.y!==e.y&&i<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next}while(e!==t);return r}(t,n)&&(tt(t.prev,t,n.prev)||tt(t,n.prev,n))||nt(t,n)&&tt(t.prev,t,t.next)>0&&tt(n.prev,n,n.next)>0)}function tt(t,n,e){return(n.y-t.y)*(e.x-n.x)-(n.x-t.x)*(e.y-n.y)}function nt(t,n){return t.x===n.x&&t.y===n.y}function et(t,n,e,r){var i=it(tt(t,n,e)),o=it(tt(t,n,r)),a=it(tt(e,r,t)),u=it(tt(e,r,n));return i!==o&&a!==u||!(0!==i||!rt(t,e,n))||!(0!==o||!rt(t,r,n))||!(0!==a||!rt(e,t,r))||!(0!==u||!rt(e,n,r))}function rt(t,n,e){return n.x<=Math.max(t.x,e.x)&&n.x>=Math.min(t.x,e.x)&&n.y<=Math.max(t.y,e.y)&&n.y>=Math.min(t.y,e.y)}function it(t){return t>0?1:t<0?-1:0}function ot(t,n){return tt(t.prev,t,t.next)<0?tt(t,n,t.next)>=0&&tt(t,t.prev,n)>=0:tt(t,n,t.prev)<0||tt(t,t.next,n)<0}function at(t,n){var e=new ft(t.i,t.x,t.y),r=new ft(n.i,n.x,n.y),i=t.next,o=n.prev;return t.next=n,n.prev=t,e.next=i,i.prev=e,r.next=e,e.prev=r,o.next=r,r.prev=o,r}function ut(t,n,e,r){var i=new ft(t,n,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function st(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ft(t,n,e){this.i=t,this.x=n,this.y=e,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function lt(t,n,e,r){for(var i=0,o=n,a=e-r;o<e;o+=r)i+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return i}V.deviation=function(t,n,e,r){var i=n&&n.length,o=Math.abs(lt(t,0,i?n[0]*e:t.length,e));if(i)for(var a=0,u=n.length;a<u;a++)o-=Math.abs(lt(t,n[a]*e,a<u-1?n[a+1]*e:t.length,e));var s=0;for(a=0;a<r.length;a+=3){var f=r[a]*e,l=r[a+1]*e,c=r[a+2]*e;s+=Math.abs((t[f]-t[c])*(t[l+1]-t[f+1])-(t[f]-t[l])*(t[c+1]-t[f+1]))}return 0===o&&0===s?0:Math.abs((s-o)/o)},V.flatten=function(t){for(var n=t[0][0].length,e={vertices:[],holes:[],dimensions:n},r=0,i=0;i<t.length;i++){for(var o=0;o<t[i].length;o++)for(var a=0;a<n;a++)e.vertices.push(t[i][o][a]);i>0&&e.holes.push(r+=t[i-1].length)}return e},J.default=N;const ct=Object.freeze({__proto__:null,default:"precision highp float;\n\nattribute vec2 aCoord, bCoord, aCoordFract, bCoordFract;\nattribute vec4 color;\nattribute float lineEnd, lineTop;\n\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float thickness, pixelRatio, depth;\nuniform vec4 viewport;\n\nvarying vec4 fragColor;\nvarying vec2 tangent;\n\nvec2 project(vec2 position, vec2 positionFract, vec2 scale, vec2 scaleFract, vec2 translate, vec2 translateFract) {\n\t// the order is important\n\treturn position * scale + translate\n + positionFract * scale + translateFract\n + position * scaleFract\n + positionFract * scaleFract;\n}\n\nvoid main() {\n\tfloat lineStart = 1. - lineEnd;\n\tfloat lineOffset = lineTop * 2. - 1.;\n\n\tvec2 diff = (bCoord + bCoordFract - aCoord - aCoordFract);\n\ttangent = normalize(diff * scale * viewport.zw);\n\tvec2 normal = vec2(-tangent.y, tangent.x);\n\n\tvec2 position = project(aCoord, aCoordFract, scale, scaleFract, translate, translateFract) * lineStart\n\t\t+ project(bCoord, bCoordFract, scale, scaleFract, translate, translateFract) * lineEnd\n\n\t\t+ thickness * normal * .5 * lineOffset / viewport.zw;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tfragColor = color / 255.;\n}"}),dt=Object.freeze({__proto__:null,default:"precision highp float;\n\nuniform sampler2D dashPattern;\n\nuniform float dashSize, pixelRatio, thickness, opacity;\n\nvarying vec4 fragColor;\nvarying vec2 tangent;\n\nvoid main() {\n\tfloat alpha = 1.;\n\n\tfloat t = fract(dot(tangent, gl_FragCoord.xy) / dashSize) * .5 + .25;\n\tfloat dash = texture2D(dashPattern, vec2(t, .5)).r;\n\n\tgl_FragColor = fragColor;\n\tgl_FragColor.a *= alpha * opacity * dash;\n}"}),vt=x(ct),ht=x(dt);var pt=g((function(t,n){var e=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0}),n.createRectShader=void 0;const r=e(vt),i=e(ht);n.createRectShader=function(t,n,e){return t(Object.assign(Object.assign({},e),{vert:r.default,frag:i.default,attributes:{lineEnd:{buffer:n,divisor:0,stride:8,offset:0},lineTop:{buffer:n,divisor:0,stride:8,offset:4},aCoord:{buffer:(t,n)=>n.positionBuffer,stride:8,offset:8,divisor:1},bCoord:{buffer:(t,n)=>n.positionBuffer,stride:8,offset:16,divisor:1},aCoordFract:{buffer:(t,n)=>n.positionFractBuffer,stride:8,offset:8,divisor:1},bCoordFract:{buffer:(t,n)=>n.positionFractBuffer,stride:8,offset:16,divisor:1},color:{buffer:(t,n)=>n.colorBuffer,stride:4,offset:0,divisor:1}}}))}}));const mt=Object.freeze({__proto__:null,default:"precision highp float;\n\nattribute vec2 aCoord, bCoord, nextCoord, prevCoord;\nattribute vec4 aColor, bColor;\nattribute float lineEnd, lineTop;\n\nuniform vec2 scale, translate;\nuniform float thickness, pixelRatio, depth;\nuniform vec4 viewport;\nuniform float miterLimit, miterMode;\n\nvarying vec4 fragColor;\nvarying vec4 startCutoff, endCutoff;\nvarying vec2 tangent;\nvarying vec2 startCoord, endCoord;\nvarying float enableStartMiter, enableEndMiter;\n\nconst float REVERSE_THRESHOLD = -.875;\nconst float MIN_DIFF = 1e-6;\n\n// TODO: possible optimizations: avoid overcalculating all for vertices and calc just one instead\n// TODO: precalculate dot products, normalize things beforehead etc.\n// TODO: refactor to rectangular algorithm\n\nfloat distToLine(vec2 p, vec2 a, vec2 b) {\n\tvec2 diff = b - a;\n\tvec2 perp = normalize(vec2(-diff.y, diff.x));\n\treturn dot(p - a, perp);\n}\n\nbool isNaN( float val ){\n return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true;\n}\n\nvoid main() {\n\tvec2 aCoord = aCoord, bCoord = bCoord, prevCoord = prevCoord, nextCoord = nextCoord;\n\n vec2 adjustedScale;\n adjustedScale.x = (abs(scale.x) < MIN_DIFF) ? MIN_DIFF : scale.x;\n adjustedScale.y = (abs(scale.y) < MIN_DIFF) ? MIN_DIFF : scale.y;\n\n vec2 scaleRatio = adjustedScale * viewport.zw;\n\tvec2 normalWidth = thickness / scaleRatio;\n\n\tfloat lineStart = 1. - lineEnd;\n\tfloat lineBot = 1. - lineTop;\n\n\tfragColor = (lineStart * aColor + lineEnd * bColor) / 255.;\n\n\tif (isNaN(aCoord.x) || isNaN(aCoord.y) || isNaN(bCoord.x) || isNaN(bCoord.y)) return;\n\n\tif (aCoord == prevCoord) prevCoord = aCoord + normalize(bCoord - aCoord);\n\tif (bCoord == nextCoord) nextCoord = bCoord - normalize(bCoord - aCoord);\n\n\n\tvec2 prevDiff = aCoord - prevCoord;\n\tvec2 currDiff = bCoord - aCoord;\n\tvec2 nextDiff = nextCoord - bCoord;\n\n\tvec2 prevTangent = normalize(prevDiff * scaleRatio);\n\tvec2 currTangent = normalize(currDiff * scaleRatio);\n\tvec2 nextTangent = normalize(nextDiff * scaleRatio);\n\n\tvec2 prevNormal = vec2(-prevTangent.y, prevTangent.x);\n\tvec2 currNormal = vec2(-currTangent.y, currTangent.x);\n\tvec2 nextNormal = vec2(-nextTangent.y, nextTangent.x);\n\n\tvec2 startJoinDirection = normalize(prevTangent - currTangent);\n\tvec2 endJoinDirection = normalize(currTangent - nextTangent);\n\n\t// collapsed/unidirectional segment cases\n\t// FIXME: there should be more elegant solution\n\tvec2 prevTanDiff = abs(prevTangent - currTangent);\n\tvec2 nextTanDiff = abs(nextTangent - currTangent);\n\tif (max(prevTanDiff.x, prevTanDiff.y) < MIN_DIFF) {\n\t\tstartJoinDirection = currNormal;\n\t}\n\tif (max(nextTanDiff.x, nextTanDiff.y) < MIN_DIFF) {\n\t\tendJoinDirection = currNormal;\n\t}\n\tif (aCoord == bCoord) {\n\t\tendJoinDirection = startJoinDirection;\n\t\tcurrNormal = prevNormal;\n\t\tcurrTangent = prevTangent;\n\t}\n\n\ttangent = currTangent;\n\n\t//calculate join shifts relative to normals\n\tfloat startJoinShift = dot(currNormal, startJoinDirection);\n\tfloat endJoinShift = dot(currNormal, endJoinDirection);\n\n\tfloat startMiterRatio = abs(1. / startJoinShift);\n\tfloat endMiterRatio = abs(1. / endJoinShift);\n\n\tvec2 startJoin = startJoinDirection * startMiterRatio;\n\tvec2 endJoin = endJoinDirection * endMiterRatio;\n\n\tvec2 startTopJoin, startBotJoin, endTopJoin, endBotJoin;\n\tstartTopJoin = sign(startJoinShift) * startJoin * .5;\n\tstartBotJoin = -startTopJoin;\n\n\tendTopJoin = sign(endJoinShift) * endJoin * .5;\n\tendBotJoin = -endTopJoin;\n\n\tvec2 aTopCoord = aCoord + normalWidth * startTopJoin;\n\tvec2 bTopCoord = bCoord + normalWidth * endTopJoin;\n\tvec2 aBotCoord = aCoord + normalWidth * startBotJoin;\n\tvec2 bBotCoord = bCoord + normalWidth * endBotJoin;\n\n\t//miter anti-clipping\n\tfloat baClipping = distToLine(bCoord, aCoord, aBotCoord) / dot(normalize(normalWidth * endBotJoin), normalize(normalWidth.yx * vec2(-startBotJoin.y, startBotJoin.x)));\n\tfloat abClipping = distToLine(aCoord, bCoord, bTopCoord) / dot(normalize(normalWidth * startBotJoin), normalize(normalWidth.yx * vec2(-endBotJoin.y, endBotJoin.x)));\n\n\t//prevent close to reverse direction switch\n\tbool prevReverse = dot(currTangent, prevTangent) <= REVERSE_THRESHOLD && abs(dot(currTangent, prevNormal)) * min(length(prevDiff), length(currDiff)) < length(normalWidth * currNormal);\n\tbool nextReverse = dot(currTangent, nextTangent) <= REVERSE_THRESHOLD && abs(dot(currTangent, nextNormal)) * min(length(nextDiff), length(currDiff)) < length(normalWidth * currNormal);\n\n\tif (prevReverse) {\n\t\t//make join rectangular\n\t\tvec2 miterShift = normalWidth * startJoinDirection * miterLimit * .5;\n\t\tfloat normalAdjust = 1. - min(miterLimit / startMiterRatio, 1.);\n\t\taBotCoord = aCoord + miterShift - normalAdjust * normalWidth * currNormal * .5;\n\t\taTopCoord = aCoord + miterShift + normalAdjust * normalWidth * currNormal * .5;\n\t}\n\telse if (!nextReverse && baClipping > 0. && baClipping < length(normalWidth * endBotJoin)) {\n\t\t//handle miter clipping\n\t\tbTopCoord -= normalWidth * endTopJoin;\n\t\tbTopCoord += normalize(endTopJoin * normalWidth) * baClipping;\n\t}\n\n\tif (nextReverse) {\n\t\t//make join rectangular\n\t\tvec2 miterShift = normalWidth * endJoinDirection * miterLimit * .5;\n\t\tfloat normalAdjust = 1. - min(miterLimit / endMiterRatio, 1.);\n\t\tbBotCoord = bCoord + miterShift - normalAdjust * normalWidth * currNormal * .5;\n\t\tbTopCoord = bCoord + miterShift + normalAdjust * normalWidth * currNormal * .5;\n\t}\n\telse if (!prevReverse && abClipping > 0. && abClipping < length(normalWidth * startBotJoin)) {\n\t\t//handle miter clipping\n\t\taBotCoord -= normalWidth * startBotJoin;\n\t\taBotCoord += normalize(startBotJoin * normalWidth) * abClipping;\n\t}\n\n\tvec2 aTopPosition = (aTopCoord) * adjustedScale + translate;\n\tvec2 aBotPosition = (aBotCoord) * adjustedScale + translate;\n\n\tvec2 bTopPosition = (bTopCoord) * adjustedScale + translate;\n\tvec2 bBotPosition = (bBotCoord) * adjustedScale + translate;\n\n\t//position is normalized 0..1 coord on the screen\n\tvec2 position = (aTopPosition * lineTop + aBotPosition * lineBot) * lineStart + (bTopPosition * lineTop + bBotPosition * lineBot) * lineEnd;\n\n\tstartCoord = aCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\tendCoord = bCoord * scaleRatio + translate * viewport.zw + viewport.xy;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tenableStartMiter = step(dot(currTangent, prevTangent), .5);\n\tenableEndMiter = step(dot(currTangent, nextTangent), .5);\n\n\t//bevel miter cutoffs\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * miterLimit * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * miterLimit * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n\n\t//round miter cutoffs\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tvec2 startMiterWidth = vec2(startJoinDirection) * thickness * abs(dot(startJoinDirection, currNormal)) * .5;\n\t\t\tstartCutoff = vec4(aCoord, aCoord);\n\t\t\tstartCutoff.zw += vec2(-startJoinDirection.y, startJoinDirection.x) / scaleRatio;\n\t\t\tstartCutoff = startCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tstartCutoff += viewport.xyxy;\n\t\t\tstartCutoff += startMiterWidth.xyxy;\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tvec2 endMiterWidth = vec2(endJoinDirection) * thickness * abs(dot(endJoinDirection, currNormal)) * .5;\n\t\t\tendCutoff = vec4(bCoord, bCoord);\n\t\t\tendCutoff.zw += vec2(-endJoinDirection.y, endJoinDirection.x) / scaleRatio;\n\t\t\tendCutoff = endCutoff * scaleRatio.xyxy + translate.xyxy * viewport.zwzw;\n\t\t\tendCutoff += viewport.xyxy;\n\t\t\tendCutoff += endMiterWidth.xyxy;\n\t\t}\n\t}\n}"}),bt=Object.freeze({__proto__:null,default:"precision highp float;\n\nuniform sampler2D dashPattern;\nuniform float dashSize, pixelRatio, thickness, opacity, miterMode;\n\nvarying vec4 fragColor;\nvarying vec2 tangent;\nvarying vec4 startCutoff, endCutoff;\nvarying vec2 startCoord, endCoord;\nvarying float enableStartMiter, enableEndMiter;\n\nfloat distToLine(vec2 p, vec2 a, vec2 b) {\n\tvec2 diff = b - a;\n\tvec2 perp = normalize(vec2(-diff.y, diff.x));\n\treturn dot(p - a, perp);\n}\n\nvoid main() {\n\tfloat alpha = 1., distToStart, distToEnd;\n\tfloat cutoff = thickness * .5;\n\n\t//bevel miter\n\tif (miterMode == 1.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToStart + 1., 0.), 1.);\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < -1.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\talpha *= min(max(distToEnd + 1., 0.), 1.);\n\t\t}\n\t}\n\n\t// round miter\n\telse if (miterMode == 2.) {\n\t\tif (enableStartMiter == 1.) {\n\t\t\tdistToStart = distToLine(gl_FragCoord.xy, startCutoff.xy, startCutoff.zw);\n\t\t\tif (distToStart < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - startCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\n\t\tif (enableEndMiter == 1.) {\n\t\t\tdistToEnd = distToLine(gl_FragCoord.xy, endCutoff.xy, endCutoff.zw);\n\t\t\tif (distToEnd < 0.) {\n\t\t\t\tfloat radius = length(gl_FragCoord.xy - endCoord);\n\n\t\t\t\tif(radius > cutoff + .5) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\talpha -= smoothstep(cutoff - .5, cutoff + .5, radius);\n\t\t\t}\n\t\t}\n\t}\n\n\tfloat t = fract(dot(tangent, gl_FragCoord.xy) / dashSize) * .5 + .25;\n\tfloat dash = texture2D(dashPattern, vec2(t, .5)).r;\n\n\tgl_FragColor = fragColor;\n\tgl_FragColor.a *= alpha * opacity * dash;\n}"}),yt=x(mt),gt=x(bt);var wt=g((function(t,n){var e=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0}),n.createMiterShader=void 0;const r=e(yt),i=e(gt);n.createMiterShader=function(t,n,e){return t(Object.assign(Object.assign({},e),{cull:{enable:!0,face:"back"},vert:r.default,frag:i.default,attributes:{lineEnd:{buffer:n,divisor:0,stride:8,offset:0},lineTop:{buffer:n,divisor:0,stride:8,offset:4},aColor:{buffer:(t,n)=>n.colorBuffer,stride:4,offset:0,divisor:1},bColor:{buffer:(t,n)=>n.colorBuffer,stride:4,offset:4,divisor:1},prevCoord:{buffer:(t,n)=>n.positionBuffer,stride:8,offset:0,divisor:1},aCoord:{buffer:(t,n)=>n.positionBuffer,stride:8,offset:8,divisor:1},bCoord:{buffer:(t,n)=>n.positionBuffer,stride:8,offset:16,divisor:1},nextCoord:{buffer:(t,n)=>n.positionBuffer,stride:8,offset:24,divisor:1}}}))}}));const xt=Object.freeze({__proto__:null,default:"precision highp float;\n\nattribute vec2 position, positionFract;\n\nuniform vec4 color;\nuniform vec2 scale, scaleFract, translate, translateFract;\nuniform float pixelRatio;\nuniform vec4 viewport;\nuniform float opacity;\nuniform float depth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n\tvec2 position = position * scale + translate\n + positionFract * scale + translateFract\n + position * scaleFract\n + positionFract * scaleFract;\n\n\tgl_Position = vec4(position * 2.0 - 1.0, depth, 1);\n\n\tfragColor = color / 255.;\n\tfragColor.a *= opacity;\n}"}),At=Object.freeze({__proto__:null,default:"precision highp float;\n\nvarying vec4 fragColor;\n\nvoid main() {\n\tgl_FragColor = fragColor;\n}"}),Ct=x(xt),jt=x(At);var Ot=g((function(t,n){var e=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0}),n.createFillShader=void 0;const r=e(Ct),i=e(jt);n.createFillShader=function(t,{blend:n,scissor:e,stencil:o,viewport:a,uniforms:u}){return t({blend:n,scissor:e,stencil:o,viewport:a,primitive:"triangles",elements:(t,n)=>n.triangles,offset:0,vert:r.default,frag:i.default,uniforms:Object.assign(Object.assign({},u),{color:(t,n)=>n.fillColor}),attributes:{position:{buffer:(t,n)=>n.positionBuffer,stride:8,offset:8},positionFract:{buffer:(t,n)=>n.positionFractBuffer,stride:8,offset:8}},depth:{enable:!1}})}})),kt=g((function(t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.createShaders=void 0,n.createShaders=function(t){const n=t.buffer({usage:"static",type:"float",data:[0,1,0,0,1,1,1,0]}),e={primitive:"triangle strip",instances:(t,n)=>n.count,count:4,offset:0,uniforms:{miterMode:(t,n)=>n.join===Ft.JoinStyle.Round?2:1,miterLimit:(t,n)=>n.miterLimit,scale:(t,n)=>n.scale,scaleFract:(t,n)=>n.scaleFract,translateFract:(t,n)=>n.translateFract,translate:(t,n)=>n.translate,thickness:(t,n)=>n.thickness,dashPattern:(t,n)=>n.dashTexture,opacity:(t,n)=>n.opacity,pixelRatio:t=>t.pixelRatio,dashSize:(t,n)=>n.dashLength,viewport:({viewportWidth:t,viewportHeight:n},{viewport:{x:e,y:r}})=>[e||0,r||0,t,n],depth:(t,n)=>n.depth},blend:{enable:!0,color:[0,0,0,0],equation:{rgb:"add",alpha:"add"},func:{srcRGB:"src alpha",dstRGB:"one minus src alpha",srcAlpha:"one minus dst alpha",dstAlpha:"one"}},depth:(t,n)=>({enable:!n.overlay}),stencil:{enable:!1},scissor:{enable:!0,box:(t,n)=>n.viewport},viewport:(t,n)=>n.viewport},r=pt.createRectShader(t,n,e);let i=null;try{i=wt.createMiterShader(t,n,e)}catch(t){i=r,console.log("No support for miter lines.")}return{rect:r,miter:i,fill:Ot.createFillShader(t,e)}}})),Tt=g((function(t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.updateDashTextureAndGetLength=void 0;const e=new Uint8Array(8).fill(255);n.updateDashTextureAndGetLength=function(t,n){let r=0,i=null;if(n.length<2)r=1,i=e;else{r=0;for(let t=0;t<n.length;++t)r+=n[t];i=new Uint8Array(2*r);let t=0,e=255;for(let r=0;r<2;r++)for(let r=0;r<n.length;++r){for(let o=0,a=2*n[r]*.5;o<a;++o)i[t++]=e;e^=255}}return t({channels:1,data:i,width:i.length,height:1,mag:"linear",min:"linear"}),r}})),_t=g((function(t,n){var e=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0}),n.updateColorBuffer=void 0;const r=e(R);n.updateColorBuffer=function(t,n,e,i){if(o=e,Array.isArray(o)&&Array.isArray(o[0])){for(let t=0;t<i;t++){let i=r.default(e[t],"uint8");n.set(i,4*t)}n.set(r.default(e[0],"uint8"),4*i)}else{let t=r.default(e,"uint8");for(let e=0;e<i+1;e++)n.set(t,4*e)}var o;t.subdata(n)}})),Ft=g((function(t,n){var e=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0}),n.JoinStyle=void 0;const r=e(M),i=e(z),o=e(R),a=e(J);var u;!function(t){t.Bevel="bevel",t.Round="round",t.Rect="rect"}(u=n.JoinStyle||(n.JoinStyle={})),n.default=function(t){const n=kt.createShaders(t);let e=0;return{createShape(s,f){const l=e;e++;const c=new Float64Array(s.length),d=new Float64Array(s.length+6),v=new Float32Array(d.length),h=new Float32Array(d.length),p=new Uint8Array(2*s.length+4),m=t.buffer({usage:"dynamic",type:"uint8",data:p}),b=t.buffer({usage:"dynamic",type:"float",data:v}),y=t.buffer({usage:"dynamic",type:"float",data:h}),g=t.texture({channels:1,data:new Uint8Array([255]),width:1,height:1,mag:"linear",min:"linear"});return e=>{const w=Object.assign(Object.assign({count:Math.floor(s.length/2),color:"white",fill:null,thickness:1,dashes:null,join:u.Bevel,miterLimit:1,close:!1,opacity:1,overlay:!1,range:[-1,-1,1,1],viewport:{x:0,y:0,width:t._gl.drawingBufferWidth,height:t._gl.drawingBufferHeight},depth:-.01*l},f),e);let{count:x,color:A,close:C,join:j,range:O,dashes:k,fill:T}=w;const _=2*x,F=r.default(s.length>_?s.slice(0,_):s,2);c.set(s),i.default(c,2,F);const M=s[0]===s[_-2]&&s[1]===s[_-1];C?M?(d[0]=c[_-4],d[1]=c[_-3]):(d[0]=c[_-2],d[1]=c[_-1]):(d[0]=c[0],d[1]=c[1]),d.set(c,2),C?M?(d[_+2]=c[2],d[_+3]=c[3],x--):(d[_+2]=c[0],d[_+3]=c[1],d[_+4]=c[2],d[_+5]=c[3]):(d[_+2]=c[_-2],d[_+3]=c[_-1],d[_+4]=c[_-2],d[_+5]=c[_-1]),v.set(d);for(let t=0;t<_;t++)h[t]=d[t]-v[t];b.subdata(v),y.subdata(h);const z=O[2]-O[0],D=O[3]-O[1],S=[(F[2]-F[0])/z,(F[3]-F[1])/D],E=[-O[0]/z+F[0]/z||0,-O[1]/D+F[1]/D||0],B=new Float32Array(S),R=[S[0]-B[0],S[1]-B[1]],J=new Float32Array(E),N=[E[0]-J[0],E[1]-J[1]],V=k?Tt.updateDashTextureAndGetLength(g,k):1;A&&_t.updateColorBuffer(m,p,A,x);const W=Object.assign(Object.assign({},w),{translate:E,translateFract:N,scale:S,scaleFract:R,colorBuffer:m,positionBuffer:b,positionFractBuffer:y,dashLength:V,dashTexture:g,triangles:T?a.default(s):null,fillColor:T?o.default(T,"uint8"):null});t._refresh(),T&&n.fill(W),j===u.Rect?n.rect(W):n.miter(W)}}}}}));const Mt=A(Ft);function zt(t){return t.reduce(((t,n)=>[...t,n.x,n.y]),[])}class Dt{constructor(t,n,e,r,i,o={}){this.createShape=t,this.identifier=n,this.points=e,this.outlineColor=r,this.fillColor=i,this.shapeProps=o;const a=e.toArray();this.pointsArray=new Float64Array(2*a.length),zt(a).forEach(((t,n)=>this.pointsArray[n]=t)),this.initialFillColor=i,this.draw=t(this.pointsArray,Object.assign({count:a.length,thickness:2,join:"rect",fill:this.fillColor,color:this.outlineColor},o))}updateFillColor(t){null!=t&&(this.fillColor="string"==typeof t?t:b.toHexString(t))}updatePoints(t){null!=t&&(this.points=t,zt(t.toArray()).forEach(((t,n)=>this.pointsArray[n]=t)))}}class St{constructor(t,n,e,r,i){this.valid=t,this.worldOrigin=n,this.worldEnd=e,this.origin=r,this.end=i}shortestDistanceFrom(t){return this.toWorldArray().map((n=>u.distance(n,t))).sort(((t,n)=>t-n))[0]}toWorldArray(){return[this.worldOrigin,this.worldEnd]}toArray(){return[this.origin,this.end]}}class Et extends Dt{constructor(t,n,e,r="#000000",i="#000000",o={thickness:3}){super(t,n,e,"string"==typeof r?r:b.toHexString(r),"string"==typeof i?i:b.toHexString(i),o)}}class Bt{constructor(t,n,e){this.valid=t,this.world=n,this.ndc=e}shortestDistanceFrom(t){return this.toWorldArray().map((n=>u.distance(n,t))).sort(((t,n)=>t-n))[0]}toWorldArray(){return this.world}toArray(){return this.ndc}}class Rt extends Dt{constructor(t,n,e,r="#000000",i={join:"round"}){super(t,n,e,"string"==typeof r?r:b.toHexString(r),void 0,i)}}function Jt(t,n,e){const r=u.fromMatrixPosition(t);return new St(e.points.valid,r,e.points.worldBase,u.transformMatrix(r,n.projectionViewMatrix),e.points.base)}function Nt(t,n,e,r=3){if(null!=n&&null!=e){const i=u.distance(n.points.worldBase,e)<u.distance(n.points.worldTip,e)?n.points.worldBase:n.points.worldTip,o=u.scale(.5,u.add(i,e)),a=s.create({origin:o,direction:u.normalize(u.subtract(n.points.worldRight,n.points.worldLeft))}),f=[0,.05,.1,.15].map((t=>function(t,n,e,r){const i=1-r,o=i*i,a=2*i*r,s=r*r;return u.create(o*t.x+a*n.x+s*e.x,o*t.y+a*n.y+s*e.y,o*t.z+a*n.z+s*e.z)}(i,s.at(a,2*r),e,t)));return new Bt(n.points.valid,f,f.map((n=>u.transformMatrix(n,t.projectionViewMatrix))))}}class Vt{constructor(t,n,e,r,i,o,a,u,s){this.valid=t,this.worldBase=n,this.worldLeft=e,this.worldRight=r,this.worldTip=i,this.base=o,this.left=a,this.right=u,this.tip=s}shortestDistanceFrom(t){return this.toWorldArray().map((n=>u.distance(n,t))).sort(((t,n)=>t-n))[0]}toWorldArray(){return[this.worldBase,this.worldLeft,this.worldRight,this.worldTip]}toArray(){return[this.base,this.left,this.tip,this.right,this.base]}}class Wt extends Dt{constructor(t,n,e,r="#000000",i="#000000",o={}){super(t,n,e,"string"==typeof r?r:b.toHexString(r),"string"==typeof i?i:b.toHexString(i),o)}}function It(t,n,e=3){return Pt(t,n,u.back(),u.up(),e)}function Lt(t,n,e=3){return Pt(t,n,u.right(),u.back(),e)}function Ut(t,n,e=3){return Pt(t,n,u.right(),u.up(),e)}function Pt(t,n,e,r,i){const a=u.transformMatrix(u.add(e,r),o.makeRotation(l.fromMatrixRotation(t))),f=u.transformMatrix(e,o.makeRotation(l.fromMatrixRotation(t))),c=u.transformMatrix(r,o.makeRotation(l.fromMatrixRotation(t))),v=u.fromMatrixPosition(t),h=u.add(v,u.scale(10*i,a)),p=s.create({origin:h,direction:f}),m=s.create({origin:h,direction:c}),b=u.cross(f,c),y=u.rotateAboutAxis(d.toRadians(45),s.at(m,-i),b,h),g=u.rotateAboutAxis(d.toRadians(45),s.at(p,i),b,h),w=u.rotateAboutAxis(d.toRadians(45),s.at(m,i),b,h),x=u.rotateAboutAxis(d.toRadians(45),s.at(p,-i),b,h);return new Vt(-1!==u.dot(f,n.direction)&&-1!==u.dot(c,n.direction),y,x,g,w,u.transformMatrix(y,n.projectionViewMatrix),u.transformMatrix(x,n.projectionViewMatrix),u.transformMatrix(g,n.projectionViewMatrix),u.transformMatrix(w,n.projectionViewMatrix))}function qt(t,n,e=3){return $t(t,n,u.right(),e)}function Gt(t,n,e=3){return $t(t,n,u.up(),e)}function Ht(t,n,e=3){return $t(t,n,u.back(),e)}function $t(t,n,e,r){const i=u.transformMatrix(e,o.makeRotation(l.fromMatrixRotation(t))),a=u.fromMatrixPosition(t),f=u.add(a,u.scale(9*r,i)),c=u.normalize(u.cross(i,u.normalize(n.viewVector))),d=s.create({origin:f,direction:c}),v=s.create({origin:f,direction:i}),h=s.at(d,-1.25*r),p=s.at(d,1.25*r),m=s.at(v,3*r);return new Vt(!isNaN(c.x),f,h,p,m,u.transformMatrix(f,n.projectionViewMatrix),u.transformMatrix(h,n.projectionViewMatrix),u.transformMatrix(p,n.projectionViewMatrix),u.transformMatrix(m,n.projectionViewMatrix))}function Qt(t,n,e,r){var i;if(3===t.length){const o=n.scene.camera.isOrthographic()?e.transformPointToOrthographicRay(r,n.image,n.scene.camera):e.transformPointToRay(r,n.image,n.scene.camera),a=u.subtract(t[1],t[0]),s=u.subtract(t[2],t[0]),f=v.epsilon(null!==(i=v.fromVectors([o.direction,o.origin,a,s]))&&void 0!==i?i:v.create(a,s)),l=u.cross(o.direction,s),c=u.dot(a,l);if(!(Math.abs(c)>=f))return!1;const d=u.subtract(o.origin,t[0]),h=u.dot(d,l)/c;if(h<0||h>1)return!1;const p=u.cross(d,a),m=u.dot(o.direction,p)/c;if(m<0||h+m>1)return!1;const b=u.dot(s,p)/c;return!isNaN(b)&&(b>0||n.scene.camera.isOrthographic())}return!1}class Xt{constructor(t,n={}){this.canvasElement=t,this.axisLines=[],this.rotationLines=[],this.translationMeshes=[],this.rotationMeshes=[],this.drawableElements=[],this.hoveredChanged=new y,this.viewport=new C(t.width,t.height),this.xArrowFillColor=n.xArrow,this.yArrowFillColor=n.yArrow,this.zArrowFillColor=n.zArrow,this.hoveredArrowFillColor=n.hovered,this.outlineColor=n.outline}dispose(){var t;null===(t=this.reglFrameDisposable)||void 0===t||t.cancel()}getDrawableElements(){return this.drawableElements}boundsContainsPoint(t){return null!=this.bounds&&null!=this.frame&&c.containsPoints(this.bounds,t)}updateFrame(t,n=!0){this.frame=t,n&&null!=t&&null!=this.transform&&(this.createOrUpdateElements(this.transform,t),this.sortMeshes(t,...this.axisLines,...this.rotationLines,...this.translationMeshes,...this.rotationMeshes),this.draw())}updateCursor(t){this.cursor=t,null!=t&&null!=this.frame?this.updateHovered():this.clearHovered()}updateTransform(t){var n;this.transform=t,null!=t&&null!=this.frame?(this.createOrUpdateElements(t,this.frame),this.sortMeshes(this.frame,...this.axisLines,...this.rotationLines,...this.translationMeshes,...this.rotationMeshes),this.draw()):(this.clear(),null===(n=this.reglFrameDisposable)||void 0===n||n.cancel(),this.reglFrameDisposable=void 0)}updateColors(t){var n,e,r,i,o,a,u,s,f,l,c,d;this.xArrowFillColor=null!==(n=t.xArrow)&&void 0!==n?n:this.xArrowFillColor,this.yArrowFillColor=null!==(e=t.yArrow)&&void 0!==e?e:this.yArrowFillColor,this.zArrowFillColor=null!==(r=t.zArrow)&&void 0!==r?r:this.zArrowFillColor,this.hoveredArrowFillColor=null!==(i=t.hovered)&&void 0!==i?i:this.hoveredArrowFillColor,this.outlineColor=null!==(o=t.outline)&&void 0!==o?o:this.outlineColor,null===(a=this.xArrow)||void 0===a||a.updateFillColor(this.xArrowFillColor),null===(u=this.yArrow)||void 0===u||u.updateFillColor(this.yArrowFillColor),null===(s=this.zArrow)||void 0===s||s.updateFillColor(this.zArrowFillColor),null===(f=this.xRotation)||void 0===f||f.updateFillColor(this.xArrowFillColor),null===(l=this.yRotation)||void 0===l||l.updateFillColor(this.yArrowFillColor),null===(c=this.zRotation)||void 0===c||c.updateFillColor(this.zArrowFillColor),null===(d=this.hoveredElement)||void 0===d||d.updateFillColor(this.hoveredArrowFillColor)}updateDimensions(t){this.viewport=new C(t.width,t.height),null!=this.transform&&null!=this.frame&&this.createOrUpdateElements(this.transform,this.frame)}onHoveredChanged(t){return this.hoveredChanged.on(t)}draw(){var t;null==this.reglFrameDisposable&&(this.reglFrameDisposable=null===(t=this.reglCommand)||void 0===t?void 0:t.frame((()=>{this.drawableElements.forEach((t=>t.draw({fill:t.fillColor})))})))}clear(){var t;null===(t=this.reglCommand)||void 0===t||t.clear({color:[0,0,0,0]})}updateHovered(){var t;const n=this.hoveredElement,e=this.frame;null!=e&&(this.hoveredElement=[...this.translationMeshes,...this.rotationMeshes].filter((t=>t.points.valid)).find((t=>null!=this.cursor&&function(t,n,e,r){return t instanceof Wt&&function(t,n,e,r){return Qt([t.points.worldLeft,t.points.worldRight,t.points.worldTip],n,e,r)||Qt([t.points.worldLeft,t.points.worldRight,t.points.worldBase],n,e,r)}(t,n,e,r)}(t,e,this.viewport,this.cursor))),this.hoveredElement!==n&&(this.hoveredChanged.emit(this.hoveredElement),null===(t=this.hoveredElement)||void 0===t||t.updateFillColor(this.hoveredArrowFillColor),null==n||n.updateFillColor(null==n?void 0:n.initialFillColor)))}clearHovered(){const t=this.hoveredElement;this.hoveredElement=void 0,this.hoveredElement!==t&&(this.hoveredChanged.emit(this.hoveredElement),t.updateFillColor(t.initialFillColor))}sortMeshes(t,...n){const e=(n,e)=>n.points.shortestDistanceFrom(t.scene.camera.position)-e.points.shortestDistanceFrom(t.scene.camera.position);this.axisLines=this.axisLines.sort(e),this.translationMeshes=this.translationMeshes.sort(e),this.rotationMeshes=this.rotationMeshes.sort(e),this.drawableElements=n.filter((t=>t.points.valid)).sort(e).reverse()}createOrUpdateElements(t,n){null==this.xArrow||null==this.yArrow||null==this.zArrow?this.createElements(t,n):this.updateElements(t,n),this.bounds=function(t,...n){let e=a.create(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),r=a.create();return n.filter((t=>t.points.valid)).map((n=>{n.points.toArray().map((n=>t.transformNdcPointToViewport(n))).forEach((t=>{e=a.create(Math.min(t.x,e.x),Math.min(t.y,e.y)),r=a.create(Math.max(t.x,r.x),Math.max(t.y,r.y))}))})),c.fromPoints(e,r)}(this.viewport,...this.rotationMeshes,...this.translationMeshes)}createElements(t,n){this.reglCommand=F({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:e}=Mt(this.reglCommand),r=this.computeTriangleSize(t,n);this.xArrow=new Wt(e,"x-translate",qt(t,n.scene.camera,r),this.outlineColor,this.xArrowFillColor),this.xRotation=new Wt(e,"x-rotate",It(t,n.scene.camera,r),this.outlineColor,this.xArrowFillColor),this.xAxis=new Et(e,"x-axis",Jt(t,n.scene.camera,this.xArrow),this.outlineColor,this.xArrowFillColor),this.yArrow=new Wt(e,"y-translate",Gt(t,n.scene.camera,r),this.outlineColor,this.yArrowFillColor),this.yRotation=new Wt(e,"y-rotate",Lt(t,n.scene.camera,r),this.outlineColor,this.yArrowFillColor),this.yAxis=new Et(e,"y-axis",Jt(t,n.scene.camera,this.yArrow),this.outlineColor,this.yArrowFillColor),this.zArrow=new Wt(e,"z-translate",Ht(t,n.scene.camera,r),this.outlineColor,this.zArrowFillColor),this.zAxis=new Et(e,"z-axis",Jt(t,n.scene.camera,this.zArrow),this.outlineColor,this.zArrowFillColor),this.zRotation=new Wt(e,"z-rotate",Ut(t,n.scene.camera,r),this.outlineColor,this.zArrowFillColor),this.createRotationLines(e,t,n),this.axisLines=[this.xAxis,this.yAxis,this.zAxis],this.translationMeshes=[this.xArrow,this.yArrow,this.zArrow],this.rotationMeshes=[this.xRotation,this.yRotation,this.zRotation]}createRotationLines(t,n,e){var r,i,o,a,u,s;const f=this.computeTriangleSize(n,e),l=Nt(e.scene.camera,this.xRotation,null===(r=this.yArrow)||void 0===r?void 0:r.points.worldTip,f),c=Nt(e.scene.camera,this.xRotation,null===(i=this.zArrow)||void 0===i?void 0:i.points.worldTip,f),d=Nt(e.scene.camera,this.yRotation,null===(o=this.xArrow)||void 0===o?void 0:o.points.worldTip,f),v=Nt(e.scene.camera,this.yRotation,null===(a=this.zArrow)||void 0===a?void 0:a.points.worldTip,f),h=Nt(e.scene.camera,this.zRotation,null===(u=this.xArrow)||void 0===u?void 0:u.points.worldTip,f),p=Nt(e.scene.camera,this.zRotation,null===(s=this.yArrow)||void 0===s?void 0:s.points.worldTip,f);null!=l&&(this.xyRotationLine=new Rt(t,"xy-rotation-line",l,this.outlineColor)),null!=c&&(this.xzRotationLine=new Rt(t,"xz-rotation-line",c,this.outlineColor)),null!=d&&(this.yxRotationLine=new Rt(t,"yx-rotation-line",d,this.outlineColor)),null!=v&&(this.yzRotationLine=new Rt(t,"yz-rotation-line",v,this.outlineColor)),null!=h&&(this.zxRotationLine=new Rt(t,"zx-rotation-line",h,this.outlineColor)),null!=p&&(this.zyRotationLine=new Rt(t,"zy-rotation-line",p,this.outlineColor)),this.rotationLines=[this.xyRotationLine,this.xzRotationLine,this.yxRotationLine,this.yzRotationLine,this.zxRotationLine,this.zyRotationLine].filter((t=>null!=t))}updateElements(t,n){var e,r,i,o,a,u,s,f,l,c,d,v,h,p,m,b,y,g;const w=this.computeTriangleSize(t,n);null!=this.xArrow&&(this.xArrow.updatePoints(qt(t,n.scene.camera,w)),null===(e=this.xAxis)||void 0===e||e.updatePoints(Jt(t,n.scene.camera,this.xArrow))),null===(r=this.xRotation)||void 0===r||r.updatePoints(It(t,n.scene.camera,w)),null!=this.yArrow&&(this.yArrow.updatePoints(Gt(t,n.scene.camera,w)),null===(i=this.yAxis)||void 0===i||i.updatePoints(Jt(t,n.scene.camera,this.yArrow))),null===(o=this.yRotation)||void 0===o||o.updatePoints(Lt(t,n.scene.camera,w)),null!=this.zArrow&&(this.zArrow.updatePoints(Ht(t,n.scene.camera,w)),null===(a=this.zAxis)||void 0===a||a.updatePoints(Jt(t,n.scene.camera,this.zArrow))),null===(u=this.zRotation)||void 0===u||u.updatePoints(Ut(t,n.scene.camera,w)),null===(s=this.xyRotationLine)||void 0===s||s.updatePoints(Nt(n.scene.camera,this.xRotation,null===(f=this.yArrow)||void 0===f?void 0:f.points.worldTip,w)),null===(l=this.xzRotationLine)||void 0===l||l.updatePoints(Nt(n.scene.camera,this.xRotation,null===(c=this.zArrow)||void 0===c?void 0:c.points.worldTip,w)),null===(d=this.yxRotationLine)||void 0===d||d.updatePoints(Nt(n.scene.camera,this.yRotation,null===(v=this.xArrow)||void 0===v?void 0:v.points.worldTip,w)),null===(h=this.yzRotationLine)||void 0===h||h.updatePoints(Nt(n.scene.camera,this.yRotation,null===(p=this.zArrow)||void 0===p?void 0:p.points.worldTip,w)),null===(m=this.zxRotationLine)||void 0===m||m.updatePoints(Nt(n.scene.camera,this.zRotation,null===(b=this.xArrow)||void 0===b?void 0:b.points.worldTip,w)),null===(y=this.zyRotationLine)||void 0===y||y.updatePoints(Nt(n.scene.camera,this.zRotation,null===(g=this.yArrow)||void 0===g?void 0:g.points.worldTip,w))}computeTriangleSize(t,n){const e=u.fromMatrixPosition(t);return n.scene.camera.isOrthographic()?.00625*n.scene.camera.fovHeight:.005*u.magnitude(u.subtract(e,n.scene.camera.position))}}const Yt=class{constructor(e){t(this,e),this.positionChanged=n(this,"positionChanged",7),this.interactionEnded=n(this,"interactionEnded",7),this.interactionStarted=n(this,"interactionStarted",7),this.xArrowColor="#ea3324",this.yArrowColor="#4faf32",this.zArrowColor="#0000ff",this.hoveredColor="#ffff00",this.disabledColor="#cccccc",this.lastAngle=0,this.handleHoveredDrawableChanged=t=>{this.hovered=t},this.handleViewerFrameDrawn=()=>{this.updatePropsFromViewer()},this.handleViewerDimensionsChange=()=>{p((()=>{null!=this.viewer&&null!=this.canvasRef&&(this.canvasRef.width=this.viewer.viewport.width,this.canvasRef.height=this.viewer.viewport.height,this.updateCanvasBounds(this.canvasRef))}))},this.handleResize=()=>{null!=this.canvasRef&&this.updateCanvasBounds(this.canvasRef)},this.handlePointerMove=t=>{if(null==this.dragging){const n=O(a.create(t.clientX,t.clientY),this.getCanvasBounds()),e=this.getTransformWidget();null!=n&&e.boundsContainsPoint(n)?e.updateCursor(n):(e.updateCursor(void 0),this.hovered=void 0)}},this.handleBeginDrag=async t=>{var n,e,r;const i=this.getCanvasBounds();if(null!=this.hovered&&null!=i&&null!=this.viewer&&null!=this.position&&null!=this.viewer.frame){this.dragging=this.hovered;const o=O(a.create(t.clientX,t.clientY),i),u=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=null!=o?d.fromPoints(u,o):0,this.lastWorldPosition=k(o,null===(n=this.viewer)||void 0===n?void 0:n.frame,null===(e=this.viewer)||void 0===e?void 0:e.viewport,this.currentTransform),null===(r=this.controller)||void 0===r||r.beginTransform(),this.interactionStarted.emit(),window.removeEventListener("pointermove",this.handlePointerMove),window.addEventListener("pointermove",this.handleDrag),window.addEventListener("pointerup",this.handleEndTransform)}},this.handleDrag=async t=>{var n,e;t.preventDefault();const r=this.getCanvasBounds();if(null!=this.dragging&&null!=this.lastWorldPosition&&null!=r&&null!=this.viewer&&null!=this.viewer.frame&&null!=this.position){const i=O(a.create(t.clientX,t.clientY),r),o=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix),u=k(i,null===(n=this.viewer)||void 0===n?void 0:n.frame,null===(e=this.viewer)||void 0===e?void 0:e.viewport,this.currentTransform);if(null!=u&&null!=i&&null!=o){const t=d.fromPoints(o,i);this.transform(this.lastWorldPosition,u,t-this.lastAngle),this.lastWorldPosition=u,this.lastAngle=t}}},this.handleEndTransform=async t=>{var n,e;const r=O(a.create(t.clientX,t.clientY),this.getCanvasBounds()),i=this.getTransformWidget();this.dragging=void 0,this.lastWorldPosition=void 0,this.position=null!=this.currentTransform?u.fromMatrixPosition(this.currentTransform):this.position,this.lastAngle=0,i.updateCursor(r),i.updateTransform(this.currentTransform),i.updateColors({xArrow:this.disabledColor,yArrow:this.disabledColor,zArrow:this.disabledColor,hovered:this.disabledColor}),window.removeEventListener("pointermove",this.handleDrag),window.removeEventListener("pointerup",this.handleEndTransform);try{const t=null===(n=this.controller)||void 0===n?void 0:n.getCurrentDelta();await(null===(e=this.controller)||void 0===e?void 0:e.endTransform()),this.interactionEnded.emit(t)}catch(t){console.error("Failed to end transform interaction",t)}window.addEventListener("pointermove",this.handlePointerMove),this.getTransformWidget().updateColors({xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,hovered:this.hoveredColor})},this.updatePropsFromViewer=()=>{const{frame:t}=this.viewer||{};null!=t&&this.getTransformWidget().updateFrame(t,null==this.dragging)},this.setupTransformWidget=t=>{var n,e;return console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${null!=(null===(n=this.viewer)||void 0===n?void 0:n.frame)}]`),this.widget=new Xt(t,{xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,hovered:this.hoveredColor}),null!=this.position&&(this.currentTransform=o.makeTranslation(this.position),this.widget.updateTransform(this.currentTransform)),null!=(null===(e=this.viewer)||void 0===e?void 0:e.frame)&&this.widget.updateFrame(this.viewer.frame,!0),this.hoveredChangeDisposable=this.widget.onHoveredChanged(this.handleHoveredDrawableChanged),this.widget},this.updateCanvasBounds=t=>{m((()=>{this.canvasBounds=t.getBoundingClientRect(),this.getTransformWidget().updateDimensions(t)}))},this.getTransform=(t,n)=>{if(null!=t&&null!=n){const t=o.toObject(null!=this.currentTransform?this.currentTransform:o.makeIdentity());return o.fromObject(Object.assign(Object.assign({},t),{m14:n.x,m24:n.y,m34:n.z}))}if(null!=n)return o.makeTranslation(n)},this.getCanvasBounds=()=>null!=this.canvasBounds?this.canvasBounds:null!=this.canvasRef?(this.updateCanvasBounds(this.canvasRef),this.canvasBounds):void 0,this.getTransformWidget=()=>{if(null==this.widget&&null!=this.canvasRef)return this.setupTransformWidget(this.canvasRef);if(null!=this.widget)return this.widget;throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove),this.canvasResizeObserver=new ResizeObserver(this.handleResize),null!=this.canvasRef&&(this.canvasResizeObserver.observe(this.canvasRef),this.setupTransformWidget(this.canvasRef)),this.handleViewerChanged(this.viewer,void 0),m((()=>{const t=window.getComputedStyle(this.hostEl);this.xArrowColor=t.getPropertyValue("--viewer-transform-widget-x-axis-arrow-color").trim(),this.yArrowColor=t.getPropertyValue("--viewer-transform-widget-y-axis-arrow-color").trim(),this.zArrowColor=t.getPropertyValue("--viewer-transform-widget-z-axis-arrow-color").trim(),this.hoveredColor=t.getPropertyValue("--viewer-transform-widget-hovered-arrow-color").trim(),this.disabledColor=t.getPropertyValue("--viewer-transform-widget-disabled-arrow-color").trim()}))}disconnectedCallback(){var t,n,e;window.removeEventListener("pointermove",this.handlePointerMove),null===(t=this.canvasResizeObserver)||void 0===t||t.disconnect(),null===(n=this.hoveredChangeDisposable)||void 0===n||n.dispose(),null===(e=this.widget)||void 0===e||e.dispose()}handleViewerChanged(t,n){var e;null==n||n.removeEventListener("frameDrawn",this.handleViewerFrameDrawn),null==n||n.removeEventListener("dimensionschange",this.handleViewerDimensionsChange),null==t||t.addEventListener("frameDrawn",this.handleViewerFrameDrawn),null==t||t.addEventListener("dimensionschange",this.handleViewerDimensionsChange),null!=(null==t?void 0:t.stream)&&(null===(e=this.controller)||void 0===e||e.dispose(),this.controller=new j(t.stream))}handlePositionChanged(t,n){var e,r;this.currentTransform=this.getTransform(n,t),this.startingTransform=this.currentTransform,console.debug(`Updating widget position [previous=${JSON.stringify(t)}, current=${JSON.stringify(n)}]`),null===(e=this.widget)||void 0===e||e.updateTransform(this.currentTransform),null==t&&(null===(r=this.controller)||void 0===r||r.clearTransform()),this.positionChanged.emit(t)}render(){var t,n;return e(r,null,e("canvas",{ref:t=>{this.canvasRef=t},class:h("widget",{hovered:null!=this.hovered}),width:null===(t=this.viewer)||void 0===t?void 0:t.viewport.width,height:null===(n=this.viewer)||void 0===n?void 0:n.viewport.height,onPointerDown:this.handleBeginDrag}))}transform(t,n,e){var r,i;null!=this.position&&null!=this.startingTransform&&null!=this.currentTransform&&null!=this.dragging&&null!=this.viewer&&null!=this.viewer.frame&&(this.currentTransform=function(t,n,e,r,i,a){switch(a){case"x-translate":return o.multiply(t,o.makeTranslation(u.create(T(t,n,e,u.right()),0,0)));case"y-translate":return o.multiply(t,o.makeTranslation(u.create(0,T(t,n,e,u.up()),0)));case"z-translate":return o.multiply(t,o.makeTranslation(u.create(0,0,T(t,n,e,u.back()))));case"x-rotate":{const n=l.fromMatrixRotation(t),e=u.transformMatrix(u.right(),o.makeRotation(n)),a=u.transformMatrix(u.left(),o.makeRotation(n)),s=u.dot(r,e)>u.dot(r,a)?e:a;return _(l.fromAxisAngle(s,i),t)}case"y-rotate":{const n=l.fromMatrixRotation(t),e=u.transformMatrix(u.up(),o.makeRotation(n)),a=u.transformMatrix(u.down(),o.makeRotation(n)),s=u.dot(r,e)>u.dot(r,a)?e:a;return _(l.fromAxisAngle(s,i),t)}case"z-rotate":{const n=l.fromMatrixRotation(t),e=u.transformMatrix(u.forward(),o.makeRotation(n)),a=u.transformMatrix(u.back(),o.makeRotation(n)),s=u.dot(r,e)>u.dot(r,a)?e:a;return _(l.fromAxisAngle(s,i),t)}default:return t}}(this.currentTransform,t,n,null===(r=this.viewer)||void 0===r?void 0:r.frame.scene.camera.viewVector,e,this.dragging.identifier),this.getTransformWidget().updateTransform(this.currentTransform),null===(i=this.controller)||void 0===i||i.updateTransform(o.multiply(this.currentTransform,o.invert(this.startingTransform))))}get hostEl(){return i(this)}static get watchers(){return{viewer:["handleViewerChanged"],position:["handlePositionChanged"]}}};Yt.style=":host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-transform-widget-x-axis-arrow-color:var(--x-axis-color);--viewer-transform-widget-y-axis-arrow-color:var(--y-axis-color);--viewer-transform-widget-z-axis-arrow-color:var(--z-axis-color);--viewer-transform-widget-hovered-arrow-color:#ffff00;--viewer-transform-widget-disabled-arrow-color:#cccccc}.widget{position:absolute;top:0;left:0}.widget.hovered{pointer-events:auto}";export{Yt as vertex_viewer_transform_widget}
@@ -1,4 +0,0 @@
1
- /**!
2
- * Copyright (c) 2022 Vertex Software LLC. All rights reserved.
3
- */
4
- import{r as t,h as e,H as i}from"./p-d6fce4c1.js";import{s}from"./p-1fc24ec6.js";import{g as n}from"./p-92fe4417.js";import{p as r}from"./p-927b528b.js";import{a as o,M as a}from"./p-40a9dd7d.js";import"./p-31b87b90.js";import{M as h}from"./p-661b5234.js";import{M as l}from"./p-7f6251da.js";import{p as d}from"./p-70e5e8a8.js";import{a as u}from"./p-3ca4a7c1.js";import{g as p}from"./p-99352cf0.js";import{E as m}from"./p-a380f0c2.js";import{E as c}from"./p-df8fbe56.js";import"./p-dfe5a97d.js";import"./p-65af7a89.js";var v=n.grpc,f=function(){function t(){}return t.serviceName="vertexvis.protobuf.sceneview.v1.SceneViewAPI",t}();function w(t,e){this.serviceHost=t,this.options=e||{}}f.UpdateModelEntities={methodName:"UpdateModelEntities",service:f,requestStream:!1,responseStream:!1,requestType:s.UpdateModelEntitiesRequest,responseType:s.UpdateModelEntitiesResponse},f.Measure={methodName:"Measure",service:f,requestStream:!1,responseStream:!1,requestType:s.MeasureRequest,responseType:s.MeasureResponse},w.prototype.updateModelEntities=function(t,e,i){2===arguments.length&&(i=arguments[1]);var s=v.unary(f.UpdateModelEntities,{request:t,host:this.serviceHost,metadata:e,transport:this.options.transport,debug:this.options.debug,onEnd:function(t){if(i)if(t.status!==v.Code.OK){var e=new Error(t.statusMessage);e.code=t.status,e.metadata=t.trailers,i(e,null)}else i(null,t.message)}});return{cancel:function(){i=null,s.close()}}},w.prototype.measure=function(t,e,i){2===arguments.length&&(i=arguments[1]);var s=v.unary(f.Measure,{request:t,host:this.serviceHost,metadata:e,transport:this.options.transport,debug:this.options.debug,onEnd:function(t){if(i)if(t.status!==v.Code.OK){var e=new Error(t.statusMessage);e.code=t.status,e.metadata=t.trailers,i(e,null)}else i(null,t.message)}});return{cancel:function(){i=null,s.close()}}};var y=w;class b{constructor(t,e){this.rectObserver=new m,this.handlePointerMove=async t=>{await this.isMeasurableEntityUnderPointer(t)?(this.clearCursor(),this.addCursor(u)):this.clearCursor()},this.handlePointerDown=t=>{this.ifNoInteraction(t,(async()=>{await this.isMeasurableEntityUnderPointer(t)?this.measureEntityUnderPointer(t):this.controller.clearEntities()}))},this.controller=t,this.measurableEntityTypes=e}get elementRect(){return this.rectObserver.rect}initialize(t,e){this.element=t,this.api=e,this.rectObserver.observe(t),t.addEventListener("pointermove",this.handlePointerMove),t.addEventListener("pointerdown",this.handlePointerDown)}dispose(){var t,e,i;this.rectObserver.disconnect(),null===(t=this.measurementInteraction)||void 0===t||t.dispose(),this.clearCursor(),null===(e=this.element)||void 0===e||e.removeEventListener("pointermove",this.handlePointerMove),null===(i=this.element)||void 0===i||i.removeEventListener("pointerdown",this.handlePointerDown),this.element=void 0,this.api=void 0}addCursor(t){this.cursor=this.ifInitialized((({api:e})=>e.addCursor(t)))}clearCursor(){var t;null===(t=this.cursor)||void 0===t||t.dispose(),this.cursor=void 0}async isMeasurableEntityUnderPointer(t){var e;const i=p(t,this.elementRect),s=await(null===(e=this.api)||void 0===e?void 0:e.getEntityTypeAtPoint(i));return null!=s&&this.measurableEntityTypes.includes(s)}measureEntityUnderPointer(t){this.ifInitialized((async({api:e})=>{const i=p(t,this.elementRect),[s]=await e.hitItems(i);null!=s?this.controller.addEntity(o.fromHit(s)):this.controller.clearEntities()}))}ifInitialized(t){if(null!=this.element&&null!=this.api)return t({element:this.element,api:this.api});throw new Error("Measurement interaction handler not initialized.")}ifNoInteraction(t,e){const i=d.create(t.clientX,t.clientY);let s=!1;const n=t=>{const e=d.create(t.clientX,t.clientY),n=d.distance(i,e);s=n>2},r=()=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",r),s||e()};window.addEventListener("pointermove",n),window.addEventListener("pointerup",r)}}const C=class{constructor(e){t(this,e),this.measurementModel=new h,this.measurementOverlays=new l,this.measurableEntityTypes=[c.PRECISE_SURFACE,c.IMPRECISE_SURFACE],this.configEnv="platprod"}connectedCallback(){this.setupInteractionHandler()}componentWillLoad(){this.setupController(),this.setupInteractionHandler()}disconnectedCallback(){this.clearInteractionHandler()}handleMeasurableEntityTypesChanged(){this.setupInteractionHandler()}handleMeasurementControllerChanged(){this.setupInteractionHandler()}handleMeasurementModelChanged(){this.setupController()}handleViewerChanged(){this.setupInteractionHandler()}render(){return e(i,null,e("vertex-viewer-measurement-overlays",{viewer:this.viewer,measurementOverlays:this.measurementOverlays}))}setupController(){var t;const e=r(this.configEnv,this.config),i=new y(e.network.sceneViewHost);this.measurementController=new a(this.measurementModel,i,(()=>{var t;return null===(t=this.viewer)||void 0===t?void 0:t.token}),null===(t=this.viewer)||void 0===t?void 0:t.deviceId)}clearInteractionHandler(){var t;null===(t=this.registeredInteractionHandler)||void 0===t||t.then((t=>t.dispose())),this.registeredInteractionHandler=void 0}setupInteractionHandler(){var t;this.clearInteractionHandler(),null!=this.measurementController&&(this.registeredInteractionHandler=null===(t=this.viewer)||void 0===t?void 0:t.registerInteractionHandler(new b(this.measurementController,this.measurableEntityTypes)))}static get watchers(){return{measurableEntityTypes:["handleMeasurableEntityTypesChanged"],measurementController:["handleMeasurementControllerChanged"],measurementModel:["handleMeasurementModelChanged"],viewer:["handleViewerChanged"]}}};C.style=":host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}";export{C as vertex_viewer_measurement_precise}
@@ -1,4 +0,0 @@
1
- /**!
2
- * Copyright (c) 2022 Vertex Software LLC. All rights reserved.
3
- */
4
- import{h as t,r as i,c as e,H as s,g as n}from"./p-d6fce4c1.js";import{v as r,h as a,p as o,l as h}from"./p-70e5e8a8.js";import{m as l}from"./p-3ca4a7c1.js";import{a as d,g as c}from"./p-99352cf0.js";import"./p-1fc24ec6.js";import"./p-92fe4417.js";import{j as u,D as m}from"./p-31b87b90.js";import{M as v}from"./p-661b5234.js";import{M as p}from"./p-7f6251da.js";import{m as w}from"./p-096e60bd.js";import"./p-df8fbe56.js";import{V as f}from"./p-29986489.js";import{E as b,m as g}from"./p-65af7a89.js";import{g as y}from"./p-1abfe4bf.js";import{c as P}from"./p-07aeee89.js";import"./p-dfe5a97d.js";class E{constructor(t,i,e,s){this.stencil=t,this.depthBuffer=i,this.viewport=e,this.camera=s}hitTest(t){const i=this.viewport.transformPointToFrame(t,this.depthBuffer);if(null!=this.stencil){const e=this.viewport.transformPointToFrame(t,this.stencil);return this.stencil.hitTest(e)||this.depthBuffer.hitTest(i)}return this.depthBuffer.hitTest(i)}snapToNearestPixel(t,i){if(null!=this.stencil){const e=this.viewport.transformPointToFrame(t,this.stencil),s=this.stencil.snapToNearestPixel(e,i);return this.viewport.transformPointToViewport(s,this.stencil)}return t}transformPointToWorld(t,{ignoreHitTest:i=!1}={}){const e=this.pickDepthBuffer(t);return null!=e?null==this.camera||this.camera.isPerspective()?this.viewport.transformPointToWorldSpace(t,e):this.viewport.transformPointToOrthographicWorldSpace(t,e):i?null==this.camera||this.camera.isPerspective()?this.viewport.transformPointToWorldSpace(t,this.depthBuffer):this.viewport.transformPointToOrthographicWorldSpace(t,this.depthBuffer):void 0}pickDepthBuffer(t){if(null!=this.stencil){const i=this.viewport.transformPointToFrame(t,this.stencil);if(this.stencil.hitTest(i))return this.stencil.depthBuffer}const i=this.viewport.transformPointToFrame(t,this.depthBuffer);return this.depthBuffer.hitTest(i)?this.depthBuffer:void 0}}class C{constructor(t){this.model=t}newMeasurement(t,i){const e=i.hitTester().transformPointToWorld(t);return null!=e?new x(t,e,this.model):void 0}editMeasurement(t){const i=this.model.getMeasurement();if(null==i)throw new Error("Cannot edit measurement. Measurement is empty.");return"start"===t?new I(i,this.model):new A(i,this.model)}clearIndicator(){this.model.setIndicator(void 0)}moveIndicator(t,i){const e=i.hitTester().transformPointToWorld(t);return this.model.setIndicator(e),null!=e}}class M{constructor(){this.measurementChanged=new b,this.indicatorChanged=new b}static empty(){return new M}getMeasurement(){return this.measurement}setMeasurement(t){this.measurement!==t&&(this.measurement=t,this.measurementChanged.emit(t))}setMeasurementFromValues(t,i,e){if(null!=t&&null!=i){const s=e?k(t,i):S(t,i);this.setMeasurement(s)}else this.setMeasurement(void 0)}onMeasurementChanged(t){return this.measurementChanged.on(t)}getIndicator(){return this.indicator}setIndicator(t){this.indicator!==t&&(this.indicator=t,this.indicatorChanged.emit(t))}onIndicatorChanged(t){return this.indicatorChanged.on(t)}}class x{constructor(t,i,e){this.pt=t,this.world=i,this.model=e,this.hitWorldValid=!0,this.preventUpdate=!1}fetchStartIfMissing(t){null==this.pendingStart&&(this.pendingStart=this.fetchStart(t))}async fetchStart(t){const i=await t.raycaster(),e=await D(i,this.pt);if(null==e){const i=t.hitTester().transformPointToWorld(this.pt);this.hitWorld=i,this.hitWorldValid=!1}else this.hitWorld=e,this.hitWorldValid=!0}update(t,i){var e;if(!this.preventUpdate){this.fetchStartIfMissing(i);const s=i.hitTester().transformPointToWorld(t,{ignoreHitTest:!0}),n=i.hitTester().hitTest(t),r=null!==(e=this.hitWorld)&&void 0!==e?e:this.world;if(null==s)throw new Error("Cannot update new measurement interaction. End point is empty.");this.hitWorldValid&&n?(this.model.setIndicator(s),this.setMeasurement(k(r,s))):(this.model.setIndicator(s),this.setMeasurement(S(r,s)))}}async finish(t,i){var e;this.preventUpdate=!0,this.fetchStartIfMissing(i),await this.pendingStart,this.model.setIndicator(void 0);const s=await i.raycaster(),n=await D(s,t),r=null!==(e=this.hitWorld)&&void 0!==e?e:this.world;if(this.preventUpdate=!1,null==n){const e=i.hitTester().transformPointToWorld(t,{ignoreHitTest:!0});if(null==e)throw new Error("Cannot complete new measurement interaction. End point is empty.");return this.setMeasurement(S(r,e))}return this.setMeasurement(this.hitWorldValid?k(r,n):S(r,n))}setMeasurement(t){return this.model.setMeasurement(t),t}}class j{constructor(t,i){this.measurement=t,this.model=i}update(t,i){const e=i.hitTester().transformPointToWorld(t,{ignoreHitTest:!0}),s=i.hitTester().hitTest(t);if(null==e)throw new Error("Cannot update new measurement interaction. End point is empty.");s?(this.model.setIndicator(e),this.setMeasurement(this.getValidMeasurement(e))):(this.model.setIndicator(e),this.setMeasurement(this.getInvalidMeasurement(e)))}async finish(t,i){const e=await i.raycaster(),s=await D(e,t);if(this.model.setIndicator(void 0),null==s){const e=i.hitTester().transformPointToWorld(t,{ignoreHitTest:!0});if(null==e)throw new Error("Cannot complete edit measurement interaction. End point is empty.");return this.setMeasurement(this.getInvalidMeasurement(e))}return this.setMeasurement(this.getValidMeasurement(s))}setMeasurement(t){return this.model.setMeasurement(t),t}}class I extends j{constructor(t,i){super(t,i)}getInvalidMeasurement(t){return S(t,this.measurement.end)}getValidMeasurement(t){return k(t,this.measurement.end)}}class A extends j{constructor(t,i){super(t,i)}getInvalidMeasurement(t){return S(this.measurement.start,t)}getValidMeasurement(t){return k(this.measurement.start,t)}}async function D(t,i){var e;const s=await t.hitItems(i),[n]=null!==(e=null==s?void 0:s.hits)&&void 0!==e?e:[];if(null!=(null==n?void 0:n.hitPoint)){const t=u(n.hitPoint);if(g.isInvalid(t))throw new Error(`Invalid hit response [${t.errors.join(",")}]`);return t}}function k(t,i){return{start:t,end:i,distance:r.distance(t,i),valid:!0}}function S(t,i){return{start:t,end:i,valid:!1}}const L=({startPt:i,endPt:e,centerPt:s,indicatorPt:n,distance:r,anchorLabelOffset:h,lineCapLength:l,linePointerEvents:c,hideStartAnchor:u,hideEndAnchor:m,onStartAnchorPointerDown:v,onEndAnchorPointerDown:p})=>{const w=null!=i&&null!=e?a.fromPoints(i,e):void 0,f=null!=w&&null!=i&&null!=h?o.add(i,o.polar(-h,w)):void 0,b=null!=w&&null!=e&&null!=h?o.add(e,o.polar(h,w)):void 0;return t("div",null,null!=i&&null!=e&&t("vertex-viewer-measurement-line",{class:P("line",{"hide-start-line-cap":u,"hide-end-line-cap":m}),start:i,end:e,capLength:l,pointerEvents:c}),!u&&null!=i&&t("div",{id:"start-anchor",class:"anchor anchor-start",style:{transform:d(i)},onPointerDown:v},t("slot",{name:"start-anchor"},t("div",{class:"anchor-placeholder"}))),!u&&f&&t("div",{class:"anchor-label anchor-label-start",style:{transform:d(f)}},t("slot",{name:"start-label"})),!m&&null!=e&&t("div",{id:"end-anchor",class:"anchor anchor-end",style:{transform:d(e)},onPointerDown:p},t("slot",{name:"end-anchor"},t("div",{class:"anchor-placeholder"}))),!m&&b&&t("div",{class:"anchor-label anchor-label-end",style:{transform:d(b)}},t("slot",{name:"end-label"})),null!=s&&t("div",{id:"label",class:"distance-label",style:{transform:d(s)}},r),null!=n&&t("div",{class:"indicator",style:{transform:d(n)}},t("slot",{name:"indicator"},t("div",{class:"indicator-placeholder"}))))},T=class{constructor(t){i(this,t),this.editBegin=e(this,"editBegin",7),this.editEnd=e(this,"editEnd",7),this.showAxisReferenceLines=!1,this.snapDistance=16,this.units="millimeters",this.fractionalDigits=2,this.anchorLabelOffset=20,this.lineCapLength=10,this.mode="",this.interactingAnchor="none",this.invalid=!1,this.measurementModel=new v,this.viewport=new f(0,0),this.interactionCount=0,this.invalidateStateCounter=0,this.stateMap={},this.measurementUnits=new m(this.units),this.model=M.empty(),this.controller=new C(this.model),this.overlays=new p,this.isUserInteractingWithModel=!1,this.handleFrameDrawn=()=>{this.invalidateState()},this.clearIndicator=()=>{this.controller.clearIndicator()},this.updateStartAnchor=async t=>{if(this.getStencilBuffer(),0===this.interactionCount){const i=c(t,this.elementBounds),e=this.snapPoint(i,t);this.updateIndicator(e)}},this.newMeasurement=t=>{if(0===this.interactionCount&&0===t.button){const i=t=>{const i=()=>{window.removeEventListener("pointerup",e),window.removeEventListener("pointermove",s)},e=async()=>{i(),t()},s=t=>{t.buttons>0&&i()};window.addEventListener("pointermove",s),window.addEventListener("pointerup",e)},e=t=>{let i=o.create(0,0);const e=e=>{o.distance(i,c(e))>=3&&t()},s=()=>(window.removeEventListener("pointermove",e),void window.removeEventListener("pointerup",s)),n=t=>{i=c(t),window.addEventListener("pointermove",e),window.addEventListener("pointerup",s)};return window.addEventListener("pointerdown",n),{dispose:()=>window.removeEventListener("pointerdown",n)}},s=()=>{const t=e((()=>{var t;this.isUserInteractingWithModel=!0,null===(t=this.stateMap.hoverCursor)||void 0===t||t.dispose()})),i=()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",n),t.dispose()},s=this.createInteractionMoveHandler(),n=async t=>{var e;if(0===t.button)if(this.isUserInteractingWithModel)this.isUserInteractingWithModel=!1;else{const s=this.getHitProvider();if(null!=s){const n=c(t,this.elementBounds),r=this.snapPoint(n,t);await(null===(e=this.interaction)||void 0===e?void 0:e.finish(r,s)),i(),this.updateMeasurementPropsFromModel(),this.endEditing()}}};this.beginEditing("replace","end"),this.newInteractionHandler={dispose:i},window.addEventListener("pointermove",s),window.addEventListener("pointerup",n)},n=this.getHitProvider();if(null!=n){const e=c(t,this.elementBounds),r=this.snapPoint(e,t);this.interaction=this.controller.newMeasurement(r,n),null!=this.interaction&&i(s)}}}}async computeElementMetrics(){var t,i,e;const s=null===(t=this.hostEl.shadowRoot)||void 0===t?void 0:t.getElementById("start-anchor"),n=null===(i=this.hostEl.shadowRoot)||void 0===i?void 0:i.getElementById("end-anchor"),r=null===(e=this.hostEl.shadowRoot)||void 0===e?void 0:e.getElementById("label");return null!=s&&null!=n&&null!=r?{startAnchor:s.getBoundingClientRect(),endAnchor:n.getBoundingClientRect(),label:r.getBoundingClientRect()}:void 0}disconnectedCallback(){var t,i;null===(t=this.stateMap.hoverCursor)||void 0===t||t.dispose(),null===(i=this.newInteractionHandler)||void 0===i||i.dispose()}componentWillLoad(){this.updatePropsFromJson(),this.model.setMeasurementFromValues(this.start,this.end,!this.invalid),this.getStencilBuffer(),this.updateViewport(),this.handleViewerChanged(this.viewer),this.handleModeChanged(),this.computePropsAndState(),this.model.onIndicatorChanged((t=>{this.indicatorPt=t}))}componentDidLoad(){new ResizeObserver((()=>this.updateViewport())).observe(this.hostEl)}componentWillUpdate(){this.computePropsAndState()}render(){return t(s,null,this.showAxisReferenceLines&&t("vertex-viewer-measurement-overlays",{measurementOverlays:this.overlays,viewer:this.viewer}),this.renderMeasurement())}renderMeasurement(){const i=this.computeElementPositions(),{startPt:e,endPt:s,labelPt:n,indicatorPt:r,hideStart:a,hideEnd:o}=i,h=this.formatDistance(this.distance);return t(L,"edit"===this.mode||"replace"===this.mode?{startPt:e,endPt:s,centerPt:n,indicatorPt:r,distance:h,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,hideStartAnchor:a,hideEndAnchor:o,onStartAnchorPointerDown:this.handleEditAnchor("start"),onEndAnchorPointerDown:this.handleEditAnchor("end")}:{startPt:e,endPt:s,centerPt:n,indicatorPt:this.indicatorPt,distance:h,hideStartAnchor:a,hideEndAnchor:o,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,linePointerEvents:"painted"})}handleViewerChanged(t,i){null!=i&&(i.removeEventListener("frameDrawn",this.handleFrameDrawn),this.removeInteractionListeners(i)),null!=t&&(t.addEventListener("frameDrawn",this.handleFrameDrawn),this.addInteractionListeners(t))}handleUnitsChanged(){this.measurementUnits=new m(this.units)}handleCameraChanged(){this.updateCamera()}handleModeChanged(){this.warnIfDepthBuffersDisabled(),null!=this.viewer&&(this.removeInteractionListeners(this.viewer),this.addInteractionListeners(this.viewer))}handleStartChanged(){this.updateInteractionModel()}handleEndChanged(){this.updateInteractionModel()}handleInvalidChanged(){this.updateInteractionModel()}computePropsAndState(){this.updateCamera(),this.updateDepthBuffer(),this.updateMeasurementPropsFromModel(),this.updateOverlays()}updateOverlays(){var t;null===(t=this.overlay)||void 0===t||t.dispose(),this.showAxisReferenceLines&&0===this.interactionCount&&!this.invalid&&null!=this.start&&null!=this.end&&(this.overlay=this.overlays.addDistanceVector(this.start,this.end))}async setCursor(t){var i,e;null===(i=this.stateMap.hoverCursor)||void 0===i||i.dispose(),this.isUserInteractingWithModel||(this.stateMap.hoverCursor=await(null===(e=this.viewer)||void 0===e?void 0:e.addCursor(t)))}computeElementPositions(){return"replace"===this.mode?this.computeReplaceElementPositions():this.computeEditOrViewElementPositions()}computeEditOrViewElementPositions(){const t=this.model.getMeasurement();return null!=this.internalCamera&&null!=t?this.computeLineElementPositions(h.create(t)):{}}computeReplaceElementPositions(){if(null!=this.internalCamera){const t=this.model.getMeasurement(),i=null!=t?this.computeLineElementPositions(h.create(t)):{},e=null!=this.indicatorPt?{indicatorPt:this.viewport.transformWorldToViewport(this.indicatorPt,this.internalCamera.projectionViewMatrix)}:{};return Object.assign(Object.assign({},i),e)}return{}}computeLineElementPositions(t){return null!=this.internalCamera?y(t,this.interactingAnchor,{viewport:this.viewport,camera:this.internalCamera}):{}}updateCamera(){var t,i;this.internalCamera=this.camera||(null===(i=null===(t=this.viewer)||void 0===t?void 0:t.frame)||void 0===i?void 0:i.scene.camera)}async updateDepthBuffer(){var t,i;this.stateMap.depthBuffer=await(null===(i=null===(t=this.viewer)||void 0===t?void 0:t.frame)||void 0===i?void 0:i.depthBuffer())}updateViewport(){const t=this.hostEl.getBoundingClientRect();this.viewport=new f(t.width,t.height),this.elementBounds=t}updatePropsFromJson(){var t,i;this.start=H(null!==(t=this.startJson)&&void 0!==t?t:this.start),this.end=H(null!==(i=this.endJson)&&void 0!==i?i:this.end)}updateInteractionModel(){this.model.setMeasurementFromValues(this.start,this.end,!this.invalid)}invalidateState(){this.invalidateStateCounter=this.invalidateStateCounter+1}async addInteractionListeners(t){const i=await t.getInteractionTarget_DEPRECATED();"replace"===this.mode&&(i.addEventListener("pointermove",this.updateStartAnchor),i.addEventListener("pointerdown",this.newMeasurement),i.addEventListener("pointerleave",this.clearIndicator))}async removeInteractionListeners(t){const i=await t.getInteractionTarget_DEPRECATED();i.removeEventListener("pointermove",this.updateStartAnchor),i.removeEventListener("pointerdown",this.newMeasurement),i.removeEventListener("pointerleave",this.clearIndicator)}handleEditAnchor(t){if("edit"===this.mode||"replace"===this.mode){const i=this.createInteractionMoveHandler(),e=async t=>{var s;const n=this.getHitProvider();if(null!=n){window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",e);const r=c(t,this.elementBounds),a=this.snapPoint(r,t);await(null===(s=this.interaction)||void 0===s?void 0:s.finish(a,n)),this.updateMeasurementPropsFromModel(),this.endEditing()}};return s=>{this.getStencilBuffer(),0===s.button&&(this.beginEditing("edit",t),this.interaction=this.controller.editMeasurement(t),window.addEventListener("pointermove",i),window.addEventListener("pointerup",e))}}}createInteractionMoveHandler(){return t=>{var i;const e=this.getHitProvider();if(null!=this.elementBounds&&null!=e){t.preventDefault(),this.getStencilBuffer();const s=c(t,this.elementBounds),n=this.snapPoint(s,t);null===(i=this.interaction)||void 0===i||i.update(n,e),this.updateMeasurementPropsFromModel()}}}async getStencilBuffer(){var t;const i=await(null===(t=this.viewer)||void 0===t?void 0:t.stencilBuffer.latestAfterInteraction());this.stateMap.stencil=i}snapPoint(t,i){const e=this.getHitProvider();if(null!=e&&!i.shiftKey){const i=Math.max(0,this.snapDistance);return e.hitTester().snapToNearestPixel(t,i)}return t}formatDistance(t){const i=null!=t?this.measurementUnits.convertWorldValueToReal(t):void 0;if(null!=this.labelFormatter)return this.labelFormatter(i);{const t=this.measurementUnits.unit.abbreviatedName;return null==i?"---":`~${i.toFixed(this.fractionalDigits)} ${t}`}}beginEditing(t,i){0===this.interactionCount&&(this.interactingAnchor=i,this.editBegin.emit({type:t,anchor:i})),this.interactionCount=this.interactionCount+1}endEditing(){if(1===this.interactionCount){const t=this.model.getMeasurement();this.interactingAnchor="none",this.updateMeasurementModel(),null!=t&&this.editEnd.emit(t)}this.interactionCount=this.interactionCount-1}updateMeasurementModel(){this.measurementModel.clearOutcome(),this.invalid||null==this.start||null==this.end||this.measurementModel.setOutcome({isApproximate:!0,results:[w(this.start,this.end)]})}getHitProvider(){if(null!=this.hitProvider)return this.hitProvider;{const t=this.getHitTester(),i=this.viewer;if(null!=i&&null!=t)return{hitTester:()=>t,raycaster:async()=>(await i.scene()).raycaster()}}}getHitTester(){const{stencil:t,depthBuffer:i}=this.stateMap;if(null!=i)return new E(t,i,this.viewport,this.internalCamera)}updateMeasurementPropsFromModel(){const t=this.model.getMeasurement();this.start=null==t?void 0:t.start,this.end=null==t?void 0:t.end,this.distance=null==t?void 0:t.distance,this.invalid=null!=t&&!t.valid}updateIndicator(t){var i;const e=this.getHitProvider();null!=e&&this.controller.moveIndicator(t,e)?this.setCursor(l):null===(i=this.stateMap.hoverCursor)||void 0===i||i.dispose()}warnIfDepthBuffersDisabled(){null!=this.viewer&&null==this.viewer.depthBuffers&&console.warn("Measurement editing is disabled. <vertex-viewer> must have its `depth-buffers` attribute set.")}get hostEl(){return n(this)}static get watchers(){return{viewer:["handleViewerChanged"],units:["handleUnitsChanged"],camera:["handleCameraChanged"],mode:["handleModeChanged"],start:["handleStartChanged"],end:["handleEndChanged"],invalid:["handleInvalidChanged"]}}};function H(t){return"string"==typeof t?r.fromJson(t):t}T.style=":host{--viewer-measurement-distance-accent-color:var(--neutral-900);--viewer-measurement-distance-contrast-color:var(--white);--viewer-measurement-distance-invalid-accent-color:var(--red-600);--viewer-measurement-distance-invalid-contrast-color:var(--white);--viewer-measurement-distance-line-stroke-width:1.25px;--viewer-measurement-distance-line-fill-width:2px;--viewer-measurement-distance-distance-border:1px solid\n var(--viewer-measurement-distance-accent-color);--viewer-measurement-distance-distance-border-radius:0.25rem;--viewer-measurement-distance-distance-padding:0.375rem 0.5rem;color:var(--viewer-measurement-distance-accent-color);font-size:0.75rem;position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none}:host([invalid]:not([invalid='false'])){--viewer-measurement-distance-accent-color:var(\n --viewer-measurement-distance-invalid-accent-color\n ) !important;--viewer-measurement-distance-contrast-color:var(\n --viewer-measurement-distance-invalid-contrast-color\n ) !important}.line{--viewer-measurement-line-stroke:var(\n --viewer-measurement-distance-contrast-color\n );--viewer-measurement-line-stroke-opacity:0.75;--viewer-measurement-line-stroke-width:var(\n --viewer-measurement-distance-line-stroke-width\n );--viewer-measurement-line-fill:var(\n --viewer-measurement-distance-accent-color\n );--viewer-measurement-line-fill-width:var(\n --viewer-measurement-distance-line-fill-width\n );position:absolute;width:100%;height:100%}.anchor{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host([interacting-anchor='start']) .anchor-start,:host([interacting-anchor='start']) .anchor-label-start{visibility:hidden}.hide-start-line-cap,:host([interacting-anchor='start']) .line{--viewer-measurement-line-start-cap-visibility:hidden}:host([interacting-anchor='end']) .anchor-end,:host([interacting-anchor='end']) .anchor-label-end{visibility:hidden}.hide-end-line-cap,:host([interacting-anchor='end']) .line{--viewer-measurement-line-end-cap-visibility:hidden}.anchor-label{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host(:not([mode=''])){cursor:inherit}:host(:not([mode=''])) .anchor{cursor:move}:host([mode='']) .anchor{visibility:hidden}.anchor-placeholder{background:var(--viewer-measurement-distance-contrast-color);width:12px;height:12px;border-radius:50%;box-sizing:border-box}:host(:not([mode=''])) .anchor-placeholder{border:2px solid var(--viewer-measurement-distance-accent-color);background:var(--viewer-measurement-distance-contrast-color)}:host([mode='']) .distance-label{color:var(--viewer-measurement-distance-contrast-color);background:var(--viewer-measurement-distance-accent-color)}.distance-label{position:absolute;background:var(--viewer-measurement-distance-contrast-color);border:var(--viewer-measurement-distance-distance-border);border-radius:var(--viewer-measurement-distance-distance-border-radius);padding:var(--viewer-measurement-distance-distance-padding);pointer-events:auto}.indicator{position:absolute}.indicator-placeholder{background:var(--viewer-measurement-distance-accent-color);border:1px solid var(--viewer-measurement-distance-contrast-color);width:6px;height:6px;border-radius:50%;box-sizing:border-box}";export{T as vertex_viewer_measurement_distance}