@deck.gl/aggregation-layers 8.10.0-alpha.7 → 9.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/dist.dev.js +9372 -356
  2. package/dist/es5/aggregation-layer.js +4 -6
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +13 -2
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +12 -1
  7. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  8. package/dist/es5/cpu-grid-layer/grid-aggregator.js +12 -8
  9. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  10. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +27 -13
  11. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  12. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +19 -10
  13. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  14. package/dist/es5/grid-aggregation-layer.js +7 -9
  15. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  16. package/dist/es5/grid-layer/grid-layer.js +1 -1
  17. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  18. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +3 -3
  19. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  20. package/dist/es5/heatmap-layer/heatmap-layer.js +58 -55
  21. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  22. package/dist/es5/heatmap-layer/triangle-layer.js +22 -12
  23. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  24. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  25. package/dist/es5/hexagon-layer/hexagon-layer.js +2 -0
  26. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  27. package/dist/es5/index.js.map +1 -1
  28. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +23 -20
  29. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  30. package/dist/es5/screen-grid-layer/screen-grid-layer.js +6 -6
  31. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  32. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  33. package/dist/es5/utils/bin-sorter.js.map +1 -1
  34. package/dist/es5/utils/cpu-aggregator.js +11 -7
  35. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  36. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +7 -2
  37. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  38. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +83 -60
  39. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  40. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
  41. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  42. package/dist/es5/utils/prop-utils.js.map +1 -1
  43. package/dist/es5/utils/resource-utils.js +12 -23
  44. package/dist/es5/utils/resource-utils.js.map +1 -1
  45. package/dist/esm/aggregation-layer.js +4 -5
  46. package/dist/esm/aggregation-layer.js.map +1 -1
  47. package/dist/esm/contour-layer/contour-layer.js +7 -1
  48. package/dist/esm/contour-layer/contour-layer.js.map +1 -1
  49. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -0
  50. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  51. package/dist/esm/cpu-grid-layer/grid-aggregator.js +2 -1
  52. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +1 -1
  53. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +19 -10
  54. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  55. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +13 -10
  56. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  57. package/dist/esm/grid-aggregation-layer.js +4 -8
  58. package/dist/esm/grid-aggregation-layer.js.map +1 -1
  59. package/dist/esm/grid-layer/grid-layer.js +1 -1
  60. package/dist/esm/grid-layer/grid-layer.js.map +1 -1
  61. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +3 -3
  62. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  63. package/dist/esm/heatmap-layer/heatmap-layer.js +40 -58
  64. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  65. package/dist/esm/heatmap-layer/triangle-layer.js +13 -7
  66. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  67. package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +1 -1
  68. package/dist/esm/hexagon-layer/hexagon-layer.js +1 -0
  69. package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
  70. package/dist/esm/index.js.map +1 -1
  71. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +21 -24
  72. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  73. package/dist/esm/screen-grid-layer/screen-grid-layer.js +5 -8
  74. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
  75. package/dist/esm/utils/aggregation-operation-utils.js.map +1 -1
  76. package/dist/esm/utils/bin-sorter.js.map +1 -1
  77. package/dist/esm/utils/cpu-aggregator.js +11 -7
  78. package/dist/esm/utils/cpu-aggregator.js.map +1 -1
  79. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +1 -1
  80. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +1 -1
  81. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +1 -1
  82. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +1 -1
  83. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +4 -3
  84. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  85. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +62 -51
  86. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  87. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
  88. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +1 -1
  89. package/dist/esm/utils/grid-aggregation-utils.js.map +1 -1
  90. package/dist/esm/utils/prop-utils.js.map +1 -1
  91. package/dist/esm/utils/resource-utils.js +10 -17
  92. package/dist/esm/utils/resource-utils.js.map +1 -1
  93. package/dist.min.js +185 -30
  94. package/package.json +7 -5
  95. package/src/aggregation-layer.ts +7 -6
  96. package/src/contour-layer/contour-layer.ts +25 -9
  97. package/src/cpu-grid-layer/cpu-grid-layer.ts +8 -3
  98. package/src/cpu-grid-layer/{grid-aggregator.js → grid-aggregator.ts} +28 -4
  99. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +38 -27
  100. package/src/gpu-grid-layer/gpu-grid-layer.ts +18 -12
  101. package/src/grid-aggregation-layer.ts +39 -13
  102. package/src/grid-layer/grid-layer.ts +2 -2
  103. package/src/heatmap-layer/heatmap-layer-utils.ts +10 -4
  104. package/src/heatmap-layer/heatmap-layer.ts +74 -67
  105. package/src/heatmap-layer/triangle-layer.ts +26 -22
  106. package/src/hexagon-layer/{hexagon-aggregator.js → hexagon-aggregator.ts} +5 -1
  107. package/src/hexagon-layer/hexagon-layer.ts +8 -5
  108. package/src/index.ts +0 -1
  109. package/src/screen-grid-layer/screen-grid-cell-layer.ts +36 -33
  110. package/src/screen-grid-layer/screen-grid-layer.ts +12 -11
  111. package/src/utils/{aggregation-operation-utils.js → aggregation-operation-utils.ts} +8 -2
  112. package/src/utils/bin-sorter.ts +1 -1
  113. package/src/utils/{cpu-aggregator.js → cpu-aggregator.ts} +42 -30
  114. package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator-constants.js → gpu-grid-aggregator-constants.ts} +4 -4
  115. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +3 -3
  116. package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator.js → gpu-grid-aggregator.ts} +123 -94
  117. package/src/utils/{grid-aggregation-utils.js → grid-aggregation-utils.ts} +1 -1
  118. package/src/utils/resource-utils.ts +59 -0
  119. package/typed/aggregation-layer.d.ts +4 -3
  120. package/typed/aggregation-layer.d.ts.map +1 -1
  121. package/typed/contour-layer/contour-layer.d.ts +19 -5
  122. package/typed/contour-layer/contour-layer.d.ts.map +1 -1
  123. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +8 -3
  124. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
  125. package/typed/cpu-grid-layer/grid-aggregator.d.ts +16 -4
  126. package/typed/cpu-grid-layer/grid-aggregator.d.ts.map +1 -1
  127. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +18 -4
  128. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -1
  129. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +8 -3
  130. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
  131. package/typed/grid-aggregation-layer.d.ts +39 -4
  132. package/typed/grid-aggregation-layer.d.ts.map +1 -1
  133. package/typed/grid-layer/grid-layer.d.ts +2 -2
  134. package/typed/grid-layer/grid-layer.d.ts.map +1 -1
  135. package/typed/heatmap-layer/heatmap-layer-utils.d.ts +7 -5
  136. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  137. package/typed/heatmap-layer/heatmap-layer.d.ts +19 -6
  138. package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  139. package/typed/heatmap-layer/triangle-layer.d.ts +10 -6
  140. package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
  141. package/typed/hexagon-layer/hexagon-aggregator.d.ts +6 -3
  142. package/typed/hexagon-layer/hexagon-aggregator.d.ts.map +1 -1
  143. package/typed/hexagon-layer/hexagon-layer.d.ts +5 -4
  144. package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  145. package/typed/index.d.ts.map +1 -1
  146. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +10 -9
  147. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  148. package/typed/screen-grid-layer/screen-grid-layer.d.ts +6 -4
  149. package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  150. package/typed/utils/aggregation-operation-utils.d.ts +18 -12
  151. package/typed/utils/aggregation-operation-utils.d.ts.map +1 -1
  152. package/typed/utils/bin-sorter.d.ts +1 -1
  153. package/typed/utils/bin-sorter.d.ts.map +1 -1
  154. package/typed/utils/cpu-aggregator.d.ts +28 -14
  155. package/typed/utils/cpu-aggregator.d.ts.map +1 -1
  156. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +1 -1
  157. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +1 -1
  158. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +1 -1
  159. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +1 -1
  160. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +1 -1
  161. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +1 -1
  162. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +1 -1
  163. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +1 -1
  164. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +35 -33
  165. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +1 -1
  166. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +1 -1
  167. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +29 -19
  168. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
  169. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +1 -1
  170. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +1 -1
  171. package/typed/utils/grid-aggregation-utils.d.ts +11 -5
  172. package/typed/utils/grid-aggregation-utils.d.ts.map +1 -1
  173. package/typed/utils/prop-utils.d.ts +1 -1
  174. package/typed/utils/prop-utils.d.ts.map +1 -1
  175. package/typed/utils/resource-utils.d.ts +13 -3
  176. package/typed/utils/resource-utils.d.ts.map +1 -1
  177. package/LICENSE +0 -19
  178. package/src/utils/resource-utils.js +0 -51
  179. /package/src/utils/gpu-grid-aggregation/{aggregate-all-fs.glsl.js → aggregate-all-fs.glsl.ts} +0 -0
  180. /package/src/utils/gpu-grid-aggregation/{aggregate-all-vs.glsl.js → aggregate-all-vs.glsl.ts} +0 -0
  181. /package/src/utils/gpu-grid-aggregation/{aggregate-to-grid-fs.glsl.js → aggregate-to-grid-fs.glsl.ts} +0 -0
  182. /package/src/utils/gpu-grid-aggregation/{aggregate-to-grid-vs.glsl.js → aggregate-to-grid-vs.glsl.ts} +0 -0
  183. /package/src/utils/gpu-grid-aggregation/{gpu-grid-aggregator-utils.js → gpu-grid-aggregator-utils.ts} +0 -0
  184. /package/src/utils/gpu-grid-aggregation/{transform-mean-vs.glsl.js → transform-mean-vs.glsl.ts} +0 -0
  185. /package/src/utils/{prop-utils.js → prop-utils.ts} +0 -0
package/dist.min.js CHANGED
@@ -4,7 +4,152 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['deck'] = factory();
6
6
  else root['deck'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var oi=Object.create;var nt=Object.defineProperty;var ii=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var ui=Object.getPrototypeOf,si=Object.prototype.hasOwnProperty;var $t=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),li=(e,t)=>{for(var r in t)nt(e,r,{get:t[r],enumerable:!0})},rt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ai(t))!si.call(e,i)&&i!==r&&nt(e,i,{get:()=>t[i],enumerable:!(n=ii(t,i))||n.enumerable});return e},Q=(e,t,r)=>(rt(e,t,"default"),r&&rt(r,t,"default")),C=(e,t,r)=>(r=e!=null?oi(ui(e)):{},rt(t||!e||!e.__esModule?nt(r,"default",{value:e,enumerable:!0}):r,e)),fi=e=>rt(nt({},"__esModule",{value:!0}),e);var pe=$t((Fs,Pr)=>{Pr.exports=globalThis.deck});var L=$t((zs,Dr)=>{Dr.exports=globalThis.deck});var H=$t((Us,Er)=>{Er.exports=globalThis.luma});var Ze={};li(Ze,{AGGREGATION_OPERATION:()=>R,CPUGridLayer:()=>ue,ContourLayer:()=>Dt,GPUGridLayer:()=>fe,GridLayer:()=>Bt,HeatmapLayer:()=>Ht,HexagonLayer:()=>bt,ScreenGridLayer:()=>vt,_AggregationLayer:()=>$,_BinSorter:()=>we,_CPUAggregator:()=>Ee,_GPUGridAggregator:()=>z});var k={},Tr=C(pe());Q(k,C(pe()));if(!Tr.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");Q(Ze,k);var ur=C(L());var N=C(H());function Xt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=Math.fround(e),i=e-n;return t[r]=n,t[r+1]=i,t}function Mr(e){return e-Math.fround(e)}function Cr(e){for(var t=new Float32Array(32),r=0;r<4;++r)for(var n=0;n<4;++n){var i=r*4+n;Xt(e[n*4+r],t,i*2)}return t}var Rr=`uniform float ONE;
7
+ "use strict";var __exports__=(()=>{var Ju=Object.create;var Ar=Object.defineProperty;var el=Object.getOwnPropertyDescriptor;var tl=Object.getOwnPropertyNames;var rl=Object.getPrototypeOf,nl=Object.prototype.hasOwnProperty;var Pn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),il=(e,t)=>{for(var r in t)Ar(e,r,{get:t[r],enumerable:!0})},hr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of tl(t))!nl.call(e,o)&&o!==r&&Ar(e,o,{get:()=>t[o],enumerable:!(n=el(t,o))||n.enumerable});return e},xe=(e,t,r)=>(hr(e,t,"default"),r&&hr(r,t,"default")),x=(e,t,r)=>(r=e!=null?Ju(rl(e)):{},hr(t||!e||!e.__esModule?Ar(r,"default",{value:e,enumerable:!0}):r,e)),ol=e=>hr(Ar({},"__esModule",{value:!0}),e);var it=Pn((ag,Xi)=>{Xi.exports=globalThis.deck});var j=Pn((ug,Hi)=>{Hi.exports=globalThis.deck});var F=Pn((_g,Vi)=>{Vi.exports=globalThis.luma});var Er={};il(Er,{AGGREGATION_OPERATION:()=>w,CPUGridLayer:()=>Je,ContourLayer:()=>gn,GPUGridLayer:()=>rt,GridLayer:()=>On,HeatmapLayer:()=>In,HexagonLayer:()=>un,ScreenGridLayer:()=>tn,_AggregationLayer:()=>ge,_BinSorter:()=>vt,_CPUAggregator:()=>yt,_GPUGridAggregator:()=>Q});var Ae={},Wi=x(it());xe(Ae,x(it()));if(!Wi.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");xe(Er,Ae);var Si=x(j());var i=function(e){return e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e}({});var ne=x(F(),1),go=x(F(),1);var $=e=>`${e}`;function fe(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}var Mn={number:{type:"number",validate(e,t){return Number.isFinite(e)&&typeof t=="object"&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:"array",validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function Gi(e){let t={};for(let[r,n]of Object.entries(e))t[r]=al(n);return t}function zi(e,t,r){let n={};for(let[o,a]of Object.entries(t))e&&o in e&&!a.private?(a.validate&&fe(a.validate(e[o],a),`${r}: invalid ${o}`),n[o]=e[o]):n[o]=a.value;return n}function al(e){let t=Ki(e);if(t!=="object")return{value:e,...Mn[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...Mn[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=Ki(e.value),{...e,...Mn[t],type:t}):{type:"object",value:null};throw new Error("props")}function Ki(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var ji=$`\
8
+ #ifdef MODULE_LOGDEPTH
9
+ logdepth_adjustPosition(gl_Position);
10
+ #endif
11
+ `,Yi=$`\
12
+ #ifdef MODULE_MATERIAL
13
+ gl_FragColor = material_filterColor(gl_FragColor);
14
+ #endif
15
+
16
+ #ifdef MODULE_LIGHTING
17
+ gl_FragColor = lighting_filterColor(gl_FragColor);
18
+ #endif
19
+
20
+ #ifdef MODULE_FOG
21
+ gl_FragColor = fog_filterColor(gl_FragColor);
22
+ #endif
23
+
24
+ #ifdef MODULE_PICKING
25
+ gl_FragColor = picking_filterHighlightColor(gl_FragColor);
26
+ gl_FragColor = picking_filterPickingColor(gl_FragColor);
27
+ #endif
28
+
29
+ #ifdef MODULE_LOGDEPTH
30
+ logdepth_setFragDepth();
31
+ #endif
32
+ `;var sl={vertex:ji,fragment:Yi},ki=/void\s+main\s*\([^)]*\)\s*\{\n?/,$i=/}\n?[^{}]*$/,Fn=[],zt="__LUMA_INJECT_DECLARATIONS__";function Zi(e){let t={vertex:{},fragment:{}};for(let r in e){let n=e[r],o=ul(r);typeof n=="string"&&(n={order:0,injection:n}),t[o][r]=n}return t}function ul(e){let t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function jt(e,t,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=t==="vertex";for(let a in r){let s=r[a];s.sort((l,f)=>l.order-f.order),Fn.length=s.length;for(let l=0,f=s.length;l<f;++l)Fn[l]=s[l].injection;let u=`${Fn.join(`
33
+ `)}
34
+ `;switch(a){case"vs:#decl":o&&(e=e.replace(zt,u));break;case"vs:#main-start":o&&(e=e.replace(ki,l=>l+u));break;case"vs:#main-end":o&&(e=e.replace($i,l=>u+l));break;case"fs:#decl":o||(e=e.replace(zt,u));break;case"fs:#main-start":o||(e=e.replace(ki,l=>l+u));break;case"fs:#main-end":o||(e=e.replace($i,l=>u+l));break;default:e=e.replace(a,l=>l+u)}}return e=e.replace(zt,""),n&&(e=e.replace(/\}\s*$/,a=>a+sl[t])),e}var ve=class{static instantiateModules(t){return t.map(r=>{if(r instanceof ve)return r;fe(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${r}' and use it directly.`),fe(r.name,"shader module has no name");let n=new ve(r);return n.dependencies=ve.instantiateModules(r.dependencies||[]),n})}constructor(t){this.name=void 0,this.vs=void 0,this.fs=void 0,this.getModuleUniforms=void 0,this.dependencies=void 0,this.deprecations=void 0,this.defines=void 0,this.injections=void 0,this.uniforms={},this.uniformTypes={};let{name:r,vs:n,fs:o,dependencies:a=[],uniformPropTypes:s={},getUniforms:u,deprecations:l=[],defines:f={},inject:c={}}=t;fe(typeof r=="string"),this.name=r,this.vs=n,this.fs=o,this.getModuleUniforms=u,this.dependencies=ve.instantiateModules(a),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=f,this.injections=Zi(c),s&&(this.uniforms=Gi(s))}getModuleSource(t){let r;switch(t){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:fe(!1)}return`#define MODULE_${this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_")}
35
+ ${r}// END MODULE_${this.name}
36
+
37
+ `}getUniforms(t,r){return this.getModuleUniforms?this.getModuleUniforms(t,r):zi(t,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(t,r){this.deprecations.forEach(n=>{var o;(o=n.regex)!==null&&o!==void 0&&o.test(t)&&(n.deprecated?r.deprecated(n.old,n.new)():r.removed(n.old,n.new)())})}_parseDeprecationDefinitions(t){return t.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),t}_defaultGetUniforms(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r={},n=this.uniforms;for(let o in n){let a=n[o];o in t&&!a.private?(a.validate&&fe(a.validate(t[o],a),`${this.name}: invalid ${o}`),r[o]=t[o]):r[o]=a.value}return r}};function qi(e){let t=ve.instantiateModules(e);return ll(t)}function ll(e){let t={},r={};return Qi({modules:e,level:0,moduleMap:t,moduleDepth:r}),Object.keys(r).sort((n,o)=>r[o]-r[n]).map(n=>t[n])}function Qi(e){let{modules:t,level:r,moduleMap:n,moduleDepth:o}=e;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let a of t)n[a.name]=a,(o[a.name]===void 0||o[a.name]<r)&&(o[a.name]=r);for(let a of t)a.dependencies&&Qi({modules:a.dependencies,level:r+1,moduleMap:n,moduleDepth:o})}function Ji(e){switch(e?.gpu.toLowerCase()){case"apple":return $`\
38
+ #define APPLE_GPU
39
+ // Apple optimizes away the calculation necessary for emulated fp64
40
+ #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
41
+ #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
42
+ // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
43
+ #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
44
+ `;case"nvidia":return $`\
45
+ #define NVIDIA_GPU
46
+ // Nvidia optimizes away the calculation necessary for emulated fp64
47
+ #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
48
+ `;case"intel":return $`\
49
+ #define INTEL_GPU
50
+ // Intel optimizes away the calculation necessary for emulated fp64
51
+ #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
52
+ // Intel's built-in 'tan' function doesn't have acceptable precision
53
+ #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
54
+ // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
55
+ #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
56
+ `;case"amd":return $`\
57
+ #define AMD_GPU
58
+ `;default:return $`\
59
+ #define DEFAULT_GPU
60
+ // Prevent driver from optimizing away the calculation necessary for emulated fp64
61
+ #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
62
+ // Headless Chrome's software shader 'tan' function doesn't have acceptable precision
63
+ #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
64
+ // If the GPU doesn't have full 32 bits precision, will causes overflow
65
+ #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
66
+ `}}function eo(e){let t=$`\
67
+ #if (__VERSION__ > 120)
68
+ # define FEATURE_GLSL_DERIVATIVES
69
+ # define FEATURE_GLSL_DRAW_BUFFERS
70
+ # define FEATURE_GLSL_FRAG_DEPTH
71
+ # define FEATURE_GLSL_TEXTURE_LOD
72
+ #endif // __VERSION
73
+ `;return!e.features.has("webgl2")&&e.features.has("glsl-frag-depth")&&(t+=$`\
74
+
75
+ // FRAG_DEPTH => gl_FragDepth is available
76
+ #ifdef GL_EXT_frag_depth
77
+ # extension GL_EXT_frag_depth : enable
78
+ # define FEATURE_GLSL_FRAG_DEPTH
79
+ # define FRAG_DEPTH
80
+ # define gl_FragDepth gl_FragDepthEXT
81
+ #endif
82
+ `),!e.features.has("webgl2")&&e!==null&&e!==void 0&&e.features.has("glsl-derivatives")&&(t+=$`\
83
+
84
+ // DERIVATIVES => dxdF, dxdY and fwidth are available
85
+ #if defined(GL_OES_standard_derivatives) || defined(FEATURE_GLSL_DERIVATIVES)
86
+ # extension GL_OES_standard_derivatives : enable
87
+ # define FEATURE_GLSL_DERIVATIVES
88
+ # define DERIVATIVES
89
+ #endif
90
+ `),!e.features.has("webgl2")&&e!==null&&e!==void 0&&e.features.has("glsl-frag-data")&&(t+=$`\
91
+
92
+ // DRAW_BUFFERS => gl_FragData[] is available
93
+ #ifdef GL_EXT_draw_buffers
94
+ # extension GL_EXT_draw_buffers : require
95
+ # define FEATURE_GLSL_DRAW_BUFFERS
96
+ # define DRAW_BUFFERS
97
+ #endif
98
+ `),!e.features.has("webgl2")&&e!==null&&e!==void 0&&e.features.has("glsl-texture-lod")&&(t+=$`\
99
+ // TEXTURE_LOD => texture2DLod etc are available
100
+ #ifdef GL_EXT_shader_texture_lod
101
+ # extension GL_EXT_shader_texture_lod : enable
102
+ # define FEATURE_GLSL_TEXTURE_LOD
103
+ # define TEXTURE_LOD
104
+ #endif
105
+ `),t}function to(e,t,r){switch(t){case 300:switch(r){case"vertex":return pr(e,fl);case"fragment":return gl(e);default:throw new Error(`unknown shader stage ${r}`)}case 100:switch(r){case"vertex":return pr(e,_l);case"fragment":return hl(e);default:throw new Error(`unknown shader stage ${r}`)}default:throw new Error(`unknown GLSL version ${t}`)}}var ro=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
106
+ `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],fl=[...ro,[ot("attribute"),"in $1"],[ot("varying"),"out $1"]],cl=[...ro,[ot("varying"),"in $1"]],no=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],_l=[...no,[ot("in"),"attribute $1"],[ot("out"),"varying $1"]],El=[...no,[ot("in"),"varying $1"]],Dn="gl_FragColor",Bn=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,dl=/void\s+main\s*\([^)]*\)\s*\{\n?/;function pr(e,t){for(let[r,n]of t)e=e.replace(r,n);return e}function gl(e){e=pr(e,cl);let t=Bn.exec(e);if(t){let r=t[1];e=e.replace(new RegExp(`\\b${Dn}\\b`,"g"),r)}else{let r="fragmentColor";e=e.replace(dl,n=>`out vec4 ${r};
107
+ ${n}`).replace(new RegExp(`\\b${Dn}\\b`,"g"),r)}return e}function hl(e){e=pr(e,El);let t=Bn.exec(e);if(t){let r=t[1];e=e.replace(Bn,"").replace(new RegExp(`\\b${r}\\b`,"g"),Dn)}return e}function ot(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Un(e,t){let r="";for(let n in e){let o=e[n];if(r+=`void ${o.signature} {
108
+ `,o.header&&(r+=` ${o.header}`),t[n]){let a=t[n];a.sort((s,u)=>s.order-u.order);for(let s of a)r+=` ${s.injection}
109
+ `}o.footer&&(r+=` ${o.footer}`),r+=`}
110
+ `}return r}function wn(e){let t={vertex:{},fragment:{}};for(let r of e){let n,o;typeof r!="string"?(n=r,o=n.hook):(n={},o=r),o=o.trim();let[a,s]=o.split(":"),u=o.replace(/\(.+/,""),l=Object.assign(n,{signature:s});switch(a){case"vs":t.vertex[u]=l;break;case"fs":t.fragment[u]=l;break;default:throw new Error(a)}}return t}var so=`
111
+
112
+ ${zt}
113
+
114
+ `,Al=$`\
115
+ precision highp float;
116
+
117
+ `;function uo(e,t){let{vs:r,fs:n}=t,o=qi(t.modules||[]);switch(e.shaderLanguage){case"glsl":return{vs:oo(e,{...t,source:r,stage:"vertex",modules:o}),fs:oo(e,{...t,source:n,stage:"fragment",modules:o}),getUniforms:ao(o)};case"wgsl":return{vs:io(e,{...t,source:r,stage:"vertex",modules:o}),fs:io(e,{...t,source:n,stage:"fragment",modules:o}),getUniforms:ao(o)}}}function io(e,t){let{source:r,stage:n,modules:o,defines:a={},hookFunctions:s=[],inject:u={},log:l}=t;fe(typeof r=="string","shader source must be a string");let f=r,c={};o.forEach(g=>{Object.assign(c,g.getDefines())}),Object.assign(c,a);let _="",E=wn(s),d={},h={},p={};for(let g in u){let T=typeof u[g]=="string"?{injection:u[g],order:0}:u[g],m=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(m){let R=m[2],S=m[3];R?S==="decl"?h[g]=[T]:p[g]=[T]:d[g]=[T]}else p[g]=[T]}for(let g of o){l&&g.checkDeprecations(f,l);let T=g.getModuleSource(n,"wgsl");_+=T;let m=g.injections[n];for(let R in m){let S=/^(v|f)s:#([\w-]+)$/.exec(R);if(S){let I=S[2]==="decl"?h:p;I[R]=I[R]||[],I[R].push(m[R])}else d[R]=d[R]||[],d[R].push(m[R])}}return _+=so,_=jt(_,n,h),_+=Un(E[n],d),_+=f,_=jt(_,n,p),_}function oo(e,t){let r=t.source.includes("->"),{id:n,source:o,stage:a,language:s=r?"wgsl":"glsl",modules:u,defines:l={},hookFunctions:f=[],inject:c={},transpileToGLSL100:_=!1,prologue:E=!r,log:d}=t;fe(typeof o=="string","shader source must be a string");let h=o.split(`
118
+ `),p=100,g="",T=o;h[0].indexOf("#version ")===0?(p=300,g=h[0],T=h.slice(1).join(`
119
+ `)):g=`#version ${p}`;let m=_?100:p,R={};u.forEach(B=>{Object.assign(R,B.getDefines())}),Object.assign(R,l);let S="";switch(s){case"wgsl":break;case"glsl":S=E?`${g}
120
+ ${pl({id:n,source:o,stage:a})}
121
+ ${`#define SHADER_TYPE_${a.toUpperCase()}`}
122
+ ${Ji(e)}
123
+ ${eo(e)}
124
+ ${Tl(R)}
125
+ ${a==="fragment"?Al:""}
126
+ `:`${g}
127
+ `;break}let y=wn(f),I={},P={},M={};for(let B in c){let z=typeof c[B]=="string"?{injection:c[B],order:0}:c[B],W=/^(v|f)s:(#)?([\w-]+)$/.exec(B);if(W){let L=W[2],re=W[3];L?re==="decl"?P[B]=[z]:M[B]=[z]:I[B]=[z]}else M[B]=[z]}for(let B of u){d&&B.checkDeprecations(T,d);let z=B.getModuleSource(a);S+=z;let W=B.injections[a];for(let L in W){let re=/^(v|f)s:#([\w-]+)$/.exec(L);if(re){let Ie=re[2]==="decl"?P:M;Ie[L]=Ie[L]||[],Ie[L].push(W[L])}else I[L]=I[L]||[],I[L].push(W[L])}}return S+=so,S=jt(S,a,P),S+=Un(y[a],I),S+=T,S=jt(S,a,M),S=to(S,m,a),S.trim()}function ao(e){return function(r){let n={};for(let o of e){let a=o.getUniforms(r,n);Object.assign(n,a)}return n}}function pl(e){let{id:t,source:r,stage:n}=e;return t&&r.indexOf("SHADER_NAME")===-1?`
128
+ #define SHADER_NAME ${t}_${n}
129
+
130
+ `:""}function Tl(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=0,r="";for(let n in e){t===0&&(r+=`
131
+ // APPLICATION DEFINES
132
+ `),t++;let o=e[n];(o||Number.isFinite(o))&&(r+=`#define ${n.toUpperCase()} ${e[n]}
133
+ `)}return t===0&&(r+=`
134
+ `),r}function fo(e,t){if(!t.vs)throw new Error("no vertex shader");let r=lo(e,t.vs),n;return t.fs&&(n=lo(e,t.fs)),{...t,vs:r,fs:n}}function lo(e,t){if(typeof t=="string")return t;switch(e.type){case"webgpu":if(t!=null&&t.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(t!=null&&t.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}}var ce=class{constructor(){this._hookFunctions=[],this._defaultModules=[]}static getDefaultShaderAssembler(){return ce.defaultShaderAssembler=ce.defaultShaderAssembler||new ce,ce.defaultShaderAssembler}addDefaultModule(t){this._defaultModules.find(r=>r.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){let r=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==r)}addShaderHook(t,r){r&&(t=Object.assign(r,{hook:t})),this._hookFunctions.push(t)}assembleShaders(t,r){let n=this._getModuleList(r.modules),o=this._hookFunctions,a=fo(t,r);return uo(t,{...a,modules:n,hookFunctions:o})}_getModuleList(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=new Array(this._defaultModules.length+t.length),n={},o=0;for(let a=0,s=this._defaultModules.length;a<s;++a){let u=this._defaultModules[a],l=u.name;r[o++]=u,n[l]=!0}for(let a=0,s=t.length;a<s;++a){let u=t[a],l=u.name;n[l]||(r[o++]=u,n[l]=!0)}return r.length=o,r}};ce.defaultShaderAssembler=void 0;var Ge=x(F(),1),Tr=class{constructor(t){this.id=void 0,this.userData={},this.topology=void 0,this.bufferLayout=[],this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.id=t.id||(0,Ge.uid)("geometry"),this.topology=t.topology,this.indices=t.indices||null,this.attributes=t.attributes,this.vertexCount=t.vertexCount,this.bufferLayout=t.bufferLayout||[],this.indices&&(0,Ge.assert)(this.indices.usage===Ge.Buffer.INDEX)}destroy(){var t;this.indices.destroy(),this.attributes.positions.destroy(),this.attributes.normals.destroy(),this.attributes.texCoords.destroy(),(t=this.attributes.colors)===null||t===void 0||t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(t){return t.byteLength/12}};function co(e,t){if(t instanceof Tr)return t;let r=Rl(e,t),{attributes:n,bufferLayout:o}=ml(e,t);return new Tr({topology:t.topology||"triangle-list",bufferLayout:o,vertexCount:t.vertexCount,indices:r,attributes:n})}function Rl(e,t){if(!t.indices)return;let r=t.indices.value;return e.createBuffer({usage:Ge.Buffer.INDEX,data:r})}function ml(e,t){let r=[],n={};for(let[a,s]of Object.entries(t.attributes)){let u=a;switch(a){case"POSITION":u="positions";break;case"NORMAL":u="normals";break;case"TEXCOORD_0":u="texCoords";break}n[u]=e.createBuffer({data:s.value,id:`${a}-buffer`}),r.push({name:u,format:`float32x${s.size}`})}let o=t._calculateVertexCount(t.attributes,t.indices);return{attributes:n,bufferLayout:r,vertexCount:o}}var _o=x(F(),1),Pe=class{static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new Pe(t),t._lumaData.defaultPipelineFactory}constructor(t){this.device=void 0,this._hashCounter=0,this._hashes={},this._useCounts={},this._pipelineCache={},this.device=t}createRenderPipeline(t){let r={...Pe.defaultProps,...t},n=this._hashRenderPipeline({...r});if(!this._pipelineCache[n]){let o=this.device.createRenderPipeline({...r,vs:this.device.createShader({stage:"vertex",source:r.vs}),fs:r.fs?this.device.createShader({stage:"fragment",source:r.fs}):null});o.hash=n,this._pipelineCache[n]=o,this._useCounts[n]=0}return this._useCounts[n]++,this._pipelineCache[n]}release(t){let r=t.hash;this._useCounts[r]--,this._useCounts[r]===0&&(this._pipelineCache[r].destroy(),delete this._pipelineCache[r],delete this._useCounts[r])}_createRenderPipeline(t){if(!t.fs)throw new Error("fs");return this.device.createRenderPipeline({...t,vs:this.device.createShader({stage:"vertex",source:t.vs}),fs:t.fs?this.device.createShader({stage:"fragment",source:t.fs}):null})}_hashRenderPipeline(t){let r=this._getHash(t.vs),n=t.fs?this._getHash(t.fs):0,o="-";switch(this.device.info.type){case"webgpu":let a=this._getHash(JSON.stringify(t.parameters)),s=this._getHash(JSON.stringify(t.bufferLayout));return`${r}/${n}V${o}T${t.topology}P${a}BL${s}}`;default:return`${r}/${n}V${o}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}};Pe.defaultProps={..._o.RenderPipeline.defaultProps,vs:void 0,fs:void 0};var J=class{constructor(t,r){this.device=void 0,this.id=void 0,this.vs=void 0,this.fs=void 0,this.pipelineFactory=void 0,this.userData={},this.parameters=void 0,this.topology=void 0,this.bufferLayout=void 0,this.vertexCount=void 0,this.instanceCount=0,this.indexBuffer=null,this.bufferAttributes={},this.constantAttributes={},this.bindings={},this.uniforms={},this.pipeline=void 0,this.vertexArray=void 0,this._pipelineNeedsUpdate="newly created",this._attributeInfos={},this._gpuGeometry=null,this._getModuleUniforms=void 0,this.props=void 0,this.props={...J.defaultProps,...r},r=this.props,this.id=r.id||(0,ne.uid)("model"),this.device=t,Object.assign(this.userData,r.userData);let n={type:t.info.type,shaderLanguage:t.info.shadingLanguages[0],gpu:t.info.gpu,features:t.features},{vs:o,fs:a,getUniforms:s}=this.props.shaderAssembler.assembleShaders(n,this.props);if(this.vs=o,this.fs=a,this._getModuleUniforms=s,this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&(this._gpuGeometry=this.setGeometry(r.geometry)),this.pipelineFactory=r.pipelineFactory||Pe.getDefaultPipelineFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),r.vertexCount&&this.setVertexCount(r.vertexCount),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.indices)throw new Error("Model.props.indices removed. Use props.indexBuffer");r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&this.updateModuleSettings(r.moduleSettings),this.setUniforms(this._getModuleUniforms()),Object.seal(this)}destroy(){this.pipelineFactory.release(this.pipeline)}draw(t){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),this.pipeline.setUniforms(this.uniforms),this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,vertexCount:this.vertexCount,instanceCount:this.instanceCount})}setGeometry(t){let r=t&&co(this.device,t);return this.setTopology(r.topology||"triangle-list"),this.bufferLayout=Eo(this.bufferLayout,r.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r),r}_setGeometryAttributes(t){this.vertexCount=t.vertexCount,this.setAttributes(t.attributes),this.setIndexBuffer(t.indices)}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){this.bufferLayout=this._gpuGeometry?Eo(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){(0,ne.deepEqual)(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setVertexCount(t){this.vertexCount=t}setInstanceCount(t){this.instanceCount=t}setShaderModuleProps(t){let r=this._getModuleUniforms(t),n=Object.keys(r).filter(a=>{let s=r[a];return!(0,ne.isNumberArray)(s)&&typeof s!="number"&&typeof s!="boolean"}),o={};for(let a of n)o[a]=r[a],delete r[a];Object.assign(this.uniforms,r),Object.assign(this.bindings,o)}updateModuleSettings(t){this.setShaderModuleProps(t)}setBindings(t){Object.assign(this.bindings,t)}setUniforms(t){this.pipeline.setUniforms(t),Object.assign(this.uniforms,t)}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t)}setAttributes(t){t.indices&&ne.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);for(let[n,o]of Object.entries(t)){var r;let a=this.bufferLayout.find(l=>l.name===n);if(!a)continue;let s=a.attributes?(r=a.attributes)===null||r===void 0?void 0:r.map(l=>l.attribute):[a.name],u=!1;for(let l of s){let f=this._attributeInfos[l];f&&(this.vertexArray.setBuffer(f.location,o),u=!0)}u||ne.log.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${n}"`)()}}setConstantAttributes(t){for(let[r,n]of Object.entries(t)){let o=this._attributeInfos[r];o?this.vertexArray.setConstant(o.location,n):ne.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)()}}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||t}_updatePipeline(){return this._pipelineNeedsUpdate&&(this.pipeline&&ne.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),this._pipelineNeedsUpdate=!1,this.pipeline=this.device.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:this.device.createShader({id:"{$this.id}-vertex",stage:"vertex",source:this.vs}),fs:this.fs?this.device.createShader({id:"{$this.id}-fragment",stage:"fragment",source:this.fs}):null}),this._attributeInfos=(0,go.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout,this.bufferLayout)),this.pipeline}};J.defaultProps={...ne.RenderPipeline.defaultProps,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:{},geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},pipelineFactory:void 0,shaderAssembler:ce.getDefaultShaderAssembler()};function Eo(e,t){let r=[...e];for(let n of t){let o=r.findIndex(a=>a.name===n.name);o<0?r.push(n):r[o]=n}return r}var Me=class{static isSupported(t){return!1}constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.device=void 0,this.gl=void 0,this.elementCount=0,this.elementIDBuffer=null}destroy(){}delete(){this.destroy()}run(t){let{clearRenderTarget:r=!0}=t||{},n=this._updateDrawOptions(t);r&&n.framebuffer}swap(){}getBuffer(t){return null}getData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}}getFramebuffer(){return null}update(t){}_updateModelProps(t){return{...t}}_buildResourceTransforms(t){}_updateDrawOptions(t){return{...t}}};var at=x(F(),1),be=class{constructor(t){this.id=void 0,this.topology=void 0,this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.userData={};let{attributes:r={},indices:n=null,vertexCount:o=null}=t;this.id=t.id||(0,at.uid)("geometry"),this.topology=t.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[a,s]of Object.entries(r)){let u=ArrayBuffer.isView(s)?{value:s}:s;(0,at.assert)(ArrayBuffer.isView(u.value),`${this._print(a)}: must be typed array or object with value as typed array`),(a==="POSITION"||a==="positions")&&!u.size&&(u.size=3),a==="indices"?((0,at.assert)(!this.indices),this.indices=u):this.attributes[a]=u}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=o||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(t){return`Geometry ${this.id} attribute ${t}`}_setAttributes(t,r){return this}_calculateVertexCount(t,r){if(r)return r.value.length;let n=1/0;for(let o of Object.values(t)){let{value:a,size:s,constant:u}=o;!u&&a&&s>=1&&(n=Math.min(n,a.length/s))}return(0,at.assert)(Number.isFinite(n)),n}};var ho=x(F(),1);var Yt=class extends be{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{id:r=(0,ho.uid)("cube-geometry"),indices:n=!0}=t;super(n?{...t,id:r,topology:"triangle-list",indices:{size:1,value:Sl},attributes:{...Il,...t.attributes}}:{...t,id:r,topology:"triangle-list",indices:void 0,attributes:{...xl,...t.attributes}})}},Sl=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),Ol=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),vl=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),bl=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),Nl=new Float32Array([1,-1,1,1,-1,-1,1,1,-1,-1,-1,1,1,-1,-1,1,1,-1,1,1,-1,-1,-1,1,1,1,1,1,1,-1,1,1,1,-1,-1,1,1,1,-1,1,1,1,1,1,1,-1,-1,1,-1,1,1,1,1,1,1,1,1,1,-1,1,-1,1,-1,1,-1,1,1,1,1,1,-1,1,-1,-1,1,1,-1,1,1,1,-1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,1,1,1,-1,1,1,1,-1,-1,1,1,-1,-1,1,1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,1,-1,1]),Cl=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),yl=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),Il={POSITION:{size:3,value:Ol},NORMAL:{size:3,value:vl},TEXCOORD_0:{size:2,value:bl}},xl={POSITION:{size:4,value:Nl},TEXCOORD_0:{size:2,value:Cl},COLOR_0:{size:3,value:yl}};var Ao=e=>`${e}`;function Ln(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=Math.fround(e),o=e-n;return t[r]=n,t[r+1]=o,t}function po(e){return e-Math.fround(e)}function To(e){let t=new Float32Array(32);for(let r=0;r<4;++r)for(let n=0;n<4;++n){let o=r*4+n;Ln(e[n*4+r],t,o*2)}return t}var Ro=Ao`\
135
+ uniform float ONE;
136
+
137
+ /*
138
+ About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
139
+
140
+ The purpose of this workaround is to prevent shader compilers from
141
+ optimizing away necessary arithmetic operations by swapping their sequences
142
+ or transform the equation to some 'equivalent' from.
143
+
144
+ The method is to multiply an artifical variable, ONE, which will be known to
145
+ the compiler to be 1 only at runtime. The whole expression is then represented
146
+ as a polynomial with respective to ONE. In the coefficients of all terms, only one a
147
+ and one b should appear
148
+
149
+ err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
150
+ */
151
+
152
+ // Divide float number to high and low floats to extend fraction bits
8
153
  vec2 split(float a) {
9
154
  const float SPLIT = 4097.0;
10
155
  float t = a * SPLIT;
@@ -17,11 +162,15 @@ vec2 split(float a) {
17
162
  #endif
18
163
  return vec2(a_hi, a_lo);
19
164
  }
165
+
166
+ // Divide float number again when high float uses too many fraction bits
20
167
  vec2 split2(vec2 a) {
21
168
  vec2 b = split(a.x);
22
169
  b.y += a.y;
23
170
  return b;
24
171
  }
172
+
173
+ // Special sum operation when a > b
25
174
  vec2 quickTwoSum(float a, float b) {
26
175
  #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
27
176
  float sum = (a + b) * ONE;
@@ -32,6 +181,8 @@ vec2 quickTwoSum(float a, float b) {
32
181
  #endif
33
182
  return vec2(sum, err);
34
183
  }
184
+
185
+ // General sum operation
35
186
  vec2 twoSum(float a, float b) {
36
187
  float s = (a + b);
37
188
  #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
@@ -101,6 +252,7 @@ vec2 sub_fp64(vec2 a, vec2 b) {
101
252
 
102
253
  vec2 mul_fp64(vec2 a, vec2 b) {
103
254
  vec2 prod = twoProd(a.x, b.x);
255
+ // y component is for the error
104
256
  prod.y += a.x * b.y;
105
257
  #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
106
258
  prod = split2(prod);
@@ -145,7 +297,10 @@ vec2 sqrt_fp64(vec2 a) {
145
297
  return sum_fp64(vec2(yn, 0.0), prod);
146
298
  #endif
147
299
  }
148
- `;var ci={ONE:1};function gi(){return ci}var de={name:"fp64-arithmetic",vs:Rr,fs:null,getUniforms:gi,fp64ify:Xt,fp64LowPart:Mr,fp64ifyMatrix4:Cr};var xe=C(L());var R={SUM:1,MEAN:2,MIN:3,MAX:4};function Nr(e,t){return e+t}function pi(e,t){return t>e?t:e}function di(e,t){return t<e?t:e}function vi(e,t){if(Number.isFinite(t))return e.length?t:null;var r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(Nr,0)/r.length:null}function mi(e,t){if(Number.isFinite(t))return e.length?e.length*t:null;var r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(Nr,0):null}function hi(e,t){if(Number.isFinite(t))return e.length?t:null;var r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(pi,-1/0):null}function yi(e,t){if(Number.isFinite(t))return e.length?t:null;var r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(di,1/0):null}function ve(e,t,r){var n=R[e]||R.SUM;switch(t=_i(t,r),n){case R.MIN:return function(i){return yi(i,t)};case R.SUM:return function(i){return mi(i,t)};case R.MEAN:return function(i){return vi(i,t)};case R.MAX:return function(i){return hi(i,t)};default:return null}}function _i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Number.isFinite(e)?e:function(r){return t.index=r.index,e(r.source,t)}}function Ir(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function(r){return t.indices=r.map(function(n){return n.index}),e(r.map(function(n){return n.source}),t)}}var me,ot;function he(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Lr={projectPoints:!1,viewport:null,createBufferObjects:!0,moduleSettings:{}},Z=3402823466e29,kt=[32775,32774],qt=[32776,32774],Fr=[32776,32775],Yt=(me={},he(me,R.SUM,32774),he(me,R.MEAN,32774),he(me,R.MIN,kt),he(me,R.MAX,qt),me);var Br={size:1,operation:R.SUM,needMin:!1,needMax:!1,combineMaxMin:!1},zr=4;var Ks={format:34836,type:5126,border:0,mipmaps:!1,parameters:(ot={},he(ot,10240,9728),he(ot,10241,9728),ot),dataFormat:6408,width:1,height:1};var Ur=`#define SHADER_NAME gpu-aggregation-to-grid-vs
300
+ `;var Pl={ONE:1};function Ml(){return Pl}var st={name:"fp64-arithmetic",vs:Ro,getUniforms:Ml,fp64ify:Ln,fp64LowPart:po,fp64ifyMatrix4:To};var Fl="Failed to create WebGL context in Node.js, headless gl returned null",Dl=" luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.",Bl={width:1,height:1,debug:!0,throwOnError:!1},Xn=null;function mo(){return Xn!==null}function So(e){e={...Bl,...e};let{width:t,height:r,webgl1:n,webgl2:o}=e;if(o&&!n)throw new Error("headless-gl does not support WebGL2");if(!Xn)throw new Error(Dl);let a=Xn(t,r,e);if(!a)throw new Error(Fl);return a}var V=x(F(),1);function kt(e){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let t=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,r=e||t;return!!(r&&r.indexOf("Electron")>=0)}function _e(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||kt()}var Rh=globalThis.self||globalThis.window||globalThis.global,mh=globalThis.window||globalThis.self||globalThis.global,Sh=globalThis.document||{},Oh=globalThis.process||{},vh=globalThis.console,Oo=globalThis.navigator||{};var Wn=globalThis;function Rr(e){if(!e&&!_e())return"Node";if(kt(e))return"Electron";let t=e||Oo.userAgent||"";if(t.indexOf("Edge")>-1)return"Edge";let r=t.indexOf("MSIE ")!==-1,n=t.indexOf("Trident/")!==-1;return r||n?"IE":Wn.chrome?"Chrome":Wn.safari?"Safari":Wn.mozInnerScreenX?"Firefox":"Unknown"}var Po=x(F(),1);var $t={};function Ul(e){globalThis.console&&globalThis.console.error&&globalThis.console.error(e)}function wl(e){globalThis.console&&globalThis.console.log&&globalThis.console.log(e)}function Ll(e,t){$t[e]=!0,t!==void 0&&Ul(t)}function Xl(e){let t=e.getError;e.getError=function(){let n;do n=t.apply(e),n!==e.NO_ERROR&&($t[n]=!0);while(n!==e.NO_ERROR);for(n in $t)if($t[n])return delete $t[n],parseInt(n,10);return e.NO_ERROR}}var Zt=function e(t){let r=t.gl;this.ext=t,this.isAlive=!0,this.hasBeenBound=!1,this.elementArrayBuffer=null,this.attribs=new Array(t.maxVertexAttribs);for(let n=0;n<this.attribs.length;n++){let o=new e.VertexAttrib(r);this.attribs[n]=o}this.maxAttrib=0};Zt.VertexAttrib=function(t){this.enabled=!1,this.buffer=null,this.size=4,this.type=t.FLOAT,this.normalized=!1,this.stride=16,this.offset=0,this.cached="",this.recache()};Zt.VertexAttrib.prototype.recache=function(){this.cached=[this.size,this.type,this.normalized,this.stride,this.offset].join(":")};var ze=function(t){let r=this;this.gl=t,Xl(t);let n=this.original={getParameter:t.getParameter,enableVertexAttribArray:t.enableVertexAttribArray,disableVertexAttribArray:t.disableVertexAttribArray,bindBuffer:t.bindBuffer,getVertexAttrib:t.getVertexAttrib,vertexAttribPointer:t.vertexAttribPointer};t.getParameter=function(a){return a===r.VERTEX_ARRAY_BINDING_OES?r.currentVertexArrayObject===r.defaultVertexArrayObject?null:r.currentVertexArrayObject:n.getParameter.apply(this,arguments)},t.enableVertexAttribArray=function(a){let s=r.currentVertexArrayObject;s.maxAttrib=Math.max(s.maxAttrib,a);let u=s.attribs[a];return u.enabled=!0,n.enableVertexAttribArray.apply(this,arguments)},t.disableVertexAttribArray=function(a){let s=r.currentVertexArrayObject;s.maxAttrib=Math.max(s.maxAttrib,a);let u=s.attribs[a];return u.enabled=!1,n.disableVertexAttribArray.apply(this,arguments)},t.bindBuffer=function(a,s){switch(a){case t.ARRAY_BUFFER:r.currentArrayBuffer=s;break;case t.ELEMENT_ARRAY_BUFFER:r.currentVertexArrayObject.elementArrayBuffer=s;break;default:}return n.bindBuffer.apply(this,arguments)},t.getVertexAttrib=function(a,s){let l=r.currentVertexArrayObject.attribs[a];switch(s){case t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:return l.buffer;case t.VERTEX_ATTRIB_ARRAY_ENABLED:return l.enabled;case t.VERTEX_ATTRIB_ARRAY_SIZE:return l.size;case t.VERTEX_ATTRIB_ARRAY_STRIDE:return l.stride;case t.VERTEX_ATTRIB_ARRAY_TYPE:return l.type;case t.VERTEX_ATTRIB_ARRAY_NORMALIZED:return l.normalized;default:return n.getVertexAttrib.apply(this,arguments)}},t.vertexAttribPointer=function(a,s,u,l,f,c){let _=r.currentVertexArrayObject;_.maxAttrib=Math.max(_.maxAttrib,a);let E=_.attribs[a];return E.buffer=r.currentArrayBuffer,E.size=s,E.type=u,E.normalized=l,E.stride=f,E.offset=c,E.recache(),n.vertexAttribPointer.apply(this,arguments)},t.instrumentExtension&&t.instrumentExtension(this,"OES_vertex_array_object"),t.canvas&&t.canvas.addEventListener("webglcontextrestored",()=>{wl("OESVertexArrayObject emulation library context restored"),r.reset_()},!0),this.reset_()};ze.prototype.VERTEX_ARRAY_BINDING_OES=34229;ze.prototype.reset_=function(){if(this.vertexArrayObjects!==void 0)for(let n=0;n<this.vertexArrayObjects.length;++n)this.vertexArrayObjects.isAlive=!1;let r=this.gl;this.maxVertexAttribs=r.getParameter(r.MAX_VERTEX_ATTRIBS),this.defaultVertexArrayObject=new Zt(this),this.currentVertexArrayObject=null,this.currentArrayBuffer=null,this.vertexArrayObjects=[this.defaultVertexArrayObject],this.bindVertexArrayOES(null)};ze.prototype.createVertexArrayOES=function(){let t=new Zt(this);return this.vertexArrayObjects.push(t),t};ze.prototype.deleteVertexArrayOES=function(t){t.isAlive=!1,this.vertexArrayObjects.splice(this.vertexArrayObjects.indexOf(t),1),this.currentVertexArrayObject===t&&this.bindVertexArrayOES(null)};ze.prototype.isVertexArrayOES=function(t){return!!(t&&t instanceof Zt&&t.hasBeenBound&&t.ext===this)};ze.prototype.bindVertexArrayOES=function(t){let r=this.gl;if(t&&!t.isAlive){Ll(r.INVALID_OPERATION,"bindVertexArrayOES: attempt to bind deleted arrayObject");return}let n=this.original,o=this.currentVertexArrayObject;this.currentVertexArrayObject=t||this.defaultVertexArrayObject,this.currentVertexArrayObject.hasBeenBound=!0;let a=this.currentVertexArrayObject;if(o===a)return;(!o||a.elementArrayBuffer!==o.elementArrayBuffer)&&n.bindBuffer.call(r,r.ELEMENT_ARRAY_BUFFER,a.elementArrayBuffer);let s=this.currentArrayBuffer,u=Math.max(o?o.maxAttrib:0,a.maxAttrib);for(let l=0;l<=u;l++){let f=a.attribs[l],c=o?o.attribs[l]:null;if((!o||f.enabled!==c.enabled)&&(f.enabled?n.enableVertexAttribArray.call(r,l):n.disableVertexAttribArray.call(r,l)),f.enabled){let _=!1;(!o||f.buffer!==c.buffer)&&(s!==f.buffer&&(n.bindBuffer.call(r,r.ARRAY_BUFFER,f.buffer),s=f.buffer),_=!0),(_||f.cached!==c.cached)&&n.vertexAttribPointer.call(r,l,f.size,f.type,f.normalized,f.stride,f.offset)}}this.currentArrayBuffer!==s&&n.bindBuffer.call(r,r.ARRAY_BUFFER,this.currentArrayBuffer)};function vo(e){if(typeof e.createVertexArray=="function")return;let t=e.getSupportedExtensions;e.getSupportedExtensions=function(){let o=t.call(this)||[];return o.indexOf("OES_vertex_array_object")<0&&o.push("OES_vertex_array_object"),o};let r=e.getExtension;e.getExtension=function(o){let a=r.call(this,o);return a||(o!=="OES_vertex_array_object"?null:(e.__OESVertexArrayObject||(this.__OESVertexArrayObject=new ze(this)),this.__OESVertexArrayObject))}}var je=x(F(),1);var Hn=x(F(),1),Wl="Invalid WebGLRenderingContext";var Hl="Requires WebGL2";function Vl(e){return typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext||typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function D(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&e._version===2)}function Vn(e){return D(e)?e:null}function bo(e){return(0,Hn.assert)(Vl(e),Wl),e}function mr(e){return(0,Hn.assert)(D(e),Hl),e}var No="OES_element_index",Co="WEBGL_draw_buffers",Kl="EXT_disjoint_timer_query",Gl="EXT_disjoint_timer_query_webgl2",zl="EXT_texture_filter_anisotropic",yo="WEBGL_debug_renderer_info",jl=35723,Yl=4352,kl=36795,$l=34047,Zl=37445,ql=37446,X=e=>D(e)?void 0:0,Ql={[i.READ_BUFFER]:e=>D(e)?void 0:i.COLOR_ATTACHMENT0,[jl]:e=>D(e)?void 0:Yl,[i.RASTERIZER_DISCARD]:X,[i.SAMPLES]:X,[kl]:(e,t)=>{let r=D(e)?e.getExtension(Gl):e.getExtension(Kl);return r&&r.GPU_DISJOINT_EXT?t(r.GPU_DISJOINT_EXT):0},[Zl]:(e,t)=>{let r=e.getExtension(yo);return t(r&&r.UNMASKED_VENDOR_WEBGL||i.VENDOR)},[ql]:(e,t)=>{let r=e.getExtension(yo);return t(r&&r.UNMASKED_RENDERER_WEBGL||i.RENDERER)},[$l]:(e,t)=>{var r;let n=((r=e.luma)===null||r===void 0||(r=r.extensions)===null||r===void 0?void 0:r[zl])||e.getExtension("EXT_texture_filter_anisotropic");return n?t(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1},[i.MAX_3D_TEXTURE_SIZE]:X,[i.MAX_ARRAY_TEXTURE_LAYERS]:X,[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]:X,[i.MAX_COLOR_ATTACHMENTS]:(e,t)=>{if(!D(e)){let r=e.getExtension(Co);return r?t(r.MAX_COLOR_ATTACHMENTS_WEBGL):0}},[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]:X,[i.MAX_COMBINED_UNIFORM_BLOCKS]:X,[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]:X,[i.MAX_DRAW_BUFFERS]:e=>{if(!D(e)){let t=e.getExtension(Co);return t?t.MAX_DRAW_BUFFERS_WEBGL:0}},[i.MAX_ELEMENT_INDEX]:e=>e.getExtension(No)?2147483647:65535,[i.MAX_ELEMENTS_INDICES]:e=>e.getExtension(No)?16777216:65535,[i.MAX_ELEMENTS_VERTICES]:e=>16777216,[i.MAX_FRAGMENT_INPUT_COMPONENTS]:X,[i.MAX_FRAGMENT_UNIFORM_BLOCKS]:X,[i.MAX_FRAGMENT_UNIFORM_COMPONENTS]:X,[i.MAX_SAMPLES]:X,[i.MAX_SERVER_WAIT_TIMEOUT]:X,[i.MAX_TEXTURE_LOD_BIAS]:X,[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]:X,[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]:X,[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]:X,[i.MAX_UNIFORM_BLOCK_SIZE]:X,[i.MAX_UNIFORM_BUFFER_BINDINGS]:X,[i.MAX_VARYING_COMPONENTS]:X,[i.MAX_VERTEX_OUTPUT_COMPONENTS]:X,[i.MAX_VERTEX_UNIFORM_BLOCKS]:X,[i.MAX_VERTEX_UNIFORM_COMPONENTS]:X,[i.MIN_PROGRAM_TEXEL_OFFSET]:X,[i.MAX_PROGRAM_TEXEL_OFFSET]:X,[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT]:X};function Io(e,t,r){let n=Ql[r],o=typeof n=="function"?n(e,t,r):n;return o!==void 0?o:t(r)}function ut(e){if(!e.luma){let r={_polyfilled:!1,_extensions:{}};e.luma=r}return e.luma}var Jl="OES_vertex_array_object",xo="ANGLE_instanced_arrays",ef="WEBGL_draw_buffers",tf="EXT_disjoint_timer_query",rf="EXT_texture_filter_anisotropic",nf="VertexArray requires WebGL2 or OES_vertex_array_object extension";function of(e,t){return{webgl2:D(e),ext:e.getExtension(t)}}var Kn={[Jl]:{meta:{suffix:"OES"},createVertexArray:()=>{(0,je.assert)(!1,nf)},deleteVertexArray:()=>{},bindVertexArray:()=>{},isVertexArray:()=>!1},[xo]:{meta:{suffix:"ANGLE"},vertexAttribDivisor(e,t){(0,je.assert)(t===0,"WebGL instanced rendering not supported")},drawElementsInstanced:()=>{},drawArraysInstanced:()=>{}},[ef]:{meta:{suffix:"WEBGL"},drawBuffers:()=>{(0,je.assert)(!1)}},[tf]:{meta:{suffix:"EXT"},createQuery:()=>{(0,je.assert)(!1)},deleteQuery:()=>{(0,je.assert)(!1)},beginQuery:()=>{(0,je.assert)(!1)},endQuery:()=>{},getQuery(e,t){return this.getQueryObject(e,t)},getQueryParameter(e,t){return this.getQueryObject(e,t)},getQueryObject:(e,t)=>{}}},Sr={readBuffer:(e,t,r)=>{D(e)&&t(r)},getVertexAttrib:(e,t,r,n)=>{let{webgl2:o,ext:a}=of(e,xo),s;switch(n){case i.VERTEX_ATTRIB_ARRAY_INTEGER:s=o?void 0:!1;break;case i.VERTEX_ATTRIB_ARRAY_DIVISOR:s=!o&&!a?0:void 0;break;default:}return s!==void 0?s:t(r,n)},getProgramParameter:(e,t,r,n)=>{if(!D(e))switch(n){case i.TRANSFORM_FEEDBACK_BUFFER_MODE:return i.SEPARATE_ATTRIBS;case i.TRANSFORM_FEEDBACK_VARYINGS:return 0;case i.ACTIVE_UNIFORM_BLOCKS:return 0;default:}return t(r,n)},getInternalformatParameter:(e,t,r,n,o)=>{if(!D(e))switch(o){case i.SAMPLES:return new Int32Array([0]);default:}return e.getInternalformatParameter(r,n,o)},getTexParameter(e,t,r,n){switch(n){case i.TEXTURE_MAX_ANISOTROPY_EXT:let o=ut(e),{_extensions:a}=o,s=a[rf];n=s&&s.TEXTURE_MAX_ANISOTROPY_EXT||i.TEXTURE_MAX_ANISOTROPY_EXT;break;default:}return t(r,n)},getParameter:Io,hint(e,t,r,n){return t(r,n)}};function Mo(e){let t=ut(e);return t._polyfilled||(vo(e),af(e),sf(e,Kn),lf(e,{target:t,target2:e}),t._polyfilled=!0),e}function af(e){let t=ut(e),r=e.getSupportedExtensions()||[];for(let n of r){let o=e.getExtension(n);t._extensions[n]=o}}function sf(e,t){let r=ut(e);for(let n of Object.getOwnPropertyNames(t))n!=="overrides"&&uf(e,{extension:n,target:r,target2:e})}function uf(e,t){let{extension:r,target:n,target2:o}=t,a=Kn[r];(0,Po.assert)(a);let{meta:s={}}=a,{suffix:u=""}=s,l=e.getExtension(r);for(let f of Object.keys(a)){let c=`${f}${u}`,_=null;f==="meta"||typeof e[f]=="function"||(l&&typeof l[c]=="function"?_=function(){return l[c](...arguments)}:typeof a[f]=="function"&&(_=a[f].bind(n))),_&&(n[f]=_,o[f]=_)}}function lf(e,t){let{target:r,target2:n}=t;Object.keys(Sr).forEach(o=>{if(typeof Sr[o]=="function"){let a=e[o]?e[o].bind(e):()=>{},s=Sr[o].bind(null,e,a);r[o]=s,n[o]=s}})}var Qt=x(F(),1);var Or={[i.BLEND]:!1,[i.BLEND_COLOR]:new Float32Array([0,0,0,0]),[i.BLEND_EQUATION_RGB]:i.FUNC_ADD,[i.BLEND_EQUATION_ALPHA]:i.FUNC_ADD,[i.BLEND_SRC_RGB]:i.ONE,[i.BLEND_DST_RGB]:i.ZERO,[i.BLEND_SRC_ALPHA]:i.ONE,[i.BLEND_DST_ALPHA]:i.ZERO,[i.COLOR_CLEAR_VALUE]:new Float32Array([0,0,0,0]),[i.COLOR_WRITEMASK]:[!0,!0,!0,!0],[i.CULL_FACE]:!1,[i.CULL_FACE_MODE]:i.BACK,[i.DEPTH_TEST]:!1,[i.DEPTH_CLEAR_VALUE]:1,[i.DEPTH_FUNC]:i.LESS,[i.DEPTH_RANGE]:new Float32Array([0,1]),[i.DEPTH_WRITEMASK]:!0,[i.DITHER]:!0,[i.CURRENT_PROGRAM]:null,[i.FRAMEBUFFER_BINDING]:null,[i.RENDERBUFFER_BINDING]:null,[i.VERTEX_ARRAY_BINDING]:null,[i.ARRAY_BUFFER_BINDING]:null,[i.FRONT_FACE]:i.CCW,[i.GENERATE_MIPMAP_HINT]:i.DONT_CARE,[i.LINE_WIDTH]:1,[i.POLYGON_OFFSET_FILL]:!1,[i.POLYGON_OFFSET_FACTOR]:0,[i.POLYGON_OFFSET_UNITS]:0,[i.SAMPLE_ALPHA_TO_COVERAGE]:!1,[i.SAMPLE_COVERAGE]:!1,[i.SAMPLE_COVERAGE_VALUE]:1,[i.SAMPLE_COVERAGE_INVERT]:!1,[i.SCISSOR_TEST]:!1,[i.SCISSOR_BOX]:new Int32Array([0,0,1024,1024]),[i.STENCIL_TEST]:!1,[i.STENCIL_CLEAR_VALUE]:0,[i.STENCIL_WRITEMASK]:4294967295,[i.STENCIL_BACK_WRITEMASK]:4294967295,[i.STENCIL_FUNC]:i.ALWAYS,[i.STENCIL_REF]:0,[i.STENCIL_VALUE_MASK]:4294967295,[i.STENCIL_BACK_FUNC]:i.ALWAYS,[i.STENCIL_BACK_REF]:0,[i.STENCIL_BACK_VALUE_MASK]:4294967295,[i.STENCIL_FAIL]:i.KEEP,[i.STENCIL_PASS_DEPTH_FAIL]:i.KEEP,[i.STENCIL_PASS_DEPTH_PASS]:i.KEEP,[i.STENCIL_BACK_FAIL]:i.KEEP,[i.STENCIL_BACK_PASS_DEPTH_FAIL]:i.KEEP,[i.STENCIL_BACK_PASS_DEPTH_PASS]:i.KEEP,[i.VIEWPORT]:[0,0,1024,1024],[i.PACK_ALIGNMENT]:4,[i.UNPACK_ALIGNMENT]:4,[i.UNPACK_FLIP_Y_WEBGL]:!1,[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:!1,[i.UNPACK_COLORSPACE_CONVERSION_WEBGL]:i.BROWSER_DEFAULT_WEBGL,[i.TRANSFORM_FEEDBACK_BINDING]:null,[i.COPY_READ_BUFFER_BINDING]:null,[i.COPY_WRITE_BUFFER_BINDING]:null,[i.PIXEL_PACK_BUFFER_BINDING]:null,[i.PIXEL_UNPACK_BUFFER_BINDING]:null,[i.FRAGMENT_SHADER_DERIVATIVE_HINT]:i.DONT_CARE,[i.READ_FRAMEBUFFER_BINDING]:null,[i.RASTERIZER_DISCARD]:!1,[i.PACK_ROW_LENGTH]:0,[i.PACK_SKIP_PIXELS]:0,[i.PACK_SKIP_ROWS]:0,[i.UNPACK_ROW_LENGTH]:0,[i.UNPACK_IMAGE_HEIGHT]:0,[i.UNPACK_SKIP_PIXELS]:0,[i.UNPACK_SKIP_ROWS]:0,[i.UNPACK_SKIP_IMAGES]:0},pe=(e,t,r)=>t?e.enable(r):e.disable(r),Fo=(e,t,r)=>e.hint(r,t),ie=(e,t,r)=>e.pixelStorei(r,t),Do=(e,t,r)=>{let n;return r===i.FRAMEBUFFER_BINDING?n=D(e)?i.DRAW_FRAMEBUFFER:i.FRAMEBUFFER:n=i.READ_FRAMEBUFFER,e.bindFramebuffer(n,t)},qt=(e,t,r)=>{let o={[i.ARRAY_BUFFER_BINDING]:i.ARRAY_BUFFER,[i.COPY_READ_BUFFER_BINDING]:i.COPY_READ_BUFFER,[i.COPY_WRITE_BUFFER_BINDING]:i.COPY_WRITE_BUFFER,[i.PIXEL_PACK_BUFFER_BINDING]:i.PIXEL_PACK_BUFFER,[i.PIXEL_UNPACK_BUFFER_BINDING]:i.PIXEL_UNPACK_BUFFER}[r];e.bindBuffer(o,t)};function Gn(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}var Bo={[i.BLEND]:pe,[i.BLEND_COLOR]:(e,t)=>e.blendColor(...t),[i.BLEND_EQUATION_RGB]:"blendEquation",[i.BLEND_EQUATION_ALPHA]:"blendEquation",[i.BLEND_SRC_RGB]:"blendFunc",[i.BLEND_DST_RGB]:"blendFunc",[i.BLEND_SRC_ALPHA]:"blendFunc",[i.BLEND_DST_ALPHA]:"blendFunc",[i.COLOR_CLEAR_VALUE]:(e,t)=>e.clearColor(...t),[i.COLOR_WRITEMASK]:(e,t)=>e.colorMask(...t),[i.CULL_FACE]:pe,[i.CULL_FACE_MODE]:(e,t)=>e.cullFace(t),[i.DEPTH_TEST]:pe,[i.DEPTH_CLEAR_VALUE]:(e,t)=>e.clearDepth(t),[i.DEPTH_FUNC]:(e,t)=>e.depthFunc(t),[i.DEPTH_RANGE]:(e,t)=>e.depthRange(...t),[i.DEPTH_WRITEMASK]:(e,t)=>e.depthMask(t),[i.DITHER]:pe,[i.FRAGMENT_SHADER_DERIVATIVE_HINT]:Fo,[i.CURRENT_PROGRAM]:(e,t)=>e.useProgram(t),[i.RENDERBUFFER_BINDING]:(e,t)=>e.bindRenderbuffer(i.RENDERBUFFER,t),[i.TRANSFORM_FEEDBACK_BINDING]:(e,t)=>{var r,n;return(r=(n=e).bindTransformFeedback)===null||r===void 0?void 0:r.call(n,i.TRANSFORM_FEEDBACK,t)},[i.VERTEX_ARRAY_BINDING]:(e,t)=>e.bindVertexArray(t),[i.FRAMEBUFFER_BINDING]:Do,[i.READ_FRAMEBUFFER_BINDING]:Do,[i.ARRAY_BUFFER_BINDING]:qt,[i.COPY_READ_BUFFER_BINDING]:qt,[i.COPY_WRITE_BUFFER_BINDING]:qt,[i.PIXEL_PACK_BUFFER_BINDING]:qt,[i.PIXEL_UNPACK_BUFFER_BINDING]:qt,[i.FRONT_FACE]:(e,t)=>e.frontFace(t),[i.GENERATE_MIPMAP_HINT]:Fo,[i.LINE_WIDTH]:(e,t)=>e.lineWidth(t),[i.POLYGON_OFFSET_FILL]:pe,[i.POLYGON_OFFSET_FACTOR]:"polygonOffset",[i.POLYGON_OFFSET_UNITS]:"polygonOffset",[i.RASTERIZER_DISCARD]:pe,[i.SAMPLE_ALPHA_TO_COVERAGE]:pe,[i.SAMPLE_COVERAGE]:pe,[i.SAMPLE_COVERAGE_VALUE]:"sampleCoverage",[i.SAMPLE_COVERAGE_INVERT]:"sampleCoverage",[i.SCISSOR_TEST]:pe,[i.SCISSOR_BOX]:(e,t)=>e.scissor(...t),[i.STENCIL_TEST]:pe,[i.STENCIL_CLEAR_VALUE]:(e,t)=>e.clearStencil(t),[i.STENCIL_WRITEMASK]:(e,t)=>e.stencilMaskSeparate(i.FRONT,t),[i.STENCIL_BACK_WRITEMASK]:(e,t)=>e.stencilMaskSeparate(i.BACK,t),[i.STENCIL_FUNC]:"stencilFuncFront",[i.STENCIL_REF]:"stencilFuncFront",[i.STENCIL_VALUE_MASK]:"stencilFuncFront",[i.STENCIL_BACK_FUNC]:"stencilFuncBack",[i.STENCIL_BACK_REF]:"stencilFuncBack",[i.STENCIL_BACK_VALUE_MASK]:"stencilFuncBack",[i.STENCIL_FAIL]:"stencilOpFront",[i.STENCIL_PASS_DEPTH_FAIL]:"stencilOpFront",[i.STENCIL_PASS_DEPTH_PASS]:"stencilOpFront",[i.STENCIL_BACK_FAIL]:"stencilOpBack",[i.STENCIL_BACK_PASS_DEPTH_FAIL]:"stencilOpBack",[i.STENCIL_BACK_PASS_DEPTH_PASS]:"stencilOpBack",[i.VIEWPORT]:(e,t)=>e.viewport(...t),[i.PACK_ALIGNMENT]:ie,[i.UNPACK_ALIGNMENT]:ie,[i.UNPACK_FLIP_Y_WEBGL]:ie,[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:ie,[i.UNPACK_COLORSPACE_CONVERSION_WEBGL]:ie,[i.PACK_ROW_LENGTH]:ie,[i.PACK_SKIP_PIXELS]:ie,[i.PACK_SKIP_ROWS]:ie,[i.UNPACK_ROW_LENGTH]:ie,[i.UNPACK_IMAGE_HEIGHT]:ie,[i.UNPACK_SKIP_PIXELS]:ie,[i.UNPACK_SKIP_ROWS]:ie,[i.UNPACK_SKIP_IMAGES]:ie,framebuffer:(e,t)=>{let r=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(i.FRAMEBUFFER,r)},blend:(e,t)=>t?e.enable(i.BLEND):e.disable(i.BLEND),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let r=typeof t=="number"?[t,t]:t;e.blendEquationSeparate(...r)},blendFunc:(e,t)=>{let r=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...r)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(i.CULL_FACE):e.disable(i.CULL_FACE),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(i.DEPTH_TEST):e.disable(i.DEPTH_TEST),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(i.DITHER):e.disable(i.DITHER),derivativeHint:(e,t)=>{e.hint(i.FRAGMENT_SHADER_DERIVATIVE_HINT,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(i.GENERATE_MIPMAP_HINT,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(i.POLYGON_OFFSET_FILL):e.disable(i.POLYGON_OFFSET_FILL),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(i.SCISSOR_TEST):e.disable(i.SCISSOR_TEST),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(i.STENCIL_TEST):e.disable(i.STENCIL_TEST),stencilMask:(e,t)=>{t=Gn(t)?t:[t,t];let[r,n]=t;e.stencilMaskSeparate(i.FRONT,r),e.stencilMaskSeparate(i.BACK,n)},stencilFunc:(e,t)=>{t=Gn(t)&&t.length===3?[...t,...t]:t;let[r,n,o,a,s,u]=t;e.stencilFuncSeparate(i.FRONT,r,n,o),e.stencilFuncSeparate(i.BACK,a,s,u)},stencilOp:(e,t)=>{t=Gn(t)&&t.length===3?[...t,...t]:t;let[r,n,o,a,s,u]=t;e.stencilOpSeparate(i.FRONT,r,n,o),e.stencilOpSeparate(i.BACK,a,s,u)},viewport:(e,t)=>e.viewport(...t)};function H(e,t,r){return t[e]!==void 0?t[e]:r[e]}var Uo={blendEquation:(e,t,r)=>e.blendEquationSeparate(H(i.BLEND_EQUATION_RGB,t,r),H(i.BLEND_EQUATION_ALPHA,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(H(i.BLEND_SRC_RGB,t,r),H(i.BLEND_DST_RGB,t,r),H(i.BLEND_SRC_ALPHA,t,r),H(i.BLEND_DST_ALPHA,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(H(i.POLYGON_OFFSET_FACTOR,t,r),H(i.POLYGON_OFFSET_UNITS,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(H(i.SAMPLE_COVERAGE_VALUE,t,r),H(i.SAMPLE_COVERAGE_INVERT,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(i.FRONT,H(i.STENCIL_FUNC,t,r),H(i.STENCIL_REF,t,r),H(i.STENCIL_VALUE_MASK,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(i.BACK,H(i.STENCIL_BACK_FUNC,t,r),H(i.STENCIL_BACK_REF,t,r),H(i.STENCIL_BACK_VALUE_MASK,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(i.FRONT,H(i.STENCIL_FAIL,t,r),H(i.STENCIL_PASS_DEPTH_FAIL,t,r),H(i.STENCIL_PASS_DEPTH_PASS,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(i.BACK,H(i.STENCIL_BACK_FAIL,t,r),H(i.STENCIL_BACK_PASS_DEPTH_FAIL,t,r),H(i.STENCIL_BACK_PASS_DEPTH_PASS,t,r))},zn={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,r)=>e({[t]:r}),hint:(e,t,r)=>e({[t]:r}),useProgram:(e,t)=>e({[i.CURRENT_PROGRAM]:t}),bindRenderbuffer:(e,t,r)=>e({[i.RENDERBUFFER_BINDING]:r}),bindTransformFeedback:(e,t,r)=>e({[i.TRANSFORM_FEEDBACK_BINDING]:r}),bindVertexArray:(e,t)=>e({[i.VERTEX_ARRAY_BINDING]:t}),bindFramebuffer:(e,t,r)=>{switch(t){case i.FRAMEBUFFER:return e({[i.DRAW_FRAMEBUFFER_BINDING]:r,[i.READ_FRAMEBUFFER_BINDING]:r});case i.DRAW_FRAMEBUFFER:return e({[i.DRAW_FRAMEBUFFER_BINDING]:r});case i.READ_FRAMEBUFFER:return e({[i.READ_FRAMEBUFFER_BINDING]:r});default:return null}},bindBuffer:(e,t,r)=>{let n={[i.ARRAY_BUFFER]:[i.ARRAY_BUFFER_BINDING],[i.COPY_READ_BUFFER]:[i.COPY_READ_BUFFER_BINDING],[i.COPY_WRITE_BUFFER]:[i.COPY_WRITE_BUFFER_BINDING],[i.PIXEL_PACK_BUFFER]:[i.PIXEL_PACK_BUFFER_BINDING],[i.PIXEL_UNPACK_BUFFER]:[i.PIXEL_UNPACK_BUFFER_BINDING]}[t];return n?e({[n]:r}):{valueChanged:!0}},blendColor:(e,t,r,n,o)=>e({[i.BLEND_COLOR]:new Float32Array([t,r,n,o])}),blendEquation:(e,t)=>e({[i.BLEND_EQUATION_RGB]:t,[i.BLEND_EQUATION_ALPHA]:t}),blendEquationSeparate:(e,t,r)=>e({[i.BLEND_EQUATION_RGB]:t,[i.BLEND_EQUATION_ALPHA]:r}),blendFunc:(e,t,r)=>e({[i.BLEND_SRC_RGB]:t,[i.BLEND_DST_RGB]:r,[i.BLEND_SRC_ALPHA]:t,[i.BLEND_DST_ALPHA]:r}),blendFuncSeparate:(e,t,r,n,o)=>e({[i.BLEND_SRC_RGB]:t,[i.BLEND_DST_RGB]:r,[i.BLEND_SRC_ALPHA]:n,[i.BLEND_DST_ALPHA]:o}),clearColor:(e,t,r,n,o)=>e({[i.COLOR_CLEAR_VALUE]:new Float32Array([t,r,n,o])}),clearDepth:(e,t)=>e({[i.DEPTH_CLEAR_VALUE]:t}),clearStencil:(e,t)=>e({[i.STENCIL_CLEAR_VALUE]:t}),colorMask:(e,t,r,n,o)=>e({[i.COLOR_WRITEMASK]:[t,r,n,o]}),cullFace:(e,t)=>e({[i.CULL_FACE_MODE]:t}),depthFunc:(e,t)=>e({[i.DEPTH_FUNC]:t}),depthRange:(e,t,r)=>e({[i.DEPTH_RANGE]:new Float32Array([t,r])}),depthMask:(e,t)=>e({[i.DEPTH_WRITEMASK]:t}),frontFace:(e,t)=>e({[i.FRONT_FACE]:t}),lineWidth:(e,t)=>e({[i.LINE_WIDTH]:t}),polygonOffset:(e,t,r)=>e({[i.POLYGON_OFFSET_FACTOR]:t,[i.POLYGON_OFFSET_UNITS]:r}),sampleCoverage:(e,t,r)=>e({[i.SAMPLE_COVERAGE_VALUE]:t,[i.SAMPLE_COVERAGE_INVERT]:r}),scissor:(e,t,r,n,o)=>e({[i.SCISSOR_BOX]:new Int32Array([t,r,n,o])}),stencilMask:(e,t)=>e({[i.STENCIL_WRITEMASK]:t,[i.STENCIL_BACK_WRITEMASK]:t}),stencilMaskSeparate:(e,t,r)=>e({[t===i.FRONT?i.STENCIL_WRITEMASK:i.STENCIL_BACK_WRITEMASK]:r}),stencilFunc:(e,t,r,n)=>e({[i.STENCIL_FUNC]:t,[i.STENCIL_REF]:r,[i.STENCIL_VALUE_MASK]:n,[i.STENCIL_BACK_FUNC]:t,[i.STENCIL_BACK_REF]:r,[i.STENCIL_BACK_VALUE_MASK]:n}),stencilFuncSeparate:(e,t,r,n,o)=>e({[t===i.FRONT?i.STENCIL_FUNC:i.STENCIL_BACK_FUNC]:r,[t===i.FRONT?i.STENCIL_REF:i.STENCIL_BACK_REF]:n,[t===i.FRONT?i.STENCIL_VALUE_MASK:i.STENCIL_BACK_VALUE_MASK]:o}),stencilOp:(e,t,r,n)=>e({[i.STENCIL_FAIL]:t,[i.STENCIL_PASS_DEPTH_FAIL]:r,[i.STENCIL_PASS_DEPTH_PASS]:n,[i.STENCIL_BACK_FAIL]:t,[i.STENCIL_BACK_PASS_DEPTH_FAIL]:r,[i.STENCIL_BACK_PASS_DEPTH_PASS]:n}),stencilOpSeparate:(e,t,r,n,o)=>e({[t===i.FRONT?i.STENCIL_FAIL:i.STENCIL_BACK_FAIL]:r,[t===i.FRONT?i.STENCIL_PASS_DEPTH_FAIL:i.STENCIL_BACK_PASS_DEPTH_FAIL]:n,[t===i.FRONT?i.STENCIL_PASS_DEPTH_PASS:i.STENCIL_BACK_PASS_DEPTH_PASS]:o}),viewport:(e,t,r,n,o)=>e({[i.VIEWPORT]:[t,r,n,o]})},Te=(e,t)=>e.isEnabled(t),jn={[i.BLEND]:Te,[i.CULL_FACE]:Te,[i.DEPTH_TEST]:Te,[i.DITHER]:Te,[i.POLYGON_OFFSET_FILL]:Te,[i.SAMPLE_ALPHA_TO_COVERAGE]:Te,[i.SAMPLE_COVERAGE]:Te,[i.SCISSOR_TEST]:Te,[i.STENCIL_TEST]:Te,[i.RASTERIZER_DISCARD]:Te},wo=new Set([i.ACTIVE_TEXTURE,i.TRANSFORM_FEEDBACK_ACTIVE,i.TRANSFORM_FEEDBACK_PAUSED,i.TRANSFORM_FEEDBACK_BUFFER_BINDING,i.UNIFORM_BUFFER_BINDING,i.ELEMENT_ARRAY_BUFFER_BINDING,i.IMPLEMENTATION_COLOR_READ_FORMAT,i.IMPLEMENTATION_COLOR_READ_TYPE,i.READ_BUFFER,i.DRAW_BUFFER0,i.DRAW_BUFFER1,i.DRAW_BUFFER2,i.DRAW_BUFFER3,i.DRAW_BUFFER4,i.DRAW_BUFFER5,i.DRAW_BUFFER6,i.DRAW_BUFFER7,i.DRAW_BUFFER8,i.DRAW_BUFFER9,i.DRAW_BUFFER10,i.DRAW_BUFFER11,i.DRAW_BUFFER12,i.DRAW_BUFFER13,i.DRAW_BUFFER14,i.DRAW_BUFFER15,i.SAMPLER_BINDING,i.TEXTURE_BINDING_2D,i.TEXTURE_BINDING_2D_ARRAY,i.TEXTURE_BINDING_3D,i.TEXTURE_BINDING_CUBE_MAP]);function Fe(e,t){let n=K.attach(e).gl;if(ff(t))return;let o={};for(let s in t){let u=Number(s),l=Bo[s];l&&(typeof l=="string"?o[l]=!0:l(n,t[s],u))}let a=n.state&&n.state.cache;if(a)for(let s in o){let u=Uo[s];u(n,t,a)}}function Lo(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Or,n=K.attach(e).gl;if(typeof t=="number"){let s=t,u=jn[s];return u?u(n,s):n.getParameter(s)}let o=Array.isArray(t)?t:Object.keys(t),a={};for(let s of o){let u=jn[s];a[s]=u?u(n,Number(s)):n.getParameter(Number(s))}return a}function ff(e){for(let t in e)return!1;return!0}function Xo(e,t){if(e===t)return!0;let r=Array.isArray(e)||ArrayBuffer.isView(e),n=Array.isArray(t)||ArrayBuffer.isView(t);if(r&&n&&e.length===t.length){for(let o=0;o<e.length;++o)if(e[o]!==t[o])return!1;return!0}return!1}var Yn=class{constructor(t){let{copyState:r=!1,log:n=()=>{}}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.gl=void 0,this.program=null,this.stateStack=[],this.enable=!0,this.cache=void 0,this.log=void 0,this.gl=t,this.cache=r?Lo(t):Object.assign({},Or),this.log=n,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.stateStack.push({})}pop(){(0,Qt.assert)(this.stateStack.length>0);let t=this.stateStack[this.stateStack.length-1];Fe(this.gl,t),this.stateStack.pop()}_updateCache(t){let r=!1,n,o=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let a in t){(0,Qt.assert)(a!==void 0);let s=t[a],u=this.cache[a];Xo(s,u)||(r=!0,n=u,o&&!(a in o)&&(o[a]=u),this.cache[a]=s)}return{valueChanged:r,oldValue:n}}};function Ye(e){return e.state}function kn(e,t){let{enable:r=!0,copyState:n}=t;if((0,Qt.assert)(n!==void 0),!e.state){e.state=new Yn(e,{copyState:n}),_f(e);for(let a in zn){let s=zn[a];cf(e,a,s)}Wo(e,"getParameter"),Wo(e,"isEnabled")}let o=Ye(e);return o.enable=r,e}function lt(e){let t=Ye(e);t||(kn(e,{copyState:!1}),t=Ye(e)),t.push()}function ke(e){let t=Ye(e);(0,Qt.assert)(t),t.pop()}function Wo(e,t){let r=e[t].bind(e);e[t]=function(o){if(o===void 0||wo.has(o))return r(o);let a=Ye(e);return o in a.cache||(a.cache[o]=r(o)),a.enable?a.cache[o]:r(o)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function cf(e,t,r){if(!e[t])return;let n=e[t].bind(e);e[t]=function(){let a=Ye(e);for(var s=arguments.length,u=new Array(s),l=0;l<s;l++)u[l]=arguments[l];let{valueChanged:f,oldValue:c}=r(a._updateCache,...u);return f&&n(...u),c},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function _f(e){let t=e.useProgram.bind(e);e.useProgram=function(n){let o=Ye(e);o.program!==n&&(t(n),o.program=n)}}var Ef={webgl2:!0,webgl1:!0,powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Ho(e,t){t={...Ef,...t};let r=null,n=a=>r=a.statusMessage||r;e.addEventListener("webglcontextcreationerror",n,!1);let o=null;if(t.type==="webgl2"&&(t={...t,webgl1:!1}),t.type==="webgl1"&&(t={...t,webgl2:!1}),!o&&t.webgl2&&(o=e.getContext("webgl2",t)),!o&&t.webgl1&&(o=e.getContext("webgl",t)),e.removeEventListener("webglcontextcreationerror",n,!1),!o)throw new Error(`Failed to create ${t.webgl2&&!t.webgl1?"WebGL2":"WebGL"} context: ${r||"Unknown error"}`);if(t.onContextLost){let{onContextLost:a}=t;e.addEventListener("webglcontextlost",s=>a(s),!1)}if(t.onContextRestored){let{onContextRestored:a}=t;e.addEventListener("webglcontextrestored",s=>a(s),!1)}return o}function Vo(e){let t=e.getParameter(i.VENDOR),r=e.getParameter(i.RENDERER),n=e.getExtension("WEBGL_debug_renderer_info"),o=e.getParameter(n?n.UNMASKED_VENDOR_WEBGL:i.VENDOR),a=e.getParameter(n?n.UNMASKED_RENDERER_WEBGL:i.RENDERER),l=df(o||t,a||r);return{type:D(e)?"webgl2":"webgl",gpu:l,vendor:o||t,renderer:a||r,version:e.getParameter(i.VERSION),shadingLanguages:["glsl"],shadingLanguageVersions:{glsl:e.getParameter(i.SHADING_LANGUAGE_VERSION)}}}function df(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function Ko(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=typeof window<"u"?window.navigator||{}:{},r=e.userAgent||t.userAgent||"",n=r.indexOf("MSIE ")!==-1,o=r.indexOf("Trident/")!==-1;return n||o}var qn=x(F(),1);function vr(e){switch(e){case"uint8":return i.UNSIGNED_BYTE;case"sint8":return i.BYTE;case"unorm8":return i.UNSIGNED_BYTE;case"snorm8":return i.BYTE;case"uint16":return i.UNSIGNED_SHORT;case"sint16":return i.SHORT;case"unorm16":return i.UNSIGNED_SHORT;case"snorm16":return i.SHORT;case"uint32":return i.UNSIGNED_INT;case"sint32":return i.INT;case"float16":return i.HALF_FLOAT;case"float32":return i.FLOAT}throw new Error(String(e))}var Z="texture-compression-bc",U="texture-compression-astc",Re="texture-compression-etc2",gf="texture-compression-etc1-webgl",br="texture-compression-pvrtc-webgl",$n="texture-compression-atc-webgl",Jt="WEBGL_compressed_texture_s3tc",er="WEBGL_compressed_texture_s3tc_srgb",ft="EXT_texture_compression_rgtc",tr="EXT_texture_compression_bptc",hf="WEBGL_compressed_texture_etc",Af="WEBGL_compressed_texture_astc",pf="WEBGL_compressed_texture_etc1",Tf="WEBGL_compressed_texture_pvrtc",Rf="WEBGL_compressed_texture_atc",Go="EXT_sRGB",Ne="EXT_texture_norm16",mf="WEBGL_color_buffer_float",Sf="EXT_color_buffer_float",Ee=(e,t)=>e.getExtension(t),$e=(e,t)=>t.every(r=>e.getExtension(r)),Zn={"texture-blend-float-webgl1":e=>D(e)?!0:Ee(e,"EXT_float_blend"),"texture-formats-srgb-webgl1":e=>D(e)?!0:Ee(e,Go),"texture-formats-depth-webgl1":e=>D(e)?!0:Ee(e,"WEBGL_depth_texture"),"texture-formats-float32-webgl1":e=>D(e)?!0:Ee(e,"OES_texture_float"),"texture-formats-float16-webgl1":e=>D(e)?!0:Ee(e,"OES_texture_half_float"),"texture-formats-norm16-webgl":e=>D(e)?Ee(e,Ne):!1,"texture-filter-linear-float32-webgl":e=>Ee(e,"OES_texture_float_linear"),"texture-filter-linear-float16-webgl":e=>Ee(e,"OES_texture_half_float_linear"),"texture-filter-anisotropic-webgl":e=>Ee(e,"EXT_texture_filter_anisotropic"),"texture-renderable-float32-webgl":e=>Ee(e,"EXT_color_buffer_float"),"texture-renderable-float16-webgl":e=>Ee(e,"EXT_color_buffer_half_float"),"texture-compression-bc":e=>$e(e,[Jt,er,ft,tr]),"texture-compression-bc5-webgl":e=>$e(e,[ft]),"texture-compression-etc2":e=>$e(e,[hf]),"texture-compression-astc":e=>$e(e,[Af]),"texture-compression-etc1-webgl":e=>$e(e,[pf]),"texture-compression-pvrtc-webgl":e=>$e(e,[Tf]),"texture-compression-atc-webgl":e=>$e(e,[Rf])};function Of(e,t){var r;return((r=Zn[t])===null||r===void 0?void 0:r.call(Zn,e))||!1}function zo(e){return Object.keys(Zn).filter(r=>Of(e,r))}var rr={"rgb8unorm-unsized":{gl:i.RGB,gl1:i.RGB,b:4,c:2,bpp:4,dataFormat:i.RGB,types:[i.UNSIGNED_BYTE,i.UNSIGNED_SHORT_5_6_5]},"rgba8unorm-unsized":{gl:i.RGBA,gl1:i.RGBA,b:4,c:2,bpp:4,dataFormat:i.RGBA,types:[i.UNSIGNED_BYTE,i.UNSIGNED_SHORT_4_4_4_4,i.UNSIGNED_SHORT_5_5_5_1]},r8unorm:{gl:i.R8,b:1,c:1,renderbuffer:!0},r8snorm:{gl:i.R8_SNORM,b:1,c:1},r8uint:{gl:i.R8UI,b:1,c:1,renderbuffer:!0},r8sint:{gl:i.R8I,b:1,c:1,renderbuffer:!0},rg8unorm:{gl:i.RG8,b:2,c:2,renderbuffer:!0},rg8snorm:{gl:i.RG8_SNORM,b:2,c:2},rg8uint:{gl:i.RG8UI,b:2,c:2,renderbuffer:!0},rg8sint:{gl:i.RG8I,b:2,c:2,renderbuffer:!0},r16uint:{gl:i.R16UI,b:2,c:1,renderbuffer:!0},r16sint:{gl:i.R16I,b:2,c:1,renderbuffer:!0},r16float:{gl:i.R16F,b:2,c:1,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl",renderbuffer:!0},"r16unorm-webgl":{gl:i.R16_EXT,b:2,c:1,f:"texture-formats-norm16-webgl",renderbuffer:!0,x:Ne},"r16snorm-webgl":{gl:i.R16_SNORM_EXT,b:2,c:1,f:"texture-formats-norm16-webgl",x:Ne},"rgba4unorm-webgl":{gl:i.RGBA4,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb565unorm-webgl":{gl:i.RGB565,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb5a1unorm-webgl":{gl:i.RGB5_A1,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb8unorm-webgl":{gl:i.RGB8,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:i.RGB8_SNORM,b:3,c:3,wgpu:!1},rgba8unorm:{gl:i.RGBA8,gl1:i.RGBA,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:i.SRGB8_ALPHA8,gl1:i.SRGB_ALPHA_EXT,b:4,c:4,gl1ext:Go,bpp:4},rgba8snorm:{gl:i.RGBA8_SNORM,b:4,c:4},rgba8uint:{gl:i.RGBA8UI,b:4,c:4,bpp:4},rgba8sint:{gl:i.RGBA8I,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:i.RG16UI,b:4,c:1,bpp:4},rg16sint:{gl:i.RG16I,b:4,c:2,bpp:4},rg16float:{gl:i.RG16F,bpp:4,b:4,c:2,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl",renderbuffer:!0},"rg16unorm-webgl":{gl:i.RG16_EXT,b:2,c:2,f:"texture-formats-norm16-webgl",x:Ne},"rg16snorm-webgl":{gl:i.RG16_SNORM_EXT,b:2,c:2,f:"texture-formats-norm16-webgl",x:Ne},r32uint:{gl:i.R32UI,b:4,c:1,bpp:4,renderbuffer:!0},r32sint:{gl:i.R32I,b:4,c:1,bpp:4,renderbuffer:!0},r32float:{gl:i.R32F,bpp:4,b:4,c:1,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl"},rgb9e5ufloat:{gl:i.RGB9_E5,b:4,c:3,p:1,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl"},rg11b10ufloat:{gl:i.R11F_G11F_B10F,b:4,c:3,p:1,render:"texture-renderable-float32-webgl",renderbuffer:!0},rgb10a2unorm:{gl:i.RGB10_A2,b:4,c:4,p:1,renderbuffer:!0},"rgb10a2unorm-webgl":{b:4,c:4,gl:i.RGB10_A2UI,p:1,wgpu:!1,bpp:4,renderbuffer:!0},"rgb16unorm-webgl":{gl:i.RGB16_EXT,b:2,c:3,f:"texture-formats-norm16-webgl",x:Ne},"rgb16snorm-webgl":{gl:i.RGB16_SNORM_EXT,b:2,c:3,f:"texture-formats-norm16-webgl",x:Ne},rg32uint:{gl:i.RG32UI,b:8,c:2,renderbuffer:!0},rg32sint:{gl:i.RG32I,b:8,c:2,renderbuffer:!0},rg32float:{gl:i.RG32F,b:8,c:2,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",renderbuffer:!0},rgba16uint:{gl:i.RGBA16UI,b:8,c:4,renderbuffer:!0},rgba16sint:{gl:i.RGBA16I,b:8,c:4,renderbuffer:!0},rgba16float:{gl:i.RGBA16F,gl1:i.RGBA,b:8,c:4,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl"},"rgba16unorm-webgl":{gl:i.RGBA16_EXT,b:2,c:4,f:"texture-formats-norm16-webgl",renderbuffer:!0,x:Ne},"rgba16snorm-webgl":{gl:i.RGBA16_SNORM_EXT,b:2,c:4,f:"texture-formats-norm16-webgl",x:Ne},"rgb32float-webgl":{gl:i.RGB32F,gl1:i.RGB,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",gl2ext:Sf,gl1ext:mf,dataFormat:i.RGB,types:[i.FLOAT]},rgba32uint:{gl:i.RGBA32UI,b:16,c:4,renderbuffer:!0},rgba32sint:{gl:i.RGBA32I,b:16,c:4,renderbuffer:!0},rgba32float:{gl:i.RGBA32F,b:16,c:4,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",renderbuffer:!0},stencil8:{gl:i.STENCIL_INDEX8,gl1:i.STENCIL_INDEX8,b:1,c:1,attachment:i.STENCIL_ATTACHMENT,renderbuffer:!0},depth16unorm:{gl:i.DEPTH_COMPONENT16,gl1:i.DEPTH_COMPONENT16,b:2,c:1,attachment:i.DEPTH_ATTACHMENT,renderbuffer:!0},depth24plus:{gl:i.DEPTH_COMPONENT24,b:3,c:1,attachment:i.DEPTH_ATTACHMENT},depth32float:{gl:i.DEPTH_COMPONENT32F,b:4,c:1,attachment:i.DEPTH_ATTACHMENT,renderbuffer:!0},"depth24plus-stencil8":{gl:i.DEPTH_STENCIL,gl1:i.DEPTH_STENCIL,b:4,c:2,p:1,attachment:i.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0,depthTexture:!0},"depth24unorm-stencil8":{gl:i.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:i.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0},"depth32float-stencil8":{gl:i.DEPTH32F_STENCIL8,b:5,c:2,p:1,attachment:i.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0},"bc1-rgb-unorm-webgl":{gl:i.COMPRESSED_RGB_S3TC_DXT1_EXT,x:Jt,f:Z},"bc1-rgb-unorm-srgb-webgl":{gl:i.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:er,f:Z},"bc1-rgba-unorm":{gl:i.COMPRESSED_RGBA_S3TC_DXT1_EXT,x:Jt,f:Z},"bc1-rgba-unorm-srgb":{gl:i.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:er,f:Z},"bc2-rgba-unorm":{gl:i.COMPRESSED_RGBA_S3TC_DXT3_EXT,x:Jt,f:Z},"bc2-rgba-unorm-srgb":{gl:i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,x:er,f:Z},"bc3-rgba-unorm":{gl:i.COMPRESSED_RGBA_S3TC_DXT5_EXT,x:Jt,f:Z},"bc3-rgba-unorm-srgb":{gl:i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,x:er,f:Z},"bc4-r-unorm":{gl:i.COMPRESSED_RED_RGTC1_EXT,x:ft,f:Z},"bc4-r-snorm":{gl:i.COMPRESSED_SIGNED_RED_RGTC1_EXT,x:ft,f:Z},"bc5-rg-unorm":{gl:i.COMPRESSED_RED_GREEN_RGTC2_EXT,x:ft,f:Z},"bc5-rg-snorm":{gl:i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,x:ft,f:Z},"bc6h-rgb-ufloat":{gl:i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,x:tr,f:Z},"bc6h-rgb-float":{gl:i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,x:tr,f:Z},"bc7-rgba-unorm":{gl:i.COMPRESSED_RGBA_BPTC_UNORM_EXT,x:tr,f:Z},"bc7-rgba-unorm-srgb":{gl:i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,x:tr,f:Z},"etc2-rgb8unorm":{gl:i.COMPRESSED_RGB8_ETC2,f:Re},"etc2-rgb8unorm-srgb":{gl:i.COMPRESSED_SRGB8_ETC2,f:Re},"etc2-rgb8a1unorm":{gl:i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:Re},"etc2-rgb8a1unorm-srgb":{gl:i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:Re},"etc2-rgba8unorm":{gl:i.COMPRESSED_RGBA8_ETC2_EAC,f:Re},"etc2-rgba8unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,f:Re},"eac-r11unorm":{gl:i.COMPRESSED_R11_EAC,f:Re},"eac-r11snorm":{gl:i.COMPRESSED_SIGNED_R11_EAC,f:Re},"eac-rg11unorm":{gl:i.COMPRESSED_RG11_EAC,f:Re},"eac-rg11snorm":{gl:i.COMPRESSED_SIGNED_RG11_EAC,f:Re},"astc-4x4-unorm":{gl:i.COMPRESSED_RGBA_ASTC_4x4_KHR,f:U},"astc-4x4-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,f:U},"astc-5x4-unorm":{gl:i.COMPRESSED_RGBA_ASTC_5x4_KHR,f:U},"astc-5x4-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,f:U},"astc-5x5-unorm":{gl:i.COMPRESSED_RGBA_ASTC_5x5_KHR,f:U},"astc-5x5-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,f:U},"astc-6x5-unorm":{gl:i.COMPRESSED_RGBA_ASTC_6x5_KHR,f:U},"astc-6x5-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,f:U},"astc-6x6-unorm":{gl:i.COMPRESSED_RGBA_ASTC_6x6_KHR,f:U},"astc-6x6-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,f:U},"astc-8x5-unorm":{gl:i.COMPRESSED_RGBA_ASTC_8x5_KHR,f:U},"astc-8x5-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,f:U},"astc-8x6-unorm":{gl:i.COMPRESSED_RGBA_ASTC_8x6_KHR,f:U},"astc-8x6-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,f:U},"astc-8x8-unorm":{gl:i.COMPRESSED_RGBA_ASTC_8x8_KHR,f:U},"astc-8x8-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,f:U},"astc-10x5-unorm":{gl:i.COMPRESSED_RGBA_ASTC_10x10_KHR,f:U},"astc-10x5-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:U},"astc-10x6-unorm":{gl:i.COMPRESSED_RGBA_ASTC_10x6_KHR,f:U},"astc-10x6-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,f:U},"astc-10x8-unorm":{gl:i.COMPRESSED_RGBA_ASTC_10x8_KHR,f:U},"astc-10x8-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,f:U},"astc-10x10-unorm":{gl:i.COMPRESSED_RGBA_ASTC_10x10_KHR,f:U},"astc-10x10-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:U},"astc-12x10-unorm":{gl:i.COMPRESSED_RGBA_ASTC_12x10_KHR,f:U},"astc-12x10-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,f:U},"astc-12x12-unorm":{gl:i.COMPRESSED_RGBA_ASTC_12x12_KHR,f:U},"astc-12x12-unorm-srgb":{gl:i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,f:U},"pvrtc-rgb4unorm-webgl":{gl:i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,f:br},"pvrtc-rgba4unorm-webgl":{gl:i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,f:br},"pvrtc-rbg2unorm-webgl":{gl:i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,f:br},"pvrtc-rgba2unorm-webgl":{gl:i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,f:br},"etc1-rbg-unorm-webgl":{gl:i.COMPRESSED_RGB_ETC1_WEBGL,f:gf},"atc-rgb-unorm-webgl":{gl:i.COMPRESSED_RGB_ATC_WEBGL,f:$n},"atc-rgba-unorm-webgl":{gl:i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,f:$n},"atc-rgbai-unorm-webgl":{gl:i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,f:$n}},vf={[i.RED]:1,[i.RED_INTEGER]:1,[i.RG]:2,[i.RG_INTEGER]:2,[i.RGB]:3,[i.RGB_INTEGER]:3,[i.RGBA]:4,[i.RGBA_INTEGER]:4,[i.DEPTH_COMPONENT]:1,[i.DEPTH_STENCIL]:1,[i.ALPHA]:1,[i.LUMINANCE]:1,[i.LUMINANCE_ALPHA]:2},bf={[i.FLOAT]:4,[i.UNSIGNED_INT]:4,[i.INT]:4,[i.UNSIGNED_SHORT]:2,[i.SHORT]:2,[i.HALF_FLOAT]:2,[i.BYTE]:1,[i.UNSIGNED_BYTE]:1};function nr(e,t){let r=ir(t),n=rr[r];if(!n||(D(e)?n.gl===void 0:n.gl1===void 0))return!1;let o=n.x||D(e)&&n.gl2ext||n.gl1ext;return o?Boolean(e.getExtension(o)):!0}function jo(e,t){var r;return nr(e,t)&&((r=rr[t])===null||r===void 0?void 0:r.renderbuffer)}function ir(e){if(typeof e=="string")return e;let t=Object.entries(rr).find(r=>{let[,n]=r;return n.gl===e||n.gl1===e});if(!t)throw new Error(`Unknown texture format ${e}`);return t[0]}function or(e,t){let r=rr[e],n=t?r?.gl:r?.gl1;if(n===void 0)throw new Error(`Unsupported texture format ${e}`);return n}function Yo(e,t){let r=ir(t);if(!nr(e,r))return!1;try{if((0,qn.decodeTextureFormat)(r).signed)return!1}catch{return!1}return r.endsWith("32float")?Boolean(e.getExtension("OES_texture_float_linear")):r.endsWith("16float")?Boolean(e.getExtension("OES_texture_half_float_linear")):!0}function ko(e,t){let r=ir(t);return!(!nr(e,r)||typeof r=="number")}function Nr(e,t){let r=ir(e),n=or(r,t),o=(0,qn.decodeTextureFormat)(r);return{format:n,dataFormat:Nf(o.format,o.integer,o.normalized,n),type:o.dataType?vr(o.dataType):i.UNSIGNED_BYTE,compressed:o.compressed}}function $o(e){let t=rr[e];if(!(t!=null&&t.attachment))throw new Error(`${e} is not a depth stencil format`);return t.attachment}function Zo(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e.RGBA,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:i.RGBA,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i.UNSIGNED_BYTE,o=null,a=null;try{o=e.createTexture(),e.bindTexture(i.TEXTURE_2D,o);let s=0,u=1,l=1,f=0,c=new Uint8Array([0,0,255,255]);e.texImage2D(e.TEXTURE_2D,s,t,u,l,f,r,n,c),a=e.createFramebuffer(),e.bindFramebuffer(i.FRAMEBUFFER,a),e.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,o,0);let _=e.checkFramebufferStatus(i.FRAMEBUFFER)===i.FRAMEBUFFER_COMPLETE;return e.bindTexture(i.TEXTURE_2D,null),_}finally{e.deleteTexture(o),e.deleteFramebuffer(a)}}function ar(e,t){let r=ir(e),n=Nr(r,t),o=vf[n.dataFormat]||4,a=bf[n.type]||1;return o*a}function Nf(e,t,r,n){if(n===i.RGBA||n===i.RGB)return n;switch(e){case"r":return t&&!r?i.RED_INTEGER:i.RED;case"rg":return t&&!r?i.RG_INTEGER:i.RG;case"rgb":return t&&!r?i.RGB_INTEGER:i.RGB;case"rgba":return t&&!r?i.RGBA_INTEGER:i.RGBA;default:return i.RGBA}}function qo(e){let t=Cf(e);for(let r of zo(e))t.add(r);return t}function Cf(e){e.getExtension("EXT_color_buffer_float"),e.getExtension("WEBGL_color_buffer_float"),e.getExtension("EXT_float_blend");let t=new Set;for(let r of Object.keys(Qo))yf(e,r)&&t.add(r);return t}function yf(e,t){let r=Qo[t];if(!r)return!1;let[n,o]=r||[],a=D(e)?o:n;if(typeof a=="boolean")return a;switch(t){case"texture-renderable-rgba32float-webgl":return D(e)?Boolean(e.getExtension(a)):Zo(e);case"glsl-derivatives":return Jn(e,a);case"glsl-frag-data":return Jn(e,a,{behavior:"require"});case"glsl-frag-depth":return Jn(e,a);default:return Boolean(e.getExtension(a))}}var Qn={};function Jn(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!Ko(r))return!0;if(t in Qn)return Qn[t];let n=r.behavior||"enable",o=`#extension GL_${t} : ${n}
301
+ void main(void) {}`,a=e.createShader(e.VERTEX_SHADER);if(!a)throw new Error("shader");e.shaderSource(a,o),e.compileShader(a);let s=e.getShaderParameter(a,e.COMPILE_STATUS);return e.deleteShader(a),Qn[t]=s,s}var Qo={webgl:[!0,!0],webgl2:[!1,!0],"timer-query-webgl":["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"],"vertex-array-object-webgl1":["OES_vertex_array_object",!0],"instanced-rendering-webgl1":["ANGLE_instanced_arrays",!0],"multiple-render-targets-webgl1":["WEBGL_draw_buffers",!0],"index-uint32-webgl1":["OES_element_index_uint",!0],"blend-minmax-webgl1":["EXT_blend_minmax",!0],"texture-blend-float-webgl1":["EXT_float_blend","EXT_float_blend"],"texture-formats-srgb-webgl1":["EXT_sRGB",!0],"texture-formats-depth-webgl1":["WEBGL_depth_texture",!0],"texture-formats-float32-webgl1":["OES_texture_float",!0],"texture-formats-float16-webgl1":["OES_texture_half_float",!0],"texture-filter-linear-float32-webgl":["OES_texture_float_linear","OES_texture_float_linear"],"texture-filter-linear-float16-webgl":["OES_texture_half_float_linear","OES_texture_half_float_linear"],"texture-filter-anisotropic-webgl":["EXT_texture_filter_anisotropic","EXT_texture_filter_anisotropic"],"texture-renderable-rgba32float-webgl":["WEBGL_color_buffer_float","EXT_color_buffer_float"],"texture-renderable-float32-webgl":[!1,"EXT_color_buffer_float"],"texture-renderable-float16-webgl":["EXT_color_buffer_half_float","EXT_color_buffer_half_float"],"glsl-frag-data":["WEBGL_draw_buffers",!0],"glsl-frag-depth":["EXT_frag_depth",!0],"glsl-derivatives":["OES_standard_derivatives",!0],"glsl-texture-lod":["EXT_shader_texture_lod",!0]};function Jo(e){let t=Vn(e);return{maxTextureDimension1D:0,maxTextureDimension2D:e.getParameter(i.MAX_TEXTURE_SIZE),maxTextureDimension3D:t?t.getParameter(i.MAX_3D_TEXTURE_SIZE):0,maxTextureArrayLayers:t?t.getParameter(i.MAX_ARRAY_TEXTURE_LAYERS):0,maxBindGroups:1,maxDynamicUniformBuffersPerPipelineLayout:0,maxDynamicStorageBuffersPerPipelineLayout:0,maxSampledTexturesPerShaderStage:e.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxSamplersPerShaderStage:e.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxStorageBuffersPerShaderStage:0,maxStorageTexturesPerShaderStage:0,maxUniformBuffersPerShaderStage:t?t.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0,maxUniformBufferBindingSize:t?t.getParameter(i.MAX_UNIFORM_BLOCK_SIZE):0,maxStorageBufferBindingSize:0,minUniformBufferOffsetAlignment:t?t.getParameter(i.UNIFORM_BUFFER_OFFSET_ALIGNMENT):0,minStorageBufferOffsetAlignment:0,maxVertexBuffers:0,maxVertexAttributes:e.getParameter(i.MAX_VERTEX_ATTRIBS),maxVertexBufferArrayStride:2048,maxInterStageShaderComponents:t?t.getParameter(i.MAX_VARYING_COMPONENTS):0,maxComputeWorkgroupStorageSize:0,maxComputeInvocationsPerWorkgroup:0,maxComputeWorkgroupSizeX:0,maxComputeWorkgroupSizeY:0,maxComputeWorkgroupSizeZ:0,maxComputeWorkgroupsPerDimension:0}}function ea(e){let t=Vn(e);function r(o){return e.getParameter(o)}function n(o,a){return t?t.getParameter(o):a||0}return{[i.ALIASED_LINE_WIDTH_RANGE]:r(i.ALIASED_LINE_WIDTH_RANGE),[i.ALIASED_POINT_SIZE_RANGE]:r(i.ALIASED_POINT_SIZE_RANGE),[i.MAX_TEXTURE_SIZE]:r(i.MAX_TEXTURE_SIZE),[i.MAX_CUBE_MAP_TEXTURE_SIZE]:r(i.MAX_CUBE_MAP_TEXTURE_SIZE),[i.MAX_TEXTURE_IMAGE_UNITS]:r(i.MAX_TEXTURE_IMAGE_UNITS),[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS]:r(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS]:r(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),[i.MAX_RENDERBUFFER_SIZE]:r(i.MAX_RENDERBUFFER_SIZE),[i.MAX_VARYING_VECTORS]:r(i.MAX_VARYING_VECTORS),[i.MAX_VERTEX_ATTRIBS]:r(i.MAX_VERTEX_ATTRIBS),[i.MAX_VERTEX_UNIFORM_VECTORS]:r(i.MAX_VERTEX_UNIFORM_VECTORS),[i.MAX_FRAGMENT_UNIFORM_VECTORS]:r(i.MAX_FRAGMENT_UNIFORM_VECTORS),[i.MAX_VIEWPORT_DIMS]:r(i.MAX_VIEWPORT_DIMS),[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT]:r(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT),[i.MAX_3D_TEXTURE_SIZE]:n(i.MAX_3D_TEXTURE_SIZE),[i.MAX_ARRAY_TEXTURE_LAYERS]:n(i.MAX_ARRAY_TEXTURE_LAYERS),[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]:n(i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),[i.MAX_COLOR_ATTACHMENTS]:n(i.MAX_COLOR_ATTACHMENTS),[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]:n(i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS),[i.MAX_COMBINED_UNIFORM_BLOCKS]:n(i.MAX_COMBINED_UNIFORM_BLOCKS),[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]:n(i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS),[i.MAX_DRAW_BUFFERS]:n(i.MAX_DRAW_BUFFERS),[i.MAX_ELEMENT_INDEX]:n(i.MAX_ELEMENT_INDEX),[i.MAX_ELEMENTS_INDICES]:n(i.MAX_ELEMENTS_INDICES),[i.MAX_ELEMENTS_VERTICES]:n(i.MAX_ELEMENTS_VERTICES),[i.MAX_FRAGMENT_INPUT_COMPONENTS]:n(i.MAX_FRAGMENT_INPUT_COMPONENTS),[i.MAX_FRAGMENT_UNIFORM_BLOCKS]:n(i.MAX_FRAGMENT_UNIFORM_BLOCKS),[i.MAX_FRAGMENT_UNIFORM_COMPONENTS]:n(i.MAX_FRAGMENT_UNIFORM_COMPONENTS),[i.MAX_SAMPLES]:n(i.MAX_SAMPLES),[i.MAX_SERVER_WAIT_TIMEOUT]:n(i.MAX_SERVER_WAIT_TIMEOUT),[i.MAX_TEXTURE_LOD_BIAS]:n(i.MAX_TEXTURE_LOD_BIAS),[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]:n(i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS),[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]:n(i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS),[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]:n(i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS),[i.MAX_UNIFORM_BLOCK_SIZE]:n(i.MAX_UNIFORM_BLOCK_SIZE),[i.MAX_UNIFORM_BUFFER_BINDINGS]:n(i.MAX_UNIFORM_BUFFER_BINDINGS),[i.MAX_VARYING_COMPONENTS]:n(i.MAX_VARYING_COMPONENTS),[i.MAX_VERTEX_OUTPUT_COMPONENTS]:n(i.MAX_VERTEX_OUTPUT_COMPONENTS),[i.MAX_VERTEX_UNIFORM_BLOCKS]:n(i.MAX_VERTEX_UNIFORM_BLOCKS),[i.MAX_VERTEX_UNIFORM_COMPONENTS]:n(i.MAX_VERTEX_UNIFORM_COMPONENTS),[i.MIN_PROGRAM_TEXEL_OFFSET]:n(i.MIN_PROGRAM_TEXEL_OFFSET),[i.MAX_PROGRAM_TEXEL_OFFSET]:n(i.MAX_PROGRAM_TEXEL_OFFSET),[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT]:n(i.UNIFORM_BUFFER_OFFSET_ALIGNMENT)}}var la=x(F(),1);var Fr=x(F(),1);var oa=x(F(),1),G=x(F(),1);function Y(e,t,r){let o=K.attach(e).gl;if(If(t))return r(e);let{nocatch:a=!0}=t;lt(o),Fe(o,t);let s;if(a)s=r(o),ke(o);else try{s=r(o)}finally{ke(o)}return s}function If(e){for(let t in e)return!1;return!0}var yr=x(F(),1);function ta(e,t,r,n){if((0,yr.isObjectEmpty)(t))return n(e);lt(e.gl);try{return xf(e,t),Fe(e,r),n(e)}finally{ke(e.gl)}}function xf(e,t){let r=K.attach(e),{gl:n}=r;if(t.cullMode)switch(t.cullMode){case"none":n.disable(i.CULL_FACE);break;case"front":n.enable(i.CULL_FACE),n.cullFace(i.FRONT);break;case"back":n.enable(i.CULL_FACE),n.cullFace(i.BACK);break}if(t.frontFace&&n.frontFace(ti("frontFace",t.frontFace,{ccw:i.CCW,cw:i.CW})),t.depthBias!==void 0&&n.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0),t.depthWriteEnabled!==void 0&&n.depthMask(Mf("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?n.enable(i.DEPTH_TEST):n.disable(i.DEPTH_TEST),n.depthFunc(Cr("depthCompare",t.depthCompare))),t.stencilWriteMask){let o=t.stencilWriteMask;n.stencilMaskSeparate(i.FRONT,o),n.stencilMaskSeparate(i.BACK,o)}if(t.stencilReadMask&&yr.log.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let o=t.stencilReadMask||4294967295,a=Cr("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?n.enable(i.STENCIL_TEST):n.disable(i.STENCIL_TEST),n.stencilFuncSeparate(i.FRONT,a,0,o),n.stencilFuncSeparate(i.BACK,a,0,o)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let o=ei("stencilPassOperation",t.stencilPassOperation),a=ei("stencilFailOperation",t.stencilFailOperation),s=ei("stencilDepthFailOperation",t.stencilDepthFailOperation);n.stencilOpSeparate(i.FRONT,a,s,o),n.stencilOpSeparate(i.BACK,a,s,o)}}function Cr(e,t){return ti(e,t,{never:i.NEVER,less:i.LESS,equal:i.EQUAL,"less-equal":i.LEQUAL,greater:i.GREATER,"not-equal":i.NOTEQUAL,"greater-equal":i.GEQUAL,always:i.ALWAYS})}function ei(e,t){return ti(e,t,{keep:i.KEEP,zero:i.ZERO,replace:i.REPLACE,invert:i.INVERT,"increment-clamp":i.INCR,"decrement-clamp":i.DECR,"increment-wrap":i.INCR_WRAP,"decrement-wrap":i.DECR_WRAP})}function Pf(e,t){return`Illegal parameter ${t} for ${e}`}function ti(e,t,r){if(!(t in r))throw new Error(Pf(e,t));return r[t]}function Mf(e,t){return t}function Ir(e){let t={};return e.addressModeU&&(t[i.TEXTURE_WRAP_S]=ri(e.addressModeU)),e.addressModeV&&(t[i.TEXTURE_WRAP_T]=ri(e.addressModeV)),e.addressModeW&&(t[i.TEXTURE_WRAP_R]=ri(e.addressModeW)),e.magFilter&&(t[i.TEXTURE_MAG_FILTER]=ra(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[i.TEXTURE_MIN_FILTER]=Ff(e.minFilter||"linear",e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[i.TEXTURE_MIN_LOD]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[i.TEXTURE_MAX_LOD]=e.lodMaxClamp),e.type==="comparison-sampler"&&(t[i.TEXTURE_COMPARE_MODE]=i.COMPARE_REF_TO_TEXTURE),e.compare&&(t[i.TEXTURE_COMPARE_FUNC]=Cr("compare",e.compare)),e.maxAnisotropy&&(t[i.TEXTURE_MAX_ANISOTROPY_EXT]=e.maxAnisotropy),t}function ri(e){switch(e){case"clamp-to-edge":return i.CLAMP_TO_EDGE;case"repeat":return i.REPEAT;case"mirror-repeat":return i.MIRRORED_REPEAT}}function ra(e){switch(e){case"nearest":return i.NEAREST;case"linear":return i.LINEAR}}function Ff(e,t){if(!t)return ra(e);switch(e){case"nearest":return t==="nearest"?i.NEAREST_MIPMAP_NEAREST:i.NEAREST_MIPMAP_LINEAR;case"linear":return t==="nearest"?i.LINEAR_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR}}function na(e){let t={...e};return e[i.TEXTURE_MIN_FILTER]!==i.NEAREST&&(t[i.TEXTURE_MIN_FILTER]=i.LINEAR),t[i.TEXTURE_WRAP_S]=i.CLAMP_TO_EDGE,t[i.TEXTURE_WRAP_T]=i.CLAMP_TO_EDGE,t}var de=x(F(),1);var Df=10,se=class extends de.Buffer{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t,r),this.device=void 0,this.gl=void 0,this.gl2=void 0,this.handle=void 0,this.glTarget=void 0,this.glUsage=void 0,this.glIndexType=i.UNSIGNED_SHORT,this.byteLength=void 0,this.bytesUsed=void 0,this.debugData=null,this.device=t,this.gl=this.device.gl,this.gl2=this.device.gl2;let n=typeof r=="object"?r.handle:void 0;this.handle=n||this.gl.createBuffer(),t.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=Bf(this.props.usage),this.glUsage=Uf(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?i.UNSIGNED_INT:i.UNSIGNED_SHORT,this.debugData=null,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.byteLength+r;(0,de.assert)(ArrayBuffer.isView(t));let o=this._getWriteTarget();return this.gl.bindBuffer(o,this.handle),this.gl.bufferData(o,n,this.glUsage),this.gl.bufferSubData(o,r,t),this.gl.bindBuffer(o,null),this.debugData=t.slice(0,Df),this.bytesUsed=n,this.byteLength=n,this.trackAllocatedMemory(n),this}_initWithByteLength(t){(0,de.assert)(t>=0);let r=t;t===0&&(r=new Float32Array(0));let n=this._getWriteTarget();return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,r,this.glUsage),this.gl.bindBuffer(n,null),this.debugData=null,this.bytesUsed=t,this.byteLength=t,this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=0,o=void 0,a=this.device.isWebGL2?i.COPY_WRITE_BUFFER:this.glTarget;this.gl.bindBuffer(a,this.handle),n!==0||o!==void 0?(this.device.assertWebGL2(),this.gl2.bufferSubData(a,r,t,n,o)):this.gl.bufferSubData(a,r,t),this.gl.bindBuffer(a,null)}async readAsync(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1?arguments[1]:void 0;this.device.assertWebGL2();let n=new Uint8Array(r),o=0;return this.gl.bindBuffer(i.COPY_READ_BUFFER,this.handle),this.gl2.getBufferSubData(i.COPY_READ_BUFFER,t,n,o,r),this.gl.bindBuffer(i.COPY_READ_BUFFER,null),n}_invalidateDebugData(){this.debugData=null}_getWriteTarget(){return this.glTarget}_getReadTarget(){return this.glTarget}};function Bf(e){return e&de.Buffer.INDEX?i.ELEMENT_ARRAY_BUFFER:e&de.Buffer.VERTEX?i.ARRAY_BUFFER:e&de.Buffer.UNIFORM?i.UNIFORM_BUFFER:i.ARRAY_BUFFER}function Uf(e){return e&de.Buffer.INDEX?i.STATIC_DRAW:e&de.Buffer.VERTEX?i.STATIC_DRAW:e&de.Buffer.UNIFORM?i.DYNAMIC_DRAW:i.STATIC_DRAW}var ia=x(F(),1);var Ze=class extends ia.Sampler{constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.parameters=void 0,this.device=t,this.parameters=Ir(r),this.device.isWebGL2&&(this.handle=this.handle||this.device.gl2.createSampler(),this._setSamplerParameters(this.parameters))}destroy(){this.handle&&(this.device.gl2.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(t){for(let[r,n]of Object.entries(t)){let o=Number(r);switch(o){case i.TEXTURE_MIN_LOD:case i.TEXTURE_MAX_LOD:this.device.gl2.samplerParameterf(this.handle,o,n);break;default:this.device.gl2.samplerParameteri(this.handle,o,n);break}}}};var wf={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},k=class extends G.Texture{constructor(t,r){var n;super(t,{...wf,format:"rgba8unorm",...r}),this.MAX_ATTRIBUTES=void 0,this.device=void 0,this.gl=void 0,this.gl2=void 0,this.handle=void 0,this.sampler=void 0,this.glFormat=void 0,this.type=void 0,this.dataFormat=void 0,this.mipmaps=void 0,this.target=void 0,this.textureUnit=void 0,this.loaded=!1,this._video=void 0,this.device=(0,G.cast)(t),this.gl=this.device.gl,this.gl2=this.device.gl2,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=i.RGBA,this.target=Lf(this.props),this.loaded=!1,typeof((n=this.props)===null||n===void 0?void 0:n.data)=="string"&&Object.assign(this.props,{data:(0,G.loadImage)(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}initialize(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.props.dimension==="cube")return this.initializeCube(t);let r=t.data;if(r instanceof Promise)return r.then(g=>this.initialize(Object.assign({},t,{pixels:g,data:g}))),this;let n=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(n&&r.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,r.addEventListener("loadeddata",()=>this.initialize(t)),this;let{parameters:o={}}=t,{pixels:a=null,pixelStore:s={},textureUnit:u=void 0}=t;r||(r=a);let{width:l,height:f,dataFormat:c,type:_,compressed:E=!1,mipmaps:d=!0}=t,{depth:h=0}=t,p=or(t.format,this.device.isWebGL2);return{width:l,height:f,compressed:E,dataFormat:c,type:_}=this._deduceParameters({format:t.format,type:_,dataFormat:c,compressed:E,data:r,width:l,height:f}),this.width=l,this.height=f,this.glFormat=p,this.type=_,this.dataFormat=c,this.textureUnit=u,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(i.TEXTURE0+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),d&&this.device.isWebGL1&&xr(this.width,this.height)&&(G.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaps`)(),d=!1),this.mipmaps=d,this.setImageData({data:r,width:l,height:f,depth:h,format:p,type:_,dataFormat:c,parameters:s,compressed:E}),this.setSampler(t.sampler),this._setSamplerParameters(o),d&&this.generateMipmap(),n&&(this._video={video:r,parameters:o,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(t){let{mipmaps:r=!0,parameters:n={}}=t;return this.setCubeMapImageData(t).then(()=>{this.loaded=!0,r&&this.generateMipmap(t),this.setSampler(t.sampler),this._setSamplerParameters(n)}),this}setSampler(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r;t instanceof Ze?(this.sampler=t,r=t.props):(this.sampler=new Ze(this.device,t),r=t);let n=Ir(r);return this._setSamplerParameters(n),this}resize(t){let{height:r,width:n,mipmaps:o=!1}=t;return n!==this.width||r!==this.height?this.initialize({width:n,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:o}):this}update(){if(this._video){let{video:t,parameters:r,lastTime:n}=this._video;if(n===t.currentTime||t.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:t,parameters:r}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=t.currentTime}}generateMipmap(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this.device.isWebGL1&&xr(this.width,this.height)?(G.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaping`)(),this):(this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),Y(this.gl,t,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this)}setImageData(t){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(t);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:n=null,level:o=0,glFormat:a=this.glFormat,offset:s=0,parameters:u={}}=t,{data:l=null,type:f=this.type,width:c=this.width,height:_=this.height,dataFormat:E=this.dataFormat,compressed:d=!1}=t;l||(l=n),{type:f,dataFormat:E,compressed:d,width:c,height:_}=this._deduceParameters({format:this.props.format,type:f,dataFormat:E,compressed:d,data:l,width:c,height:_});let{gl:h}=this;h.bindTexture(this.target,this.handle);let p=null;({data:l,dataType:p}=this._getDataType({data:l,compressed:d}));let g;if(Y(this.gl,u,()=>{switch(p){case"null":h.texImage2D(r,o,a,c,_,0,E,f,l);break;case"typed-array":h.texImage2D(r,o,a,c,_,0,E,f,l,s);break;case"buffer":g=this.device.assertWebGL2(),g.bindBuffer(i.PIXEL_UNPACK_BUFFER,l.handle||l),g.texImage2D(r,o,a,c,_,0,E,f,s),g.bindBuffer(i.PIXEL_UNPACK_BUFFER,null);break;case"browser-object":this.device.isWebGL2?h.texImage2D(r,o,a,c,_,0,E,f,l):h.texImage2D(r,o,a,E,f,l);break;case"compressed":for(let[T,m]of l.entries())h.compressedTexImage2D(r,T,m.format,m.width,m.height,0,m.data);break;default:(0,G.assert)(!1,"Unknown image data type")}}),l&&l.byteLength)this.trackAllocatedMemory(l.byteLength,"Texture");else{let T=ar(this.props.format,this.device.isWebGL2);this.trackAllocatedMemory(this.width*this.height*T,"Texture")}return this.loaded=!0,this}setSubImageData(t){let{target:r=this.target,pixels:n=null,data:o=null,x:a=0,y:s=0,width:u=this.width,height:l=this.height,level:f=0,glFormat:c=this.glFormat,type:_=this.type,dataFormat:E=this.dataFormat,compressed:d=!1,offset:h=0,parameters:p={}}=t;if({type:_,dataFormat:E,compressed:d,width:u,height:l}=this._deduceParameters({format:this.props.format,type:_,dataFormat:E,compressed:d,data:o,width:u,height:l}),(0,G.assert)(this.depth===1,"texSubImage not supported for 3D textures"),o||(o=n),o&&o.data){let g=o;o=g.data,u=g.shape[0],l=g.shape[1]}o instanceof se&&(o=o.handle),this.gl.bindTexture(this.target,this.handle),Y(this.gl,p,()=>{if(d)this.gl.compressedTexSubImage2D(r,f,a,s,u,l,c,o);else if(o===null)this.gl.texSubImage2D(r,f,a,s,u,l,E,_,null);else if(ArrayBuffer.isView(o))this.gl.texSubImage2D(r,f,a,s,u,l,E,_,o,h);else if(typeof WebGLBuffer<"u"&&o instanceof WebGLBuffer){let g=this.device.assertWebGL2();g.bindBuffer(i.PIXEL_UNPACK_BUFFER,o),g.texSubImage2D(r,f,a,s,u,l,E,_,h),g.bindBuffer(i.PIXEL_UNPACK_BUFFER,null)}else this.device.isWebGL2?this.device.assertWebGL2().texSubImage2D(r,f,a,s,u,l,E,_,o):this.gl.texSubImage2D(r,f,a,s,E,_,o)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return G.log.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(i.ACTIVE_TEXTURE)-i.TEXTURE0}bind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.textureUnit,{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(r.TEXTURE0+t)),r.bindTexture(this.target,this.handle),t}unbind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.textureUnit,{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(r.TEXTURE0+t)),r.bindTexture(this.target,null),t}_getDataType(t){let{data:r,compressed:n=!1}=t;return n?{data:r,dataType:"compressed"}:r===null?{data:r,dataType:"null"}:ArrayBuffer.isView(r)?{data:r,dataType:"typed-array"}:r instanceof se?{data:r.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&r instanceof WebGLBuffer?{data:r,dataType:"buffer"}:{data:r,dataType:"browser-object"}}_deduceParameters(t){let{format:r,data:n}=t,{width:o,height:a,dataFormat:s,type:u,compressed:l}=t,f=Nr(r,this.device.isWebGL2);return s=s||f.dataFormat,u=u||f.type,l=l||f.compressed,{width:o,height:a}=this._deduceImageSize(n,o,a),{dataFormat:s,type:u,compressed:l,width:o,height:a,format:r,data:n}}_deduceImageSize(t,r,n){let o;return typeof ImageData<"u"&&t instanceof ImageData?o={width:t.width,height:t.height}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?o={width:t.naturalWidth,height:t.naturalHeight}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?o={width:t.width,height:t.height}:typeof ImageBitmap<"u"&&t instanceof ImageBitmap?o={width:t.width,height:t.height}:typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?o={width:t.videoWidth,height:t.videoHeight}:t?o={width:r,height:n}:o={width:r>=0?r:1,height:n>=0?n:1},(0,G.assert)(o,"Could not deduced texture size"),(0,G.assert)(r===void 0||o.width===r,"Deduced texture width does not match supplied width"),(0,G.assert)(n===void 0||o.height===n,"Deduced texture height does not match supplied height"),o}async setCubeMapImageData(t){let{gl:r}=this,{width:n,height:o,pixels:a,data:s,format:u=i.RGBA,type:l=i.UNSIGNED_BYTE}=t,f=a||s,c=await Promise.all(k.FACES.map(_=>{let E=f[_];return Promise.all(Array.isArray(E)?E:[E])}));this.bind(),k.FACES.forEach((_,E)=>{c[E].length>1&&this.props.mipmaps!==!1&&G.log.warn(`${this.id} has mipmap and multiple LODs.`)(),c[E].forEach((d,h)=>{n&&o?r.texImage2D(_,h,u,n,o,0,u,l,d):r.texImage2D(_,h,u,u,l,d)})}),this.unbind()}setImageDataForFace(t){let{face:r,width:n,height:o,pixels:a,data:s,format:u=i.RGBA,type:l=i.UNSIGNED_BYTE}=t,{gl:f}=this,c=a||s;return this.bind(),c instanceof Promise?c.then(_=>this.setImageDataForFace(Object.assign({},t,{face:r,data:_,pixels:_}))):this.width||this.height?f.texImage2D(r,0,u,n,o,0,u,l,c):f.texImage2D(r,0,u,u,l,c),this}setImageData3D(t){let{level:r=0,dataFormat:n,format:o,type:a,width:s,height:u,depth:l=1,offset:f=0,data:c,parameters:_={}}=t;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let E=Nr(o,this.device.isWebGL2);if(Y(this.gl,_,()=>{ArrayBuffer.isView(c)&&this.gl.texImage3D(this.target,r,E.format,s,u,l,0,E.dataFormat,E.type,c),c instanceof se&&(this.gl.bindBuffer(i.PIXEL_UNPACK_BUFFER,c.handle),this.gl.texImage3D(this.target,r,n,s,u,l,0,o,a,f))}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{let d=ar(this.props.format,this.device.isWebGL2);this.trackAllocatedMemory(this.width*this.height*this.depth*d,"Texture")}return this.loaded=!0,this}_setSamplerParameters(t){if(this.device.isWebGL1&&xr(this.width,this.height)&&(t=na(t)),!(0,oa.isObjectEmpty)(t)){Xf(t),this.gl.bindTexture(this.target,this.handle);for(let[r,n]of Object.entries(t)){let o=Number(r),a=n;switch(o){case i.TEXTURE_MIN_LOD:case i.TEXTURE_MAX_LOD:this.gl.texParameterf(this.target,o,a);break;default:this.gl.texParameteri(this.target,o,a);break}}this.gl.bindTexture(this.target,null)}}_getWebGL1NPOTParameterOverride(t,r){if(this.device.isWebGL1&&xr(this.width,this.height))switch(t){case i.TEXTURE_MIN_FILTER:if(r!==i.LINEAR&&r!==i.NEAREST)return i.LINEAR;break;case i.TEXTURE_WRAP_S:case i.TEXTURE_WRAP_T:return i.CLAMP_TO_EDGE;default:break}return r}};k.FACES=[i.TEXTURE_CUBE_MAP_POSITIVE_X,i.TEXTURE_CUBE_MAP_NEGATIVE_X,i.TEXTURE_CUBE_MAP_POSITIVE_Y,i.TEXTURE_CUBE_MAP_NEGATIVE_Y,i.TEXTURE_CUBE_MAP_POSITIVE_Z,i.TEXTURE_CUBE_MAP_NEGATIVE_Z];function Lf(e){switch(e.dimension){case"2d":return i.TEXTURE_2D;case"cube":return i.TEXTURE_CUBE_MAP;case"2d-array":return i.TEXTURE_2D_ARRAY;case"3d":return i.TEXTURE_3D;case"1d":case"cube-array":default:throw new Error(e.dimension)}}function xr(e,t){return!e||!t?!1:!(0,G.isPowerOfTwo)(e)||!(0,G.isPowerOfTwo)(t)}function Xf(e){G.log.log(1,"texture sampler parameters",e)()}var ua=x(F(),1);var Ce=x(F(),1);var aa=x(F(),1);function Pr(e,t){if(typeof t!="string")return t;let r=Number(t);if(!isNaN(r))return r;t=t.replace(/^.*\./,"");let n=e[t];return(0,aa.assert)(n!==void 0,`Accessing undefined constant GL.${t}`),n}var ct="Resource subclass must define virtual methods",Mr=class extends Ce.Resource{constructor(t,r,n){super(t,r,n),this.device=void 0,this.gl=void 0,this.gl2=void 0,this._handle=void 0,this._bound=!1,this.byteLength=0,this.device=K.attach(t);let o=this.device.gl;bo(o);let{id:a}=r||{};this.gl=o,this.gl2=o,this.id=a||(0,Ce.uid)(this.constructor.name),this._handle=r?.handle,this._handle===void 0&&(this._handle=this._createHandle()),this.byteLength=0}toString(){return`${this.constructor.name}(${this.id})`}get handle(){return this._handle}delete(){let{deleteChildren:t=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=this._handle&&this._deleteHandle(this._handle);return this._handle&&this.removeStats(),this._handle=null,r&&t&&r.filter(Boolean).forEach(n=>n.destroy()),this}bind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.handle;if(typeof t!="function")return this._bindHandle(t),this;let r;return this._bound?r=t():(this._bindHandle(this.handle),this._bound=!0,r=t(),this._bound=!1,this._bindHandle(null)),r}unbind(){this.bind(null)}getParameter(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t=Pr(this.gl,t),(0,Ce.assert)(t);let o=(this.constructor.PARAMETERS||{})[t];if(o){let a=D(this.gl);if(!((!("webgl2"in o)||a)&&(!("extension"in o)||this.gl.getExtension(o.extension)))){let u=o.webgl1,l="webgl2"in o?o.webgl2:o.webgl1;return a?l:u}}return this._getParameter(t,r)}getParameters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{parameters:r,keys:n}=t,o=this.constructor.PARAMETERS||{},a=D(this.gl),s={},u=r||Object.keys(o);for(let l of u){let f=o[l];if(f&&(!("webgl2"in f)||a)&&(!("extension"in f)||this.gl.getExtension(f.extension))){let _=n?this.device.getGLKey(l):l;s[_]=this.getParameter(l,t),n&&f.type==="GLenum"&&(s[_]=this.device.getGLKey(s[_]))}}return s}setParameter(t,r){t=Pr(this.gl,t),(0,Ce.assert)(t);let o=(this.constructor.PARAMETERS||{})[t];if(o){let a=D(this.gl);if(!((!("webgl2"in o)||a)&&(!("extension"in o)||this.gl.getExtension(o.extension))))throw new Error("Parameter not available on this platform");o.type==="GLenum"&&(r=Pr(r))}return this._setParameter(t,r),this}setParameters(t){for(let r in t)this.setParameter(r,t[r]);return this}stubRemovedMethods(t,r,n){return(0,Ce.stubRemovedMethods)(this,t,r,n)}initialize(t){}_createHandle(){throw new Error(ct)}_deleteHandle(){throw new Error(ct)}_bindHandle(t){throw new Error(ct)}_getOptsFromHandle(){throw new Error(ct)}_getParameter(t,r){throw new Error(ct)}_setParameter(t,r){throw new Error(ct)}};var sa;sa=Symbol.toStringTag;var De=class extends Mr{get[sa](){return"Renderbuffer"}get width(){return this.props.width}get height(){return this.props.height}get format(){return this.props.format}get samples(){return this.props.samples}get attachment(){}static isTextureFormatSupported(t,r){return jo(t.gl,r)}constructor(t,r){if(typeof r.format=="number")throw new Error("Renderbuffer");super(t,r,De.defaultProps),this.glFormat=void 0,this.glFormat=or(this.props.format,t.isWebGL2),this._initialize(this.props)}resize(t){(t.width!==this.width||t.height!==this.height)&&(Object.assign(this.props,{...t,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(t){let{format:r,width:n,height:o,samples:a}=t;(0,ua.assert)(r,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(i.RENDERBUFFER,this.handle),a!==0&&this.device.isWebGL2?this.gl2.renderbufferStorageMultisample(i.RENDERBUFFER,a,this.glFormat,n,o):this.gl.renderbufferStorage(i.RENDERBUFFER,this.glFormat,n,o),this.gl.bindRenderbuffer(i.RENDERBUFFER,null),this.trackAllocatedMemory(n*o*(a||1)*ar(this.glFormat,this.device.isWebGL2))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(t){this.gl.bindRenderbuffer(i.RENDERBUFFER,t)}};De.defaultProps={id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0};var me=class extends Fr.Framebuffer{get texture(){return this.colorAttachments[0]}constructor(t,r){super(t,r),this.device=void 0,this.gl=void 0,this.handle=void 0;let n=r.handle===null;if(this.device=t,this.gl=t.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),!n){t.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures(),this.gl.bindFramebuffer(i.FRAMEBUFFER,this.handle);for(let o=0;o<this.colorAttachments.length;++o){let a=this.colorAttachments[o],s=i.COLOR_ATTACHMENT0+o;a&&this._attachOne(s,a)}this.depthStencilAttachment&&this._attachOne($o(this.depthStencilAttachment.format),this.depthStencilAttachment),this.gl.bindFramebuffer(i.FRAMEBUFFER,null)}r.check!==!1&&this._checkStatus()}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}_checkStatus(){let{gl:t}=this,r=t.bindFramebuffer(i.FRAMEBUFFER,this.handle),n=t.checkFramebufferStatus(i.FRAMEBUFFER);if(t.bindFramebuffer(i.FRAMEBUFFER,r||null),n!==t.FRAMEBUFFER_COMPLETE)throw new Error(`Framebuffer ${Hf(n)}`)}createDepthStencilTexture(t){return new De(this.device,{id:`${this.id}-depth-stencil`,format:t,width:this.width,height:this.height})}resizeAttachments(t,r){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;t===void 0&&(t=this.gl.drawingBufferWidth),r===void 0&&(r=this.gl.drawingBufferHeight);for(let n of this.colorAttachments)n.resize({width:t,height:r});return this.depthStencilAttachment&&this.depthStencilAttachment.resize({width:t,height:r}),this}_attachOne(t,r){if(r instanceof De)return this._attachWEBGLRenderbuffer(t,r),r;if(Array.isArray(r)){let[n,o=0,a=0]=r;return this._attachTexture(t,n,o,a),n}else if(r instanceof k)return this._attachTexture(t,r,0,0),r;throw new Error("attach")}_attachWEBGLRenderbuffer(t,r){this.gl.framebufferRenderbuffer(i.FRAMEBUFFER,t,i.RENDERBUFFER,r.handle)}_attachTexture(t,r,n,o){let{gl:a,gl2:s}=this.device;switch(a.bindTexture(r.target,r.handle),r.target){case i.TEXTURE_2D_ARRAY:case i.TEXTURE_3D:this.device.assertWebGL2(),s?.framebufferTextureLayer(i.FRAMEBUFFER,t,r.target,o,n);break;case i.TEXTURE_CUBE_MAP:let u=Wf(n);a.framebufferTexture2D(i.FRAMEBUFFER,t,u,r.handle,o);break;case i.TEXTURE_2D:a.framebufferTexture2D(i.FRAMEBUFFER,t,i.TEXTURE_2D,r.handle,o);break;default:(0,Fr.assert)(!1,"Illegal texture type")}a.bindTexture(r.target,null)}};function Wf(e){return e<i.TEXTURE_CUBE_MAP_POSITIVE_X?e+i.TEXTURE_CUBE_MAP_POSITIVE_X:e}function Hf(e){switch(e){case i.FRAMEBUFFER_COMPLETE:return"success";case i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"Mismatched attachments";case i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"No attachments";case i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"Height/width mismatch";case i.FRAMEBUFFER_UNSUPPORTED:return"Unsupported or split attachments";case i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:return"Samples mismatch";default:return`${e}`}}var Dr=class extends la.CanvasContext{constructor(t,r){super(r),this.device=void 0,this.presentationSize=void 0,this._framebuffer=null,this.device=t,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new me(this.device,{handle:null}),this._framebuffer}update(){let t=this.getPixelSize();(t[0]!==this.presentationSize[0]||t[1]!==this.presentationSize[1])&&(this.presentationSize=t)}resize(t){if(this.canvas){let n=this.getDevicePixelRatio(t?.useDevicePixels);this.setDevicePixelRatio(n,t);return}let r=this.device.gl.getExtension("STACKGL_resize_drawingbuffer");r&&t&&"width"in t&&"height"in t&&r.resize(t.width,t.height)}commit(){}};var Se=x(F(),1),Vf={spector:Se.log.get("spector")||Se.log.get("inspect")},Kf="https://spectorcdn.babylonjs.com/spector.bundle.js",Gf=1,te=null,fa=!1;async function ca(e){if(!globalThis.SPECTOR)try{await(0,Se.loadScript)(Kf)}catch(t){Se.log.warn(String(t))}}function _a(e){var t,r;if(e={...Vf,...e},!((t=e)!==null&&t!==void 0&&t.spector)||(!te&&globalThis.SPECTOR&&(Se.log.probe(Gf,"SPECTOR found and initialized")(),te=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=te)),!te))return null;if(!fa){var n,o;fa=!0,te.spyCanvases(),(n=te)===null||n===void 0||n.onCaptureStarted.add(u=>Se.log.info("Spector capture started:",u)()),(o=te)===null||o===void 0||o.onCapture.add(u=>{var l,f,c;Se.log.info("Spector capture complete:",u)(),(l=te)===null||l===void 0||l.getResultUI(),(f=te)===null||f===void 0||f.resultView.display(),(c=te)===null||c===void 0||c.resultView.addCapture(u)})}if((r=e)!==null&&r!==void 0&&r.canvas){var a,s;if(typeof e.spector=="string"&&e.spector!==e.canvas.id)return te;(a=te)===null||a===void 0||a.startCapture((s=e)===null||s===void 0?void 0:s.canvas,500),new Promise(u=>setTimeout(u,2e3)).then(u=>{var l;Se.log.info("Spector capture stopped after 2 seconds")(),(l=te)===null||l===void 0||l.stopCapture()})}return te}var Be=x(F(),1);var zf="https://unpkg.com/webgl-debug@2.0.1/index.js";function Ea(e){return e.luma=e.luma||{},e.luma}async function da(){_e()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await(0,Be.loadScript)(zf))}function ga(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e?t.debug?Yf(e,t):jf(e):null}function jf(e){let t=Ea(e);return t.realContext?t.realContext:e}function Yf(e,t){if(!globalThis.WebGLDebugUtils)return Be.log.warn("webgl-debug not loaded")(),e;let r=Ea(e);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...i,...e});let n=globalThis.WebGLDebugUtils.makeDebugContext(e,kf.bind(null,t),$f.bind(null,t));for(let s in i)!(s in n)&&typeof i[s]=="number"&&(n[s]=i[s]);class o{}Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.setPrototypeOf(o,n);let a=Object.create(o);return r.realContext=e,r.debugContext=a,a.debug=!0,a}function ni(e,t){t=Array.from(t).map(n=>n===void 0?"undefined":n);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${e}(${r})`}function kf(e,t,r,n){n=Array.from(n).map(l=>l===void 0?"undefined":l);let o=globalThis.WebGLDebugUtils.glEnumToString(t),a=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,n),s=e.webgl2?"gl2":"gl1",u=`${o} in ${s}.${r}(${a})`;Be.log.error(u)();debugger;if(e.throwOnError)throw new Error(u)}function $f(e,t,r){let n="";if(Be.log.level>=1&&(n=ni(t,r),Be.log.log(1,n)()),e.break&&e.break.length>0&&(n=n||ni(t,r),e.break.every(a=>n.indexOf(a)!==-1)))debugger;for(let o of r)if(o===void 0){if(n=n||ni(t,r),e.throwOnError)throw new Error(`Undefined argument: ${n}`);Be.log.error(`Undefined argument: ${n}`)();debugger}}var ue=x(F(),1);var Ur=x(F(),1);var Zf="Failed to deduce GL constant from typed array";function Br(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return i.FLOAT;case Uint16Array:return i.UNSIGNED_SHORT;case Uint32Array:return i.UNSIGNED_INT;case Uint8Array:return i.UNSIGNED_BYTE;case Uint8ClampedArray:return i.UNSIGNED_BYTE;case Int8Array:return i.BYTE;case Int16Array:return i.SHORT;case Int32Array:return i.INT;default:throw new Error(Zf)}}function _t(e,t){let{clamped:r=!0}=t||{};switch(e){case i.FLOAT:return Float32Array;case i.UNSIGNED_SHORT:case i.UNSIGNED_SHORT_5_6_5:case i.UNSIGNED_SHORT_4_4_4_4:case i.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;case i.UNSIGNED_INT:return Uint32Array;case i.UNSIGNED_BYTE:return r?Uint8ClampedArray:Uint8Array;case i.BYTE:return Int8Array;case i.SHORT:return Int16Array;case i.INT:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var qf={offset:0,stride:0,type:i.FLOAT,size:1,divisor:0,normalized:!1,integer:!1},Qf={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},ee=class{static getBytesPerElement(t){return _t(t.type||i.FLOAT).BYTES_PER_ELEMENT}static getBytesPerVertex(t){return(0,Ur.assert)(t.size),_t(t.type||i.FLOAT).BYTES_PER_ELEMENT*t.size}static resolve(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return new ee(qf,...r)}constructor(){this.offset=void 0,this.stride=void 0,this.type=void 0,this.size=void 0,this.divisor=void 0,this.normalized=void 0,this.integer=void 0,this.buffer=void 0,this.index=void 0;for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach(o=>this._assign(o)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return ee.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return ee.getBytesPerVertex(this)}_assign(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return t=(0,Ur.checkProps)("Accessor",t,Qf),t.type!==void 0&&(this.type=t.type,(t.type===i.INT||t.type===i.UNSIGNED_INT)&&(this.integer=!0)),t.size!==void 0&&(this.size=t.size),t.offset!==void 0&&(this.offset=t.offset),t.stride!==void 0&&(this.stride=t.stride),t.normalize!==void 0&&(this.normalized=t.normalize),t.normalized!==void 0&&(this.normalized=t.normalized),t.integer!==void 0&&(this.integer=t.integer),t.divisor!==void 0&&(this.divisor=t.divisor),t.buffer!==void 0&&(this.buffer=t.buffer),t.index!==void 0&&(typeof t.index=="boolean"?this.index=t.index?1:0:this.index=t.index),t.instanced!==void 0&&(this.divisor=t.instanced?1:0),t.isInstanced!==void 0&&(this.divisor=t.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};var ha=10,Aa={offset:"accessor.offset",stride:"accessor.stride",type:"accessor.type",size:"accessor.size",divisor:"accessor.divisor",normalized:"accessor.normalized",integer:"accessor.integer",instanced:"accessor.divisor",isInstanced:"accessor.divisor"},pa={removedProps:{},replacedProps:{bytes:"byteLength"},deprecatedProps:Aa},Jf={removedProps:Aa};function ec(e){return ArrayBuffer.isView(e)?{data:e}:typeof e=="number"?{byteLength:e}:(e=(0,ue.checkProps)("Buffer",e,pa),{...e})}var Et=class extends se{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(super(K.attach(t),ec(r)),this.accessor=void 0,this.setAccessor(Object.assign({},r,r.accessor)),this.props.data){let n=Br(this.props.data);(0,ue.assert)(n),this.setAccessor(new ee(this.accessor,{type:n}))}Object.seal(this)}getElementCount(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.accessor;return Math.round(this.byteLength/ee.getBytesPerElement(t))}getVertexCount(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.accessor;return Math.round(this.byteLength/ee.getBytesPerVertex(t))}initialize(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ArrayBuffer.isView(t)&&(t={data:t}),Number.isFinite(t)&&(t={byteLength:t}),t=(0,ue.checkProps)("Buffer",t,pa),this.glUsage=t.glUsage||i.STATIC_DRAW,this.debugData=null,this.setAccessor(Object.assign({},t,t.accessor)),t.data?this._setData(t.data,t.byteOffset,t.byteLength):this._setByteLength(t.byteLength||0),this}setProps(t){return t=(0,ue.checkProps)("Buffer",t,Jf),"accessor"in t&&this.setAccessor(t.accessor),this}setAccessor(t){return t=Object.assign({},t),delete t.buffer,this.accessor=new ee(t),this}reallocate(t){return t>this.byteLength?(this._setByteLength(t),!0):(this.bytesUsed=t,!1)}setData(t){return this.initialize(t)}subData(t){ArrayBuffer.isView(t)&&(t={data:t});let{data:r,offset:n=0,srcOffset:o=0}=t,a=t.byteLength||t.length;(0,ue.assert)(r);let s=this.gl.webgl2?i.COPY_WRITE_BUFFER:this.glTarget;return this.gl.bindBuffer(s,this.handle),o!==0||a!==void 0?(mr(this.gl),this.gl.bufferSubData(this.glTarget,n,r,o,a)):this.gl.bufferSubData(s,n,r),this.gl.bindBuffer(s,null),this.debugData=null,this._inferType(r),this}copyData(t){let{sourceBuffer:r,readOffset:n=0,writeOffset:o=0,size:a}=t,{gl:s,gl2:u}=this;return mr(s),s.bindBuffer(i.COPY_READ_BUFFER,r.handle),s.bindBuffer(i.COPY_WRITE_BUFFER,this.handle),u?.copyBufferSubData(i.COPY_READ_BUFFER,i.COPY_WRITE_BUFFER,n,o,a),s.bindBuffer(i.COPY_READ_BUFFER,null),s.bindBuffer(i.COPY_WRITE_BUFFER,null),this.debugData=null,this}getData(t){var r;let{dstData:n=null,length:o=0}=t||{},{srcByteOffset:a=0,dstOffset:s=0}=t||{};mr(this.gl);let u=_t(this.accessor.type||i.FLOAT,{clamped:!1}),l=this._getAvailableElementCount(a),f=s,c,_;n?(_=n.length,c=_-f):(c=Math.min(l,o||l),_=f+c);let E=Math.min(l,c);return o=o||E,(0,ue.assert)(o<=E),n=n||new u(_),this.gl.bindBuffer(i.COPY_READ_BUFFER,this.handle),(r=this.gl2)===null||r===void 0||r.getBufferSubData(i.COPY_READ_BUFFER,a,n,s,o),this.gl.bindBuffer(i.COPY_READ_BUFFER,null),n}bind(t){let{glTarget:r=this.glTarget,index:n=this.accessor&&this.accessor.index,offset:o=0,size:a}=t||{};if(r===i.UNIFORM_BUFFER||r===i.TRANSFORM_FEEDBACK_BUFFER)if(a!==void 0){var s;(s=this.gl2)===null||s===void 0||s.bindBufferRange(r,n,this.handle,o,a)}else{var u;(0,ue.assert)(o===0),(u=this.gl2)===null||u===void 0||u.bindBufferBase(r,n,this.handle)}else this.gl.bindBuffer(r,this.handle);return this}unbind(t){let{glTarget:r=this.glTarget,index:n=this.accessor&&this.accessor.index}=t||{};if(r===i.UNIFORM_BUFFER||r===i.TRANSFORM_FEEDBACK_BUFFER){var a;(a=this.gl2)===null||a===void 0||a.bindBufferBase(r,n,null)}else this.gl.bindBuffer(r,null);return this}getDebugData(){return this.debugData?{data:this.debugData,changed:!1}:(this.debugData=this.getData({length:Math.min(ha,this.byteLength)}),{data:this.debugData,changed:!0})}invalidateDebugData(){this.debugData=null}_setData(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.byteLength+r;(0,ue.assert)(ArrayBuffer.isView(t)),this.trackDeallocatedMemory();let o=this._getTarget();this.gl.bindBuffer(o,this.handle),this.gl.bufferData(o,n,this.glUsage),this.gl.bufferSubData(o,r,t),this.gl.bindBuffer(o,null),this.debugData=t.slice(0,ha),this.bytesUsed=n,this.byteLength=n,this.trackAllocatedMemory(n);let a=Br(t);return(0,ue.assert)(a),this.setAccessor(new ee(this.accessor,{type:a})),this}_setByteLength(t){(0,ue.assert)(t>=0),this.trackDeallocatedMemory();let r=t;t===0&&(r=new Float32Array(0));let n=this._getTarget();return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,r,this.glUsage),this.gl.bindBuffer(n,null),this.debugData=null,this.bytesUsed=t,this.byteLength=t,this.trackAllocatedMemory(t),this}_getTarget(){return this.gl.webgl2?i.COPY_WRITE_BUFFER:this.glTarget}_getAvailableElementCount(t){let r=_t(this.accessor.type||i.FLOAT,{clamped:!1}),n=t/r.BYTES_PER_ELEMENT;return this.getElementCount()-n}_inferType(t){this.accessor.type||this.setAccessor(new ee(this.accessor,{type:Br(t)}))}getParameter(t){this.gl.bindBuffer(this.glTarget,this.handle);let r=this.gl.getBufferParameter(this.glTarget,t);return this.gl.bindBuffer(this.glTarget,null),r}get type(){return this.accessor.type}};var Ue=x(F(),1);function ii(e,t){return{name:tc(e,t),language:"glsl",version:rc(e)}}function tc(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"unnamed",n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return n?n[1]:t}function rc(e){let t=100,r=e.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let n=parseInt(r[1],10);Number.isFinite(n)&&(t=n)}return t}var nc=["warning","error","info"];function oi(e){let t=e.split(/\r?\n/),r=[];for(let n of t){if(n.length<=1)continue;let o=n.split(":"),[a,s,u,...l]=o,f=parseInt(u,10);isNaN(f)&&(f=0);let c=parseInt(s,10);isNaN(c)&&(c=0);let _=a.toLowerCase(),E=nc.includes(_)?_:"info";r.push({message:l.join(":").trim(),type:E,lineNum:f,linePos:c})}return r}var wr=class extends Ue.Shader{constructor(t,r){switch(super(t,{id:ic(r),...r}),this.device=void 0,this.handle=void 0,this.device=t,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(i.VERTEX_SHADER);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(i.FRAGMENT_SHADER);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async compilationInfo(){let t=this.device.gl.getShaderInfoLog(this.handle);return t?oi(t):[]}_compile(t){t=(a=>a.startsWith("#version ")?a:`#version 100
302
+ ${a}`)(t);let{gl:n}=this.device;if(n.shaderSource(this.handle,t),n.compileShader(this.handle),!n.getShaderParameter(this.handle,i.COMPILE_STATUS)){let a=n.getShaderInfoLog(this.handle),u=(a?oi(a):[]).filter(_=>_.type==="error"),l=(0,Ue.formatCompilerLog)(u,t,{showSourceCode:!0}),f=ii(t).name,c=`${this.stage} shader ${f}`;throw Ue.log.error(`GLSL compilation errors in ${c}
303
+ ${l}`)(),new Error(`GLSL compilation errors in ${f}`)}}};function ic(e){return ii(e.source).name||e.id||(0,Ue.uid)(`unnamed ${e.stage}-shader`)}var Ta=x(F(),1);var oc=256,ac=1024,sc=16384,ai=6144,Lr=class extends Ta.RenderPass{constructor(t,r){super(t,r),this.device=void 0,this.glParameters=void 0,this.device=t,this.setParameters(this.props.parameters),this.clear()}end(){}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r={};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[i.RASTERIZER_DISCARD]=this.props.discard,t.viewport&&(t.viewport.length>=6?(r.viewport=t.viewport.slice(0,4),r.depthRange=[t.viewport[4],t.viewport[5]]):r.viewport=t.viewport),r.scissorTest=Boolean(t.scissorRect),t.scissorRect&&(r.scissor=t.scissorRect),t.blendConstant&&(r.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),t[i.STENCIL_REF]=t.stencilReference),this.glParameters=r,Fe(this.device,r)}clear(){let t={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=sc,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=oc,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=ac,t.clearStencil=this.props.clearStencil),r!==0&&Y(this.device,t,()=>{this.device.gl.clear(r)})}clearColorBuffer(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0,0,0];Y(this.device.gl2,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl2.clearBufferiv(ai,t,r);break;case Uint32Array:this.device.gl2.clearBufferuiv(ai,t,r);break;case Float32Array:default:this.device.gl2.clearBufferfv(ai,t,r);break}})}};var oe=x(F(),1),Na=x(F(),1);function Ra(e){return uc.includes(e)}var uc=[i.SAMPLER_2D,i.SAMPLER_CUBE,i.SAMPLER_3D,i.SAMPLER_2D_SHADOW,i.SAMPLER_2D_ARRAY,i.SAMPLER_2D_ARRAY_SHADOW,i.SAMPLER_CUBE_SHADOW,i.INT_SAMPLER_2D,i.INT_SAMPLER_3D,i.INT_SAMPLER_CUBE,i.INT_SAMPLER_2D_ARRAY,i.UNSIGNED_INT_SAMPLER_2D,i.UNSIGNED_INT_SAMPLER_3D,i.UNSIGNED_INT_SAMPLER_CUBE,i.UNSIGNED_INT_SAMPLER_2D_ARRAY],ma={[i.FLOAT]:[i.FLOAT,1,"float","f32","float32"],[i.FLOAT_VEC2]:[i.FLOAT,2,"vec2","vec2<f32>","float32x2"],[i.FLOAT_VEC3]:[i.FLOAT,3,"vec3","vec3<f32>","float32x3"],[i.FLOAT_VEC4]:[i.FLOAT,4,"vec4","vec4<f32>","float32x4"],[i.INT]:[i.INT,1,"int","i32","sint32"],[i.INT_VEC2]:[i.INT,2,"ivec2","vec2<i32>","sint32x2"],[i.INT_VEC3]:[i.INT,3,"ivec3","vec3<i32>","sint32x3"],[i.INT_VEC4]:[i.INT,4,"ivec4","vec4<i32>","sint32x4"],[i.UNSIGNED_INT]:[i.UNSIGNED_INT,1,"uint","u32","uint32"],[i.UNSIGNED_INT_VEC2]:[i.UNSIGNED_INT,2,"uvec2","vec2<u32>","uint32x2"],[i.UNSIGNED_INT_VEC3]:[i.UNSIGNED_INT,3,"uvec3","vec3<u32>","uint32x3"],[i.UNSIGNED_INT_VEC4]:[i.UNSIGNED_INT,4,"uvec4","vec4<u32>","uint32x4"],[i.BOOL]:[i.FLOAT,1,"bool","f32","float32"],[i.BOOL_VEC2]:[i.FLOAT,2,"bvec2","vec2<f32>","float32x2"],[i.BOOL_VEC3]:[i.FLOAT,3,"bvec3","vec3<f32>","float32x3"],[i.BOOL_VEC4]:[i.FLOAT,4,"bvec4","vec4<f32>","float32x4"],[i.FLOAT_MAT2]:[i.FLOAT,8,"mat2","mat2x2<f32>"],[i.FLOAT_MAT2x3]:[i.FLOAT,8,"mat2x3","mat2x3<f32>"],[i.FLOAT_MAT2x4]:[i.FLOAT,8,"mat2x4","mat2x4<f32>"],[i.FLOAT_MAT3x2]:[i.FLOAT,12,"mat3x2","mat3x2<f32>"],[i.FLOAT_MAT3]:[i.FLOAT,12,"mat3","mat3x3<f32>"],[i.FLOAT_MAT3x4]:[i.FLOAT,12,"mat3x4","mat3x4<f32>"],[i.FLOAT_MAT4x2]:[i.FLOAT,16,"mat4x2","mat4x2<f32>"],[i.FLOAT_MAT4x3]:[i.FLOAT,16,"mat4x3","mat4x3<f32>"],[i.FLOAT_MAT4]:[i.FLOAT,16,"mat4","mat4x4<f32>"]};function si(e){let t=ma[e];if(!t)throw new Error("uniform");let[r,n,,o]=t;return{format:o,components:n,glType:r}}function Sa(e){let t=ma[e];if(!t)throw new Error("attribute");let[,r,,n,o]=t;return{attributeType:n,vertexFormat:o,components:r}}function Oa(e,t){let r={attributes:[],bindings:[]};r.attributes=lc(e,t);let n=_c(e,t);for(let u of n){let l=u.uniforms.map(f=>({name:f.name,format:f.format,byteOffset:f.byteOffset,byteStride:f.byteStride,arrayLength:f.arrayLength}));r.bindings.push({type:"uniform",name:u.name,location:u.location,visibility:(u.vertex?1:0)&(u.fragment?2:0),minBindingSize:u.byteLength,uniforms:l})}let o=cc(e,t),a=0;for(let u of o)if(Ra(u.type)){let{viewDimension:l,sampleType:f}=dc(u.type);r.bindings.push({type:"texture",name:u.name,location:a,viewDimension:l,sampleType:f}),u.textureUnit=a,a+=1}o.length&&(r.uniforms=o);let s=fc(e,t);return s!=null&&s.length&&(r.varyings=s),r}function lc(e,t){let r=[],n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let o=0;o<n;o++){let a=e.getActiveAttrib(t,o);if(!a)throw new Error("activeInfo");let{name:s,type:u}=a,l=e.getAttribLocation(t,s);if(l>=0){let{attributeType:f}=Sa(u),c=/instance/i.test(s)?"instance":"vertex";r.push({name:s,location:l,stepMode:c,type:f})}}return r.sort((o,a)=>o.location-a.location),r}function fc(e,t){if(!D(e))return[];let r=e,n=[],o=e.getProgramParameter(t,i.TRANSFORM_FEEDBACK_VARYINGS);for(let a=0;a<o;a++){let s=r.getTransformFeedbackVarying(t,a);if(!s)throw new Error("activeInfo");let{name:u,type:l,size:f}=s,{glType:c,components:_}=si(l),E=new ee({type:c,size:f*_}),d={location:a,name:u,accessor:E};n.push(d)}return n.sort((a,s)=>a.location-s.location),n}function cc(e,t){let r=[],n=e.getProgramParameter(t,i.ACTIVE_UNIFORMS);for(let o=0;o<n;o++){let a=e.getActiveUniform(t,o);if(!a)throw new Error("activeInfo");let{name:s,size:u,type:l}=a,{name:f,isArray:c}=gc(s),_=e.getUniformLocation(t,f),E={location:_,name:f,size:u,type:l,isArray:c};if(r.push(E),E.size>1)for(let d=0;d<E.size;d++){let h=`${f}[${d}]`;_=e.getUniformLocation(t,h);let p={...E,name:h,location:_};r.push(p)}}return r}function _c(e,t){if(!D(e))return[];let r=e,n=(s,u)=>r.getActiveUniformBlockParameter(t,s,u),o=[],a=r.getProgramParameter(t,i.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<a;s++){let u={name:r.getActiveUniformBlockName(t,s)||"",location:n(s,i.UNIFORM_BLOCK_BINDING),byteLength:n(s,i.UNIFORM_BLOCK_DATA_SIZE),vertex:n(s,i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),fragment:n(s,i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),uniformCount:n(s,i.UNIFORM_BLOCK_ACTIVE_UNIFORMS),uniforms:[]},l=n(s,i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES)||[],f=r.getActiveUniforms(t,l,i.UNIFORM_TYPE),c=r.getActiveUniforms(t,l,i.UNIFORM_SIZE),_=r.getActiveUniforms(t,l,i.UNIFORM_OFFSET),E=r.getActiveUniforms(t,l,i.UNIFORM_ARRAY_STRIDE);for(let d=0;d<u.uniformCount;++d){let h=r.getActiveUniform(t,l[d]);if(!h)throw new Error("activeInfo");u.uniforms.push({name:h.name,format:si(f[d]).format,type:f[d],arrayLength:c[d],byteOffset:_[d],byteStride:E[d]})}o.push(u)}return o.sort((s,u)=>s.location-u.location),o}var Ec={[i.SAMPLER_2D]:["2d","float"],[i.SAMPLER_CUBE]:["cube","float"],[i.SAMPLER_3D]:["3d","float"],[i.SAMPLER_2D_SHADOW]:["3d","depth"],[i.SAMPLER_2D_ARRAY]:["2d-array","float"],[i.SAMPLER_2D_ARRAY_SHADOW]:["2d-array","depth"],[i.SAMPLER_CUBE_SHADOW]:["cube","float"],[i.INT_SAMPLER_2D]:["2d","sint"],[i.INT_SAMPLER_3D]:["3d","sint"],[i.INT_SAMPLER_CUBE]:["cube","sint"],[i.INT_SAMPLER_2D_ARRAY]:["2d-array","uint"],[i.UNSIGNED_INT_SAMPLER_2D]:["2d","uint"],[i.UNSIGNED_INT_SAMPLER_3D]:["3d","uint"],[i.UNSIGNED_INT_SAMPLER_CUBE]:["cube","uint"],[i.UNSIGNED_INT_SAMPLER_2D_ARRAY]:["2d-array","uint"]};function dc(e){let t=Ec[e];if(!t)throw new Error("sampler");let[r,n]=t;return{viewDimension:r,sampleType:n}}function gc(e){if(e[e.length-1]!=="]")return{name:e,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}function va(e,t,r,n){let o=e,a=n;a===!0&&(a=1),a===!1&&(a=0);let s=typeof a=="number"?[a]:a;switch(r){case i.SAMPLER_2D:case i.SAMPLER_CUBE:case i.SAMPLER_3D:case i.SAMPLER_2D_SHADOW:case i.SAMPLER_2D_ARRAY:case i.SAMPLER_2D_ARRAY_SHADOW:case i.SAMPLER_CUBE_SHADOW:case i.INT_SAMPLER_2D:case i.INT_SAMPLER_3D:case i.INT_SAMPLER_CUBE:case i.INT_SAMPLER_2D_ARRAY:case i.UNSIGNED_INT_SAMPLER_2D:case i.UNSIGNED_INT_SAMPLER_3D:case i.UNSIGNED_INT_SAMPLER_CUBE:case i.UNSIGNED_INT_SAMPLER_2D_ARRAY:if(typeof n!="number")throw new Error("samplers must be set to integers");return e.uniform1i(t,n);case i.FLOAT:return e.uniform1fv(t,s);case i.FLOAT_VEC2:return e.uniform2fv(t,s);case i.FLOAT_VEC3:return e.uniform3fv(t,s);case i.FLOAT_VEC4:return e.uniform4fv(t,s);case i.INT:return e.uniform1iv(t,s);case i.INT_VEC2:return e.uniform2iv(t,s);case i.INT_VEC3:return e.uniform3iv(t,s);case i.INT_VEC4:return e.uniform4iv(t,s);case i.BOOL:return e.uniform1iv(t,s);case i.BOOL_VEC2:return e.uniform2iv(t,s);case i.BOOL_VEC3:return e.uniform3iv(t,s);case i.BOOL_VEC4:return e.uniform4iv(t,s);case i.UNSIGNED_INT:return o.uniform1uiv(t,s,1);case i.UNSIGNED_INT_VEC2:return o.uniform2uiv(t,s,2);case i.UNSIGNED_INT_VEC3:return o.uniform3uiv(t,s,3);case i.UNSIGNED_INT_VEC4:return o.uniform4uiv(t,s,4);case i.FLOAT_MAT2:return e.uniformMatrix2fv(t,!1,s);case i.FLOAT_MAT3:return e.uniformMatrix3fv(t,!1,s);case i.FLOAT_MAT4:return e.uniformMatrix4fv(t,!1,s);case i.FLOAT_MAT2x3:return o.uniformMatrix2x3fv(t,!1,s);case i.FLOAT_MAT2x4:return o.uniformMatrix2x4fv(t,!1,s);case i.FLOAT_MAT3x2:return o.uniformMatrix3x2fv(t,!1,s);case i.FLOAT_MAT3x4:return o.uniformMatrix3x4fv(t,!1,s);case i.FLOAT_MAT4x2:return o.uniformMatrix4x2fv(t,!1,s);case i.FLOAT_MAT4x3:return o.uniformMatrix4x3fv(t,!1,s)}throw new Error("Illegal uniform")}var ba=4,Xr=class extends oe.RenderPipeline{constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.vs=void 0,this.fs=void 0,this.introspectedLayout=void 0,this.uniforms={},this.bindings={},this.varyings=null,this._textureUniforms={},this._textureIndexCounter=0,this._uniformCount=0,this._uniformSetters={},this.device=t,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=(0,oe.cast)(r.vs),this.fs=(0,oe.cast)(r.fs);let{varyings:n,bufferMode:o=i.SEPARATE_ATTRIBS}=r;if(n&&n.length>0){var a;this.device.assertWebGL2(),this.varyings=n,(a=this.device.gl2)===null||a===void 0||a.transformFeedbackVaryings(this.handle,n,o)}this._compileAndLink(),this.introspectedLayout=Oa(this.device.gl,this.handle),this.shaderLayout=(0,Na.mergeShaderLayout)(this.introspectedLayout,r.shaderLayout)}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(t){for(let[r,n]of Object.entries(t)){let o=this.shaderLayout.bindings.find(a=>a.name===r);if(!o){let a=this.shaderLayout.bindings.map(s=>`"${s.name}"`).join(", ");oe.log.warn(`Unknown binding "${r}" in render pipeline "${this.id}", expected one of ${a}`)();continue}switch(n||oe.log.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(n instanceof se)&&!(n.buffer instanceof se))throw new Error("buffer value");break;case"texture":if(!(n instanceof k||n instanceof me))throw new Error("texture value");break;case"sampler":oe.log.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(o.type)}this.bindings[r]=n}}setUniforms(t){Object.assign(this.uniforms,t)}draw(t){var r;let{renderPass:n,vertexArray:o,vertexCount:a,instanceCount:s,firstVertex:u=0}=t,l=hc(this.props.topology),f=Boolean(o.indexBuffer),c=(r=o.indexBuffer)===null||r===void 0?void 0:r.glIndexType,_=Number(s)>0;if(!this._areTexturesRenderable()||a===0)return!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(n);let E=Ac(this.props.topology),d=null;d&&d.begin(E),this._applyBindings(),this._applyUniforms();let h=n;return ta(this.device,this.props.parameters,h.glParameters,()=>{if(f&&_){var p;(p=this.device.gl2)===null||p===void 0||p.drawElementsInstanced(l,a||0,c,u,s||0)}else if(f)this.device.gl.drawElements(l,a||0,c,u);else if(_){var g;(g=this.device.gl2)===null||g===void 0||g.drawArraysInstanced(l,u,a||0,s||0)}else this.device.gl.drawArrays(l,u,a||0);d&&d.end()}),o.unbindAfterRender(n),!0}_compileAndLink(){let{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),oe.log.time(ba,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),oe.log.timeEnd(ba,`linkProgram for ${this.id}`)(),!t.debug&&oe.log.level,!t.getProgramParameter(this.handle,t.LINK_STATUS))throw new Error(`Error linking: ${t.getProgramInfoLog(this.handle)}`);if(t.validateProgram(this.handle),!t.getProgramParameter(this.handle,t.VALIDATE_STATUS))throw new Error(`Error validating: ${t.getProgramInfoLog(this.handle)}`)}_areTexturesRenderable(){let t=!0;for(let[,r]of Object.entries(this._textureUniforms))r.update(),t=t&&r.loaded;for(let[,r]of Object.entries(this.bindings))r.loaded!==void 0&&(t=t&&r.loaded);return t}_applyBindings(){this.device.gl.useProgram(this.handle);let{gl2:t}=this.device;if(!t)throw new Error("bindings");let r=0,n=0;for(let o of this.shaderLayout.bindings){let a=this.bindings[o.name];if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:s}=o,u=t.getUniformBlockIndex(this.handle,s);if(u===i.INVALID_INDEX)throw new Error(`Invalid uniform block name ${s}`);t.uniformBlockBinding(this.handle,n,u),a instanceof se?t.bindBufferBase(i.UNIFORM_BUFFER,n,a.handle):t.bindBufferRange(i.UNIFORM_BUFFER,n,a.buffer.handle,a.offset||0,a.size||a.buffer.byteLength-a.offset),n+=1;break;case"texture":if(!(a instanceof k||a instanceof me))throw new Error("texture");let l;if(a instanceof k)l=a;else if(a instanceof me&&a.colorAttachments[0]instanceof k)oe.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=a.colorAttachments[0];else throw new Error("No texture");t.activeTexture(i.TEXTURE0+r),t.bindTexture(l.target,l.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(){for(let r of this.shaderLayout.uniforms||[]){var t;let{name:n,location:o,type:a,textureUnit:s}=r,u=(t=this.uniforms[n])!==null&&t!==void 0?t:s;u!==void 0&&va(this.device.gl,o,a,u)}}};function hc(e){switch(e){case"point-list":return i.POINTS;case"line-list":return i.LINES;case"line-strip":return i.LINE_STRIP;case"line-loop-webgl":return i.LINE_LOOP;case"triangle-list":return i.TRIANGLES;case"triangle-strip":return i.TRIANGLE_STRIP;case"triangle-fan-webgl":return i.TRIANGLE_FAN;default:throw new Error(e)}}function Ac(e){switch(e){case"point-list":return i.POINTS;case"line-list":return i.LINES;case"line-strip":return i.LINES;case"line-loop-webgl":return i.LINES;case"triangle-list":return i.TRIANGLES;case"triangle-strip":return i.TRIANGLES;case"triangle-fan-webgl":return i.TRIANGLES;default:throw new Error(e)}}var ya=x(F(),1);var Hr=x(F(),1);var Wr=class extends Hr.CommandBuffer{constructor(t){super({}),this.device=void 0,this.commands=[],this.device=t}submitCommands(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.commands;for(let r of t)switch(r.name){case"copy-buffer-to-buffer":pc(this.device,r.options);break;case"copy-buffer-to-texture":Tc(this.device,r.options);break;case"copy-texture-to-buffer":Rc(this.device,r.options);break;case"copy-texture-to-texture":mc(this.device,r.options);break}}};function pc(e,t){let r=t.source,n=t.destination,o=e.assertWebGL2();if(o){var a,s;o.bindBuffer(i.COPY_READ_BUFFER,r.handle),o.bindBuffer(i.COPY_WRITE_BUFFER,n.handle),o.copyBufferSubData(i.COPY_READ_BUFFER,i.COPY_WRITE_BUFFER,(a=t.sourceOffset)!==null&&a!==void 0?a:0,(s=t.destinationOffset)!==null&&s!==void 0?s:0,t.size),o.bindBuffer(i.COPY_READ_BUFFER,null),o.bindBuffer(i.COPY_WRITE_BUFFER,null)}else throw new Error("copyBufferToBuffer not implemented in WebGL1")}function Tc(e,t){throw new Error("Not implemented")}function Rc(e,t){let{source:r,mipLevel:n=0,aspect:o="all",width:a=t.source.width,height:s=t.source.height,depthOrArrayLayers:u=0,origin:l=[0,0],destination:f,byteOffset:c=0,bytesPerRow:_,rowsPerImage:E}=t;if(o!=="all")throw new Error("not supported");if(n!==0||u!==void 0||_||E)throw new Error("not implemented");let d=e.assertWebGL2(),{framebuffer:h,destroyFramebuffer:p}=Ca(r);try{let g=f,T=a||h.width,m=s||h.height,R=i.RGBA,S=i.UNSIGNED_BYTE;d.bindBuffer(i.PIXEL_PACK_BUFFER,g.handle),d.bindFramebuffer(i.FRAMEBUFFER,h.handle),d.readPixels(l[0],l[1],T,m,R,S,c)}finally{d.bindBuffer(i.PIXEL_PACK_BUFFER,null),d.bindFramebuffer(i.FRAMEBUFFER,null),p&&h.destroy()}}function mc(e,t){let{source:r,origin:n=[0,0],destination:o}=t,{width:a=t.destination.width,height:s=t.destination.width}=t,u=0,l=i.RGBA,{framebuffer:f,destroyFramebuffer:c}=Ca(r),[_,E]=n,d=!1;e.gl.bindFramebuffer(i.FRAMEBUFFER,f.handle);let h=null,p;if(o instanceof k)h=o,a=Number.isFinite(a)?a:h.width,s=Number.isFinite(s)?s:h.height,h.bind(0),p=h.destination;else throw new Error("whoops");return d||e.gl.copyTexImage2D(p,u,l,_,E,a,s,0),h&&h.unbind(),c&&f.destroy(),h}function Ca(e){if(e instanceof Hr.Texture){let{width:t,height:r,id:n}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${n}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var Vr=class extends ya.CommandEncoder{constructor(t,r){super(t,r),this.device=void 0,this.commandBuffer=void 0,this.device=t,this.commandBuffer=new Wr(t)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}};var gt=x(F(),1);var Ia;Ia=Symbol.toStringTag;var dt=class extends gt.VertexArray{get[Ia](){return"VertexArray"}static isConstantAttributeZeroSupported(t){return t.info.type==="webgl2"||Rr()==="Chrome"}constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.buffer=null,this.bufferValue=null,this.init=!1,this.device=t,this.handle=this.device.gl2.createVertexArray()}destroy(){if(super.destroy(),this.buffer){var t;(t=this.buffer)===null||t===void 0||t.destroy()}this.handle&&(this.device.gl2.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){let r=t;if(r&&r.glTarget!==i.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setBuffer()");this.device.gl2.bindVertexArray(this.handle),this.device.gl2.bindBuffer(i.ELEMENT_ARRAY_BUFFER,r?r.handle:null),this.indexBuffer=r}setBuffer(t,r){let n=r;if(n.glTarget===i.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setIndexBuffer()");let{size:o,type:a,stride:s,offset:u,normalized:l,integer:f,divisor:c}=this._getAccessor(t);this.device.gl2.bindVertexArray(this.handle),this.device.gl.bindBuffer(i.ARRAY_BUFFER,n.handle),f?(this.device.assertWebGL2(),this.device.gl2.vertexAttribIPointer(t,o,a,s,u)):this.device.gl.vertexAttribPointer(t,o,a,l,s,u),this.device.gl.enableVertexAttribArray(t),this.device.gl2.vertexAttribDivisor(t,c||0),this.attributes[t]=n}setConstant(t,r){this._enable(t,!1),this.attributes[t]=r}bindBeforeRender(){if(this.device.gl2.bindVertexArray(this.handle),!this.init){let t=this.indexBuffer;this.device.gl2.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t?.handle||null),this.init=!0}this._applyConstantAttributes()}unbindAfterRender(){this.device.gl2.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){let r=this.attributes[t];ArrayBuffer.isView(r)&&this.device.setConstantAttribute(t,r)}}_getAccessor(t){let r=this.attributeInfos[t];if(!r)throw new Error(`Unknown attribute location ${t}`);let n=vr(r.bufferDataType);return{size:r.bufferComponents,type:n,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,o=dt.isConstantAttributeZeroSupported(this.device)||t!==0;(r||o)&&(t=Number(t),this.device.gl2.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl2.bindVertexArray(null))}getConstantBuffer(t,r){let n=Sc(r),o=n.byteLength*t,a=n.length*t,s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:o}),s=s||this.buffer.reallocate(o),s=s||!Oc(n,this.bufferValue),s){let u=(0,gt.getScratchArray)(r.constructor,a);(0,gt.fillArray)({target:u,source:n,start:0,count:a}),this.buffer.subData(u),this.bufferValue=r}return this.buffer}};function Sc(e){return Array.isArray(e)?new Float32Array(e):e}function Oc(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var Kr=1,K=class extends V.Device{static isSupported(){return typeof WebGLRenderingContext<"u"||mo()}get features(){return this._features=this._features||qo(this.gl),this._features}get limits(){return this._limits=this._limits||Jo(this.gl),this._limits}static attach(t){if(t instanceof K)return t;if(t?.device instanceof V.Device)return t.device;if(!vc(t))throw new Error("Invalid WebGLRenderingContext");return new K({gl:t})}static async create(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};V.log.groupCollapsed(Kr,"WebGLDevice created"),typeof t.canvas=="string"&&await V.CanvasContext.pageLoaded,(V.log.get("debug")||t.debug)&&await da();let{spector:r}=t;return(V.log.get("spector")||r)&&await ca(),V.log.probe(Kr+1,"DOM is loaded")(),t.gl&&t.gl.device?K.attach(t.gl):new K(t)}constructor(t){var r;super({...t,id:t.id||(0,V.uid)("webgl-device")}),this.info=void 0,this.canvasContext=void 0,this.handle=void 0,this.lost=void 0,this._resolveContextLost=void 0,this._features=void 0,this._limits=void 0,this.renderPass=null,this.gl=void 0,this.gl2=null,this.debug=!1,this.isWebGL1=void 0,this.isWebGL2=void 0,this._canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1},this._extensions={},this._polyfilled=!1,this.spector=void 0,this._webglLimits=void 0,this._constants=void 0;let n=(r=t.gl)===null||r===void 0?void 0:r.device;if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new Dr(this,t),this.lost=new Promise(f=>{this._resolveContextLost=f});let o=f=>{var c;return(c=this._resolveContextLost)===null||c===void 0?void 0:c.call(this,{reason:"destroyed",message:"Computer entered sleep mode, or too many apps or browser tabs are using the GPU."})},a=t.gl||null;if(a=a||(_e()?Ho(this.canvasContext.canvas,{...t,onContextLost:o}):null),a=a||(_e()?null:So({...t,onContextLost:o})),!a)throw new Error("WebGL context creation failed");this.handle=a,this.gl=this.handle,this.gl2=this.gl,this.isWebGL2=bc(this.gl),this.isWebGL1=!this.isWebGL2,this.info=Vo(this.gl),this.gl.device=this,this.gl._version=this.isWebGL2?2:1,Mo(this.gl);let{enable:s=!0,copyState:u=!1}=t;if(kn(this.gl,{enable:s,copyState:u,log:function(){for(var f=arguments.length,c=new Array(f),_=0;_<f;_++)c[_]=arguments[_];return V.log.log(1,...c)()}}),_e()&&t.debug&&(this.gl=ga(this.gl,{...t,webgl2:this.isWebGL2,throwOnError:!0}),this.gl2=this.gl,this.debug=!0,V.log.level=Math.max(V.log.level,1),V.log.warn("WebGL debug mode activated. Performance reduced.")()),_e()&&t.spector){let f=this.handle.canvas||t.canvas;this.spector=_a({...this.props,canvas:f})}let l=`Created ${this.info.type}${this.debug?" debug":""} context: ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;V.log.probe(Kr,l)(),V.log.groupEnd(Kr)()}destroy(){let t=this.gl.getExtension("STACKGL_destroy_context");t&&t.destroy()}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(t){return nr(this.gl,t)}isTextureFormatFilterable(t){return Yo(this.gl,t)}isTextureFormatRenderable(t){return ko(this.gl,t)}assertWebGL2(){if(!this.gl2)throw new Error("Requires WebGL2");return this.gl2}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){let r=this._getBufferProps(t);return new Et(this,r)}_createTexture(t){return new k(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new Ze(this,t)}createShader(t){return new wr(this,t)}createFramebuffer(t){return new me(this,t)}createRenderPipeline(t){return new Xr(this,t)}createVertexArray(t){return new dt(this,t)}beginRenderPass(t){return new Lr(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(t){throw new Error("compute shaders not supported in WebGL")}getDefaultRenderPass(){return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:this.canvasContext.getCurrentFramebuffer()}),this.renderPass}createCommandEncoder(t){return new Vr(this,t)}submit(){var t;(t=this.renderPass)===null||t===void 0||t.end(),this.renderPass=null}get webglLimits(){return this._webglLimits=this._webglLimits||ea(this.gl),this._webglLimits}loseDevice(){var t;let r=!1,n=this.gl.getExtension("WEBGL_lose_context");return n&&(r=!0,n.loseContext()),(t=this._resolveContextLost)===null||t===void 0||t.call(this,{reason:"destroyed",message:"Application triggered context loss"}),r}pushState(){lt(this.gl)}popState(){ke(this.gl)}setSpectorMetadata(t,r){t.__SPECTOR_Metadata=r}getGLKey(t,r){r=r||this.gl2||this.gl;let n=Number(t);for(let o in r)if(r[o]===n)return`GL.${o}`;return String(t)}setConstantAttribute(t,r){this._constants=this._constants||new Array(this.limits.maxVertexAttributes).fill(null);let n=this._constants[t];switch(n&&Ic(n,r)&&V.log.info(1,`setConstantAttribute(${t}) could have been skipped, value unchanged`)(),this._constants[t]=r,r.constructor){case Float32Array:Nc(this,t,r);break;case Int32Array:Cc(this,t,r);break;case Uint32Array:yc(this,t,r);break;default:(0,V.assert)(!1)}}};K.type="webgl";function vc(e){return typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext||typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function bc(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&e._version===2)}function Nc(e,t,r){switch(r.length){case 1:e.gl.vertexAttrib1fv(t,r);break;case 2:e.gl.vertexAttrib2fv(t,r);break;case 3:e.gl.vertexAttrib3fv(t,r);break;case 4:e.gl.vertexAttrib4fv(t,r);break;default:(0,V.assert)(!1)}}function Cc(e,t,r){var n;e.assertWebGL2(),(n=e.gl2)===null||n===void 0||n.vertexAttribI4iv(t,r)}function yc(e,t,r){var n;e.assertWebGL2(),(n=e.gl2)===null||n===void 0||n.vertexAttribI4uiv(t,r)}function Ic(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var xa=x(F(),1);var xc=256,Pc=1024,Mc=16384;var Fc="clear: bad arguments";function Gr(e,t){let r=K.attach(e),{framebuffer:n=null,color:o=null,depth:a=null,stencil:s=null}=t||{},u={};n&&(u.framebuffer=n);let l=0;o&&(l|=Mc,o!==!0&&(u.clearColor=o)),a&&(l|=xc,a!==!0&&(u.clearDepth=a)),s&&(l|=Pc,a!==!0&&(u.clearStencil=a)),(0,xa.assert)(l!==0,Fc),Y(r.gl,u,()=>{r.gl.clear(l)})}var sr=x(F(),1);var ui=x(F(),1);function Pa(e){switch(e){case i.ALPHA:case i.R32F:case i.RED:return 1;case i.RG32F:case i.RG:return 2;case i.RGB:case i.RGB32F:return 3;case i.RGBA:case i.RGBA32F:return 4;default:return(0,ui.assert)(!1),0}}function Ma(e){switch(e){case i.UNSIGNED_BYTE:return 1;case i.UNSIGNED_SHORT_5_6_5:case i.UNSIGNED_SHORT_4_4_4_4:case i.UNSIGNED_SHORT_5_5_5_1:return 2;case i.FLOAT:return 4;default:return(0,ui.assert)(!1),0}}function ht(e,t){let{sourceX:r=0,sourceY:n=0,sourceFormat:o=i.RGBA,targetByteOffset:a=0}=t||{},{target:s,sourceWidth:u,sourceHeight:l,sourceType:f}=t||{},{framebuffer:c,deleteFramebuffer:_}=Dc(e);(0,sr.assert)(c),u=u||c.width,l=l||c.height;let d=c.device.assertWebGL2();if(f=f||(s?s.type:i.UNSIGNED_BYTE),!s){let h=Pa(o),p=Ma(f),g=a+u*l*h*p;s=new Et(d,{byteLength:g,accessor:{type:f,size:h}})}return s.bind({glTarget:i.PIXEL_PACK_BUFFER}),Y(d,{framebuffer:c},()=>{d.readPixels(r,n,u,l,o,f,a)}),s.unbind({glTarget:i.PIXEL_PACK_BUFFER}),_&&c.destroy(),s}function Dc(e){return e instanceof sr.Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:Bc(e),deleteFramebuffer:!0}}function Bc(e,t){let{device:r,width:n,height:o,id:a}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${a}`,width:n,height:o,colorAttachments:[e]})}var Le=x(j());var w={SUM:1,MEAN:2,MIN:3,MAX:4};function Fa(e,t){return e+t}function Uc(e,t){return t>e?t:e}function wc(e,t){return t<e?t:e}function Lc(e,t){if(Number.isFinite(t))return e.length?t:null;var r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(Fa,0)/r.length:null}function Xc(e,t){if(Number.isFinite(t))return e.length?e.length*t:null;var r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(Fa,0):null}function Wc(e,t){if(Number.isFinite(t))return e.length?t:null;var r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(Uc,-1/0):null}function Hc(e,t){if(Number.isFinite(t))return e.length?t:null;var r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(wc,1/0):null}function At(e,t,r){var n=w[e]||w.SUM;switch(t=Vc(t,r),n){case w.MIN:return function(o){return Hc(o,t)};case w.SUM:return function(o){return Xc(o,t)};case w.MEAN:return function(o){return Lc(o,t)};case w.MAX:return function(o){return Wc(o,t)};default:return null}}function Vc(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Number.isFinite(e)?e:function(r){return t.index=r.index,e(r.source,t)}}function Da(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function(r){return t.indices=r.map(function(n){return n.index}),e(r.map(function(n){return n.source}),t)}}var pt;function zr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Ba={projectPoints:!1,viewport:null,createBufferObjects:!0,moduleSettings:{}},we=3402823466e29,li=[32775,32774],fi=[32776,32774],Ua=[32776,32775],ci=(pt={},zr(pt,w.SUM,32774),zr(pt,w.MEAN,32774),zr(pt,w.MIN,li),zr(pt,w.MAX,fi),pt);var wa={size:1,operation:w.SUM,needMin:!1,needMax:!1,combineMaxMin:!1},La=4;var Xa=`#define SHADER_NAME gpu-aggregation-to-grid-vs
149
304
 
150
305
  attribute vec3 positions;
151
306
  attribute vec3 positions64Low;
@@ -193,7 +348,7 @@ void main(void) {
193
348
  gl_Position = vec4(pos, 0.0, 1.0);
194
349
  gl_PointSize = 1.0;
195
350
  }
196
- `;var Gr=`#define SHADER_NAME gpu-aggregation-to-grid-fs
351
+ `;var Wa=`#define SHADER_NAME gpu-aggregation-to-grid-fs
197
352
 
198
353
  precision highp float;
199
354
 
@@ -203,7 +358,7 @@ void main(void) {
203
358
  gl_FragColor = vec4(vWeights, 1.0);
204
359
  DECKGL_FILTER_COLOR(gl_FragColor, geometry);
205
360
  }
206
- `;var Wr=`#version 300 es
361
+ `;var Ha=`#version 300 es
207
362
  #define SHADER_NAME gpu-aggregation-all-vs-64
208
363
 
209
364
  in vec2 position;
@@ -231,7 +386,7 @@ void main(void) {
231
386
  vTextureCoord = vec2(texCoordYFP64.x, texCoordXFP64.x);
232
387
  gl_PointSize = 1.0;
233
388
  }
234
- `;var jr=`#version 300 es
389
+ `;var Va=`#version 300 es
235
390
  #define SHADER_NAME gpu-aggregation-all-fs
236
391
 
237
392
  precision highp float;
@@ -248,7 +403,7 @@ void main(void) {
248
403
  fragColor.rgb = textureColor.rgb;
249
404
  fragColor.a = combineMaxMin ? textureColor.r : textureColor.a;
250
405
  }
251
- `;var Vr=`#define SHADER_NAME gpu-aggregation-transform-mean-vs
406
+ `;var Ka=`#define SHADER_NAME gpu-aggregation-transform-mean-vs
252
407
  attribute vec4 aggregationValues;
253
408
  varying vec4 meanValues;
254
409
 
@@ -259,8 +414,8 @@ void main()
259
414
  meanValues.w = aggregationValues.w;
260
415
  gl_PointSize = 1.0;
261
416
  }
262
- `;var ye=C(H()),it;function Kt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var xi=(it={},Kt(it,10240,9728),Kt(it,10241,9728),it);function _e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.width,n=r===void 0?1:r,i=t.height,o=i===void 0?1:i,a=t.data,u=a===void 0?null:a,s=t.unpackFlipY,l=s===void 0?!0:s,f=t.parameters,c=f===void 0?xi:f,g=new ye.Texture2D(e,{data:u,format:(0,ye.isWebGL2)(e)?34836:6408,type:5126,border:0,mipmaps:!1,parameters:c,dataFormat:6408,width:n,height:o,unpackFlipY:l});return g}function ke(e,t){var r=t.id,n=t.width,i=n===void 0?1:n,o=t.height,a=o===void 0?1:o,u=t.texture,s=new ye.Framebuffer(e,{id:r,width:i,height:a,attachments:Kt({},36064,u)});return s}function bi(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Si(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
263
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function Si(e,t){if(e){if(typeof e=="string")return Hr(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Hr(e,t)}}function Hr(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function $r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?$r(Object(r),!0).forEach(function(n){Qt(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$r(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Qt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Oi(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Ai=["aggregationBuffer","maxMinBuffer","minBuffer","maxBuffer"],Xr={maxData:"maxBuffer",minData:"minBuffer",maxMinData:"maxMinBuffer"},wi=[N.FEATURES.WEBGL2,N.FEATURES.COLOR_ATTACHMENT_RGBA32F,N.FEATURES.BLEND_EQUATION_MINMAX,N.FEATURES.FLOAT_BLEND,N.FEATURES.TEXTURE_FLOAT],z=function(){e.getAggregationData=function(n){var i=n.aggregationData,o=n.maxData,a=n.minData,u=n.maxMinData,s=n.pixelIndex,l=s*zr,f={};return i&&(f.cellCount=i[l+3],f.cellWeight=i[l]),u?(f.maxCellWieght=u[0],f.minCellWeight=u[3]):(o&&(f.maxCellWieght=o[0],f.totalCount=o[3]),a&&(f.minCellWeight=a[0],f.totalCount=o[3])),f},e.getCellData=function(n){for(var i=n.countsData,o=n.size,a=o===void 0?1:o,u=i.length/4,s=new Float32Array(u*a),l=new Uint32Array(u),f=0;f<u;f++){for(var c=0;c<a;c++)s[f*a+c]=i[f*4+c];l[f]=i[f*4+3]}return{cellCounts:l,cellWeights:s}},e.isSupported=function(n){return(0,N.hasFeatures)(n,wi)};function e(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Oi(this,e),this.id=n.id||"gpu-grid-aggregator",this.gl=r,this.state={weightAttributes:{},textures:{},meanTextures:{},buffers:{},framebuffers:{},maxMinFramebuffers:{},minFramebuffers:{},maxFramebuffers:{},equations:{},resources:{},results:{}},this._hasGPUSupport=(0,N.isWebGL2)(r)&&(0,N.hasFeatures)(this.gl,N.FEATURES.BLEND_EQUATION_MINMAX,N.FEATURES.COLOR_ATTACHMENT_RGBA32F,N.FEATURES.TEXTURE_FLOAT),this._hasGPUSupport&&this._setupModels()}var t=e.prototype;return t.delete=function(){var n=this.gridAggregationModel,i=this.allAggregationModel,o=this.meanTransform,a=this.state,u=a.textures,s=a.framebuffers,l=a.maxMinFramebuffers,f=a.minFramebuffers,c=a.maxFramebuffers,g=a.meanTextures,p=a.resources;n?.delete(),i?.delete(),o?.delete(),Ti([s,u,l,f,c,g,p])},t.run=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.setState({results:{}});var i=this._normalizeAggregationParams(n);return this._hasGPUSupport||xe.log.log(1,"GPUGridAggregator: not supported")(),this._runAggregation(i)},t.getData=function(n){var i={},o=this.state.results;o[n].aggregationData||(o[n].aggregationData=o[n].aggregationBuffer.getData()),i.aggregationData=o[n].aggregationData;for(var a in Xr){var u=Xr[a];(o[n][a]||o[n][u])&&(o[n][a]=o[n][a]||o[n][u].getData(),i[a]=o[n][a])}return i},t.updateShaders=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.setState({shaderOptions:n,modelDirty:!0})},t._normalizeAggregationParams=function(n){var i=B(B({},Lr),n),o=i.weights;return o&&(i.weights=Pi(o)),i},t.setState=function(n){Object.assign(this.state,n)},t._getAggregateData=function(n){var i={},o=this.state,a=o.textures,u=o.framebuffers,s=o.maxMinFramebuffers,l=o.minFramebuffers,f=o.maxFramebuffers,c=o.resources,g=n.weights;for(var p in g){i[p]={};var m=g[p],h=m.needMin,v=m.needMax,y=m.combineMaxMin;i[p].aggregationTexture=a[p],i[p].aggregationBuffer=(0,N.readPixelsToBuffer)(u[p],{target:g[p].aggregationBuffer,sourceType:5126}),h&&v&&y?(i[p].maxMinBuffer=(0,N.readPixelsToBuffer)(s[p],{target:g[p].maxMinBuffer,sourceType:5126}),i[p].maxMinTexture=c["".concat(p,"-maxMinTexture")]):(h&&(i[p].minBuffer=(0,N.readPixelsToBuffer)(l[p],{target:g[p].minBuffer,sourceType:5126}),i[p].minTexture=c["".concat(p,"-minTexture")]),v&&(i[p].maxBuffer=(0,N.readPixelsToBuffer)(f[p],{target:g[p].maxBuffer,sourceType:5126}),i[p].maxTexture=c["".concat(p,"-maxTexture")]))}return this._trackGPUResultBuffers(i,g),i},t._renderAggregateData=function(n){var i=n.cellSize,o=n.projectPoints,a=n.attributes,u=n.moduleSettings,s=n.numCol,l=n.numRow,f=n.weights,c=n.translation,g=n.scaling,p=this.state,m=p.maxMinFramebuffers,h=p.minFramebuffers,v=p.maxFramebuffers,y=[s,l],O={blend:!0,depthTest:!1,blendFunc:[1,1]},A={cellSize:i,gridSize:y,projectPoints:o,translation:c,scaling:g};for(var P in f){var T=f[P],D=T.needMin,E=T.needMax,M=D&&E&&f[P].combineMaxMin;this._renderToWeightsTexture({id:P,parameters:O,moduleSettings:u,uniforms:A,gridSize:y,attributes:a,weights:f}),M?this._renderToMaxMinTexture({id:P,parameters:B(B({},O),{},{blendEquation:Fr}),gridSize:y,minOrMaxFb:m[P],clearParams:{clearColor:[0,0,0,Z]},combineMaxMin:M}):(D&&this._renderToMaxMinTexture({id:P,parameters:B(B({},O),{},{blendEquation:kt}),gridSize:y,minOrMaxFb:h[P],clearParams:{clearColor:[Z,Z,Z,0]},combineMaxMin:M}),E&&this._renderToMaxMinTexture({id:P,parameters:B(B({},O),{},{blendEquation:qt}),gridSize:y,minOrMaxFb:v[P],clearParams:{clearColor:[0,0,0,0]},combineMaxMin:M}))}},t._renderToMaxMinTexture=function(n){var i=n.id,o=n.parameters,a=n.gridSize,u=n.minOrMaxFb,s=n.combineMaxMin,l=n.clearParams,f=l===void 0?{}:l,c=this.state.framebuffers,g=this.gl,p=this.allAggregationModel;(0,N.withParameters)(g,B(B({},f),{},{framebuffer:u,viewport:[0,0,a[0],a[1]]}),function(){g.clear(16384),p.draw({parameters:o,uniforms:{uSampler:c[i].texture,gridSize:a,combineMaxMin:s}})})},t._renderToWeightsTexture=function(n){var i=n.id,o=n.parameters,a=n.moduleSettings,u=n.uniforms,s=n.gridSize,l=n.weights,f=this.state,c=f.framebuffers,g=f.equations,p=f.weightAttributes,m=this.gl,h=this.gridAggregationModel,v=l[i].operation,y=v===R.MIN?[Z,Z,Z,0]:[0,0,0,0];if((0,N.withParameters)(m,{framebuffer:c[i],viewport:[0,0,s[0],s[1]],clearColor:y},function(){m.clear(16384);var D={weights:p[i]};h.draw({parameters:B(B({},o),{},{blendEquation:g[i]}),moduleSettings:a,uniforms:u,attributes:D})}),v===R.MEAN){var O=this.state,A=O.meanTextures,P=O.textures,T={_sourceTextures:{aggregationValues:A[i]},_targetTexture:P[i],elementCount:P[i].width*P[i].height};this.meanTransform?this.meanTransform.update(T):this.meanTransform=Mi(m,T),this.meanTransform.run({parameters:{blend:!1,depthTest:!1}}),c[i].attach(Qt({},36064,P[i]))}},t._runAggregation=function(n){this._updateModels(n),this._setupFramebuffers(n),this._renderAggregateData(n);var i=this._getAggregateData(n);return this.setState({results:i}),i},t._setupFramebuffers=function(n){var i=this.state,o=i.textures,a=i.framebuffers,u=i.maxMinFramebuffers,s=i.minFramebuffers,l=i.maxFramebuffers,f=i.meanTextures,c=i.equations,g=n.weights,p=n.numCol,m=n.numRow,h={width:p,height:m};for(var v in g){var y=g[v],O=y.needMin,A=y.needMax,P=y.combineMaxMin,T=y.operation;o[v]=g[v].aggregationTexture||o[v]||_e(this.gl,{id:"".concat(v,"-texture"),width:p,height:m}),o[v].resize(h);var D=o[v];T===R.MEAN&&(f[v]=f[v]||_e(this.gl,{id:"".concat(v,"-mean-texture"),width:p,height:m}),f[v].resize(h),D=f[v]),a[v]?a[v].attach(Qt({},36064,D)):a[v]=ke(this.gl,{id:"".concat(v,"-fb"),width:p,height:m,texture:D}),a[v].resize(h),c[v]=Yt[T]||Yt.SUM,(O||A)&&(O&&A&&P?u[v]||(D=g[v].maxMinTexture||this._getMinMaxTexture("".concat(v,"-maxMinTexture")),u[v]=ke(this.gl,{id:"".concat(v,"-maxMinFb"),texture:D})):(O&&(s[v]||(D=g[v].minTexture||this._getMinMaxTexture("".concat(v,"-minTexture")),s[v]=ke(this.gl,{id:"".concat(v,"-minFb"),texture:D}))),A&&(l[v]||(D=g[v].maxTexture||this._getMinMaxTexture("".concat(v,"-maxTexture")),l[v]=ke(this.gl,{id:"".concat(v,"-maxFb"),texture:D})))))}},t._getMinMaxTexture=function(n){var i=this.state.resources;return i[n]||(i[n]=_e(this.gl,{id:"resourceName"})),i[n]},t._setupModels=function(){var n,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=i.numCol,a=o===void 0?0:o,u=i.numRow,s=u===void 0?0:u,l=this.gl,f=this.state.shaderOptions;if((n=this.gridAggregationModel)===null||n===void 0||n.delete(),this.gridAggregationModel=Di(l,f),!this.allAggregationModel){var c=a*s;this.allAggregationModel=Ei(l,c)}},t._setupWeightAttributes=function(n){var i=this.state.weightAttributes,o=n.weights;for(var a in o)i[a]=n.attributes[a]},t._trackGPUResultBuffers=function(n,i){var o=this.state.resources;for(var a in n)if(n[a]){var u=bi(Ai),s;try{for(u.s();!(s=u.n()).done;){var l=s.value;if(n[a][l]&&i[a][l]!==n[a][l]){var f="gpu-result-".concat(a,"-").concat(l);o[f]&&o[f].delete(),o[f]=n[a][l]}}}catch(c){u.e(c)}finally{u.f()}}},t._updateModels=function(n){var i=n.vertexCount,o=n.attributes,a=n.numCol,u=n.numRow,s=this.state.modelDirty;s&&(this._setupModels(n),this.setState({modelDirty:!1})),this._setupWeightAttributes(n),this.gridAggregationModel.setVertexCount(i),this.gridAggregationModel.setAttributes(o),this.allAggregationModel.setInstanceCount(a*u)},e}();function Pi(e){var t={};for(var r in e)t[r]=B(B({},Br),e[r]);return t}function Ti(e){e=Array.isArray(e)?e:[e],e.forEach(function(t){for(var r in t)t[r].delete()})}function Di(e,t){var r=(0,xe._mergeShaders)({vs:Ur,fs:Gr,modules:[de,xe.project32]},t);return new N.Model(e,B({id:"Gird-Aggregation-Model",vertexCount:1,drawMode:0},r))}function Ei(e,t){return new N.Model(e,{id:"All-Aggregation-Model",vs:Wr,fs:jr,modules:[de],vertexCount:1,drawMode:0,isInstanced:!0,instanceCount:t,attributes:{position:[0,0]}})}function Mi(e,t){return new N.Transform(e,B({vs:Vr,_targetTextureVarying:"meanValues"},t))}var ee=C(H()),Se=C(L());var j=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function J(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array,n;if(Number.isFinite(e[0]))n=new r(e);else{n=new r(e.length*4);for(var i=0,o=0;o<e.length;o++){var a=e[o];n[i++]=a[0],n[i++]=a[1],n[i++]=a[2],n[i++]=Number.isFinite(a[3])?a[3]:255}}if(t)for(var u=0;u<n.length;u++)n[u]/=255;return n}var kr=`#define SHADER_NAME screen-grid-layer-vertex-shader
417
+ `;var Kc={minFilter:"nearest",magFilter:"nearest"};function Tt(e,t){var r=t.width,n=r===void 0?1:r,o=t.height,a=o===void 0?1:o,s=t.data,u=s===void 0?null:s,l=t.unpackFlipY,f=l===void 0?!0:l,c=t.parameters,_=c===void 0?Kc:c,E=e.createTexture({data:u,format:"rgba32float",mipmaps:!1,sampler:_,width:n,height:a});return E}function ur(e,t){var r=t.id,n=t.width,o=n===void 0?1:n,a=t.height,s=a===void 0?1:a,u=t.texture,l=e.createFramebuffer({id:r,width:o,height:s,colorAttachments:[u]});return l}function Gc(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=zc(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
418
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function zc(e,t){if(e){if(typeof e=="string")return Ga(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ga(e,t)}}function Ga(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function za(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?za(Object(r),!0).forEach(function(n){_i(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):za(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function _i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Yc=["aggregationBuffer","maxMinBuffer","minBuffer","maxBuffer"],ja={maxData:"maxBuffer",minData:"minBuffer",maxMinData:"maxMinBuffer"},kc=["webgl2","blend-minmax-webgl1","texture-renderable-float32-webgl","texture-blend-float-webgl1","texture-formats-float32-webgl1"],Q=function(){e.getAggregationData=function(n){var o=n.aggregationData,a=n.maxData,s=n.minData,u=n.maxMinData,l=n.pixelIndex,f=l*La,c={};return o&&(c.cellCount=o[f+3],c.cellWeight=o[f]),u?(c.maxCellWieght=u[0],c.minCellWeight=u[3]):(a&&(c.maxCellWieght=a[0],c.totalCount=a[3]),s&&(c.minCellWeight=s[0],c.totalCount=s[3])),c},e.getCellData=function(n){for(var o=n.countsData,a=n.size,s=a===void 0?1:a,u=o.length/4,l=new Float32Array(u*s),f=new Uint32Array(u),c=0;c<u;c++){for(var _=0;_<s;_++)l[c*s+_]=o[c*4+_];f[c]=o[c*4+3]}return{cellCounts:f,cellWeights:l}},e.isSupported=function(n){return kc.every(function(o){return n.features.has(o)})};function e(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};jc(this,e),this.state={weightAttributes:{},textures:{},meanTextures:{},buffers:{},framebuffers:{},maxMinFramebuffers:{},minFramebuffers:{},maxFramebuffers:{},equations:{},shaderOptions:{},modelDirty:!1,resources:{},results:{}},this.id=void 0,this.device=void 0,this._hasGPUSupport=void 0,this.gridAggregationModel=void 0,this.allAggregationModel=void 0,this.meanTransform=void 0,this.id=n.id||"gpu-grid-aggregator",this.device=r;var o=["blend-minmax-webgl1","texture-renderable-float32-webgl","texture-formats-float32-webgl1"];this._hasGPUSupport=this.device.info.type==="webgl2"&&o.every(function(a){return r.features.has(a)}),this._hasGPUSupport&&this._setupModels()}var t=e.prototype;return t.delete=function(){var n=this.gridAggregationModel,o=this.allAggregationModel,a=this.meanTransform,s=this.state,u=s.textures,l=s.framebuffers,f=s.maxMinFramebuffers,c=s.minFramebuffers,_=s.maxFramebuffers,E=s.meanTextures,d=s.resources;n?.destroy(),o?.destroy(),a?.destroy(),Zc([l,u,f,c,_,E,d])},t.run=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.setState({results:{}});var o=this._normalizeAggregationParams(n);return this._hasGPUSupport||Le.log.log(1,"GPUGridAggregator: not supported")(),this._runAggregation(o)},t.getData=function(n){var o={},a=this.state.results;a[n].aggregationData||(a[n].aggregationData=a[n].aggregationBuffer.getData()),o.aggregationData=a[n].aggregationData;for(var s in ja){var u=ja[s];(a[n][s]||a[n][u])&&(a[n][s]=a[n][s]||a[n][u].getData(),o[s]=a[n][s])}return o},t.updateShaders=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.setState({shaderOptions:n,modelDirty:!0})},t._normalizeAggregationParams=function(n){var o=q(q({},Ba),n),a=o.weights;return a&&(o.weights=$c(a)),o},t.setState=function(n){Object.assign(this.state,n)},t._getAggregateData=function(n){var o={},a=this.state,s=a.textures,u=a.framebuffers,l=a.maxMinFramebuffers,f=a.minFramebuffers,c=a.maxFramebuffers,_=a.resources,E=n.weights;for(var d in E){o[d]={};var h=E[d],p=h.needMin,g=h.needMax,T=h.combineMaxMin;o[d].aggregationTexture=s[d],o[d].aggregationBuffer=ht(u[d],{target:E[d].aggregationBuffer,sourceType:5126}),p&&g&&T?(o[d].maxMinBuffer=ht(l[d],{target:E[d].maxMinBuffer,sourceType:5126}),o[d].maxMinTexture=_["".concat(d,"-maxMinTexture")]):(p&&(o[d].minBuffer=ht(f[d],{target:E[d].minBuffer,sourceType:5126}),o[d].minTexture=_["".concat(d,"-minTexture")]),g&&(o[d].maxBuffer=ht(c[d],{target:E[d].maxBuffer,sourceType:5126}),o[d].maxTexture=_["".concat(d,"-maxTexture")]))}return this._trackGPUResultBuffers(o,E),o},t._renderAggregateData=function(n){var o=n.cellSize,a=n.projectPoints,s=n.attributes,u=n.moduleSettings,l=n.numCol,f=n.numRow,c=n.weights,_=n.translation,E=n.scaling,d=this.state,h=d.maxMinFramebuffers,p=d.minFramebuffers,g=d.maxFramebuffers,T=[l,f],m={blend:!0,depthTest:!1,blendFunc:[1,1]},R={cellSize:o,gridSize:T,projectPoints:a,translation:_,scaling:E};for(var S in c){var y=c[S],I=y.needMin,P=y.needMax,M=I&&P&&c[S].combineMaxMin;this._renderToWeightsTexture({id:S,parameters:m,moduleSettings:u,uniforms:R,gridSize:T,attributes:s,weights:c}),M?this._renderToMaxMinTexture({id:S,parameters:q(q({},m),{},{blendEquation:Ua}),gridSize:T,minOrMaxFb:h[S],clearParams:{clearColor:[0,0,0,we]},combineMaxMin:M}):(I&&this._renderToMaxMinTexture({id:S,parameters:q(q({},m),{},{blendEquation:li}),gridSize:T,minOrMaxFb:p[S],clearParams:{clearColor:[we,we,we,0]},combineMaxMin:M}),P&&this._renderToMaxMinTexture({id:S,parameters:q(q({},m),{},{blendEquation:fi}),gridSize:T,minOrMaxFb:g[S],clearParams:{clearColor:[0,0,0,0]},combineMaxMin:M}))}},t._renderToMaxMinTexture=function(n){var o=this,a=n.id,s=n.parameters,u=n.gridSize,l=n.minOrMaxFb,f=n.combineMaxMin,c=n.clearParams,_=c===void 0?{}:c,E=this.state.framebuffers,d=this.allAggregationModel;Y(this.device,q(q({},_),{},{framebuffer:l,viewport:[0,0,u[0],u[1]]}),function(){Gr(o.device,{color:!0}),d.setUniforms({gridSize:u,combineMaxMin:f}),d.setBindings({uSampler:E[a].texture}),d.draw()})},t._renderToWeightsTexture=function(n){var o=this,a=n.id,s=n.parameters,u=n.moduleSettings,l=n.uniforms,f=n.gridSize,c=n.weights,_=this.state,E=_.framebuffers,d=_.equations,h=_.weightAttributes,p=this.gridAggregationModel,g=c[a].operation,T=g===w.MIN?[we,we,we,0]:[0,0,0,0];if(Y(this.device,{framebuffer:E[a],viewport:[0,0,f[0],f[1]],clearColor:T},function(){Gr(o.device,{color:!0});var I={weights:h[a]};p.draw({parameters:q(q({},s),{},{blendEquation:d[a]}),moduleSettings:u,uniforms:l,attributes:I})}),g===w.MEAN){var m=this.state,R=m.meanTextures,S=m.textures,y={_sourceTextures:{aggregationValues:R[a]},_targetTexture:S[a],elementCount:S[a].width*S[a].height};this.meanTransform?this.meanTransform.update(y):this.meanTransform=Jc(this.device,y),this.meanTransform.run({parameters:{blend:!1,depthTest:!1}}),E[a].attach(_i({},36064,S[a]))}},t._runAggregation=function(n){this._updateModels(n),this._setupFramebuffers(n),this._renderAggregateData(n);var o=this._getAggregateData(n);return this.setState({results:o}),o},t._setupFramebuffers=function(n){var o=this.state,a=o.textures,s=o.framebuffers,u=o.maxMinFramebuffers,l=o.minFramebuffers,f=o.maxFramebuffers,c=o.meanTextures,_=o.equations,E=n.weights,d=n.numCol,h=n.numRow,p={width:d,height:h};for(var g in E){var T=E[g],m=T.needMin,R=T.needMax,S=T.combineMaxMin,y=T.operation;a[g]=E[g].aggregationTexture||a[g]||Tt(this.device,{id:"".concat(g,"-texture"),width:d,height:h}),a[g].resize(p);var I=a[g];y===w.MEAN&&(c[g]=c[g]||Tt(this.device,{id:"".concat(g,"-mean-texture"),width:d,height:h}),c[g].resize(p),I=c[g]),s[g]?s[g].attach(_i({},36064,I)):s[g]=ur(this.device,{id:"".concat(g,"-fb"),width:d,height:h,texture:I}),s[g].resize(p),_[g]=ci[y]||ci[w.SUM],(m||R)&&(m&&R&&S?u[g]||(I=E[g].maxMinTexture||this._getMinMaxTexture("".concat(g,"-maxMinTexture")),u[g]=ur(this.device,{id:"".concat(g,"-maxMinFb"),texture:I})):(m&&(l[g]||(I=E[g].minTexture||this._getMinMaxTexture("".concat(g,"-minTexture")),l[g]=ur(this.device,{id:"".concat(g,"-minFb"),texture:I}))),R&&(f[g]||(I=E[g].maxTexture||this._getMinMaxTexture("".concat(g,"-maxTexture")),f[g]=ur(this.device,{id:"".concat(g,"-maxFb"),texture:I})))))}},t._getMinMaxTexture=function(n){var o=this.state.resources;return o[n]||(o[n]=Tt(this.device,{id:"resourceName"})),o[n]},t._setupModels=function(){var n,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},a=o.numCol,s=a===void 0?0:a,u=o.numRow,l=u===void 0?0:u,f=this.state.shaderOptions;if((n=this.gridAggregationModel)===null||n===void 0||n.destroy(),this.gridAggregationModel=qc(this.device,f),!this.allAggregationModel){var c=s*l;this.allAggregationModel=Qc(this.device,c)}},t._setupWeightAttributes=function(n){var o=this.state.weightAttributes,a=n.weights;for(var s in a)o[s]=n.attributes[s]},t._trackGPUResultBuffers=function(n,o){var a=this.state.resources;for(var s in n)if(n[s]){var u=Gc(Yc),l;try{for(u.s();!(l=u.n()).done;){var f=l.value;if(n[s][f]&&o[s][f]!==n[s][f]){var c="gpu-result-".concat(s,"-").concat(f);a[c]&&a[c].delete(),a[c]=n[s][f]}}}catch(_){u.e(_)}finally{u.f()}}},t._updateModels=function(n){var o=n.vertexCount,a=n.attributes,s=n.numCol,u=n.numRow,l=this.state.modelDirty;l&&(this._setupModels(n),this.setState({modelDirty:!1})),this._setupWeightAttributes(n),this.gridAggregationModel.setVertexCount(o),this.gridAggregationModel.setAttributes(a),this.allAggregationModel.setInstanceCount(s*u)},e}();function $c(e){var t={};for(var r in e)t[r]=q(q({},wa),e[r]);return t}function Zc(e){e=Array.isArray(e)?e:[e],e.forEach(function(t){for(var r in t)t[r].delete()})}function qc(e,t){var r=(0,Le._mergeShaders)({vs:Xa,fs:Wa,modules:[st,Le.project32]},t);return new J(e,q({id:"Grid-Aggregation-Model",vertexCount:1,drawMode:0,shaderAssembler:(0,Le.getShaderAssembler)()},r))}function Qc(e,t){return new J(e,{id:"All-Aggregation-Model",vs:Ha,fs:Va,modules:[st],vertexCount:1,topology:"point-list",isInstanced:!0,instanceCount:t,attributes:{position:[0,0]}})}function Jc(e,t){return new Me(e,q({vs:Ka,_targetTextureVarying:"meanValues"},t))}var mt=x(j());var le=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function Xe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array,n;if(Number.isFinite(e[0]))n=new r(e);else{n=new r(e.length*4);for(var o=0,a=0;a<e.length;a++){var s=e[a];n[o++]=s[0],n[o++]=s[1],n[o++]=s[2],n[o++]=Number.isFinite(s[3])?s[3]:255}}if(t)for(var u=0;u<n.length;u++)n[u]/=255;return n}var Ya=`#define SHADER_NAME screen-grid-layer-vertex-shader
264
419
  #define RANGE_COUNT 6
265
420
 
266
421
  attribute vec3 positions;
@@ -320,7 +475,7 @@ void main(void) {
320
475
 
321
476
  gl_Position = vec4(instancePositions + positions * cellScale, 1.);
322
477
  }
323
- `;var qr=`#define SHADER_NAME screen-grid-layer-fragment-shader
478
+ `;var ka=`#define SHADER_NAME screen-grid-layer-fragment-shader
324
479
 
325
480
  precision highp float;
326
481
 
@@ -335,16 +490,16 @@ void main(void) {
335
490
 
336
491
  DECKGL_FILTER_COLOR(gl_FragColor, geometry);
337
492
  }
338
- `;function at(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?at=function(r){return typeof r}:at=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},at(e)}function Yr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Zt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Yr(Object(r),!0).forEach(function(n){Ci(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yr(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ci(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ri(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ut(e,t,r){return typeof Reflect<"u"&&Reflect.get?ut=Reflect.get:ut=function(i,o,a){var u=Ni(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},ut(e,t,r||e)}function Ni(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=be(e),e!==null););return e}function Ii(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Jt(e,t)}function Jt(e,t){return Jt=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},Jt(e,t)}function Li(e){var t=zi();return function(){var n=be(e),i;if(t){var o=be(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Fi(this,i)}}function Fi(e,t){if(t&&(at(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Bi(e)}function Bi(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function zi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function be(e){return be=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},be(e)}var Ui=[0,0,0,0],Gi=[0,255,0,255],Wi=["minColor","maxColor","colorRange","colorDomain"],ji={cellSizePixels:{value:100,min:1},cellMarginPixels:{value:2,min:0,max:5},colorDomain:null,colorRange:j},Oe=function(e){Ii(r,e);var t=Li(r);function r(){var i;Ri(this,r);for(var o=arguments.length,a=new Array(o),u=0;u<o;u++)a[u]=arguments[u];return i=t.call.apply(t,[this].concat(a)),i.state=void 0,i}r.isSupported=function(o){return(0,ee.hasFeatures)(o,[ee.FEATURES.TEXTURE_FLOAT])};var n=r.prototype;return n.getShaders=function(){return{vs:kr,fs:qr,modules:[Se.picking]}},n.initializeState=function(){var o=this.context.gl,a=this.getAttributeManager();a.addInstanced({instancePositions:{size:3,update:this.calculateInstancePositions},instanceCounts:{size:4,noAlloc:!0}}),this.setState({model:this._getModel(o)})},n.shouldUpdateState=function(o){var a=o.changeFlags;return a.somethingChanged},n.updateState=function(o){ut(be(r.prototype),"updateState",this).call(this,o);var a=o.oldProps,u=o.props,s=o.changeFlags,l=this.getAttributeManager();u.numInstances!==a.numInstances?l.invalidateAll():a.cellSizePixels!==u.cellSizePixels&&l.invalidate("instancePositions"),this._updateUniforms(a,u,s)},n.draw=function(o){var a=o.uniforms,u=this.props,s=u.parameters,l=u.maxTexture,f=this.props.minColor||Ui,c=this.props.maxColor||Gi,g=this.props.colorDomain||[1,0],p=this.state.model;p.setUniforms(a).setUniforms({minColor:f,maxColor:c,maxTexture:l,colorDomain:g}).draw({parameters:Zt({depthTest:!1,depthMask:!1},s)})},n.calculateInstancePositions=function(o,a){for(var u=a.numInstances,s=this.context.viewport,l=s.width,f=s.height,c=this.props.cellSizePixels,g=Math.ceil(l/c),p=o.value,m=o.size,h=0;h<u;h++){var v=h%g,y=Math.floor(h/g);p[h*m+0]=v*c/l*2-1,p[h*m+1]=1-y*c/f*2,p[h*m+2]=0}},n._getModel=function(o){return new ee.Model(o,Zt(Zt({},this.getShaders()),{},{id:this.props.id,geometry:new ee.Geometry({drawMode:6,attributes:{positions:new Float32Array([0,0,0,1,0,0,1,1,0,0,1,0])}}),isInstanced:!0}))},n._shouldUseMinMax=function(){var o=this.props,a=o.minColor,u=o.maxColor,s=o.colorDomain,l=o.colorRange;return a||u?(Se.log.deprecated("ScreenGridLayer props: minColor and maxColor","colorRange, colorDomain")(),!0):!(s||l)},n._updateUniforms=function(o,a,u){var s=this.state.model;if(Wi.some(function(y){return o[y]!==a[y]})&&s.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),o.colorRange!==a.colorRange&&s.setUniforms({colorRange:J(a.colorRange)}),o.cellMarginPixels!==a.cellMarginPixels||o.cellSizePixels!==a.cellSizePixels||u.viewportChanged){var l=this.context.viewport,f=l.width,c=l.height,g=this.props,p=g.cellSizePixels,m=g.cellMarginPixels,h=p>m?m:0,v=new Float32Array([(p-h)/f*2,-(p-h)/c*2,1]);s.setUniforms({cellScale:v})}},r}(Se.Layer);Oe.layerName="ScreenGridCellLayer";Oe.defaultProps=ji;var Ae=C(L()),Jr=C(H());function Kr(e,t){var r={};for(var n in e)t.includes(n)||(r[n]=e[n]);return r}function st(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?st=function(r){return typeof r}:st=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},st(e)}function Qr(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Vi(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
339
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function Vi(e,t){if(e){if(typeof e=="string")return Zr(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Zr(e,t)}}function Zr(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Hi(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function qe(e,t,r){return typeof Reflect<"u"&&Reflect.get?qe=Reflect.get:qe=function(i,o,a){var u=$i(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},qe(e,t,r||e)}function $i(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=ie(e),e!==null););return e}function Xi(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&er(e,t)}function er(e,t){return er=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},er(e,t)}function ki(e){var t=Ki();return function(){var n=ie(e),i;if(t){var o=ie(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return qi(this,i)}}function qi(e,t){if(t&&(st(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Yi(e)}function Yi(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ki(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ie(e){return ie=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},ie(e)}var $=function(e){Xi(r,e);var t=ki(r);function r(){var i;Hi(this,r);for(var o=arguments.length,a=new Array(o),u=0;u<o;u++)a[u]=arguments[u];return i=t.call.apply(t,[this].concat(a)),i.state=void 0,i}var n=r.prototype;return n.initializeAggregationLayer=function(o){qe(ie(r.prototype),"initializeState",this).call(this,this.context),this.setState({ignoreProps:Kr(this.constructor._propTypes,o.data.props),dimensions:o})},n.updateState=function(o){qe(ie(r.prototype),"updateState",this).call(this,o);var a=o.changeFlags;if(a.extensionsChanged){var u=this.getShaders({});u&&u.defines&&(u.defines.NON_INSTANCED_MODEL=1),this.updateShaders(u)}this._updateAttributes()},n.updateAttributes=function(o){this.setState({changedAttributes:o})},n.getAttributes=function(){return this.getAttributeManager().getShaderAttributes()},n.getModuleSettings=function(){var o=this.context,a=o.viewport,u=o.mousePosition,s=o.gl,l=Object.assign(Object.create(this.props),{viewport:a,mousePosition:u,pickingActive:0,devicePixelRatio:(0,Jr.cssToDeviceRatio)(s)});return l},n.updateShaders=function(o){},n.isAggregationDirty=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=o.props,s=o.oldProps,l=o.changeFlags,f=a.compareAll,c=f===void 0?!1:f,g=a.dimension,p=this.state.ignoreProps,m=g.props,h=g.accessors,v=h===void 0?[]:h,y=l.updateTriggersChanged;if(l.dataChanged)return!0;if(y){if(y.all)return!0;var O=Qr(v),A;try{for(O.s();!(A=O.n()).done;){var P=A.value;if(y[P])return!0}}catch(M){O.e(M)}finally{O.f()}}if(c)return l.extensionsChanged?!0:(0,Ae._compareProps)({oldProps:s,newProps:u,ignoreProps:p,propTypes:this.constructor._propTypes});var T=Qr(m),D;try{for(T.s();!(D=T.n()).done;){var E=D.value;if(u[E]!==s[E])return!0}}catch(M){T.e(M)}finally{T.f()}return!1},n.isAttributeChanged=function(o){var a=this.state.changedAttributes;return o?a&&a[o]!==void 0:!Qi(a)},n._getAttributeManager=function(){return new Ae.AttributeManager(this.context.gl,{id:this.props.id,stats:this.context.stats})},r}(Ae.CompositeLayer);$.layerName="AggregationLayer";function Qi(e){var t=!0;for(var r in e){t=!1;break}return t}var wn=C(H()),Pn=C(L());var rn=C(L());function Zi(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Ji(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
340
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function Ji(e,t){if(e){if(typeof e=="string")return en(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return en(e,t)}}function en(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function lt(e,t,r){var n=r;return n.domain=function(){return e},n.range=function(){return t},n}function tn(e,t){var r=function(i){return ua(e,t,i)};return lt(e,t,r)}function ea(e,t){var r=function(i){return sa(e,t,i)};return lt(e,t,r)}function ta(e,t){for(var r=e.sort(nn),n=0,i=Math.max(1,t.length),o=new Array(i-1);++n<i;)o[n-1]=ra(r,n/i);var a=function(s){return oa(o,t,s)};return a.thresholds=function(){return o},lt(e,t,a)}function nn(e,t){return e-t}function ra(e,t){var r=e.length;if(t<=0||r<2)return e[0];if(t>=1)return e[r-1];var n=(r-1)*t,i=Math.floor(n),o=e[i],a=e[i+1];return o+(a-o)*(n-i)}function na(e,t){for(var r=0,n=e.length;r<n;){var i=r+n>>>1;nn(e[i],t)>0?n=i:r=i+1}return r}function oa(e,t,r){return t[na(e,r)]}function ia(e,t,r,n){var i="".concat(n),o=t.get(i);return o===void 0&&(o=e.push(n),t.set(i,o)),r[(o-1)%r.length]}function aa(e,t){var r=new Map,n=[],i=Zi(e),o;try{for(i.s();!(o=i.n()).done;){var a=o.value,u="".concat(a);r.has(u)||r.set(u,n.push(a))}}catch(l){i.e(l)}finally{i.f()}var s=function(f){return ia(n,r,t,f)};return lt(e,t,s)}function ua(e,t,r){var n=e[1]-e[0];if(n<=0)return rn.log.warn("quantizeScale: invalid domain, returning range[0]")(),t[0];var i=n/t.length,o=Math.floor((r-e[0])/i),a=Math.max(Math.min(o,t.length-1),0);return t[a]}function sa(e,t,r){return(r-e[0])/(e[1]-e[0])*(t[1]-t[0])+t[0]}function on(e){return e!=null}function la(e){var t=[];return e.forEach(function(r){!t.includes(r)&&on(r)&&t.push(r)}),t}function an(e,t){var r=typeof t=="function"?e.map(t):e;return r.filter(on)}function un(e,t){return an(e,t)}function sn(e,t){return la(an(e,t))}function ln(e,t,r){return Math.max(t,Math.min(r,e))}function fn(e){switch(e){case"quantize":return tn;case"linear":return ea;case"quantile":return ta;case"ordinal":return aa;default:return tn}}function cn(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=dn(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
341
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function tr(e,t){return ga(e)||ca(e,t)||dn(e,t)||fa()}function fa(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
342
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dn(e,t){if(e){if(typeof e=="string")return gn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,t)}}function gn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ca(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,o=!1,a,u;try{for(r=r.call(e);!(i=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));i=!0);}catch(s){o=!0,u=s}finally{try{!i&&r.return!=null&&r.return()}finally{if(o)throw u}}return n}}function ga(e){if(Array.isArray(e))return e}function pa(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var vn=function(t){return t.length},da=3402823466e29,mn=function(t){return t.points},hn=function(t){return t.index},pn=function(t,r){return t<r?-1:t>r?1:t>=r?0:NaN},va={getValue:vn,getPoints:mn,getIndex:hn,filterData:null},we=function(){function e(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:va;pa(this,e),this.maxCount=void 0,this.maxValue=void 0,this.minValue=void 0,this.totalCount=void 0,this.aggregatedBins=void 0,this.sortedBins=void 0,this.binMap=void 0,this.aggregatedBins=this.getAggregatedBins(r,n),this._updateMinMaxValues(),this.binMap=this.getBinMap()}var t=e.prototype;return t.getAggregatedBins=function(n,i){for(var o=i.getValue,a=o===void 0?vn:o,u=i.getPoints,s=u===void 0?mn:u,l=i.getIndex,f=l===void 0?hn:l,c=i.filterData,g=typeof c=="function",p=n.length,m=[],h=0,v=0;v<p;v++){var y=n[v],O=s(y),A=f(y),P=g?O.filter(c):O;y.filteredPoints=g?P:null;var T=P.length?a(P):null;T!=null&&(m[h]={i:Number.isFinite(A)?A:v,value:T,counts:P.length},h++)}return m},t._percentileToIndex=function(n){var i=this.sortedBins.length;if(i<2)return[0,0];var o=n.map(function(c){return ln(c,0,100)}),a=tr(o,2),u=a[0],s=a[1],l=Math.ceil(u/100*(i-1)),f=Math.floor(s/100*(i-1));return[l,f]},t.getBinMap=function(){var n={},i=cn(this.aggregatedBins),o;try{for(i.s();!(o=i.n()).done;){var a=o.value;n[a.i]=a}}catch(u){i.e(u)}finally{i.f()}return n},t._updateMinMaxValues=function(){var n=0,i=0,o=da,a=0,u=cn(this.aggregatedBins),s;try{for(u.s();!(s=u.n()).done;){var l=s.value;n=n>l.counts?n:l.counts,i=i>l.value?i:l.value,o=o<l.value?o:l.value,a+=l.counts}}catch(f){u.e(f)}finally{u.f()}this.maxCount=n,this.maxValue=i,this.minValue=o,this.totalCount=a},t.getValueRange=function(n){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort(function(u,s){return pn(u.value,s.value)})),!this.sortedBins.length)return[];var i=0,o=this.sortedBins.length-1;if(Array.isArray(n)){var a=this._percentileToIndex(n);i=a[0],o=a[1]}return[this.sortedBins[i].value,this.sortedBins[o].value]},t.getValueDomainByScale=function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],o=tr(i,2),a=o[0],u=a===void 0?0:a,s=o[1],l=s===void 0?100:s;if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort(function(c,g){return pn(c.value,g.value)})),!this.sortedBins.length)return[];var f=this._percentileToIndex([u,l]);return this._getScaleDomain(n,f)},t._getScaleDomain=function(n,i){var o=tr(i,2),a=o[0],u=o[1],s=this.sortedBins;switch(n){case"quantize":case"linear":return[s[a].value,s[u].value];case"quantile":return un(s.slice(a,u+1),function(l){return l.value});case"ordinal":return sn(s,function(l){return l.value});default:return[s[a].value,s[u].value]}},e}();var On=C(L());var te=C(L()),_n=6378e3;function ft(e){return Number.isFinite(e)?e:0}function ct(e,t){for(var r=e.positions.value,n=1/0,i=-1/0,o=1/0,a=-1/0,u,s,l=0;l<t;l++)s=r[l*3],u=r[l*3+1],n=u<n?u:n,i=u>i?u:i,o=s<o?s:o,a=s>a?s:a;var f={xMin:ft(o),xMax:ft(a),yMin:ft(n),yMax:ft(i)};return f}function ma(e,t,r,n){var i=n.width,o=n.height,a=r===te.COORDINATE_SYSTEM.CARTESIAN?[-i/2,-o/2]:[-180,-90];te.log.assert(r===te.COORDINATE_SYSTEM.CARTESIAN||r===te.COORDINATE_SYSTEM.LNGLAT||r===te.COORDINATE_SYSTEM.DEFAULT);var u=e.xMin,s=e.yMin;return[-1*(yn(u-a[0],t.xOffset)+a[0]),-1*(yn(s-a[1],t.yOffset)+a[1])]}function yn(e,t){var r=e<0?-1:1,n=r<0?Math.abs(e)+t:Math.abs(e);return n=Math.floor(n/t)*t,n*r}function rr(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!r)return{xOffset:t,yOffset:t};var n=e.yMin,i=e.yMax,o=(n+i)/2;return ha(t,o)}function gt(e,t,r,n){var i=rr(e,t,n!==te.COORDINATE_SYSTEM.CARTESIAN),o=ma(e,i,n,r),a=e.xMin,u=e.yMin,s=e.xMax,l=e.yMax,f=s-a+i.xOffset,c=l-u+i.yOffset,g=Math.ceil(f/i.xOffset),p=Math.ceil(c/i.yOffset);return{gridOffset:i,translation:o,width:f,height:c,numCol:g,numRow:p}}function ha(e,t){var r=ya(e),n=_a(t,e);return{yOffset:r,xOffset:n}}function ya(e){return e/_n*(180/Math.PI)}function _a(e,t){return t/_n*(180/Math.PI)/Math.cos(e*Math.PI/180)}function xn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function xa(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?xn(Object(r),!0).forEach(function(n){ba(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xn(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ba(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Sa(e,t){return wa(e)||Aa(e,t)||Sn(e,t)||Oa()}function Oa(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
343
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Aa(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,o=!1,a,u;try{for(r=r.call(e);!(i=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));i=!0);}catch(s){o=!0,u=s}finally{try{!i&&r.return!=null&&r.return()}finally{if(o)throw u}}return n}}function wa(e){if(Array.isArray(e))return e}function Pa(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Sn(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
344
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function Sn(e,t){if(e){if(typeof e=="string")return bn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return bn(e,t)}}function bn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Pe(e,t){var r=Ta(e,t),n=Da(r);return{gridHash:r.gridHash,gridOffset:r.gridOffset,data:n}}function Ta(e,t){var r=e.data,n=r===void 0?[]:r,i=e.cellSize,o=t.attributes,a=t.viewport,u=t.projectPoints,s=t.numInstances,l=o.positions.value,f=o.positions.getAccessor(),c=f.size,g=t.boundingBox||Ea(o.positions,s),p=t.posOffset||[180,90],m=t.gridOffset||rr(g,i);if(m.xOffset<=0||m.yOffset<=0)return{gridHash:{},gridOffset:m};var h=a.width,v=a.height,y=Math.ceil(h/m.xOffset),O=Math.ceil(v/m.yOffset),A={},P=(0,On.createIterable)(n),T=P.iterable,D=P.objectInfo,E=new Array(3),M=Pa(T),F;try{for(M.s();!(F=M.n()).done;){var V=F.value;D.index++,E[0]=l[D.index*c],E[1]=l[D.index*c+1],E[2]=c>=3?l[D.index*c+2]:0;var G=u?a.project(E):E,U=Sa(G,2),K=U[0],wr=U[1];if(Number.isFinite(K)&&Number.isFinite(wr)){var Je=Math.floor((wr+p[1])/m.yOffset),et=Math.floor((K+p[0])/m.xOffset);if(!u||et>=0&&et<y&&Je>=0&&Je<O){var tt="".concat(Je,"-").concat(et);A[tt]=A[tt]||{count:0,points:[],lonIdx:et,latIdx:Je},A[tt].count+=1,A[tt].points.push({source:V,index:D.index})}}}}catch(ni){M.e(ni)}finally{M.f()}return{gridHash:A,gridOffset:m,offsets:[p[0]*-1,p[1]*-1]}}function Da(e){var t=e.gridHash,r=e.gridOffset,n=e.offsets,i=new Array(Object.keys(t).length),o=0;for(var a in t){var u=a.split("-"),s=parseInt(u[0],10),l=parseInt(u[1],10),f=o++;i[f]=xa({index:f,position:[n[0]+r.xOffset*l,n[1]+r.yOffset*s]},t[a])}return i}function Ea(e,t){for(var r=e.value,n=e.getAccessor(),i=n.size,o=1/0,a=-1/0,u=1/0,s=-1/0,l,f,c=0;c<t;c++)f=r[c*i],l=r[c*i+1],Number.isFinite(f)&&Number.isFinite(l)&&(o=l<o?l:o,a=l>a?l:a,u=f<u?f:u,s=f>s?f:s);return{xMin:u,xMax:s,yMin:o,yMax:a}}function pt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?pt=function(r){return typeof r}:pt=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},pt(e)}function Ma(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Ca(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
345
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function Ca(e,t){if(e){if(typeof e=="string")return An(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return An(e,t)}}function An(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ra(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Te(e,t,r){return typeof Reflect<"u"&&Reflect.get?Te=Reflect.get:Te=function(i,o,a){var u=Na(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},Te(e,t,r||e)}function Na(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=re(e),e!==null););return e}function Ia(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&nr(e,t)}function nr(e,t){return nr=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},nr(e,t)}function La(e){var t=za();return function(){var n=re(e),i;if(t){var o=re(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Fa(this,i)}}function Fa(e,t){if(t&&(pt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ba(e)}function Ba(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function za(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function re(e){return re=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},re(e)}var ae=function(e){Ia(r,e);var t=La(r);function r(){var i;Ra(this,r);for(var o=arguments.length,a=new Array(o),u=0;u<o;u++)a[u]=arguments[u];return i=t.call.apply(t,[this].concat(a)),i.state=void 0,i}var n=r.prototype;return n.initializeAggregationLayer=function(o){var a=o.dimensions,u=this.context.gl;Te(re(r.prototype),"initializeAggregationLayer",this).call(this,a),this.setState({layerData:{},gpuGridAggregator:new z(u,{id:"".concat(this.id,"-gpu-aggregator")}),cpuGridAggregator:Pe})},n.updateState=function(o){Te(re(r.prototype),"updateState",this).call(this,o),this.updateAggregationState(o);var a=this.state,u=a.aggregationDataDirty,s=a.aggregationWeightsDirty,l=a.gpuAggregation;if(!(this.getNumInstances()<=0)){var f=!1;(u||l&&s)&&(this._updateAggregation(o),f=!0),!l&&(u||s)&&(this._updateWeightBins(),this._uploadAggregationResults(),f=!0),this.setState({aggregationDirty:f})}},n.finalizeState=function(o){var a,u=this.state.weights.count;u&&u.aggregationBuffer&&u.aggregationBuffer.delete(),(a=this.state.gpuGridAggregator)===null||a===void 0||a.delete(),Te(re(r.prototype),"finalizeState",this).call(this,o)},n.updateShaders=function(o){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(o)},n.updateAggregationState=function(o){Pn.log.assert(!1)},n.allocateResources=function(o,a){if(this.state.numRow!==o||this.state.numCol!==a){var u=a*o*4*4,s=this.context.gl,l=this.state.weights;for(var f in l){var c=l[f];c.aggregationBuffer&&c.aggregationBuffer.delete(),c.aggregationBuffer=new wn.Buffer(s,{byteLength:u,accessor:{size:4,type:5126,divisor:1}})}}},n.updateResults=function(o){var a=o.aggregationData,u=o.maxMinData,s=o.maxData,l=o.minData,f=this.state.weights.count;f&&(f.aggregationData=a,f.maxMinData=u,f.maxData=s,f.minData=l)},n._updateAggregation=function(o){var a=this.state,u=a.cpuGridAggregator,s=a.gpuGridAggregator,l=a.gridOffset,f=a.posOffset,c=a.translation,g=c===void 0?[0,0]:c,p=a.scaling,m=p===void 0?[0,0,0]:p,h=a.boundingBox,v=a.projectPoints,y=a.gpuAggregation,O=a.numCol,A=a.numRow,P=o.props,T=this.context.viewport,D=this.getAttributes(),E=this.getNumInstances();if(y){var F=this.state.weights;s.run({weights:F,cellSize:[l.xOffset,l.yOffset],numCol:O,numRow:A,translation:g,scaling:m,vertexCount:E,projectPoints:v,attributes:D,moduleSettings:this.getModuleSettings()})}else{var M=u(P,{gridOffset:l,projectPoints:v,attributes:D,viewport:T,posOffset:f,boundingBox:h});this.setState({layerData:M})}},n._updateWeightBins=function(){var o=this.state.getValue,a=new we(this.state.layerData.data||[],{getValue:o});this.setState({sortedBins:a})},n._uploadAggregationResults=function(){var o=this.state,a=o.numCol,u=o.numRow,s=this.state.layerData.data,l=this.state.sortedBins,f=l.aggregatedBins,c=l.minValue,g=l.maxValue,p=l.totalCount,m=4,h=a*u*m,v=new Float32Array(h).fill(0),y=Ma(f),O;try{for(y.s();!(O=y.n()).done;){var A=O.value,P=s[A.i],T=P.lonIdx,D=P.latIdx,E=A.value,M=A.counts,F=(T+D*a)*m;v[F]=E,v[F+m-1]=M}}catch(K){y.e(K)}finally{y.f()}var V=new Float32Array([g,0,0,c]),G=new Float32Array([g,0,0,p]),U=new Float32Array([c,0,0,p]);this.updateResults({aggregationData:v,maxMinData:V,maxData:G,minData:U})},r}($);ae.layerName="GridAggregationLayer";function dt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?dt=function(r){return typeof r}:dt=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},dt(e)}function Ua(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function De(e,t,r){return typeof Reflect<"u"&&Reflect.get?De=Reflect.get:De=function(i,o,a){var u=Ga(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},De(e,t,r||e)}function Ga(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=ne(e),e!==null););return e}function Wa(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&or(e,t)}function or(e,t){return or=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},or(e,t)}function ja(e){var t=$a();return function(){var n=ne(e),i;if(t){var o=ne(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Va(this,i)}}function Va(e,t){if(t&&(dt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ha(e)}function Ha(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $a(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ne(e){return ne=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},ne(e)}function Tn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function ir(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Tn(Object(r),!0).forEach(function(n){ar(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Tn(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ar(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Xa=ir(ir({},Oe.defaultProps),{},{getPosition:{type:"accessor",value:function(t){return t.position}},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM"}),Dn="positions",ka={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},vt=function(e){Wa(r,e);var t=ja(r);function r(){var i;Ua(this,r);for(var o=arguments.length,a=new Array(o),u=0;u<o;u++)a[u]=arguments[u];return i=t.call.apply(t,[this].concat(a)),i.state=void 0,i}var n=r.prototype;return n.initializeState=function(){var o,a=this.context.gl;if(!Oe.isSupported(a)){this.setState({supported:!1}),ur.log.error("ScreenGridLayer: ".concat(this.id," is not supported on this browser"))();return}De(ne(r.prototype),"initializeAggregationLayer",this).call(this,{dimensions:ka,getCellSize:function(f){return f.cellSizePixels}});var u={count:{size:1,operation:R.SUM,needMax:!0,maxTexture:_e(a,{id:"".concat(this.id,"-max-texture")})}};this.setState({supported:!0,projectPoints:!0,weights:u,subLayerData:{attributes:{}},maxTexture:u.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]});var s=this.getAttributeManager();s.add((o={},ar(o,Dn,{size:3,accessor:"getPosition",type:5130,fp64:this.use64bitPositions()}),ar(o,"count",{size:3,accessor:"getWeight"}),o))},n.shouldUpdateState=function(o){var a=o.changeFlags;return this.state.supported&&a.somethingChanged},n.updateState=function(o){De(ne(r.prototype),"updateState",this).call(this,o)},n.renderLayers=function(){if(!this.state.supported)return[];var o=this.state,a=o.maxTexture,u=o.numRow,s=o.numCol,l=o.weights,f=this.props.updateTriggers,c=l.count.aggregationBuffer,g=this.getSubLayerClass("cells",Oe);return new g(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:f}),{data:{attributes:{instanceCounts:c}},maxTexture:a,numInstances:u*s})},n.finalizeState=function(o){De(ne(r.prototype),"finalizeState",this).call(this,o);var a=this.state,u=a.aggregationBuffer,s=a.maxBuffer,l=a.maxTexture;u?.delete(),s?.delete(),l?.delete()},n.getPickingInfo=function(o){var a=o.info,u=a.index;if(u>=0){var s=this.state,l=s.gpuGridAggregator,f=s.gpuAggregation,c=s.weights,g=f?l.getData("count"):c.count;a.object=z.getAggregationData(ir({pixelIndex:u},g))}return a},n.updateResults=function(o){var a=o.aggregationData,u=o.maxData,s=this.state.weights.count;s.aggregationData=a,s.aggregationBuffer.setData({data:a}),s.maxData=u,s.maxTexture.setImageData({data:u})},n.updateAggregationState=function(o){var a=o.props.cellSizePixels,u=o.oldProps.cellSizePixels!==a,s=o.changeFlags.viewportChanged,l=o.props.gpuAggregation;this.state.gpuAggregation!==o.props.gpuAggregation&&l&&!z.isSupported(this.context.gl)&&(ur.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),l=!1);var f=l!==this.state.gpuAggregation;this.setState({gpuAggregation:l});var c=this.isAttributeChanged(Dn),g=this.state.dimensions,p=g.data,m=g.weights,h=c||f||s||this.isAggregationDirty(o,{compareAll:l,dimension:p}),v=this.isAggregationDirty(o,{dimension:m});this.setState({aggregationDataDirty:h,aggregationWeightsDirty:v});var y=this.context.viewport;if(s||u){var O=y.width,A=y.height,P=Math.ceil(O/a),T=Math.ceil(A/a);this.allocateResources(T,P),this.setState({scaling:[O/2,-A/2,1],gridOffset:{xOffset:a,yOffset:a},width:O,height:A,numCol:P,numRow:T})}v&&this._updateAccessors(o),(h||v)&&this._resetResults()},n._updateAccessors=function(o){var a=o.props,u=a.getWeight,s=a.aggregation,l=a.data,f=this.state.weights.count;f&&(f.getWeight=u,f.operation=R[s]),this.setState({getValue:ve(s,u,{data:l})})},n._resetResults=function(){var o=this.state.weights.count;o&&(o.aggregationData=null)},r}(ae);vt.layerName="ScreenGridLayer";vt.defaultProps=Xa;var Ln=C(pe());function Ye(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ye=function(r){return typeof r}:Ye=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ye(e)}function En(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function X(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?En(Object(r),!0).forEach(function(n){Nn(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):En(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Nn(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qa(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Mn(){}var Cn=["getBins","getDomain","getScaleFunc"],Rn=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],Ya=function(t){return t.cellSize},Ee=function(){function e(r){qa(this,e),this.state={layerData:{},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=r.getCellSize||Ya,this._getAggregator=r.getAggregator,this._addDimension(r.dimensions||Rn)}e.defaultDimensions=function(){return Rn};var t=e.prototype;return t.updateState=function(n,i){var o=n.oldProps,a=n.props,u=n.changeFlags;this.updateGetValueFuncs(o,a,u);var s=this.needsReProjectPoints(o,a,u),l=!1;if(u.dataChanged||s)this.getAggregatedData(a,i),l=!0;else{var f=this.getDimensionChanges(o,a,u)||[];f.forEach(function(c){return typeof c=="function"&&c()}),l=!0}return this.setState({aggregationDirty:l}),this.state},t.setState=function(n){this.state=X(X({},this.state),n)},t.setDimensionState=function(n,i){this.setState({dimensions:X(X({},this.state.dimensions),{},Nn({},n,X(X({},this.state.dimensions[n]),i)))})},t.normalizeResult=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return n.hexagons?X({data:n.hexagons},n):n.layerData?X({data:n.layerData},n):n},t.getAggregatedData=function(n,i){var o=this._getAggregator(n),a=o(n,i);this.setState({layerData:this.normalizeResult(a)}),this.changeFlags={layerData:!0},this.getSortedBins(n)},t.updateGetValueFuncs=function(n,i,o){for(var a in this.dimensionUpdaters){var u=this.dimensionUpdaters[a].getBins.triggers,s=u.value,l=u.weight,f=u.aggregation,c=i[s.prop],g=this.needUpdateDimensionStep(this.dimensionUpdaters[a].getBins,n,i,o);g&&(c?c=Ir(c,{data:i.data}):c=ve(i[f.prop],i[l.prop],{data:i.data})),c&&this.setDimensionState(a,{getValue:c})}},t.needsReProjectPoints=function(n,i,o){return this._getCellSize(n)!==this._getCellSize(i)||this._getAggregator(n)!==this._getAggregator(i)||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getPosition)},t.addDimension=function(n){this._addDimension(n)},t._addDimension=function(){var n=this,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];i.forEach(function(o){var a=o.key;n.dimensionUpdaters[a]=n.getDimensionUpdaters(o),n.state.dimensions[a]={getValue:null,domain:null,sortedBins:null,scaleFunc:Mn}})},t.getDimensionUpdaters=function(n){var i=n.key,o=n.accessor,a=n.pickingInfo,u=n.getBins,s=n.getDomain,l=n.getScaleFunc,f=n.nullValue;return{key:i,accessor:o,pickingInfo:a,getBins:X({updater:this.getDimensionSortedBins},u),getDomain:X({updater:this.getDimensionValueDomain},s),getScaleFunc:X({updater:this.getDimensionScale},l),attributeAccessor:this.getSubLayerDimensionAttribute(i,f)}},t.needUpdateDimensionStep=function(n,i,o,a){return Object.values(n.triggers).some(function(u){return u.updateTrigger?a.dataChanged||a.updateTriggersChanged&&(a.updateTriggersChanged.all||a.updateTriggersChanged[u.updateTrigger]):i[u.prop]!==o[u.prop]})},t.getDimensionChanges=function(n,i,o){var a=this,u=[],s=function(c){var g=Cn.find(function(p){return a.needUpdateDimensionStep(a.dimensionUpdaters[c][p],n,i,o)});g&&u.push(a.dimensionUpdaters[c][g].updater.bind(a,i,a.dimensionUpdaters[c]))};for(var l in this.dimensionUpdaters)s(l);return u.length?u:null},t.getUpdateTriggers=function(n){var i=this,o=n.updateTriggers||{},a={},u=function(f){var c=i.dimensionUpdaters[f].accessor;a[c]={},Cn.forEach(function(g){Object.values(i.dimensionUpdaters[f][g].triggers).forEach(function(p){var m=p.prop,h=p.updateTrigger;if(h){var v=o[h];Ye(v)==="object"&&!Array.isArray(v)?Object.assign(a[c],v):v!==void 0&&(a[c][m]=v)}else a[c][m]=n[m]})})};for(var s in this.dimensionUpdaters)u(s);return a},t.getSortedBins=function(n){for(var i in this.dimensionUpdaters)this.getDimensionSortedBins(n,this.dimensionUpdaters[i])},t.getDimensionSortedBins=function(n,i){var o=i.key,a=this.state.dimensions[o].getValue,u=new we(this.state.layerData.data||[],{getValue:a,filterData:n._filterData});this.setDimensionState(o,{sortedBins:u}),this.getDimensionValueDomain(n,i)},t.getDimensionValueDomain=function(n,i){var o=i.getDomain,a=i.key,u=o.triggers,s=u.lowerPercentile,l=u.upperPercentile,f=u.scaleType,c=this.state.dimensions[a].sortedBins.getValueDomainByScale(n[f.prop],[n[s.prop],n[l.prop]]);this.setDimensionState(a,{valueDomain:c}),this.getDimensionScale(n,i)},t.getDimensionScale=function(n,i){var o=i.key,a=i.getScaleFunc,u=i.getDomain,s=a.triggers,l=s.domain,f=s.range,c=u.triggers.scaleType,g=a.onSet,p=n[f.prop],m=n[l.prop]||this.state.dimensions[o].valueDomain,h=fn(c&&n[c.prop]),v=h(m,p);Ye(g)==="object"&&typeof n[g.props]=="function"&&n[g.props](v.domain()),this.setDimensionState(o,{scaleFunc:v})},t.getSubLayerDimensionAttribute=function(n,i){var o=this;return function(a){var u=o.state.dimensions[n],s=u.sortedBins,l=u.scaleFunc,f=s.binMap[a.index];if(f&&f.counts===0)return i;var c=f&&f.value,g=l.domain(),p=c>=g[0]&&c<=g[g.length-1];return p?l(c):i}},t.getSubLayerAccessors=function(n){var i={};for(var o in this.dimensionUpdaters){var a=this.dimensionUpdaters[o].accessor;i[a]=this.getSubLayerDimensionAttribute(n,o)}return i},t.getPickingInfo=function(n){var i=n.info,o=i.picked&&i.index>-1,a=null;if(o){var u=this.state.layerData.data[i.index],s={};for(var l in this.dimensionUpdaters){var f=this.dimensionUpdaters[l].pickingInfo,c=this.state.dimensions[l].sortedBins,g=c.binMap[u.index]&&c.binMap[u.index].value;s[f]=g}a=Object.assign(s,u,{points:u.filteredPoints||u.points})}return i.picked=Boolean(a),i.object=a,i},t.getAccessor=function(n){return this.dimensionUpdaters.hasOwnProperty(n)?this.dimensionUpdaters[n].attributeAccessor:Mn},e}();function mt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?mt=function(r){return typeof r}:mt=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},mt(e)}function Ka(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ht(e,t,r){return typeof Reflect<"u"&&Reflect.get?ht=Reflect.get:ht=function(i,o,a){var u=Qa(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},ht(e,t,r||e)}function Qa(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Me(e),e!==null););return e}function Za(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&sr(e,t)}function sr(e,t){return sr=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},sr(e,t)}function Ja(e){var t=ru();return function(){var n=Me(e),i;if(t){var o=Me(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return eu(this,i)}}function eu(e,t){if(t&&(mt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tu(e)}function tu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ru(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Me(e){return Me=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Me(e)}function In(){}var nu={colorDomain:null,colorRange:j,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:In,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:In,gridAggregator:Pe,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:function(t){return t.position}},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},ue=function(e){Za(r,e);var t=Ja(r);function r(){return Ka(this,r),t.apply(this,arguments)}var n=r.prototype;return n.initializeState=function(){var o=new Ee({getAggregator:function(s){return s.gridAggregator},getCellSize:function(s){return s.cellSize}});this.state={cpuAggregator:o,aggregatorState:o.state};var a=this.getAttributeManager();a.add({positions:{size:3,type:5130,accessor:"getPosition"}})},n.updateState=function(o){ht(Me(r.prototype),"updateState",this).call(this,o),this.setState({aggregatorState:this.state.cpuAggregator.updateState(o,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})},n.getPickingInfo=function(o){var a=o.info;return this.state.cpuAggregator.getPickingInfo({info:a})},n._onGetSublayerColor=function(o){return this.state.cpuAggregator.getAccessor("fillColor")(o)},n._onGetSublayerElevation=function(o){return this.state.cpuAggregator.getAccessor("elevation")(o)},n._getSublayerUpdateTriggers=function(){return this.state.cpuAggregator.getUpdateTriggers(this.props)},n.renderLayers=function(){var o=this.props,a=o.elevationScale,u=o.extruded,s=o.cellSize,l=o.coverage,f=o.material,c=o.transitions,g=this.state.cpuAggregator,p=this.getSubLayerClass("grid-cell",Ln.GridCellLayer),m=this._getSublayerUpdateTriggers();return new p({cellSize:s,coverage:l,material:f,elevationScale:a,extruded:u,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:c&&{getFillColor:c.getColorValue||c.getColorWeight,getElevation:c.getElevationValue||c.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:m}),{data:g.state.layerData.data})},r}($);ue.layerName="CPUGridLayer";ue.defaultProps=nu;var Wn=C(L()),jn=C(pe());var Ce=Math.PI/3,ou=[0,Ce,2*Ce,3*Ce,4*Ce,5*Ce];function iu(e){return e[0]}function au(e){return e[1]}function lr(){var e=0,t=0,r=1,n=1,i=iu,o=au,a,u,s;function l(c){var g={},p=[],m,h=c.length;for(m=0;m<h;++m)if(!(isNaN(y=+i.call(null,v=c[m],m,c))||isNaN(O=+o.call(null,v,m,c)))){var v,y,O,A=Math.round(O=O/s),P=Math.round(y=y/u-(A&1)/2),T=O-A;if(Math.abs(T)*3>1){var D=y-P,E=P+(y<P?-1:1)/2,M=A+(O<A?-1:1),F=y-E,V=O-M;D*D+T*T>F*F+V*V&&(P=E+(A&1?1:-1)/2,A=M)}var G=P+"-"+A,U=g[G];U?U.push(v):(p.push(U=g[G]=[v]),U.x=(P+(A&1)/2)*u,U.y=A*s)}return p}function f(c){var g=0,p=0;return ou.map(function(m){var h=Math.sin(m)*c,v=-Math.cos(m)*c,y=h-g,O=v-p;return g=h,p=v,[y,O]})}return l.hexagon=function(c){return"m"+f(c==null?a:+c).join("l")+"z"},l.centers=function(){for(var c=[],g=Math.round(t/s),p=Math.round(e/u),m=g*s;m<n+a;m+=s,++g)for(var h=p*u+(g&1)*u/2;h<r+u/2;h+=u)c.push([h,m]);return c},l.mesh=function(){var c=f(a).slice(0,4).join("l");return l.centers().map(function(g){return"M"+g+"m"+c}).join("")},l.x=function(c){return arguments.length?(i=c,l):i},l.y=function(c){return arguments.length?(o=c,l):o},l.radius=function(c){return arguments.length?(a=+c,u=a*2*Math.sin(Ce),s=a*1.5,l):a},l.size=function(c){return arguments.length?(e=t=0,r=+c[0],n=+c[1],l):[r-e,n-t]},l.extent=function(c){return arguments.length?(e=+c[0][0],t=+c[0][1],r=+c[1][0],n=+c[1][1],l):[[e,t],[r,n]]},l.radius(1)}var yt=C(L());function uu(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=su(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
346
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function su(e,t){if(e){if(typeof e=="string")return Fn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Fn(e,t)}}function Fn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Bn(e,t){var r=e.data,n=e.radius,i=t.viewport,o=t.attributes,a=r.length?lu(r,t):null,u=fu(n,i,a),s=[],l=(0,yt.createIterable)(r),f=l.iterable,c=l.objectInfo,g=o.positions.value,p=o.positions.getAccessor(),m=p.size,h=uu(f),v;try{for(h.s();!(v=h.n()).done;){var y=v.value;c.index++;var O=c.index*m,A=[g[O],g[O+1]],P=Number.isFinite(A[0])&&Number.isFinite(A[1]);P?s.push({screenCoord:i.projectFlat(A),source:y,index:c.index}):yt.log.warn("HexagonLayer: invalid position")()}}catch(E){h.e(E)}finally{h.f()}var T=lr().radius(u).x(function(E){return E.screenCoord[0]}).y(function(E){return E.screenCoord[1]}),D=T(s);return{hexagons:D.map(function(E,M){return{position:i.unprojectFlat([E.x,E.y]),points:E,index:M}}),radiusCommon:u}}function lu(e,t){var r=t.attributes,n=r.positions.value,i=r.positions.getAccessor(),o=i.size,a=1/0,u=1/0,s=-1/0,l=-1/0,f;for(f=0;f<o*e.length;f+=o){var c=n[f],g=n[f+1],p=Number.isFinite(c)&&Number.isFinite(g);p&&(a=Math.min(c,a),s=Math.max(c,s),u=Math.min(g,u),l=Math.max(g,l))}return[a,u,s,l].every(Number.isFinite)?[(a+s)/2,(u+l)/2]:null}function fu(e,t,r){var n=t.getDistanceScales(r),i=n.unitsPerMeter;return e*i[0]}function _t(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_t=function(r){return typeof r}:_t=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},_t(e)}function zn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Un(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?zn(Object(r),!0).forEach(function(n){cu(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zn(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function cu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function gu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function xt(e,t,r){return typeof Reflect<"u"&&Reflect.get?xt=Reflect.get:xt=function(i,o,a){var u=pu(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},xt(e,t,r||e)}function pu(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Re(e),e!==null););return e}function du(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&fr(e,t)}function fr(e,t){return fr=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},fr(e,t)}function vu(e){var t=yu();return function(){var n=Re(e),i;if(t){var o=Re(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return mu(this,i)}}function mu(e,t){if(t&&(_t(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return hu(e)}function hu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function yu(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Re(e){return Re=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Re(e)}function Gn(){}var _u={colorDomain:null,colorRange:j,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",value:0,min:0,max:100},upperPercentile:{type:"number",value:100,min:0,max:100},colorScaleType:"quantize",onSetColorDomain:Gn,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",value:0,min:0,max:100},elevationUpperPercentile:{type:"number",value:100,min:0,max:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:Gn,radius:{type:"number",value:1e3,min:1},coverage:{type:"number",min:0,max:1,value:1},extruded:!1,hexagonAggregator:Bn,getPosition:{type:"accessor",value:function(t){return t.position}},material:!0,_filterData:{type:"function",value:null,optional:!0}},bt=function(e){du(r,e);var t=vu(r);function r(){var i;gu(this,r);for(var o=arguments.length,a=new Array(o),u=0;u<o;u++)a[u]=arguments[u];return i=t.call.apply(t,[this].concat(a)),i.state=void 0,i}var n=r.prototype;return n.initializeState=function(){var o=new Ee({getAggregator:function(s){return s.hexagonAggregator},getCellSize:function(s){return s.radius}});this.state={cpuAggregator:o,aggregatorState:o.state,vertices:null};var a=this.getAttributeManager();a.add({positions:{size:3,type:5130,accessor:"getPosition"}})},n.updateState=function(o){if(xt(Re(r.prototype),"updateState",this).call(this,o),o.changeFlags.propsOrDataChanged){var a=this.state.cpuAggregator.updateState(o,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==a.layerData){var u=a.layerData||{},s=u.hexagonVertices;this.setState({vertices:s&&this.convertLatLngToMeterOffset(s)})}this.setState({aggregatorState:a})}},n.convertLatLngToMeterOffset=function(o){var a=this.context.viewport;if(Array.isArray(o)&&o.length===6){var u=o[0],s=o[3],l=[(u[0]+s[0])/2,(u[1]+s[1])/2],f=a.projectFlat(l),c=a.getDistanceScales(l),g=c.metersPerUnit,p=o.map(function(m){var h=a.projectFlat(m);return[(h[0]-f[0])*g[0],(h[1]-f[1])*g[1]]});return p}return Wn.log.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null},n.getPickingInfo=function(o){var a=o.info;return this.state.cpuAggregator.getPickingInfo({info:a})},n._onGetSublayerColor=function(o){return this.state.cpuAggregator.getAccessor("fillColor")(o)},n._onGetSublayerElevation=function(o){return this.state.cpuAggregator.getAccessor("elevation")(o)},n._getSublayerUpdateTriggers=function(){return this.state.cpuAggregator.getUpdateTriggers(this.props)},n.renderLayers=function(){var o=this.props,a=o.elevationScale,u=o.extruded,s=o.coverage,l=o.material,f=o.transitions,c=this.state,g=c.aggregatorState,p=c.vertices,m=this.getSubLayerClass("hexagon-cell",jn.ColumnLayer),h=this._getSublayerUpdateTriggers(),v=p?{vertices:p,radius:1}:{radius:g.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new m(Un(Un({},v),{},{diskResolution:6,elevationScale:a,extruded:u,coverage:s,material:l,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:f&&{getFillColor:f.getColorValue||f.getColorWeight,getElevation:f.getElevationValue||f.getElevationWeight}}),this.getSubLayerProps({id:"hexagon-cell",updateTriggers:h}),{data:g.layerData.data})},r}($);bt.layerName="HexagonLayer";bt.defaultProps=_u;var Tt=C(pe());var ho=C(L());var x;function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var _=.5,w=1/6,d={N:[0,_],E:[_,0],S:[0,-_],W:[-_,0],NE:[_,_],NW:[-_,_],SE:[_,-_],SW:[-_,-_]},Ne=[d.W,d.SW,d.S],Ie=[d.S,d.SE,d.E],Le=[d.E,d.NE,d.N],Fe=[d.NW,d.W,d.N],Be=[[-_,w],[-_,-w],[-w,-_],[w,-_]],ze=[[-w,-_],[w,-_],[_,-w],[_,w]],Ue=[[_,-w],[_,w],[w,_],[-w,_]],Ge=[[-_,w],[-_,-w],[w,_],[-w,_]],Vn=[d.W,d.SW,d.SE,d.E],Hn=[d.S,d.SE,d.NE,d.N],$n=[d.NW,d.W,d.E,d.NE],Xn=[d.NW,d.SW,d.S,d.N],kn=[[-_,w],[-_,-w],[_,-w],[_,w]],qn=[[-w,-_],[w,-_],[w,_],[-w,_]],xu=[d.NW,d.SW,d.SE,d.NE],Yn=[d.NW,d.SW,d.SE,d.E,d.N],Kn=[d.W,d.SW,d.SE,d.NE,d.N],Qn=[d.NW,d.W,d.S,d.SE,d.NE],Zn=[d.NW,d.SW,d.S,d.E,d.NE],Jn=[d.NW,d.W,[_,-w],[_,w],d.N],eo=[[-w,-_],[w,-_],d.E,d.NE,d.N],to=[[-_,w],[-_,-w],d.S,d.SE,d.E],ro=[d.W,d.SW,d.S,[w,_],[-w,_]],no=[d.NW,d.W,[-w,-_],[w,-_],d.N],oo=[[-_,w],[-_,-w],d.E,d.NE,d.N],io=[d.S,d.SE,d.E,[w,_],[-w,_]],ao=[d.W,d.SW,d.S,[_,-w],[_,w]],uo=[d.W,d.SW,d.SE,d.E,[w,_],[-w,_]],so=[[-_,w],[-_,-w],d.S,d.SE,d.NE,d.N],lo=[d.NW,d.W,[-w,-_],[w,-_],d.E,d.NE],fo=[d.NW,d.SW,d.S,[_,-w],[_,w],d.N],We=[d.W,d.SW,d.S,d.E,d.NE,d.N],je=[d.NW,d.W,d.S,d.SE,d.E,d.N],St=[[-_,w],[-_,-w],[-w,-_],[w,-_],d.E,d.NE,d.N],Ot=[d.W,d.SW,d.S,[_,-w],[_,w],[w,_],[-w,_]],At=[d.NW,d.W,[-w,-_],[w,-_],[_,-w],[_,w],d.N],wt=[[-_,w],[-_,-w],d.S,d.SE,d.E,[w,_],[-w,_]],co=[[-_,w],[-_,-w],[-w,-_],[w,-_],[_,-w],[_,w],[w,_],[-w,_]],go={0:[],1:[[d.W,d.S]],2:[[d.S,d.E]],3:[[d.W,d.E]],4:[[d.N,d.E]],5:{0:[[d.W,d.S],[d.N,d.E]],1:[[d.W,d.N],[d.S,d.E]]},6:[[d.N,d.S]],7:[[d.W,d.N]],8:[[d.W,d.N]],9:[[d.N,d.S]],10:{0:[[d.W,d.N],[d.S,d.E]],1:[[d.W,d.S],[d.N,d.E]]},11:[[d.N,d.E]],12:[[d.W,d.E]],13:[[d.S,d.E]],14:[[d.W,d.S]],15:[]};function S(e){return parseInt(e,4)}var po=(x={},b(x,S("0000"),[]),b(x,S("2222"),[]),b(x,S("2221"),[Ne]),b(x,S("2212"),[Ie]),b(x,S("2122"),[Le]),b(x,S("1222"),[Fe]),b(x,S("0001"),[Ne]),b(x,S("0010"),[Ie]),b(x,S("0100"),[Le]),b(x,S("1000"),[Fe]),b(x,S("2220"),[Be]),b(x,S("2202"),[ze]),b(x,S("2022"),[Ue]),b(x,S("0222"),[Ge]),b(x,S("0002"),[Be]),b(x,S("0020"),[ze]),b(x,S("0200"),[Ue]),b(x,S("2000"),[Ge]),b(x,S("0011"),[Vn]),b(x,S("0110"),[Hn]),b(x,S("1100"),[$n]),b(x,S("1001"),[Xn]),b(x,S("2211"),[Vn]),b(x,S("2112"),[Hn]),b(x,S("1122"),[$n]),b(x,S("1221"),[Xn]),b(x,S("2200"),[kn]),b(x,S("2002"),[qn]),b(x,S("0022"),[kn]),b(x,S("0220"),[qn]),b(x,S("1111"),[xu]),b(x,S("1211"),[Yn]),b(x,S("2111"),[Kn]),b(x,S("1112"),[Qn]),b(x,S("1121"),[Zn]),b(x,S("1011"),[Yn]),b(x,S("0111"),[Kn]),b(x,S("1110"),[Qn]),b(x,S("1101"),[Zn]),b(x,S("1200"),[Jn]),b(x,S("0120"),[eo]),b(x,S("0012"),[to]),b(x,S("2001"),[ro]),b(x,S("1022"),[Jn]),b(x,S("2102"),[eo]),b(x,S("2210"),[to]),b(x,S("0221"),[ro]),b(x,S("1002"),[no]),b(x,S("2100"),[oo]),b(x,S("0210"),[io]),b(x,S("0021"),[ao]),b(x,S("1220"),[no]),b(x,S("0122"),[oo]),b(x,S("2012"),[io]),b(x,S("2201"),[ao]),b(x,S("0211"),[uo]),b(x,S("2110"),[so]),b(x,S("1102"),[lo]),b(x,S("1021"),[fo]),b(x,S("2011"),[uo]),b(x,S("0112"),[so]),b(x,S("1120"),[lo]),b(x,S("1201"),[fo]),b(x,S("2101"),[We]),b(x,S("0121"),[We]),b(x,S("1012"),[je]),b(x,S("1210"),[je]),b(x,S("0101"),{0:[Ne,Le],1:[We],2:[We]}),b(x,S("1010"),{0:[Fe,Ie],1:[je],2:[je]}),b(x,S("2121"),{0:[We],1:[We],2:[Ne,Le]}),b(x,S("1212"),{0:[je],1:[je],2:[Fe,Ie]}),b(x,S("2120"),{0:[St],1:[St],2:[Be,Le]}),b(x,S("2021"),{0:[Ot],1:[Ot],2:[Ne,Ue]}),b(x,S("1202"),{0:[At],1:[At],2:[Fe,ze]}),b(x,S("0212"),{0:[wt],1:[wt],2:[Ie,Ge]}),b(x,S("0102"),{0:[Be,Le],1:[St],2:[St]}),b(x,S("0201"),{0:[Ne,Ue],1:[Ot],2:[Ot]}),b(x,S("1020"),{0:[Fe,ze],1:[At],2:[At]}),b(x,S("2010"),{0:[Ie,Ge],1:[wt],2:[wt]}),b(x,S("2020"),{0:[Ge,ze],1:[co],2:[Be,Ue]}),b(x,S("0202"),{0:[Ue,Be],1:[co],2:[Ge,ze]}),x);function vo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function mo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?vo(Object(r),!0).forEach(function(n){bu(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):vo(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function bu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var se={ISO_LINES:1,ISO_BANDS:2},Su={zIndex:0,zOffset:.005};function Ke(e,t){return Array.isArray(t)?e<t[0]?0:e<t[1]?1:2:e>=t?1:0}function yo(e){var t=e.cellWeights,r=e.x,n=e.y,i=e.width,o=e.height,a=e.threshold;e.thresholdValue&&(ho.log.deprecated("thresholdValue","threshold")(),a=e.thresholdValue);var u=r<0,s=r>=i-1,l=n<0,f=n>=o-1,c=u||s||l||f,g={},p={};u||f?p.top=0:(g.top=t[(n+1)*i+r],p.top=Ke(g.top,a)),s||f?p.topRight=0:(g.topRight=t[(n+1)*i+r+1],p.topRight=Ke(g.topRight,a)),s||l?p.right=0:(g.right=t[n*i+r+1],p.right=Ke(g.right,a)),u||l?p.current=0:(g.current=t[n*i+r],p.current=Ke(g.current,a));var m=p.top,h=p.topRight,v=p.right,y=p.current,O=-1;Number.isFinite(a)&&(O=m<<3|h<<2|v<<1|y),Array.isArray(a)&&(O=m<<6|h<<4|v<<2|y);var A=0;return c||(A=Ke((g.top+g.topRight+g.right+g.current)/4,a)),{code:O,meanCode:A}}function cr(e){var t=e.gridOrigin,r=e.cellSize,n=e.x,i=e.y,o=e.code,a=e.meanCode,u=e.type,s=u===void 0?se.ISO_LINES:u,l=mo(mo({},Su),e.thresholdData),f=s===se.ISO_BANDS?po[o]:go[o];Array.isArray(f)||(f=f[a]);var c=l.zIndex*l.zOffset,g=(n+1)*r[0],p=(i+1)*r[1],m=t[0]+g,h=t[1]+p;if(s===se.ISO_BANDS){var v=[];return f.forEach(function(O){var A=[];O.forEach(function(P){var T=m+P[0]*r[0],D=h+P[1]*r[1];A.push([T,D,c])}),v.push(A)}),v}var y=[];return f.forEach(function(O){O.forEach(function(A){var P=m+A[0]*r[0],T=h+A[1]*r[1];y.push([P,T,c])})}),y}function _o(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Ou(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
347
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function Ou(e,t){if(e){if(typeof e=="string")return xo(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return xo(e,t)}}function xo(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function bo(e){var t=e.thresholdData,r=e.cellWeights,n=e.gridSize,i=e.gridOrigin,o=e.cellSize,a=[],u=[],s=n[0],l=n[1],f=0,c=0,g=_o(t),p;try{for(g.s();!(p=g.n()).done;)for(var m=p.value,h=m.contour,v=h.threshold,y=-1;y<s;y++)for(var O=-1;O<l;O++){var A=yo({cellWeights:r,threshold:v,x:y,y:O,width:s,height:l}),P=A.code,T=A.meanCode,D={type:se.ISO_BANDS,gridOrigin:i,cellSize:o,x:y,y:O,width:s,height:l,code:P,meanCode:T,thresholdData:m};if(Array.isArray(v)){D.type=se.ISO_BANDS;var E=cr(D),M=_o(E),F;try{for(M.s();!(F=M.n()).done;){var V=F.value;u[c++]={vertices:V,contour:h}}}catch(K){M.e(K)}finally{M.f()}}else{D.type=se.ISO_LINES;for(var G=cr(D),U=0;U<G.length;U+=2)a[f++]={start:G[U],end:G[U+1],contour:h}}}}catch(K){g.e(K)}finally{g.f()}return{contourSegments:a,contourPolygons:u}}var wo=C(L());function Pt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Pt=function(r){return typeof r}:Pt=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Pt(e)}function So(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Au(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qe(e,t,r){return typeof Reflect<"u"&&Reflect.get?Qe=Reflect.get:Qe=function(i,o,a){var u=wu(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},Qe(e,t,r||e)}function wu(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=le(e),e!==null););return e}function Pu(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&gr(e,t)}function gr(e,t){return gr=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},gr(e,t)}function Tu(e){var t=Mu();return function(){var n=le(e),i;if(t){var o=le(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Du(this,i)}}function Du(e,t){if(t&&(Pt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Eu(e)}function Eu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Mu(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function le(e){return le=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},le(e)}var Oo=[255,255,255,255],Cu=1,Ru=1,Nu={cellSize:{type:"number",min:1,max:1e3,value:1e3},getPosition:{type:"accessor",value:function(t){return t.position}},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM",contours:{type:"object",value:[{threshold:Ru}],optional:!0,compare:3},zOffset:.005},Ao="positions",Iu={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},Dt=function(e){Pu(r,e);var t=Tu(r);function r(){return Au(this,r),t.apply(this,arguments)}var n=r.prototype;return n.initializeState=function(){var o;Qe(le(r.prototype),"initializeAggregationLayer",this).call(this,{dimensions:Iu}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:R.SUM}}});var a=this.getAttributeManager();a.add((o={},So(o,Ao,{size:3,accessor:"getPosition",type:5130,fp64:this.use64bitPositions()}),So(o,"count",{size:3,accessor:"getWeight"}),o))},n.updateState=function(o){Qe(le(r.prototype),"updateState",this).call(this,o);var a=!1,u=o.oldProps,s=o.props,l=this.state.aggregationDirty;(u.contours!==s.contours||u.zOffset!==s.zOffset)&&(a=!0,this._updateThresholdData(o.props)),this.getNumInstances()>0&&(l||a)&&this._generateContours()},n.renderLayers=function(){var o=this.state.contourData,a=o.contourSegments,u=o.contourPolygons,s=this.getSubLayerClass("lines",Tt.LineLayer),l=this.getSubLayerClass("bands",Tt.SolidPolygonLayer),f=a&&a.length>0&&new s(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:function(p){return p.start},getTargetPosition:function(p){return p.end},getColor:function(p){return p.contour.color||Oo},getWidth:function(p){return p.contour.strokeWidth||Cu}}),c=u&&u.length>0&&new l(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:function(p){return p.vertices},getFillColor:function(p){return p.contour.color||Oo}});return[f,c]},n.updateAggregationState=function(o){var a=o.props,u=o.oldProps,s=a.cellSize,l=a.coordinateSystem,f=this.context.viewport,c=u.cellSize!==s,g=a.gpuAggregation;this.state.gpuAggregation!==a.gpuAggregation&&g&&!z.isSupported(this.context.gl)&&(wo.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),g=!1);var p=g!==this.state.gpuAggregation;this.setState({gpuAggregation:g});var m=this.state.dimensions,h=this.isAttributeChanged(Ao),v=m.data,y=m.weights,O=this.state.boundingBox;if(h&&(O=ct(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:O})),h||c){var A=gt(O,s,f,l),P=A.gridOffset,T=A.translation,D=A.width,E=A.height,M=A.numCol,F=A.numRow;this.allocateResources(F,M),this.setState({gridOffset:P,boundingBox:O,translation:T,posOffset:T.slice(),gridOrigin:[-1*T[0],-1*T[1]],width:D,height:E,numCol:M,numRow:F})}var V=h||p||this.isAggregationDirty(o,{dimension:v,compareAll:g}),G=this.isAggregationDirty(o,{dimension:y});G&&this._updateAccessors(o),(V||G)&&this._resetResults(),this.setState({aggregationDataDirty:V,aggregationWeightsDirty:G})},n._updateAccessors=function(o){var a=o.props,u=a.getWeight,s=a.aggregation,l=a.data,f=this.state.weights.count;f&&(f.getWeight=u,f.operation=R[s]),this.setState({getValue:ve(s,u,{data:l})})},n._resetResults=function(){var o=this.state.weights.count;o&&(o.aggregationData=null)},n._generateContours=function(){var o=this.state,a=o.numCol,u=o.numRow,s=o.gridOrigin,l=o.gridOffset,f=o.thresholdData,c=this.state.weights.count,g=c.aggregationData;g||(g=c.aggregationBuffer.getData(),c.aggregationData=g);var p=z.getCellData({countsData:g}),m=p.cellWeights,h=bo({thresholdData:f,cellWeights:m,gridSize:[a,u],gridOrigin:s,cellSize:[l.xOffset,l.yOffset]});this.setState({contourData:h})},n._updateThresholdData=function(o){for(var a=o.contours,u=o.zOffset,s=a.length,l=new Array(s),f=0;f<s;f++){var c=a[f];l[f]={contour:c,zIndex:c.zIndex||f,zOffset:u}}this.setState({thresholdData:l})},r}(ae);Dt.layerName="ContourLayer";Dt.defaultProps=Nu;var Lo=C(L());var hr=C(H()),No=C(L());var W=C(L()),Ct=C(H());var Po=`#version 300 es
493
+ `;function jr(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jr=function(r){return typeof r}:jr=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},jr(e)}function $a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function Ei(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?$a(Object(r),!0).forEach(function(n){e_(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$a(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function e_(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Yr(e,t,r){return typeof Reflect<"u"&&Reflect.get?Yr=Reflect.get:Yr=function(o,a,s){var u=r_(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},Yr(e,t,r||e)}function r_(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Rt(e),e!==null););return e}function n_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&di(e,t)}function di(e,t){return di=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},di(e,t)}function i_(e){var t=s_();return function(){var n=Rt(e),o;if(t){var a=Rt(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return o_(this,o)}}function o_(e,t){if(t&&(jr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return a_(e)}function a_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Rt(e){return Rt=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Rt(e)}var u_=[0,0,0,0],l_=[0,255,0,255],f_=["minColor","maxColor","colorRange","colorDomain"],c_={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0,max:5},colorDomain:null,colorRange:le},St=function(e){n_(r,e);var t=i_(r);function r(){var o;t_(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}r.isSupported=function(a){return a.features.has("texture-formats-float32-webgl1")};var n=r.prototype;return n.getShaders=function(){return{vs:Ya,fs:ka,modules:[mt.picking]}},n.initializeState=function(){var a=this.getAttributeManager();a.addInstanced({instancePositions:{size:3,update:this.calculateInstancePositions},instanceCounts:{size:4,noAlloc:!0}}),this.setState({model:this._getModel()})},n.shouldUpdateState=function(a){var s=a.changeFlags;return s.somethingChanged},n.updateState=function(a){Yr(Rt(r.prototype),"updateState",this).call(this,a);var s=a.oldProps,u=a.props,l=a.changeFlags,f=this.getAttributeManager();u.numInstances!==s.numInstances?f.invalidateAll():s.cellSizePixels!==u.cellSizePixels&&f.invalidate("instancePositions"),this._updateUniforms(s,u,l)},n.draw=function(a){var s=a.uniforms,u=this.props,l=u.parameters,f=u.maxTexture,c=this.props.minColor||u_,_=this.props.maxColor||l_,E=this.props.colorDomain||[1,0],d=this.state.model;d.setUniforms(s),d.setBindings({maxTexture:f}),d.setUniforms({minColor:c,maxColor:_,colorDomain:E}),d.setParameters(Ei({depthWriteEnabled:!1},l)),d.draw(this.context.renderPass)},n.calculateInstancePositions=function(a,s){for(var u=s.numInstances,l=this.context.viewport,f=l.width,c=l.height,_=this.props.cellSizePixels,E=Math.ceil(f/_),d=a.value,h=a.size,p=0;p<u;p++){var g=p%E,T=Math.floor(p/E);d[p*h+0]=g*_/f*2-1,d[p*h+1]=1-T*_/c*2,d[p*h+2]=0}},n._getModel=function(){return new J(this.context.device,Ei(Ei({},this.getShaders()),{},{id:this.props.id,geometry:new be({topology:"triangle-fan-webgl",attributes:{positions:new Float32Array([0,0,0,1,0,0,1,1,0,0,1,0])}}),isInstanced:!0}))},n._shouldUseMinMax=function(){var a=this.props,s=a.minColor,u=a.maxColor,l=a.colorDomain,f=a.colorRange;return s||u?(mt.log.deprecated("ScreenGridLayer props: minColor and maxColor","colorRange, colorDomain")(),!0):!(l||f)},n._updateUniforms=function(a,s,u){var l=this.state.model;if(f_.some(function(T){return a[T]!==s[T]})&&l.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),a.colorRange!==s.colorRange&&l.setUniforms({colorRange:Xe(s.colorRange)}),a.cellMarginPixels!==s.cellMarginPixels||a.cellSizePixels!==s.cellSizePixels||u.viewportChanged){var f=this.context.viewport,c=f.width,_=f.height,E=this.props,d=E.cellSizePixels,h=E.cellMarginPixels,p=d>h?h:0,g=new Float32Array([(d-p)/c*2,-(d-p)/_*2,1]);l.setUniforms({cellScale:g})}},r}(mt.Layer);St.layerName="ScreenGridCellLayer";St.defaultProps=c_;var Os=x(j());var Ot=x(j());function Za(e,t){var r={};for(var n in e)t.includes(n)||(r[n]=e[n]);return r}function kr(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?kr=function(r){return typeof r}:kr=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},kr(e)}function qa(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=__(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
494
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function __(e,t){if(e){if(typeof e=="string")return Qa(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Qa(e,t)}}function Qa(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function lr(e,t,r){return typeof Reflect<"u"&&Reflect.get?lr=Reflect.get:lr=function(o,a,s){var u=d_(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},lr(e,t,r||e)}function d_(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=qe(e),e!==null););return e}function g_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&gi(e,t)}function gi(e,t){return gi=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},gi(e,t)}function h_(e){var t=T_();return function(){var n=qe(e),o;if(t){var a=qe(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return A_(this,o)}}function A_(e,t){if(t&&(kr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return p_(e)}function p_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function T_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function qe(e){return qe=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},qe(e)}var ge=function(e){g_(r,e);var t=h_(r);function r(){var o;E_(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeAggregationLayer=function(a){lr(qe(r.prototype),"initializeState",this).call(this,this.context),this.setState({ignoreProps:Za(this.constructor._propTypes,a.data.props),dimensions:a})},n.updateState=function(a){lr(qe(r.prototype),"updateState",this).call(this,a);var s=a.changeFlags;if(s.extensionsChanged){var u=this.getShaders({});u&&u.defines&&(u.defines.NON_INSTANCED_MODEL=1),this.updateShaders(u)}this._updateAttributes()},n.updateAttributes=function(a){this.setState({changedAttributes:a})},n.getAttributes=function(){return this.getAttributeManager().getAttributes()},n.getModuleSettings=function(){var a=this.context,s=a.viewport,u=a.mousePosition,l=a.device,f=Object.assign(Object.create(this.props),{viewport:s,mousePosition:u,pickingActive:0,devicePixelRatio:l.canvasContext.cssToDeviceRatio()});return f},n.updateShaders=function(a){},n.isAggregationDirty=function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=a.props,l=a.oldProps,f=a.changeFlags,c=s.compareAll,_=c===void 0?!1:c,E=s.dimension,d=this.state.ignoreProps,h=E.props,p=E.accessors,g=p===void 0?[]:p,T=f.updateTriggersChanged;if(f.dataChanged)return!0;if(T){if(T.all)return!0;var m=qa(g),R;try{for(m.s();!(R=m.n()).done;){var S=R.value;if(T[S])return!0}}catch(M){m.e(M)}finally{m.f()}}if(_)return f.extensionsChanged?!0:(0,Ot._compareProps)({oldProps:l,newProps:u,ignoreProps:d,propTypes:this.constructor._propTypes});var y=qa(h),I;try{for(y.s();!(I=y.n()).done;){var P=I.value;if(u[P]!==l[P])return!0}}catch(M){y.e(M)}finally{y.f()}return!1},n.isAttributeChanged=function(a){var s=this.state.changedAttributes;return a?s&&s[a]!==void 0:!R_(s)},n._getAttributeManager=function(){return new Ot.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})},r}(Ot.CompositeLayer);ge.layerName="AggregationLayer";function R_(e){var t=!0;for(var r in e){t=!1;break}return t}var ts=x(j());function m_(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=S_(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
495
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function S_(e,t){if(e){if(typeof e=="string")return Ja(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ja(e,t)}}function Ja(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function $r(e,t,r){var n=r;return n.domain=function(){return e},n.range=function(){return t},n}function es(e,t){var r=function(o){return x_(e,t,o)};return $r(e,t,r)}function O_(e,t){var r=function(o){return P_(e,t,o)};return $r(e,t,r)}function v_(e,t){for(var r=e.sort(rs),n=0,o=Math.max(1,t.length),a=new Array(o-1);++n<o;)a[n-1]=b_(r,n/o);var s=function(l){return C_(a,t,l)};return s.thresholds=function(){return a},$r(e,t,s)}function rs(e,t){return e-t}function b_(e,t){var r=e.length;if(t<=0||r<2)return e[0];if(t>=1)return e[r-1];var n=(r-1)*t,o=Math.floor(n),a=e[o],s=e[o+1];return a+(s-a)*(n-o)}function N_(e,t){for(var r=0,n=e.length;r<n;){var o=r+n>>>1;rs(e[o],t)>0?n=o:r=o+1}return r}function C_(e,t,r){return t[N_(e,r)]}function y_(e,t,r,n){var o="".concat(n),a=t.get(o);return a===void 0&&(a=e.push(n),t.set(o,a)),r[(a-1)%r.length]}function I_(e,t){var r=new Map,n=[],o=m_(e),a;try{for(o.s();!(a=o.n()).done;){var s=a.value,u="".concat(s);r.has(u)||r.set(u,n.push(s))}}catch(f){o.e(f)}finally{o.f()}var l=function(c){return y_(n,r,t,c)};return $r(e,t,l)}function x_(e,t,r){var n=e[1]-e[0];if(n<=0)return ts.log.warn("quantizeScale: invalid domain, returning range[0]")(),t[0];var o=n/t.length,a=Math.floor((r-e[0])/o),s=Math.max(Math.min(a,t.length-1),0);return t[s]}function P_(e,t,r){return(r-e[0])/(e[1]-e[0])*(t[1]-t[0])+t[0]}function ns(e){return e!=null}function M_(e){var t=[];return e.forEach(function(r){!t.includes(r)&&ns(r)&&t.push(r)}),t}function is(e,t){var r=typeof t=="function"?e.map(t):e;return r.filter(ns)}function os(e,t){return is(e,t)}function as(e,t){return M_(is(e,t))}function ss(e,t,r){return Math.max(t,Math.min(r,e))}function us(e){switch(e){case"quantize":return es;case"linear":return O_;case"quantile":return v_;case"ordinal":return I_;default:return es}}function ls(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_s(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
496
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function hi(e,t){return B_(e)||D_(e,t)||_s(e,t)||F_()}function F_(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
497
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _s(e,t){if(e){if(typeof e=="string")return fs(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return fs(e,t)}}function fs(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function D_(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,a=!1,s,u;try{for(r=r.call(e);!(o=(s=r.next()).done)&&(n.push(s.value),!(t&&n.length===t));o=!0);}catch(l){a=!0,u=l}finally{try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}return n}}function B_(e){if(Array.isArray(e))return e}function U_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Es=function(t){return t.length},w_=3402823466e29,ds=function(t){return t.points},gs=function(t){return t.index},cs=function(t,r){return t<r?-1:t>r?1:t>=r?0:NaN},L_={getValue:Es,getPoints:ds,getIndex:gs,filterData:null},vt=function(){function e(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:L_;U_(this,e),this.maxCount=void 0,this.maxValue=void 0,this.minValue=void 0,this.totalCount=void 0,this.aggregatedBins=void 0,this.sortedBins=void 0,this.binMap=void 0,this.aggregatedBins=this.getAggregatedBins(r,n),this._updateMinMaxValues(),this.binMap=this.getBinMap()}var t=e.prototype;return t.getAggregatedBins=function(n,o){for(var a=o.getValue,s=a===void 0?Es:a,u=o.getPoints,l=u===void 0?ds:u,f=o.getIndex,c=f===void 0?gs:f,_=o.filterData,E=typeof _=="function",d=n.length,h=[],p=0,g=0;g<d;g++){var T=n[g],m=l(T),R=c(T),S=E?m.filter(_):m;T.filteredPoints=E?S:null;var y=S.length?s(S):null;y!=null&&(h[p]={i:Number.isFinite(R)?R:g,value:y,counts:S.length},p++)}return h},t._percentileToIndex=function(n){var o=this.sortedBins.length;if(o<2)return[0,0];var a=n.map(function(_){return ss(_,0,100)}),s=hi(a,2),u=s[0],l=s[1],f=Math.ceil(u/100*(o-1)),c=Math.floor(l/100*(o-1));return[f,c]},t.getBinMap=function(){var n={},o=ls(this.aggregatedBins),a;try{for(o.s();!(a=o.n()).done;){var s=a.value;n[s.i]=s}}catch(u){o.e(u)}finally{o.f()}return n},t._updateMinMaxValues=function(){var n=0,o=0,a=w_,s=0,u=ls(this.aggregatedBins),l;try{for(u.s();!(l=u.n()).done;){var f=l.value;n=n>f.counts?n:f.counts,o=o>f.value?o:f.value,a=a<f.value?a:f.value,s+=f.counts}}catch(c){u.e(c)}finally{u.f()}this.maxCount=n,this.maxValue=o,this.minValue=a,this.totalCount=s},t.getValueRange=function(n){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort(function(u,l){return cs(u.value,l.value)})),!this.sortedBins.length)return[];var o=0,a=this.sortedBins.length-1;if(Array.isArray(n)){var s=this._percentileToIndex(n);o=s[0],a=s[1]}return[this.sortedBins[o].value,this.sortedBins[a].value]},t.getValueDomainByScale=function(n){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=hi(o,2),s=a[0],u=s===void 0?0:s,l=a[1],f=l===void 0?100:l;if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort(function(_,E){return cs(_.value,E.value)})),!this.sortedBins.length)return[];var c=this._percentileToIndex([u,f]);return this._getScaleDomain(n,c)},t._getScaleDomain=function(n,o){var a=hi(o,2),s=a[0],u=a[1],l=this.sortedBins;switch(n){case"quantize":case"linear":return[l[s].value,l[u].value];case"quantile":return os(l.slice(s,u+1),function(f){return f.value});case"ordinal":return as(l,function(f){return f.value});default:return[l[s].value,l[u].value]}},e}();var ms=x(j());var We=x(j()),As=6378e3;function Zr(e){return Number.isFinite(e)?e:0}function qr(e,t){for(var r=e.positions.value,n=1/0,o=-1/0,a=1/0,s=-1/0,u,l,f=0;f<t;f++)l=r[f*3],u=r[f*3+1],n=u<n?u:n,o=u>o?u:o,a=l<a?l:a,s=l>s?l:s;var c={xMin:Zr(a),xMax:Zr(s),yMin:Zr(n),yMax:Zr(o)};return c}function X_(e,t,r,n){var o=n.width,a=n.height,s=r===We.COORDINATE_SYSTEM.CARTESIAN?[-o/2,-a/2]:[-180,-90];We.log.assert(r===We.COORDINATE_SYSTEM.CARTESIAN||r===We.COORDINATE_SYSTEM.LNGLAT||r===We.COORDINATE_SYSTEM.DEFAULT);var u=e.xMin,l=e.yMin;return[-1*(hs(u-s[0],t.xOffset)+s[0]),-1*(hs(l-s[1],t.yOffset)+s[1])]}function hs(e,t){var r=e<0?-1:1,n=r<0?Math.abs(e)+t:Math.abs(e);return n=Math.floor(n/t)*t,n*r}function Ai(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!r)return{xOffset:t,yOffset:t};var n=e.yMin,o=e.yMax,a=(n+o)/2;return W_(t,a)}function Qr(e,t,r,n){var o=Ai(e,t,n!==We.COORDINATE_SYSTEM.CARTESIAN),a=X_(e,o,n,r),s=e.xMin,u=e.yMin,l=e.xMax,f=e.yMax,c=l-s+o.xOffset,_=f-u+o.yOffset,E=Math.ceil(c/o.xOffset),d=Math.ceil(_/o.yOffset);return{gridOffset:o,translation:a,width:c,height:_,numCol:E,numRow:d}}function W_(e,t){var r=H_(e),n=V_(t,e);return{yOffset:r,xOffset:n}}function H_(e){return e/As*(180/Math.PI)}function V_(e,t){return t/As*(180/Math.PI)/Math.cos(e*Math.PI/180)}function ps(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function K_(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ps(Object(r),!0).forEach(function(n){G_(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ps(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function G_(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function z_(e,t){return k_(e)||Y_(e,t)||Rs(e,t)||j_()}function j_(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
498
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Y_(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,a=!1,s,u;try{for(r=r.call(e);!(o=(s=r.next()).done)&&(n.push(s.value),!(t&&n.length===t));o=!0);}catch(l){a=!0,u=l}finally{try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}return n}}function k_(e){if(Array.isArray(e))return e}function $_(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Rs(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
499
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function Rs(e,t){if(e){if(typeof e=="string")return Ts(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ts(e,t)}}function Ts(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function bt(e,t){var r=Z_(e,t),n=q_(r);return{gridHash:r.gridHash,gridOffset:r.gridOffset,data:n}}function Z_(e,t){var r=e.data,n=r===void 0?[]:r,o=e.cellSize,a=t.attributes,s=t.viewport,u=t.projectPoints,l=t.numInstances,f=a.positions.value,c=a.positions.getAccessor(),_=c.size,E=t.boundingBox||Q_(a.positions,l),d=t.posOffset||[180,90],h=t.gridOffset||Ai(E,o);if(h.xOffset<=0||h.yOffset<=0)return{gridHash:{},gridOffset:h,offsets:[0,0]};var p=s.width,g=s.height,T=Math.ceil(p/h.xOffset),m=Math.ceil(g/h.yOffset),R={},S=(0,ms.createIterable)(n),y=S.iterable,I=S.objectInfo,P=new Array(3),M=$_(y),B;try{for(M.s();!(B=M.n()).done;){var z=B.value;I.index++,P[0]=f[I.index*_],P[1]=f[I.index*_+1],P[2]=_>=3?f[I.index*_+2]:0;var W=u?s.project(P):P,L=z_(W,2),re=L[0],xn=L[1];if(Number.isFinite(re)&&Number.isFinite(xn)){var Ie=Math.floor((xn+d[1])/h.yOffset),dr=Math.floor((re+d[0])/h.xOffset);if(!u||dr>=0&&dr<T&&Ie>=0&&Ie<m){var gr="".concat(Ie,"-").concat(dr);R[gr]=R[gr]||{count:0,points:[],lonIdx:dr,latIdx:Ie},R[gr].count+=1,R[gr].points.push({source:z,index:I.index})}}}}catch(Qu){M.e(Qu)}finally{M.f()}return{gridHash:R,gridOffset:h,offsets:[d[0]*-1,d[1]*-1]}}function q_(e){var t=e.gridHash,r=e.gridOffset,n=e.offsets,o=new Array(Object.keys(t).length),a=0;for(var s in t){var u=s.split("-"),l=parseInt(u[0],10),f=parseInt(u[1],10),c=a++;o[c]=K_({index:c,position:[n[0]+r.xOffset*f,n[1]+r.yOffset*l]},t[s])}return o}function Q_(e,t){for(var r=e.value,n=e.getAccessor(),o=n.size,a=1/0,s=-1/0,u=1/0,l=-1/0,f,c,_=0;_<t;_++)c=r[_*o],f=r[_*o+1],Number.isFinite(c)&&Number.isFinite(f)&&(a=f<a?f:a,s=f>s?f:s,u=c<u?c:u,l=c>l?c:l);return{xMin:u,xMax:l,yMin:a,yMax:s}}function Jr(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Jr=function(r){return typeof r}:Jr=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Jr(e)}function J_(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=eE(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
500
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function eE(e,t){if(e){if(typeof e=="string")return Ss(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ss(e,t)}}function Ss(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function tE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Nt(e,t,r){return typeof Reflect<"u"&&Reflect.get?Nt=Reflect.get:Nt=function(o,a,s){var u=rE(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},Nt(e,t,r||e)}function rE(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=He(e),e!==null););return e}function nE(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&pi(e,t)}function pi(e,t){return pi=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},pi(e,t)}function iE(e){var t=sE();return function(){var n=He(e),o;if(t){var a=He(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return oE(this,o)}}function oE(e,t){if(t&&(Jr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return aE(e)}function aE(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sE(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function He(e){return He=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},He(e)}var Qe=function(e){nE(r,e);var t=iE(r);function r(){var o;tE(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeAggregationLayer=function(a){var s=a.dimensions;Nt(He(r.prototype),"initializeAggregationLayer",this).call(this,s),this.setState({layerData:{},gpuGridAggregator:new Q(this.context.device,{id:"".concat(this.id,"-gpu-aggregator")}),cpuGridAggregator:bt})},n.updateState=function(a){Nt(He(r.prototype),"updateState",this).call(this,a),this.updateAggregationState(a);var s=this.state,u=s.aggregationDataDirty,l=s.aggregationWeightsDirty,f=s.gpuAggregation;if(!(this.getNumInstances()<=0)){var c=!1;(u||f&&l)&&(this._updateAggregation(a),c=!0),!f&&(u||l)&&(this._updateWeightBins(),this._uploadAggregationResults(),c=!0),this.setState({aggregationDirty:c})}},n.finalizeState=function(a){var s,u=this.state.weights.count;u&&u.aggregationBuffer&&u.aggregationBuffer.delete(),(s=this.state.gpuGridAggregator)===null||s===void 0||s.delete(),Nt(He(r.prototype),"finalizeState",this).call(this,a)},n.updateShaders=function(a){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(a)},n.updateAggregationState=function(a){Os.log.assert(!1)},n.allocateResources=function(a,s){if(this.state.numRow!==a||this.state.numCol!==s){var u=s*a*4*4,l=this.state.weights;for(var f in l){var c=l[f];c.aggregationBuffer&&c.aggregationBuffer.delete(),c.aggregationBuffer=this.context.device.createBuffer({byteLength:u,accessor:{size:4,type:5126,divisor:1}})}}},n.updateResults=function(a){var s=a.aggregationData,u=a.maxMinData,l=a.maxData,f=a.minData,c=this.state.weights.count;c&&(c.aggregationData=s,c.maxMinData=u,c.maxData=l,c.minData=f)},n._updateAggregation=function(a){var s=this.state,u=s.cpuGridAggregator,l=s.gpuGridAggregator,f=s.gridOffset,c=s.posOffset,_=s.translation,E=_===void 0?[0,0]:_,d=s.scaling,h=d===void 0?[0,0,0]:d,p=s.boundingBox,g=s.projectPoints,T=s.gpuAggregation,m=s.numCol,R=s.numRow,S=a.props,y=this.context.viewport,I=this.getAttributes(),P=this.getNumInstances();if(T){var B=this.state.weights;l.run({weights:B,cellSize:[f.xOffset,f.yOffset],numCol:m,numRow:R,translation:E,scaling:h,vertexCount:P,projectPoints:g,attributes:I,moduleSettings:this.getModuleSettings()})}else{var M=u(S,{gridOffset:f,projectPoints:g,attributes:I,viewport:y,posOffset:c,boundingBox:p});this.setState({layerData:M})}},n._updateWeightBins=function(){var a=this.state.getValue,s=new vt(this.state.layerData.data||[],{getValue:a});this.setState({sortedBins:s})},n._uploadAggregationResults=function(){var a=this.state,s=a.numCol,u=a.numRow,l=this.state.layerData.data,f=this.state.sortedBins,c=f.aggregatedBins,_=f.minValue,E=f.maxValue,d=f.totalCount,h=4,p=s*u*h,g=new Float32Array(p).fill(0),T=J_(c),m;try{for(T.s();!(m=T.n()).done;){var R=m.value,S=l[R.i],y=S.lonIdx,I=S.latIdx,P=R.value,M=R.counts,B=(y+I*s)*h;g[B]=P,g[B+h-1]=M}}catch(re){T.e(re)}finally{T.f()}var z=new Float32Array([E,0,0,_]),W=new Float32Array([E,0,0,d]),L=new Float32Array([_,0,0,d]);this.updateResults({aggregationData:g,maxMinData:z,maxData:W,minData:L})},r}(ge);Qe.layerName="GridAggregationLayer";function en(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?en=function(r){return typeof r}:en=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},en(e)}function uE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ct(e,t,r){return typeof Reflect<"u"&&Reflect.get?Ct=Reflect.get:Ct=function(o,a,s){var u=lE(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},Ct(e,t,r||e)}function lE(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Ve(e),e!==null););return e}function fE(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ti(e,t)}function Ti(e,t){return Ti=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},Ti(e,t)}function cE(e){var t=dE();return function(){var n=Ve(e),o;if(t){var a=Ve(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return _E(this,o)}}function _E(e,t){if(t&&(en(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return EE(e)}function EE(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function dE(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ve(e){return Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ve(e)}function vs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function Ri(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?vs(Object(r),!0).forEach(function(n){mi(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):vs(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function mi(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var gE=Ri(Ri({},St.defaultProps),{},{getPosition:{type:"accessor",value:function(t){return t.position}},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM"}),bs="positions",hE={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},tn=function(e){fE(r,e);var t=cE(r);function r(){var o;uE(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeState=function(){var a;if(!St.isSupported(this.context.device)){this.setState({supported:!1}),Si.log.error("ScreenGridLayer: ".concat(this.id," is not supported on this browser"))();return}Ct(Ve(r.prototype),"initializeAggregationLayer",this).call(this,{dimensions:hE,getCellSize:function(f){return f.cellSizePixels}});var s={count:{size:1,operation:w.SUM,needMax:!0,maxTexture:Tt(this.context.device,{id:"".concat(this.id,"-max-texture")})}};this.setState({supported:!0,projectPoints:!0,weights:s,subLayerData:{attributes:{}},maxTexture:s.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]});var u=this.getAttributeManager();u.add((a={},mi(a,bs,{size:3,accessor:"getPosition",type:5130,fp64:this.use64bitPositions()}),mi(a,"count",{size:3,accessor:"getWeight"}),a))},n.shouldUpdateState=function(a){var s=a.changeFlags;return this.state.supported&&s.somethingChanged},n.updateState=function(a){Ct(Ve(r.prototype),"updateState",this).call(this,a)},n.renderLayers=function(){if(!this.state.supported)return[];var a=this.state,s=a.maxTexture,u=a.numRow,l=a.numCol,f=a.weights,c=this.props.updateTriggers,_=f.count.aggregationBuffer,E=this.getSubLayerClass("cells",St);return new E(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:c}),{data:{attributes:{instanceCounts:_}},maxTexture:s,numInstances:u*l})},n.finalizeState=function(a){Ct(Ve(r.prototype),"finalizeState",this).call(this,a);var s=this.state,u=s.aggregationBuffer,l=s.maxBuffer,f=s.maxTexture;u?.delete(),l?.delete(),f?.delete()},n.getPickingInfo=function(a){var s=a.info,u=s.index;if(u>=0){var l=this.state,f=l.gpuGridAggregator,c=l.gpuAggregation,_=l.weights,E=c?f.getData("count"):_.count;s.object=Q.getAggregationData(Ri({pixelIndex:u},E))}return s},n.updateResults=function(a){var s=a.aggregationData,u=a.maxData,l=this.state.weights.count;l.aggregationData=s,l.aggregationBuffer.setData({data:s}),l.maxData=u,l.maxTexture.setImageData({data:u})},n.updateAggregationState=function(a){var s=a.props.cellSizePixels,u=a.oldProps.cellSizePixels!==s,l=a.changeFlags.viewportChanged,f=a.props.gpuAggregation;this.state.gpuAggregation!==a.props.gpuAggregation&&f&&!Q.isSupported(this.context.device)&&(Si.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),f=!1);var c=f!==this.state.gpuAggregation;this.setState({gpuAggregation:f});var _=this.isAttributeChanged(bs),E=this.state.dimensions,d=E.data,h=E.weights,p=_||c||l||this.isAggregationDirty(a,{compareAll:f,dimension:d}),g=this.isAggregationDirty(a,{dimension:h});this.setState({aggregationDataDirty:p,aggregationWeightsDirty:g});var T=this.context.viewport;if(l||u){var m=T.width,R=T.height,S=Math.ceil(m/s),y=Math.ceil(R/s);this.allocateResources(y,S),this.setState({scaling:[m/2,-R/2,1],gridOffset:{xOffset:s,yOffset:s},width:m,height:R,numCol:S,numRow:y})}g&&this._updateAccessors(a),(p||g)&&this._resetResults()},n._updateAccessors=function(a){var s=a.props,u=s.getWeight,l=s.aggregation,f=s.data,c=this.state.weights.count;c&&(c.getWeight=u,c.operation=w[l]),this.setState({getValue:At(l,u,{data:f})})},n._resetResults=function(){var a=this.state.weights.count;a&&(a.aggregationData=null)},r}(Qe);tn.layerName="ScreenGridLayer";tn.defaultProps=gE;var Ms=x(it());function fr(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?fr=function(r){return typeof r}:fr=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},fr(e)}function Ns(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function he(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ns(Object(r),!0).forEach(function(n){xs(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ns(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function xs(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function AE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Cs(){}var ys=["getBins","getDomain","getScaleFunc"],Is=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],pE=function(t){return t.cellSize},yt=function(){function e(r){AE(this,e),this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=void 0,this._getAggregator=void 0,this._getCellSize=r.getCellSize||pE,this._getAggregator=r.getAggregator,this._addDimension(r.dimensions||Is)}e.defaultDimensions=function(){return Is};var t=e.prototype;return t.updateState=function(n,o){var a=n.oldProps,s=n.props,u=n.changeFlags;this.updateGetValueFuncs(a,s,u);var l=this.needsReProjectPoints(a,s,u),f=!1;if(u.dataChanged||l)this.getAggregatedData(s,o),f=!0;else{var c=this.getDimensionChanges(a,s,u)||[];c.forEach(function(_){return typeof _=="function"&&_()}),f=!0}return this.setState({aggregationDirty:f}),this.state},t.setState=function(n){this.state=he(he({},this.state),n)},t.setDimensionState=function(n,o){this.setState({dimensions:he(he({},this.state.dimensions),{},xs({},n,he(he({},this.state.dimensions[n]),o)))})},t.normalizeResult=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return n.hexagons?he({data:n.hexagons},n):n.layerData?he({data:n.layerData},n):n},t.getAggregatedData=function(n,o){var a=this._getAggregator(n),s=a(n,o);this.setState({layerData:this.normalizeResult(s)}),this.changeFlags={layerData:!0},this.getSortedBins(n)},t.updateGetValueFuncs=function(n,o,a){for(var s in this.dimensionUpdaters){var u=this.dimensionUpdaters[s].getBins.triggers,l=u.value,f=u.weight,c=u.aggregation,_=o[l.prop],E=this.needUpdateDimensionStep(this.dimensionUpdaters[s].getBins,n,o,a);E&&(_?_=Da(_,{data:o.data}):_=At(o[c.prop],o[f.prop],{data:o.data})),_&&this.setDimensionState(s,{getValue:_})}},t.needsReProjectPoints=function(n,o,a){return this._getCellSize(n)!==this._getCellSize(o)||this._getAggregator(n)!==this._getAggregator(o)||a.updateTriggersChanged&&(a.updateTriggersChanged.all||a.updateTriggersChanged.getPosition)},t.addDimension=function(n){this._addDimension(n)},t._addDimension=function(){var n=this,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];o.forEach(function(a){var s=a.key;n.dimensionUpdaters[s]=n.getDimensionUpdaters(a),n.state.dimensions[s]={getValue:null,domain:null,sortedBins:null,scaleFunc:Cs}})},t.getDimensionUpdaters=function(n){var o=n.key,a=n.accessor,s=n.pickingInfo,u=n.getBins,l=n.getDomain,f=n.getScaleFunc,c=n.nullValue;return{key:o,accessor:a,pickingInfo:s,getBins:he({updater:this.getDimensionSortedBins.bind(this)},u),getDomain:he({updater:this.getDimensionValueDomain.bind(this)},l),getScaleFunc:he({updater:this.getDimensionScale.bind(this)},f),attributeAccessor:this.getSubLayerDimensionAttribute(o,c)}},t.needUpdateDimensionStep=function(n,o,a,s){return Object.values(n.triggers).some(function(u){return u.updateTrigger?s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged[u.updateTrigger]):o[u.prop]!==a[u.prop]})},t.getDimensionChanges=function(n,o,a){var s=this,u=[],l=function(_){var E=ys.find(function(d){return s.needUpdateDimensionStep(s.dimensionUpdaters[_][d],n,o,a)});E&&u.push(s.dimensionUpdaters[_][E].updater.bind(s,o,s.dimensionUpdaters[_]))};for(var f in this.dimensionUpdaters)l(f);return u.length?u:null},t.getUpdateTriggers=function(n){var o=this,a=n.updateTriggers||{},s={},u=function(c){var _=o.dimensionUpdaters[c].accessor;s[_]={},ys.forEach(function(E){Object.values(o.dimensionUpdaters[c][E].triggers).forEach(function(d){var h=d.prop,p=d.updateTrigger;if(p){var g=a[p];fr(g)==="object"&&!Array.isArray(g)?Object.assign(s[_],g):g!==void 0&&(s[_][h]=g)}else s[_][h]=n[h]})})};for(var l in this.dimensionUpdaters)u(l);return s},t.getSortedBins=function(n){for(var o in this.dimensionUpdaters)this.getDimensionSortedBins(n,this.dimensionUpdaters[o])},t.getDimensionSortedBins=function(n,o){var a=o.key,s=this.state.dimensions[a].getValue,u=new vt(this.state.layerData.data||[],{getValue:s,filterData:n._filterData});this.setDimensionState(a,{sortedBins:u}),this.getDimensionValueDomain(n,o)},t.getDimensionValueDomain=function(n,o){var a=o.getDomain,s=o.key,u=a.triggers,l=u.lowerPercentile,f=u.upperPercentile,c=u.scaleType,_=this.state.dimensions[s].sortedBins.getValueDomainByScale(n[c.prop],[n[l.prop],n[f.prop]]);this.setDimensionState(s,{valueDomain:_}),this.getDimensionScale(n,o)},t.getDimensionScale=function(n,o){var a=o.key,s=o.getScaleFunc,u=o.getDomain,l=s.triggers,f=l.domain,c=l.range,_=u.triggers.scaleType,E=s.onSet,d=n[c.prop],h=n[f.prop]||this.state.dimensions[a].valueDomain,p=us(_&&n[_.prop]),g=p(h,d);fr(E)==="object"&&typeof n[E.props]=="function"&&n[E.props](g.domain()),this.setDimensionState(a,{scaleFunc:g})},t.getSubLayerDimensionAttribute=function(n,o){var a=this;return function(s){var u=a.state.dimensions[n],l=u.sortedBins,f=u.scaleFunc,c=l.binMap[s.index];if(c&&c.counts===0)return o;var _=c&&c.value,E=f.domain(),d=_>=E[0]&&_<=E[E.length-1];return d?f(_):o}},t.getSubLayerAccessors=function(n){var o={};for(var a in this.dimensionUpdaters){var s=this.dimensionUpdaters[a].accessor;o[s]=this.getSubLayerDimensionAttribute(n,a)}return o},t.getPickingInfo=function(n){var o=n.info,a=o.picked&&o.index>-1,s=null;if(a){var u=this.state.layerData.data[o.index],l={};for(var f in this.dimensionUpdaters){var c=this.dimensionUpdaters[f].pickingInfo,_=this.state.dimensions[f].sortedBins,E=_.binMap[u.index]&&_.binMap[u.index].value;l[c]=E}s=Object.assign(l,u,{points:u.filteredPoints||u.points})}return o.picked=Boolean(s),o.object=s,o},t.getAccessor=function(n){return this.dimensionUpdaters.hasOwnProperty(n)?this.dimensionUpdaters[n].attributeAccessor:Cs},e}();function rn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?rn=function(r){return typeof r}:rn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},rn(e)}function TE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function nn(e,t,r){return typeof Reflect<"u"&&Reflect.get?nn=Reflect.get:nn=function(o,a,s){var u=RE(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},nn(e,t,r||e)}function RE(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=It(e),e!==null););return e}function mE(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Oi(e,t)}function Oi(e,t){return Oi=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},Oi(e,t)}function SE(e){var t=bE();return function(){var n=It(e),o;if(t){var a=It(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return OE(this,o)}}function OE(e,t){if(t&&(rn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return vE(e)}function vE(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bE(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function It(e){return It=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},It(e)}function Ps(){}var NE={colorDomain:null,colorRange:le,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:Ps,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:Ps,gridAggregator:bt,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:function(t){return t.position}},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},Je=function(e){mE(r,e);var t=SE(r);function r(){var o;TE(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeState=function(){var a=new yt({getAggregator:function(l){return l.gridAggregator},getCellSize:function(l){return l.cellSize}});this.state={cpuAggregator:a,aggregatorState:a.state};var s=this.getAttributeManager();s.add({positions:{size:3,type:5130,accessor:"getPosition"}})},n.updateState=function(a){nn(It(r.prototype),"updateState",this).call(this,a),this.setState({aggregatorState:this.state.cpuAggregator.updateState(a,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})},n.getPickingInfo=function(a){var s=a.info;return this.state.cpuAggregator.getPickingInfo({info:s})},n._onGetSublayerColor=function(a){return this.state.cpuAggregator.getAccessor("fillColor")(a)},n._onGetSublayerElevation=function(a){return this.state.cpuAggregator.getAccessor("elevation")(a)},n._getSublayerUpdateTriggers=function(){return this.state.cpuAggregator.getUpdateTriggers(this.props)},n.renderLayers=function(){var a=this.props,s=a.elevationScale,u=a.extruded,l=a.cellSize,f=a.coverage,c=a.material,_=a.transitions,E=this.state.cpuAggregator,d=this.getSubLayerClass("grid-cell",Ms.GridCellLayer),h=this._getSublayerUpdateTriggers();return new d({cellSize:l,coverage:f,material:c,elevationScale:s,extruded:u,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:_&&{getFillColor:_.getColorValue||_.getColorWeight,getElevation:_.getElevationValue||_.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:h}),{data:E.state.layerData.data})},r}(ge);Je.layerName="CPUGridLayer";Je.defaultProps=NE;var Ls=x(j()),Xs=x(it());var xt=Math.PI/3,CE=[0,xt,2*xt,3*xt,4*xt,5*xt];function yE(e){return e[0]}function IE(e){return e[1]}function vi(){var e=0,t=0,r=1,n=1,o=yE,a=IE,s,u,l;function f(_){var E={},d=[],h,p=_.length;for(h=0;h<p;++h)if(!(isNaN(T=+o.call(null,g=_[h],h,_))||isNaN(m=+a.call(null,g,h,_)))){var g,T,m,R=Math.round(m=m/l),S=Math.round(T=T/u-(R&1)/2),y=m-R;if(Math.abs(y)*3>1){var I=T-S,P=S+(T<S?-1:1)/2,M=R+(m<R?-1:1),B=T-P,z=m-M;I*I+y*y>B*B+z*z&&(S=P+(R&1?1:-1)/2,R=M)}var W=S+"-"+R,L=E[W];L?L.push(g):(d.push(L=E[W]=[g]),L.x=(S+(R&1)/2)*u,L.y=R*l)}return d}function c(_){var E=0,d=0;return CE.map(function(h){var p=Math.sin(h)*_,g=-Math.cos(h)*_,T=p-E,m=g-d;return E=p,d=g,[T,m]})}return f.hexagon=function(_){return"m"+c(_==null?s:+_).join("l")+"z"},f.centers=function(){for(var _=[],E=Math.round(t/l),d=Math.round(e/u),h=E*l;h<n+s;h+=l,++E)for(var p=d*u+(E&1)*u/2;p<r+u/2;p+=u)_.push([p,h]);return _},f.mesh=function(){var _=c(s).slice(0,4).join("l");return f.centers().map(function(E){return"M"+E+"m"+_}).join("")},f.x=function(_){return arguments.length?(o=_,f):o},f.y=function(_){return arguments.length?(a=_,f):a},f.radius=function(_){return arguments.length?(s=+_,u=s*2*Math.sin(xt),l=s*1.5,f):s},f.size=function(_){return arguments.length?(e=t=0,r=+_[0],n=+_[1],f):[r-e,n-t]},f.extent=function(_){return arguments.length?(e=+_[0][0],t=+_[0][1],r=+_[1][0],n=+_[1][1],f):[[e,t],[r,n]]},f.radius(1)}var on=x(j());function xE(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=PE(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
501
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function PE(e,t){if(e){if(typeof e=="string")return Fs(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Fs(e,t)}}function Fs(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ds(e,t){var r=e.data,n=e.radius,o=t.viewport,a=t.attributes,s=r.length?ME(r,t):null,u=FE(n,o,s),l=[],f=(0,on.createIterable)(r),c=f.iterable,_=f.objectInfo,E=a.positions.value,d=a.positions.getAccessor(),h=d.size,p=xE(c),g;try{for(p.s();!(g=p.n()).done;){var T=g.value;_.index++;var m=_.index*h,R=[E[m],E[m+1]],S=Number.isFinite(R[0])&&Number.isFinite(R[1]);S?l.push({screenCoord:o.projectFlat(R),source:T,index:_.index}):on.log.warn("HexagonLayer: invalid position")()}}catch(P){p.e(P)}finally{p.f()}var y=vi().radius(u).x(function(P){return P.screenCoord[0]}).y(function(P){return P.screenCoord[1]}),I=y(l);return{hexagons:I.map(function(P,M){return{position:o.unprojectFlat([P.x,P.y]),points:P,index:M}}),radiusCommon:u}}function ME(e,t){var r=t.attributes,n=r.positions.value,o=r.positions.getAccessor(),a=o.size,s=1/0,u=1/0,l=-1/0,f=-1/0,c;for(c=0;c<a*e.length;c+=a){var _=n[c],E=n[c+1],d=Number.isFinite(_)&&Number.isFinite(E);d&&(s=Math.min(_,s),l=Math.max(_,l),u=Math.min(E,u),f=Math.max(E,f))}return[s,u,l,f].every(Number.isFinite)?[(s+l)/2,(u+f)/2]:null}function FE(e,t,r){var n=t.getDistanceScales(r),o=n.unitsPerMeter;return e*o[0]}function an(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?an=function(r){return typeof r}:an=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},an(e)}function Bs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function Us(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Bs(Object(r),!0).forEach(function(n){DE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Bs(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function DE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function BE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function sn(e,t,r){return typeof Reflect<"u"&&Reflect.get?sn=Reflect.get:sn=function(o,a,s){var u=UE(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},sn(e,t,r||e)}function UE(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Pt(e),e!==null););return e}function wE(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&bi(e,t)}function bi(e,t){return bi=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},bi(e,t)}function LE(e){var t=HE();return function(){var n=Pt(e),o;if(t){var a=Pt(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return XE(this,o)}}function XE(e,t){if(t&&(an(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return WE(e)}function WE(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function HE(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Pt(e){return Pt=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Pt(e)}function ws(){}var VE={colorDomain:null,colorRange:le,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",value:0,min:0,max:100},upperPercentile:{type:"number",value:100,min:0,max:100},colorScaleType:"quantize",onSetColorDomain:ws,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",value:0,min:0,max:100},elevationUpperPercentile:{type:"number",value:100,min:0,max:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:ws,radius:{type:"number",value:1e3,min:1},coverage:{type:"number",min:0,max:1,value:1},extruded:!1,hexagonAggregator:Ds,getPosition:{type:"accessor",value:function(t){return t.position}},material:!0,_filterData:{type:"function",value:null,optional:!0}},un=function(e){wE(r,e);var t=LE(r);function r(){var o;BE(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeState=function(){var a=new yt({getAggregator:function(l){return l.hexagonAggregator},getCellSize:function(l){return l.radius}});this.state={cpuAggregator:a,aggregatorState:a.state,vertices:null};var s=this.getAttributeManager();s.add({positions:{size:3,type:5130,accessor:"getPosition"}})},n.updateState=function(a){if(sn(Pt(r.prototype),"updateState",this).call(this,a),a.changeFlags.propsOrDataChanged){var s=this.state.cpuAggregator.updateState(a,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==s.layerData){var u=s.layerData||{},l=u.hexagonVertices;this.setState({vertices:l&&this.convertLatLngToMeterOffset(l)})}this.setState({aggregatorState:s})}},n.convertLatLngToMeterOffset=function(a){var s=this.context.viewport;if(Array.isArray(a)&&a.length===6){var u=a[0],l=a[3],f=[(u[0]+l[0])/2,(u[1]+l[1])/2],c=s.projectFlat(f),_=s.getDistanceScales(f),E=_.metersPerUnit,d=a.map(function(h){var p=s.projectFlat(h);return[(p[0]-c[0])*E[0],(p[1]-c[1])*E[1]]});return d}return Ls.log.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null},n.getPickingInfo=function(a){var s=a.info;return this.state.cpuAggregator.getPickingInfo({info:s})},n._onGetSublayerColor=function(a){return this.state.cpuAggregator.getAccessor("fillColor")(a)},n._onGetSublayerElevation=function(a){return this.state.cpuAggregator.getAccessor("elevation")(a)},n._getSublayerUpdateTriggers=function(){return this.state.cpuAggregator.getUpdateTriggers(this.props)},n.renderLayers=function(){var a=this.props,s=a.elevationScale,u=a.extruded,l=a.coverage,f=a.material,c=a.transitions,_=this.state,E=_.aggregatorState,d=_.vertices,h=this.getSubLayerClass("hexagon-cell",Xs.ColumnLayer),p=this._getSublayerUpdateTriggers(),g=d?{vertices:d,radius:1}:{radius:E.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new h(Us(Us({},g),{},{diskResolution:6,elevationScale:s,extruded:u,coverage:l,material:f,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:c&&{getFillColor:c.getColorValue||c.getColorWeight,getElevation:c.getElevationValue||c.getElevationWeight}}),this.getSubLayerProps({id:"hexagon-cell",updateTriggers:p}),{data:E.layerData.data})},r}(ge);un.layerName="HexagonLayer";un.defaultProps=VE;var dn=x(it());var Eu=x(j());var v;function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var O=.5,C=1/6,A={N:[0,O],E:[O,0],S:[0,-O],W:[-O,0],NE:[O,O],NW:[-O,O],SE:[O,-O],SW:[-O,-O]},Mt=[A.W,A.SW,A.S],Ft=[A.S,A.SE,A.E],Dt=[A.E,A.NE,A.N],Bt=[A.NW,A.W,A.N],Ut=[[-O,C],[-O,-C],[-C,-O],[C,-O]],wt=[[-C,-O],[C,-O],[O,-C],[O,C]],Lt=[[O,-C],[O,C],[C,O],[-C,O]],Xt=[[-O,C],[-O,-C],[C,O],[-C,O]],Ws=[A.W,A.SW,A.SE,A.E],Hs=[A.S,A.SE,A.NE,A.N],Vs=[A.NW,A.W,A.E,A.NE],Ks=[A.NW,A.SW,A.S,A.N],Gs=[[-O,C],[-O,-C],[O,-C],[O,C]],zs=[[-C,-O],[C,-O],[C,O],[-C,O]],KE=[A.NW,A.SW,A.SE,A.NE],js=[A.NW,A.SW,A.SE,A.E,A.N],Ys=[A.W,A.SW,A.SE,A.NE,A.N],ks=[A.NW,A.W,A.S,A.SE,A.NE],$s=[A.NW,A.SW,A.S,A.E,A.NE],Zs=[A.NW,A.W,[O,-C],[O,C],A.N],qs=[[-C,-O],[C,-O],A.E,A.NE,A.N],Qs=[[-O,C],[-O,-C],A.S,A.SE,A.E],Js=[A.W,A.SW,A.S,[C,O],[-C,O]],eu=[A.NW,A.W,[-C,-O],[C,-O],A.N],tu=[[-O,C],[-O,-C],A.E,A.NE,A.N],ru=[A.S,A.SE,A.E,[C,O],[-C,O]],nu=[A.W,A.SW,A.S,[O,-C],[O,C]],iu=[A.W,A.SW,A.SE,A.E,[C,O],[-C,O]],ou=[[-O,C],[-O,-C],A.S,A.SE,A.NE,A.N],au=[A.NW,A.W,[-C,-O],[C,-O],A.E,A.NE],su=[A.NW,A.SW,A.S,[O,-C],[O,C],A.N],Wt=[A.W,A.SW,A.S,A.E,A.NE,A.N],Ht=[A.NW,A.W,A.S,A.SE,A.E,A.N],ln=[[-O,C],[-O,-C],[-C,-O],[C,-O],A.E,A.NE,A.N],fn=[A.W,A.SW,A.S,[O,-C],[O,C],[C,O],[-C,O]],cn=[A.NW,A.W,[-C,-O],[C,-O],[O,-C],[O,C],A.N],_n=[[-O,C],[-O,-C],A.S,A.SE,A.E,[C,O],[-C,O]],uu=[[-O,C],[-O,-C],[-C,-O],[C,-O],[O,-C],[O,C],[C,O],[-C,O]],lu={0:[],1:[[A.W,A.S]],2:[[A.S,A.E]],3:[[A.W,A.E]],4:[[A.N,A.E]],5:{0:[[A.W,A.S],[A.N,A.E]],1:[[A.W,A.N],[A.S,A.E]]},6:[[A.N,A.S]],7:[[A.W,A.N]],8:[[A.W,A.N]],9:[[A.N,A.S]],10:{0:[[A.W,A.N],[A.S,A.E]],1:[[A.W,A.S],[A.N,A.E]]},11:[[A.N,A.E]],12:[[A.W,A.E]],13:[[A.S,A.E]],14:[[A.W,A.S]],15:[]};function N(e){return parseInt(e,4)}var fu=(v={},b(v,N("0000"),[]),b(v,N("2222"),[]),b(v,N("2221"),[Mt]),b(v,N("2212"),[Ft]),b(v,N("2122"),[Dt]),b(v,N("1222"),[Bt]),b(v,N("0001"),[Mt]),b(v,N("0010"),[Ft]),b(v,N("0100"),[Dt]),b(v,N("1000"),[Bt]),b(v,N("2220"),[Ut]),b(v,N("2202"),[wt]),b(v,N("2022"),[Lt]),b(v,N("0222"),[Xt]),b(v,N("0002"),[Ut]),b(v,N("0020"),[wt]),b(v,N("0200"),[Lt]),b(v,N("2000"),[Xt]),b(v,N("0011"),[Ws]),b(v,N("0110"),[Hs]),b(v,N("1100"),[Vs]),b(v,N("1001"),[Ks]),b(v,N("2211"),[Ws]),b(v,N("2112"),[Hs]),b(v,N("1122"),[Vs]),b(v,N("1221"),[Ks]),b(v,N("2200"),[Gs]),b(v,N("2002"),[zs]),b(v,N("0022"),[Gs]),b(v,N("0220"),[zs]),b(v,N("1111"),[KE]),b(v,N("1211"),[js]),b(v,N("2111"),[Ys]),b(v,N("1112"),[ks]),b(v,N("1121"),[$s]),b(v,N("1011"),[js]),b(v,N("0111"),[Ys]),b(v,N("1110"),[ks]),b(v,N("1101"),[$s]),b(v,N("1200"),[Zs]),b(v,N("0120"),[qs]),b(v,N("0012"),[Qs]),b(v,N("2001"),[Js]),b(v,N("1022"),[Zs]),b(v,N("2102"),[qs]),b(v,N("2210"),[Qs]),b(v,N("0221"),[Js]),b(v,N("1002"),[eu]),b(v,N("2100"),[tu]),b(v,N("0210"),[ru]),b(v,N("0021"),[nu]),b(v,N("1220"),[eu]),b(v,N("0122"),[tu]),b(v,N("2012"),[ru]),b(v,N("2201"),[nu]),b(v,N("0211"),[iu]),b(v,N("2110"),[ou]),b(v,N("1102"),[au]),b(v,N("1021"),[su]),b(v,N("2011"),[iu]),b(v,N("0112"),[ou]),b(v,N("1120"),[au]),b(v,N("1201"),[su]),b(v,N("2101"),[Wt]),b(v,N("0121"),[Wt]),b(v,N("1012"),[Ht]),b(v,N("1210"),[Ht]),b(v,N("0101"),{0:[Mt,Dt],1:[Wt],2:[Wt]}),b(v,N("1010"),{0:[Bt,Ft],1:[Ht],2:[Ht]}),b(v,N("2121"),{0:[Wt],1:[Wt],2:[Mt,Dt]}),b(v,N("1212"),{0:[Ht],1:[Ht],2:[Bt,Ft]}),b(v,N("2120"),{0:[ln],1:[ln],2:[Ut,Dt]}),b(v,N("2021"),{0:[fn],1:[fn],2:[Mt,Lt]}),b(v,N("1202"),{0:[cn],1:[cn],2:[Bt,wt]}),b(v,N("0212"),{0:[_n],1:[_n],2:[Ft,Xt]}),b(v,N("0102"),{0:[Ut,Dt],1:[ln],2:[ln]}),b(v,N("0201"),{0:[Mt,Lt],1:[fn],2:[fn]}),b(v,N("1020"),{0:[Bt,wt],1:[cn],2:[cn]}),b(v,N("2010"),{0:[Ft,Xt],1:[_n],2:[_n]}),b(v,N("2020"),{0:[Xt,wt],1:[uu],2:[Ut,Lt]}),b(v,N("0202"),{0:[Lt,Ut],1:[uu],2:[Xt,wt]}),v);function cu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function _u(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?cu(Object(r),!0).forEach(function(n){GE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):cu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function GE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var et={ISO_LINES:1,ISO_BANDS:2},zE={zIndex:0,zOffset:.005};function cr(e,t){return Array.isArray(t)?e<t[0]?0:e<t[1]?1:2:e>=t?1:0}function du(e){var t=e.cellWeights,r=e.x,n=e.y,o=e.width,a=e.height,s=e.threshold;e.thresholdValue&&(Eu.log.deprecated("thresholdValue","threshold")(),s=e.thresholdValue);var u=r<0,l=r>=o-1,f=n<0,c=n>=a-1,_=u||l||f||c,E={},d={};u||c?d.top=0:(E.top=t[(n+1)*o+r],d.top=cr(E.top,s)),l||c?d.topRight=0:(E.topRight=t[(n+1)*o+r+1],d.topRight=cr(E.topRight,s)),l||f?d.right=0:(E.right=t[n*o+r+1],d.right=cr(E.right,s)),u||f?d.current=0:(E.current=t[n*o+r],d.current=cr(E.current,s));var h=d.top,p=d.topRight,g=d.right,T=d.current,m=-1;Number.isFinite(s)&&(m=h<<3|p<<2|g<<1|T),Array.isArray(s)&&(m=h<<6|p<<4|g<<2|T);var R=0;return _||(R=cr((E.top+E.topRight+E.right+E.current)/4,s)),{code:m,meanCode:R}}function Ni(e){var t=e.gridOrigin,r=e.cellSize,n=e.x,o=e.y,a=e.code,s=e.meanCode,u=e.type,l=u===void 0?et.ISO_LINES:u,f=_u(_u({},zE),e.thresholdData),c=l===et.ISO_BANDS?fu[a]:lu[a];Array.isArray(c)||(c=c[s]);var _=f.zIndex*f.zOffset,E=(n+1)*r[0],d=(o+1)*r[1],h=t[0]+E,p=t[1]+d;if(l===et.ISO_BANDS){var g=[];return c.forEach(function(m){var R=[];m.forEach(function(S){var y=h+S[0]*r[0],I=p+S[1]*r[1];R.push([y,I,_])}),g.push(R)}),g}var T=[];return c.forEach(function(m){m.forEach(function(R){var S=h+R[0]*r[0],y=p+R[1]*r[1];T.push([S,y,_])})}),T}function gu(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=jE(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
502
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function jE(e,t){if(e){if(typeof e=="string")return hu(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return hu(e,t)}}function hu(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Au(e){var t=e.thresholdData,r=e.cellWeights,n=e.gridSize,o=e.gridOrigin,a=e.cellSize,s=[],u=[],l=n[0],f=n[1],c=0,_=0,E=gu(t),d;try{for(E.s();!(d=E.n()).done;)for(var h=d.value,p=h.contour,g=p.threshold,T=-1;T<l;T++)for(var m=-1;m<f;m++){var R=du({cellWeights:r,threshold:g,x:T,y:m,width:l,height:f}),S=R.code,y=R.meanCode,I={type:et.ISO_BANDS,gridOrigin:o,cellSize:a,x:T,y:m,width:l,height:f,code:S,meanCode:y,thresholdData:h};if(Array.isArray(g)){I.type=et.ISO_BANDS;var P=Ni(I),M=gu(P),B;try{for(M.s();!(B=M.n()).done;){var z=B.value;u[_++]={vertices:z,contour:p}}}catch(re){M.e(re)}finally{M.f()}}else{I.type=et.ISO_LINES;for(var W=Ni(I),L=0;L<W.length;L+=2)s[c++]={start:W[L],end:W[L+1],contour:p}}}}catch(re){E.e(re)}finally{E.f()}return{contourSegments:s,contourPolygons:u}}var mu=x(j());function En(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?En=function(r){return typeof r}:En=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},En(e)}function pu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function YE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _r(e,t,r){return typeof Reflect<"u"&&Reflect.get?_r=Reflect.get:_r=function(o,a,s){var u=kE(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},_r(e,t,r||e)}function kE(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=tt(e),e!==null););return e}function $E(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ci(e,t)}function Ci(e,t){return Ci=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},Ci(e,t)}function ZE(e){var t=JE();return function(){var n=tt(e),o;if(t){var a=tt(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return qE(this,o)}}function qE(e,t){if(t&&(En(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return QE(e)}function QE(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function JE(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function tt(e){return tt=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},tt(e)}var Tu=[255,255,255,255],ed=1,td=1,rd={cellSize:{type:"number",min:1,max:1e3,value:1e3},getPosition:{type:"accessor",value:function(t){return t.position}},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM",contours:{type:"object",value:[{threshold:td}],optional:!0,compare:3},zOffset:.005},Ru="positions",nd={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},gn=function(e){$E(r,e);var t=ZE(r);function r(){var o;YE(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeState=function(){var a;_r(tt(r.prototype),"initializeAggregationLayer",this).call(this,{dimensions:nd}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:w.SUM}}});var s=this.getAttributeManager();s.add((a={},pu(a,Ru,{size:3,accessor:"getPosition",type:5130,fp64:this.use64bitPositions()}),pu(a,"count",{size:3,accessor:"getWeight"}),a))},n.updateState=function(a){_r(tt(r.prototype),"updateState",this).call(this,a);var s=!1,u=a.oldProps,l=a.props,f=this.state.aggregationDirty;(u.contours!==l.contours||u.zOffset!==l.zOffset)&&(s=!0,this._updateThresholdData(a.props)),this.getNumInstances()>0&&(f||s)&&this._generateContours()},n.renderLayers=function(){var a=this.state.contourData,s=a.contourSegments,u=a.contourPolygons,l=this.getSubLayerClass("lines",dn.LineLayer),f=this.getSubLayerClass("bands",dn.SolidPolygonLayer),c=s&&s.length>0&&new l(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:function(d){return d.start},getTargetPosition:function(d){return d.end},getColor:function(d){return d.contour.color||Tu},getWidth:function(d){return d.contour.strokeWidth||ed}}),_=u&&u.length>0&&new f(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:function(d){return d.vertices},getFillColor:function(d){return d.contour.color||Tu}});return[c,_]},n.updateAggregationState=function(a){var s=a.props,u=a.oldProps,l=s.cellSize,f=s.coordinateSystem,c=this.context.viewport,_=u.cellSize!==l,E=s.gpuAggregation;this.state.gpuAggregation!==s.gpuAggregation&&E&&!Q.isSupported(this.context.device)&&(mu.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),E=!1);var d=E!==this.state.gpuAggregation;this.setState({gpuAggregation:E});var h=this.state.dimensions,p=this.isAttributeChanged(Ru),g=h.data,T=h.weights,m=this.state.boundingBox;if(p&&(m=qr(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:m})),p||_){var R=Qr(m,l,c,f),S=R.gridOffset,y=R.translation,I=R.width,P=R.height,M=R.numCol,B=R.numRow;this.allocateResources(B,M),this.setState({gridOffset:S,boundingBox:m,translation:y,posOffset:y.slice(),gridOrigin:[-1*y[0],-1*y[1]],width:I,height:P,numCol:M,numRow:B})}var z=p||d||this.isAggregationDirty(a,{dimension:g,compareAll:E}),W=this.isAggregationDirty(a,{dimension:T});W&&this._updateAccessors(a),(z||W)&&this._resetResults(),this.setState({aggregationDataDirty:z,aggregationWeightsDirty:W})},n._updateAccessors=function(a){var s=a.props,u=s.getWeight,l=s.aggregation,f=s.data,c=this.state.weights.count;c&&(c.getWeight=u,c.operation=w[l]),this.setState({getValue:At(l,u,{data:f})})},n._resetResults=function(){var a=this.state.weights.count;a&&(a.aggregationData=null)},n._generateContours=function(){var a=this.state,s=a.numCol,u=a.numRow,l=a.gridOrigin,f=a.gridOffset,c=a.thresholdData,_=this.state.weights.count,E=_.aggregationData;E||(E=_.aggregationBuffer.getData(),_.aggregationData=E);var d=Q.getCellData({countsData:E}),h=d.cellWeights,p=Au({thresholdData:c,cellWeights:h,gridSize:[s,u],gridOrigin:l,cellSize:[f.xOffset,f.yOffset]});this.setState({contourData:p})},n._updateThresholdData=function(a){for(var s=a.contours,u=a.zOffset,l=s.length,f=new Array(l),c=0;c<l;c++){var _=s[c];f[c]={contour:_,zIndex:_.zIndex||c,zOffset:u}}this.setState({thresholdData:f})},r}(Qe);gn.layerName="ContourLayer";gn.defaultProps=rd;var Pu=x(j());var Iu=x(j());var ae=x(j());var Su=`#version 300 es
348
503
  #define SHADER_NAME gpu-grid-cell-layer-vertex-shader
349
504
  #define RANGE_COUNT 6
350
505
 
@@ -450,7 +605,7 @@ void main(void) {
450
605
  vColor = vec4(color.rgb, color.a * opacity) / 255.;
451
606
  }
452
607
  }
453
- `;var To=`#version 300 es
608
+ `;var Ou=`#version 300 es
454
609
  #define SHADER_NAME gpu-grid-cell-layer-fragment-shader
455
610
 
456
611
  precision highp float;
@@ -463,9 +618,9 @@ void main(void) {
463
618
  fragColor = vColor;
464
619
  fragColor = picking_filterColor(fragColor);
465
620
  }
466
- `;function Et(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Et=function(r){return typeof r}:Et=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Et(e)}function Do(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Eo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Do(Object(r),!0).forEach(function(n){Lu(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Do(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Lu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Fu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Mt(e,t,r){return typeof Reflect<"u"&&Reflect.get?Mt=Reflect.get:Mt=function(i,o,a){var u=Bu(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},Mt(e,t,r||e)}function Bu(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Ve(e),e!==null););return e}function zu(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&vr(e,t)}function vr(e,t){return vr=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},vr(e,t)}function Uu(e){var t=ju();return function(){var n=Ve(e),i;if(t){var o=Ve(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Gu(this,i)}}function Gu(e,t){if(t&&(Et(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wu(e)}function Wu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ju(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ve(e){return Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ve(e)}var pr=0,dr=1,Vu={colorDomain:null,colorRange:j,elevationDomain:null,elevationRange:[0,1e3],elevationScale:{type:"number",min:0,value:1},gridSize:{type:"array",value:[1,1]},gridOrigin:{type:"array",value:[0,0]},gridOffset:{type:"array",value:[0,0]},cellSize:{type:"number",min:0,max:1e3,value:1e3},offset:{type:"array",value:[1,1]},coverage:{type:"number",min:0,max:1,value:1},extruded:!0,material:!0},Rt=function(e){zu(r,e);var t=Uu(r);function r(){return Fu(this,r),t.apply(this,arguments)}var n=r.prototype;return n.getShaders=function(){return Mt(Ve(r.prototype),"getShaders",this).call(this,{vs:Po,fs:To,modules:[W.project32,W.gouraudLighting,W.picking,de]})},n.initializeState=function(o){var a=o.gl,u=this.getAttributeManager();u.addInstanced({colors:{size:4,noAlloc:!0},elevations:{size:4,noAlloc:!0}});var s=this._getModel(a);this._setupUniformBuffer(s),this.setState({model:s})},n._getModel=function(o){return new Ct.Model(o,Eo(Eo({},this.getShaders()),{},{id:this.props.id,geometry:new Ct.CubeGeometry,isInstanced:!0}))},n.draw=function(o){var a=o.uniforms,u=this.props,s=u.cellSize,l=u.offset,f=u.extruded,c=u.elevationScale,g=u.coverage,p=u.gridSize,m=u.gridOrigin,h=u.gridOffset,v=u.elevationRange,y=u.colorMaxMinBuffer,O=u.elevationMaxMinBuffer,A=[(0,W.fp64LowPart)(m[0]),(0,W.fp64LowPart)(m[1])],P=[(0,W.fp64LowPart)(h[0]),(0,W.fp64LowPart)(h[1])],T=this.getDomainUniforms(),D=J(this.props.colorRange);this.bindUniformBuffers(y,O),this.state.model.setUniforms(a).setUniforms(T).setUniforms({cellSize:s,offset:l,extruded:f,elevationScale:c,coverage:g,gridSize:p,gridOrigin:m,gridOriginLow:A,gridOffset:h,gridOffsetLow:P,colorRange:D,elevationRange:v}).draw(),this.unbindUniformBuffers(y,O)},n.bindUniformBuffers=function(o,a){o.bind({target:35345,index:pr}),a.bind({target:35345,index:dr})},n.unbindUniformBuffers=function(o,a){o.unbind({target:35345,index:pr}),a.unbind({target:35345,index:dr})},n.getDomainUniforms=function(){var o=this.props,a=o.colorDomain,u=o.elevationDomain,s={};return a!==null?(s.colorDomainValid=!0,s.colorDomain=a):s.colorDomainValid=!1,u!==null?(s.elevationDomainValid=!0,s.elevationDomain=u):s.elevationDomainValid=!1,s},n._setupUniformBuffer=function(o){var a=this.context.gl,u=o.program.handle,s=a.getUniformBlockIndex(u,"ColorData"),l=a.getUniformBlockIndex(u,"ElevationData");a.uniformBlockBinding(u,s,pr),a.uniformBlockBinding(u,l,dr)},r}(W.Layer);Rt.layerName="GPUGridCellLayer";Rt.defaultProps=Vu;function Nt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Nt=function(r){return typeof r}:Nt=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Nt(e)}function Mo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Co(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Mo(Object(r),!0).forEach(function(n){It(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mo(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function It(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Hu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function He(e,t,r){return typeof Reflect<"u"&&Reflect.get?He=Reflect.get:He=function(i,o,a){var u=$u(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},He(e,t,r||e)}function $u(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=oe(e),e!==null););return e}function Xu(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&mr(e,t)}function mr(e,t){return mr=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},mr(e,t)}function ku(e){var t=Ku();return function(){var n=oe(e),i;if(t){var o=oe(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return qu(this,i)}}function qu(e,t){if(t&&(Nt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Yu(e)}function Yu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ku(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function oe(e){return oe=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},oe(e)}var Qu={colorDomain:null,colorRange:j,getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",elevationDomain:null,elevationRange:[0,1e3],getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},cellSize:{type:"number",min:1,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:function(t){return t.position}},extruded:!1,material:!0},Zu={data:{props:["cellSize","colorAggregation","elevationAggregation"]}},Ro="positions",fe=function(e){Xu(r,e);var t=ku(r);function r(){return Hu(this,r),t.apply(this,arguments)}var n=r.prototype;return n.initializeState=function(o){var a,u=o.gl,s=z.isSupported(u);s||No.log.error("GPUGridLayer is not supported on this browser, use GridLayer instead")(),He(oe(r.prototype),"initializeAggregationLayer",this).call(this,{dimensions:Zu}),this.setState({gpuAggregation:!0,projectPoints:!1,isSupported:s,weights:{color:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:new hr.Buffer(u,{byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})},elevation:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:new hr.Buffer(u,{byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})}},positionAttributeName:"positions"});var l=this.getAttributeManager();l.add((a={},It(a,Ro,{size:3,accessor:"getPosition",type:5130,fp64:this.use64bitPositions()}),It(a,"color",{size:3,accessor:"getColorWeight"}),It(a,"elevation",{size:3,accessor:"getElevationWeight"}),a))},n.updateState=function(o){if(this.state.isSupported!==!1){He(oe(r.prototype),"updateState",this).call(this,o);var a=this.state.aggregationDirty;a&&this.setState({gridHash:null})}},n.getHashKeyForIndex=function(o){var a=this.state,u=a.numRow,s=a.numCol,l=a.boundingBox,f=a.gridOffset,c=[s,u],g=[l.xMin,l.yMin],p=[f.xOffset,f.yOffset],m=Math.floor(o/c[0]),h=o-m*c[0],v=Math.floor((m*p[1]+g[1]+90+p[1]/2)/p[1]),y=Math.floor((h*p[0]+g[0]+180+p[0]/2)/p[0]);return"".concat(v,"-").concat(y)},n.getPositionForIndex=function(o){var a=this.state,u=a.numRow,s=a.numCol,l=a.boundingBox,f=a.gridOffset,c=[s,u],g=[l.xMin,l.yMin],p=[f.xOffset,f.yOffset],m=Math.floor(o/c[0]),h=o-m*c[0],v=m*p[1]+g[1],y=h*p[0]+g[0];return[y,v]},n.getPickingInfo=function(o){var a=o.info,u=o.mode,s=a.index,l=null;if(s>=0){var f=this.state.gpuGridAggregator,c=this.getPositionForIndex(s),g=z.getAggregationData(Co({pixelIndex:s},f.getData("color"))),p=z.getAggregationData(Co({pixelIndex:s},f.getData("elevation")));if(l={colorValue:g.cellWeight,elevationValue:p.cellWeight,count:g.cellCount||p.cellCount,position:c,totalCount:g.totalCount||p.totalCount},u!=="hover"){var m=this.props,h=this.state.gridHash;if(!h){var v=this.state,y=v.gridOffset,O=v.translation,A=v.boundingBox,P=this.context.viewport,T=this.getAttributes(),D=Pe(m,{gridOffset:y,attributes:T,viewport:P,translation:O,boundingBox:A});h=D.gridHash,this.setState({gridHash:h})}var E=this.getHashKeyForIndex(s),M=h[E];Object.assign(l,M)}}return a.picked=Boolean(l),a.object=l,a},n.renderLayers=function(){if(!this.state.isSupported)return null;var o=this.props,a=o.elevationScale,u=o.extruded,s=o.cellSize,l=o.coverage,f=o.material,c=o.elevationRange,g=o.colorDomain,p=o.elevationDomain,m=this.state,h=m.weights,v=m.numRow,y=m.numCol,O=m.gridOrigin,A=m.gridOffset,P=h.color,T=h.elevation,D=J(this.props.colorRange),E=this.getSubLayerClass("gpu-grid-cell",Rt);return new E({gridSize:[y,v],gridOrigin:O,gridOffset:[A.xOffset,A.yOffset],colorRange:D,elevationRange:c,colorDomain:g,elevationDomain:p,cellSize:s,coverage:l,material:f,elevationScale:a,extruded:u},this.getSubLayerProps({id:"gpu-grid-cell"}),{data:{attributes:{colors:P.aggregationBuffer,elevations:T.aggregationBuffer}},colorMaxMinBuffer:P.maxMinBuffer,elevationMaxMinBuffer:T.maxMinBuffer,numInstances:y*v})},n.finalizeState=function(o){var a=this.state.weights,u=a.color,s=a.elevation;[u,s].forEach(function(l){var f=l.aggregationBuffer,c=l.maxMinBuffer;c.delete(),f?.delete()}),He(oe(r.prototype),"finalizeState",this).call(this,o)},n.updateAggregationState=function(o){var a=o.props,u=o.oldProps,s=a.cellSize,l=a.coordinateSystem,f=this.context.viewport,c=u.cellSize!==s,g=this.state.dimensions,p=this.isAttributeChanged(Ro),m=p||this.isAttributeChanged(),h=this.state.boundingBox;if(p&&(h=ct(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:h})),p||c){var v=gt(h,s,f,l),y=v.gridOffset,O=v.translation,A=v.width,P=v.height,T=v.numCol,D=v.numRow;this.allocateResources(D,T),this.setState({gridOffset:y,translation:O,gridOrigin:[-1*O[0],-1*O[1]],width:A,height:P,numCol:T,numRow:D})}var E=m||this.isAggregationDirty(o,{dimension:g.data,compareAll:!0});E&&this._updateAccessors(o),this.setState({aggregationDataDirty:E})},n._updateAccessors=function(o){var a=o.props,u=a.colorAggregation,s=a.elevationAggregation,l=this.state.weights,f=l.color,c=l.elevation;f.operation=R[u],c.operation=R[s]},r}(ae);fe.layerName="GPUGridLayer";fe.defaultProps=Qu;function Lt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Lt=function(r){return typeof r}:Lt=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Lt(e)}function Ju(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function es(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_r(e,t)}function _r(e,t){return _r=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},_r(e,t)}function ts(e){var t=os();return function(){var n=Ft(e),i;if(t){var o=Ft(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return rs(this,i)}}function rs(e,t){if(t&&(Lt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ns(e)}function ns(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function os(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ft(e){return Ft=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ft(e)}function Io(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function yr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Io(Object(r),!0).forEach(function(n){is(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Io(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function is(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var as=yr(yr(yr({},fe.defaultProps),ue.defaultProps),{},{gpuAggregation:!1}),Bt=function(e){es(r,e);var t=ts(r);function r(){var i;Ju(this,r);for(var o=arguments.length,a=new Array(o),u=0;u<o;u++)a[u]=arguments[u];return i=t.call.apply(t,[this].concat(a)),i.state=void 0,i}var n=r.prototype;return n.initializeState=function(){this.state={useGPUAggregation:!0}},n.updateState=function(o){var a=o.props;this.setState({useGPUAggregation:this.canUseGPUAggregation(a)})},n.renderLayers=function(){var o=this.props,a=o.data,u=o.updateTriggers,s=this.state.useGPUAggregation?"GPU":"CPU",l=this.state.useGPUAggregation?this.getSubLayerClass("GPU",fe):this.getSubLayerClass("CPU",ue);return new l(this.props,this.getSubLayerProps({id:s,updateTriggers:u}),{data:a})},n.canUseGPUAggregation=function(o){var a=o.gpuAggregation,u=o.lowerPercentile,s=o.upperPercentile,l=o.getColorValue,f=o.getElevationValue,c=o.colorScaleType;return!(!a||!z.isSupported(this.context.gl)||u!==0||s!==100||l!==null||f!==null||c==="quantile"||c==="ordinal")},r}(Lo.CompositeLayer);Bt.layerName="GridLayer";Bt.defaultProps=as;var Go=C(H());function zo(e,t){return ls(e)||ss(e,t)||Uo(e,t)||us()}function us(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
467
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ss(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,o=!1,a,u;try{for(r=r.call(e);!(i=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));i=!0);}catch(s){o=!0,u=s}finally{try{!i&&r.return!=null&&r.return()}finally{if(o)throw u}}return n}}function ls(e){if(Array.isArray(e))return e}function fs(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Uo(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
468
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,u;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){a=!0,u=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}}}function Uo(e,t){if(e){if(typeof e=="string")return Fo(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Fo(e,t)}}function Fo(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Wo(e){var t=e.map(function(u){return u[0]}),r=e.map(function(u){return u[1]}),n=Math.min.apply(null,t),i=Math.max.apply(null,t),o=Math.min.apply(null,r),a=Math.max.apply(null,r);return[n,o,i,a]}function jo(e,t){return t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3]}var Bo=new Float32Array(12);function xr(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,r=0,n=fs(e),i;try{for(n.s();!(i=n.n()).done;)for(var o=i.value,a=0;a<t;a++)Bo[r++]=o[a]||0}catch(u){n.e(u)}finally{n.f()}return Bo}function Vo(e,t,r){var n=zo(e,4),i=n[0],o=n[1],a=n[2],u=n[3],s=a-i,l=u-o,f=s,c=l;s/l<t/r?f=t/r*l:c=r/t*s,f<t&&(f=t,c=r);var g=(a+i)/2,p=(u+o)/2;return[g-f/2,p-c/2,g+f/2,p+c/2]}function Ho(e,t){var r=zo(t,4),n=r[0],i=r[1],o=r[2],a=r[3];return[(e[0]-n)/(o-n),(e[1]-i)/(a-i)]}function $o(e){var t=e.gl,r=e.floatTargetSupport;return r?{format:(0,Go.isWebGL2)(t)?34836:6408,type:5126}:{format:6408,type:5121}}var I=C(H()),q=C(L());var Wt=C(H()),jt=C(L());var Xo=`#define SHADER_NAME heatp-map-layer-vertex-shader
621
+ `;function hn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?hn=function(r){return typeof r}:hn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},hn(e)}function vu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function bu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?vu(Object(r),!0).forEach(function(n){id(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):vu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function id(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function od(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function An(e,t,r){return typeof Reflect<"u"&&Reflect.get?An=Reflect.get:An=function(o,a,s){var u=ad(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},An(e,t,r||e)}function ad(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Vt(e),e!==null););return e}function sd(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&xi(e,t)}function xi(e,t){return xi=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},xi(e,t)}function ud(e){var t=cd();return function(){var n=Vt(e),o;if(t){var a=Vt(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return ld(this,o)}}function ld(e,t){if(t&&(hn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return fd(e)}function fd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Vt(e){return Vt=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Vt(e)}var yi=0,Ii=1,_d={colorDomain:null,colorRange:le,elevationDomain:null,elevationRange:[0,1e3],elevationScale:{type:"number",min:0,value:1},gridSize:{type:"array",value:[1,1]},gridOrigin:{type:"array",value:[0,0]},gridOffset:{type:"array",value:[0,0]},cellSize:{type:"number",min:0,max:1e3,value:1e3},offset:{type:"array",value:[1,1]},coverage:{type:"number",min:0,max:1,value:1},extruded:!0,material:!0},pn=function(e){sd(r,e);var t=ud(r);function r(){var o;od(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.getShaders=function(){return An(Vt(r.prototype),"getShaders",this).call(this,{vs:Su,fs:Ou,modules:[ae.project32,ae.gouraudLighting,ae.picking,st]})},n.initializeState=function(){var a=this.getAttributeManager();a.addInstanced({colors:{size:4,noAlloc:!0},elevations:{size:4,noAlloc:!0}});var s=this._getModel();this._setupUniformBuffer(s),this.setState({model:s})},n._getModel=function(){return new J(this.context.device,bu(bu({},this.getShaders()),{},{id:this.props.id,geometry:new Yt,isInstanced:!0}))},n.draw=function(a){var s=a.uniforms,u=this.props,l=u.cellSize,f=u.offset,c=u.extruded,_=u.elevationScale,E=u.coverage,d=u.gridSize,h=u.gridOrigin,p=u.gridOffset,g=u.elevationRange,T=u.colorMaxMinBuffer,m=u.elevationMaxMinBuffer,R=this.state.model,S=[(0,ae.fp64LowPart)(h[0]),(0,ae.fp64LowPart)(h[1])],y=[(0,ae.fp64LowPart)(p[0]),(0,ae.fp64LowPart)(p[1])],I=this.getDomainUniforms(),P=Xe(this.props.colorRange);this.bindUniformBuffers(T,m),R.setUniforms(s),R.setUniforms(I),R.setUniforms({cellSize:l,offset:f,extruded:c,elevationScale:_,coverage:E,gridSize:d,gridOrigin:h,gridOriginLow:S,gridOffset:p,gridOffsetLow:y,colorRange:P,elevationRange:g}),R.draw(this.context.renderPass),this.unbindUniformBuffers(T,m)},n.bindUniformBuffers=function(a,s){a.bind({target:35345,index:yi}),s.bind({target:35345,index:Ii})},n.unbindUniformBuffers=function(a,s){a.unbind({target:35345,index:yi}),s.unbind({target:35345,index:Ii})},n.getDomainUniforms=function(){var a=this.props,s=a.colorDomain,u=a.elevationDomain,l={};return s!==null?(l.colorDomainValid=!0,l.colorDomain=s):l.colorDomainValid=!1,u!==null?(l.elevationDomainValid=!0,l.elevationDomain=u):l.elevationDomainValid=!1,l},n._setupUniformBuffer=function(a){var s=a.pipeline.handle,u=this.context.gl,l=u.getUniformBlockIndex(s,"ColorData"),f=u.getUniformBlockIndex(s,"ElevationData");u.uniformBlockBinding(s,l,yi),u.uniformBlockBinding(s,f,Ii)},r}(ae.Layer);pn.layerName="GPUGridCellLayer";pn.defaultProps=_d;function Tn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Tn=function(r){return typeof r}:Tn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Tn(e)}function Nu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function Cu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Nu(Object(r),!0).forEach(function(n){Rn(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Nu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Rn(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ed(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Kt(e,t,r){return typeof Reflect<"u"&&Reflect.get?Kt=Reflect.get:Kt=function(o,a,s){var u=dd(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},Kt(e,t,r||e)}function dd(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Ke(e),e!==null););return e}function gd(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Pi(e,t)}function Pi(e,t){return Pi=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},Pi(e,t)}function hd(e){var t=Td();return function(){var n=Ke(e),o;if(t){var a=Ke(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return Ad(this,o)}}function Ad(e,t){if(t&&(Tn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pd(e)}function pd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Td(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ke(e){return Ke=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ke(e)}var Rd={colorDomain:null,colorRange:le,getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",elevationDomain:null,elevationRange:[0,1e3],getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},cellSize:{type:"number",min:1,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:function(t){return t.position}},extruded:!1,material:!0},md={data:{props:["cellSize","colorAggregation","elevationAggregation"]}},yu="positions",rt=function(e){gd(r,e);var t=hd(r);function r(){var o;Ed(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeState=function(a){var s,u=a.device,l=Q.isSupported(u);l||Iu.log.error("GPUGridLayer is not supported on this browser, use GridLayer instead")(),Kt(Ke(r.prototype),"initializeAggregationLayer",this).call(this,{dimensions:md}),this.setState({gpuAggregation:!0,projectPoints:!1,isSupported:l,weights:{color:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:u.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})},elevation:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:u.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})}},positionAttributeName:"positions"});var f=this.getAttributeManager();f.add((s={},Rn(s,yu,{size:3,accessor:"getPosition",type:5130,fp64:this.use64bitPositions()}),Rn(s,"color",{size:3,accessor:"getColorWeight"}),Rn(s,"elevation",{size:3,accessor:"getElevationWeight"}),s))},n.updateState=function(a){if(this.state.isSupported!==!1){Kt(Ke(r.prototype),"updateState",this).call(this,a);var s=this.state.aggregationDirty;s&&this.setState({gridHash:null})}},n.getHashKeyForIndex=function(a){var s=this.state,u=s.numRow,l=s.numCol,f=s.boundingBox,c=s.gridOffset,_=[l,u],E=[f.xMin,f.yMin],d=[c.xOffset,c.yOffset],h=Math.floor(a/_[0]),p=a-h*_[0],g=Math.floor((h*d[1]+E[1]+90+d[1]/2)/d[1]),T=Math.floor((p*d[0]+E[0]+180+d[0]/2)/d[0]);return"".concat(g,"-").concat(T)},n.getPositionForIndex=function(a){var s=this.state,u=s.numRow,l=s.numCol,f=s.boundingBox,c=s.gridOffset,_=[l,u],E=[f.xMin,f.yMin],d=[c.xOffset,c.yOffset],h=Math.floor(a/_[0]),p=a-h*_[0],g=h*d[1]+E[1],T=p*d[0]+E[0];return[T,g]},n.getPickingInfo=function(a){var s=a.info,u=a.mode,l=s.index,f=null;if(l>=0){var c=this.state.gpuGridAggregator,_=this.getPositionForIndex(l),E=Q.getAggregationData(Cu({pixelIndex:l},c.getData("color"))),d=Q.getAggregationData(Cu({pixelIndex:l},c.getData("elevation")));if(f={colorValue:E.cellWeight,elevationValue:d.cellWeight,count:E.cellCount||d.cellCount,position:_,totalCount:E.totalCount||d.totalCount},u!=="hover"){var h=this.props,p=this.state.gridHash;if(!p){var g=this.state,T=g.gridOffset,m=g.translation,R=g.boundingBox,S=this.context.viewport,y=this.getAttributes(),I=bt(h,{gridOffset:T,attributes:y,viewport:S,translation:m,boundingBox:R});p=I.gridHash,this.setState({gridHash:p})}var P=this.getHashKeyForIndex(l),M=p[P];Object.assign(f,M)}}return s.picked=Boolean(f),s.object=f,s},n.renderLayers=function(){if(!this.state.isSupported)return null;var a=this.props,s=a.elevationScale,u=a.extruded,l=a.cellSize,f=a.coverage,c=a.material,_=a.elevationRange,E=a.colorDomain,d=a.elevationDomain,h=this.state,p=h.weights,g=h.numRow,T=h.numCol,m=h.gridOrigin,R=h.gridOffset,S=p.color,y=p.elevation,I=Xe(this.props.colorRange),P=this.getSubLayerClass("gpu-grid-cell",pn);return new P({gridSize:[T,g],gridOrigin:m,gridOffset:[R.xOffset,R.yOffset],colorRange:I,elevationRange:_,colorDomain:E,elevationDomain:d,cellSize:l,coverage:f,material:c,elevationScale:s,extruded:u},this.getSubLayerProps({id:"gpu-grid-cell"}),{data:{attributes:{colors:S.aggregationBuffer,elevations:y.aggregationBuffer}},colorMaxMinBuffer:S.maxMinBuffer,elevationMaxMinBuffer:y.maxMinBuffer,numInstances:T*g})},n.finalizeState=function(a){var s=this.state.weights,u=s.color,l=s.elevation;[u,l].forEach(function(f){var c=f.aggregationBuffer,_=f.maxMinBuffer;_?.destroy(),c?.destroy()}),Kt(Ke(r.prototype),"finalizeState",this).call(this,a)},n.updateAggregationState=function(a){var s=a.props,u=a.oldProps,l=s.cellSize,f=s.coordinateSystem,c=this.context.viewport,_=u.cellSize!==l,E=this.state.dimensions,d=this.isAttributeChanged(yu),h=d||this.isAttributeChanged(),p=this.state.boundingBox;if(d&&(p=qr(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:p})),d||_){var g=Qr(p,l,c,f),T=g.gridOffset,m=g.translation,R=g.width,S=g.height,y=g.numCol,I=g.numRow;this.allocateResources(I,y),this.setState({gridOffset:T,translation:m,gridOrigin:[-1*m[0],-1*m[1]],width:R,height:S,numCol:y,numRow:I})}var P=h||this.isAggregationDirty(a,{dimension:E.data,compareAll:!0});P&&this._updateAccessors(a),this.setState({aggregationDataDirty:P})},n._updateAccessors=function(a){var s=a.props,u=s.colorAggregation,l=s.elevationAggregation,f=this.state.weights,c=f.color,_=f.elevation;c.operation=w[u],_.operation=w[l]},r}(Qe);rt.layerName="GPUGridLayer";rt.defaultProps=Rd;function mn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?mn=function(r){return typeof r}:mn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},mn(e)}function Sd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Od(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Fi(e,t)}function Fi(e,t){return Fi=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},Fi(e,t)}function vd(e){var t=Cd();return function(){var n=Sn(e),o;if(t){var a=Sn(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return bd(this,o)}}function bd(e,t){if(t&&(mn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Nd(e)}function Nd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Cd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Sn(e){return Sn=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Sn(e)}function xu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function Mi(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?xu(Object(r),!0).forEach(function(n){yd(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function yd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Id=Mi(Mi(Mi({},rt.defaultProps),Je.defaultProps),{},{gpuAggregation:!1}),On=function(e){Od(r,e);var t=vd(r);function r(){var o;Sd(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeState=function(){this.state={useGPUAggregation:!0}},n.updateState=function(a){var s=a.props;this.setState({useGPUAggregation:this.canUseGPUAggregation(s)})},n.renderLayers=function(){var a=this.props,s=a.data,u=a.updateTriggers,l=this.state.useGPUAggregation?"GPU":"CPU",f=this.state.useGPUAggregation?this.getSubLayerClass("GPU",rt):this.getSubLayerClass("CPU",Je);return new f(this.props,this.getSubLayerProps({id:l,updateTriggers:u}),{data:s})},n.canUseGPUAggregation=function(a){var s=a.gpuAggregation,u=a.lowerPercentile,l=a.upperPercentile,f=a.getColorValue,c=a.getElevationValue,_=a.colorScaleType;return!(!s||!Q.isSupported(this.context.device)||u!==0||l!==100||f!==null||c!==null||_==="quantile"||_==="ordinal")},r}(Pu.CompositeLayer);On.layerName="GridLayer";On.defaultProps=Id;function Du(e,t){return Md(e)||Pd(e,t)||Bu(e,t)||xd()}function xd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
622
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pd(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,a=!1,s,u;try{for(r=r.call(e);!(o=(s=r.next()).done)&&(n.push(s.value),!(t&&n.length===t));o=!0);}catch(l){a=!0,u=l}finally{try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}return n}}function Md(e){if(Array.isArray(e))return e}function Fd(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Bu(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
623
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,u;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return a=f.done,f},e:function(f){s=!0,u=f},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw u}}}}function Bu(e,t){if(e){if(typeof e=="string")return Mu(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Mu(e,t)}}function Mu(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Uu(e){var t=e.map(function(u){return u[0]}),r=e.map(function(u){return u[1]}),n=Math.min.apply(null,t),o=Math.max.apply(null,t),a=Math.min.apply(null,r),s=Math.max.apply(null,r);return[n,a,o,s]}function wu(e,t){return t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3]}var Fu=new Float32Array(12);function Di(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,r=0,n=Fd(e),o;try{for(n.s();!(o=n.n()).done;)for(var a=o.value,s=0;s<t;s++)Fu[r++]=a[s]||0}catch(u){n.e(u)}finally{n.f()}return Fu}function Lu(e,t,r){var n=Du(e,4),o=n[0],a=n[1],s=n[2],u=n[3],l=s-o,f=u-a,c=l,_=f;l/f<t/r?c=t/r*f:_=r/t*l,c<t&&(c=t,_=r);var E=(s+o)/2,d=(u+a)/2;return[E-c/2,d-_/2,E+c/2,d+_/2]}function Xu(e,t){var r=Du(t,4),n=r[0],o=r[1],a=r[2],s=r[3];return[(e[0]-n)/(a-n),(e[1]-o)/(s-o)]}function Wu(e){var t=e.device,r=e.floatTargetSupport;return r?{format:t.info.type==="webgl2"?34836:6408,type:5126}:{format:6408,type:5121}}var Oe=x(j());var Cn=x(j());var Hu=`#define SHADER_NAME heatp-map-layer-vertex-shader
469
624
 
470
625
  uniform sampler2D maxTexture;
471
626
  uniform float intensity;
@@ -493,7 +648,7 @@ void main(void) {
493
648
  vIntensityMax = intensity / maxValue;
494
649
  vIntensityMin = intensity / minValue;
495
650
  }
496
- `;var ko=`#define SHADER_NAME triangle-layer-fragment-shader
651
+ `;var Vu=`#define SHADER_NAME triangle-layer-fragment-shader
497
652
 
498
653
  precision highp float;
499
654
 
@@ -528,7 +683,7 @@ void main(void) {
528
683
  linearColor.a *= opacity;
529
684
  gl_FragColor =linearColor;
530
685
  }
531
- `;function Ut(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ut=function(r){return typeof r}:Ut=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ut(e)}function qo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function zt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?qo(Object(r),!0).forEach(function(n){cs(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qo(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function cs(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function gs(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ps(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&br(e,t)}function br(e,t){return br=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},br(e,t)}function ds(e){var t=hs();return function(){var n=Gt(e),i;if(t){var o=Gt(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return vs(this,i)}}function vs(e,t){if(t&&(Ut(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ms(e)}function ms(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function hs(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Gt(e){return Gt=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Gt(e)}var Sr=function(e){ps(r,e);var t=ds(r);function r(){return gs(this,r),t.apply(this,arguments)}var n=r.prototype;return n.getShaders=function(){return{vs:Xo,fs:ko,modules:[jt.project32]}},n.initializeState=function(o){var a=o.gl,u=this.getAttributeManager();u.add({positions:{size:3,noAlloc:!0},texCoords:{size:2,noAlloc:!0}}),this.setState({model:this._getModel(a)})},n._getModel=function(o){var a=this.props.vertexCount;return new Wt.Model(o,zt(zt({},this.getShaders()),{},{id:this.props.id,geometry:new Wt.Geometry({drawMode:6,vertexCount:a})}))},n.draw=function(o){var a=o.uniforms,u=this.state.model,s=this.props,l=s.texture,f=s.maxTexture,c=s.colorTexture,g=s.intensity,p=s.threshold,m=s.aggregationMode,h=s.colorDomain;u.setUniforms(zt(zt({},a),{},{texture:l,maxTexture:f,colorTexture:c,intensity:g,threshold:p,aggregationMode:m,colorDomain:h})).draw()},r}(jt.Layer);Sr.layerName="TriangleLayer";var Yo=`attribute vec3 positions;
686
+ `;function bn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?bn=function(r){return typeof r}:bn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},bn(e)}function Ku(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function vn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ku(Object(r),!0).forEach(function(n){Dd(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ku(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Dd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ud(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Bi(e,t)}function Bi(e,t){return Bi=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},Bi(e,t)}function wd(e){var t=Wd();return function(){var n=Nn(e),o;if(t){var a=Nn(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return Ld(this,o)}}function Ld(e,t){if(t&&(bn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Xd(e)}function Xd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Wd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Nn(e){return Nn=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Nn(e)}var Ui=function(e){Ud(r,e);var t=wd(r);function r(){var o;Bd(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.getShaders=function(){return{vs:Hu,fs:Vu,modules:[Cn.project32]}},n.initializeState=function(a){var s=a.device,u=this.getAttributeManager();u.add({positions:{size:3,noAlloc:!0},texCoords:{size:2,noAlloc:!0}}),this.setState({model:this._getModel(s)})},n._getModel=function(a){var s=this.props.vertexCount;return new J(a,vn(vn({},this.getShaders()),{},{id:this.props.id,geometry:new be({topology:"triangle-fan-webgl",vertexCount:s})}))},n.draw=function(a){var s=a.uniforms,u=this.state.model,l=this.props,f=l.texture,c=l.maxTexture,_=l.colorTexture,E=l.intensity,d=l.threshold,h=l.aggregationMode,p=l.colorDomain;u.setUniforms(vn(vn({},s),{},{texture:f,maxTexture:c,colorTexture:_,intensity:E,threshold:d,aggregationMode:h,colorDomain:p})),u.draw(this.context.renderPass)},r}(Cn.Layer);Ui.layerName="TriangleLayer";var Gu=`attribute vec3 positions;
532
687
  attribute vec3 positions64Low;
533
688
  attribute float weights;
534
689
  varying vec4 weightsTexture;
@@ -547,7 +702,7 @@ void main()
547
702
  gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ;
548
703
  gl_Position.xy = (gl_Position.xy * 2.) - (1.);
549
704
  }
550
- `;var Ko=`varying vec4 weightsTexture;
705
+ `;var zu=`varying vec4 weightsTexture;
551
706
  float gaussianKDE(float u){
552
707
  return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666);
553
708
  }
@@ -560,7 +715,7 @@ void main()
560
715
  gl_FragColor = weightsTexture * gaussianKDE(2. * dist);
561
716
  DECKGL_FILTER_COLOR(gl_FragColor, geometry);
562
717
  }
563
- `;var Qo=`attribute vec4 inTexture;
718
+ `;var ju=`attribute vec4 inTexture;
564
719
  varying vec4 outTexture;
565
720
 
566
721
  void main()
@@ -569,12 +724,12 @@ outTexture = inTexture;
569
724
  gl_Position = vec4(0, 0, 0, 1.);
570
725
  gl_PointSize = 1.0;
571
726
  }
572
- `;var Zo=`varying vec4 outTexture;
727
+ `;var Yu=`varying vec4 outTexture;
573
728
  void main() {
574
729
  gl_FragColor = outTexture;
575
730
  gl_FragColor.g = outTexture.r / max(1.0, outTexture.a);
576
731
  }
577
- `;function Vt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Vt=function(r){return typeof r}:Vt=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Vt(e)}var $e;function Jo(e,t){return bs(e)||xs(e,t)||_s(e,t)||ys()}function ys(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
578
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _s(e,t){if(e){if(typeof e=="string")return ei(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ei(e,t)}}function ei(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function xs(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,o=!1,a,u;try{for(r=r.call(e);!(i=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));i=!0);}catch(s){o=!0,u=s}finally{try{!i&&r.return!=null&&r.return()}finally{if(o)throw u}}return n}}function bs(e){if(Array.isArray(e))return e}function ti(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Xe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ti(Object(r),!0).forEach(function(n){ge(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ti(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ss(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ce(e,t,r){return typeof Reflect<"u"&&Reflect.get?ce=Reflect.get:ce=function(i,o,a){var u=Os(i,o);if(u){var s=Object.getOwnPropertyDescriptor(u,o);return s.get?s.get.call(a):s.value}},ce(e,t,r||e)}function Os(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Y(e),e!==null););return e}function As(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ar(e,t)}function Ar(e,t){return Ar=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},Ar(e,t)}function ws(e){var t=Ds();return function(){var n=Y(e),i;if(t){var o=Y(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Ps(this,i)}}function Ps(e,t){if(t&&(Vt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ts(e)}function Ts(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ds(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Y(e){return Y=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Y(e)}function ge(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Es=2,Or={mipmaps:!1,parameters:($e={},ge($e,10240,9729),ge($e,10241,9729),ge($e,10242,33071),ge($e,10243,33071),$e),dataFormat:6408},ri=[0,0],Ms={SUM:0,MEAN:1},Cs={getPosition:{type:"accessor",value:function(t){return t.position}},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:j,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},Rs=[I.FEATURES.BLEND_EQUATION_MINMAX,I.FEATURES.TEXTURE_FLOAT],Ns=[I.FEATURES.COLOR_ATTACHMENT_RGBA32F,I.FEATURES.FLOAT_BLEND],Is={data:{props:["radiusPixels"]}},Ht=function(e){As(r,e);var t=ws(r);function r(){var i;Ss(this,r);for(var o=arguments.length,a=new Array(o),u=0;u<o;u++)a[u]=arguments[u];return i=t.call.apply(t,[this].concat(a)),i.state=void 0,i}var n=r.prototype;return n.initializeState=function(){var o=this.context.gl;if(!(0,I.hasFeatures)(o,Rs)){this.setState({supported:!1}),q.log.error("HeatmapLayer: ".concat(this.id," is not supported on this browser"))();return}ce(Y(r.prototype),"initializeAggregationLayer",this).call(this,Is),this.setState({supported:!0,colorDomain:ri}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()},n.shouldUpdateState=function(o){var a=o.changeFlags;return a.somethingChanged},n.updateState=function(o){this.state.supported&&(ce(Y(r.prototype),"updateState",this).call(this,o),this._updateHeatmapState(o))},n._updateHeatmapState=function(o){var a=o.props,u=o.oldProps,s=this._getChangeFlags(o);(s.dataChanged||s.viewportChanged)&&(s.boundsChanged=this._updateBounds(s.dataChanged),this._updateTextureRenderingBounds()),s.dataChanged||s.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):s.viewportZoomChanged&&this._debouncedUpdateWeightmap(),a.colorRange!==u.colorRange&&this._updateColorTexture(o),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:o.context.viewport.zoom})},n.renderLayers=function(){if(!this.state.supported)return[];var o=this.state,a=o.weightsTexture,u=o.triPositionBuffer,s=o.triTexCoordBuffer,l=o.maxWeightsTexture,f=o.colorTexture,c=o.colorDomain,g=this.props,p=g.updateTriggers,m=g.intensity,h=g.threshold,v=g.aggregation,y=this.getSubLayerClass("triangle",Sr);return new y(this.getSubLayerProps({id:"triangle-layer",updateTriggers:p}),{coordinateSystem:q.COORDINATE_SYSTEM.DEFAULT,data:{attributes:{positions:u,texCoords:s}},vertexCount:4,maxTexture:l,colorTexture:f,aggregationMode:Ms[v]||0,texture:a,intensity:m,threshold:h,colorDomain:c})},n.finalizeState=function(o){ce(Y(r.prototype),"finalizeState",this).call(this,o);var a=this.state,u=a.weightsTransform,s=a.weightsTexture,l=a.maxWeightTransform,f=a.maxWeightsTexture,c=a.triPositionBuffer,g=a.triTexCoordBuffer,p=a.colorTexture,m=a.updateTimer;u?.delete(),s?.delete(),l?.delete(),f?.delete(),c?.delete(),g?.delete(),p?.delete(),m&&clearTimeout(m)},n._getAttributeManager=function(){return new q.AttributeManager(this.context.gl,{id:this.props.id,stats:this.context.stats})},n._getChangeFlags=function(o){var a={},u=this.state.dimensions;a.dataChanged=this.isAttributeChanged()||this.isAggregationDirty(o,{compareAll:!0,dimension:u.data}),a.viewportChanged=o.changeFlags.viewportChanged;var s=this.state.zoom;return(!o.context.viewport||o.context.viewport.zoom!==s)&&(a.viewportZoomChanged=!0),a},n._createTextures=function(){var o=this.context.gl,a=this.state,u=a.textureSize,s=a.format,l=a.type;this.setState({weightsTexture:new I.Texture2D(o,Xe({width:u,height:u,format:s,type:l},Or)),maxWeightsTexture:new I.Texture2D(o,Xe({format:s,type:l},Or))})},n._setupAttributes=function(){var o=this.getAttributeManager();o.add({positions:{size:3,type:5130,accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})},n._setupTextureParams=function(){var o=this.context.gl,a=this.props.weightsTextureSize,u=Math.min(a,(0,I.getParameters)(o,3379)),s=(0,I.hasFeatures)(o,Ns),l=$o({gl:o,floatTargetSupport:s}),f=l.format,c=l.type,g=s?1:1/255;this.setState({textureSize:u,format:f,type:c,weightsScale:g}),s||q.log.warn("HeatmapLayer: ".concat(this.id," rendering to float texture not supported, fallingback to low precession format"))()},n.getShaders=function(o){return ce(Y(r.prototype),"getShaders",this).call(this,o==="max-weights-transform"?{vs:Qo,_fs:Zo}:{vs:Yo,_fs:Ko})},n._createWeightsTransform=function(){var o,a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=this.context.gl,s=this.state.weightsTransform,l=this.state.weightsTexture;(o=s)===null||o===void 0||o.delete(),s=new I.Transform(u,Xe({id:"".concat(this.id,"-weights-transform"),elementCount:1,_targetTexture:l,_targetTextureVarying:"weightsTexture"},a)),this.setState({weightsTransform:s})},n._setupResources=function(){var o=this.context.gl;this._createTextures();var a=this.state,u=a.textureSize,s=a.weightsTexture,l=a.maxWeightsTexture,f=this.getShaders("weights-transform");this._createWeightsTransform(f);var c=this.getShaders("max-weights-transform"),g=new I.Transform(o,Xe(Xe({id:"".concat(this.id,"-max-weights-transform"),_sourceTextures:{inTexture:s},_targetTexture:l,_targetTextureVarying:"outTexture"},c),{},{elementCount:u*u}));this.setState({weightsTexture:s,maxWeightsTexture:l,maxWeightTransform:g,zoom:null,triPositionBuffer:new I.Buffer(o,{byteLength:48,accessor:{size:3}}),triTexCoordBuffer:new I.Buffer(o,{byteLength:48,accessor:{size:2}})})},n.updateShaders=function(o){this._createWeightsTransform(o)},n._updateMaxWeightValue=function(){var o=this.state.maxWeightTransform;o.run({parameters:{blend:!0,depthTest:!1,blendFunc:[1,1],blendEquation:32776}})},n._updateBounds=function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,a=this.context.viewport,u=[a.unproject([0,0]),a.unproject([a.width,0]),a.unproject([a.width,a.height]),a.unproject([0,a.height])].map(function(m){return m.map(Math.fround)}),s=Wo(u),l={visibleWorldBounds:s,viewportCorners:u},f=!1;if(o||!this.state.worldBounds||!jo(this.state.worldBounds,s)){var c=this._worldToCommonBounds(s),g=this._commonToWorldBounds(c);this.props.coordinateSystem===q.COORDINATE_SYSTEM.LNGLAT&&(g[1]=Math.max(g[1],-85.051129),g[3]=Math.min(g[3],85.051129),g[0]=Math.max(g[0],-360),g[2]=Math.min(g[2],360));var p=this._worldToCommonBounds(g);l.worldBounds=g,l.normalizedCommonBounds=p,f=!0}return this.setState(l),f},n._updateTextureRenderingBounds=function(){var o=this.state,a=o.triPositionBuffer,u=o.triTexCoordBuffer,s=o.normalizedCommonBounds,l=o.viewportCorners,f=this.context.viewport;a.subData(xr(l,3));var c=l.map(function(g){return Ho(f.projectPosition(g),s)});u.subData(xr(c,2))},n._updateColorTexture=function(o){var a=o.props.colorRange,u=this.state.colorTexture,s=J(a,!1,Uint8Array);u?u.setImageData({data:s,width:a.length}):u=new I.Texture2D(this.context.gl,Xe({data:s,width:a.length,height:1},Or)),this.setState({colorTexture:u})},n._updateWeightmap=function(){var o=this,a,u=this.props,s=u.radiusPixels,l=u.colorDomain,f=u.aggregation,c=this.state,g=c.weightsTransform,p=c.worldBounds,m=c.textureSize,h=c.weightsTexture,v=c.weightsScale;this.state.isWeightMapDirty=!1;var y=this._worldToCommonBounds(p,{useLayerCoordinateSystem:!0});if(l&&f==="SUM"){var O=this.context.viewport,A=O.distanceScales.metersPerUnit[2]*(y[2]-y[0])/m;this.state.colorDomain=l.map(function(T){return T*A*v})}else this.state.colorDomain=l||ri;var P={radiusPixels:s,commonBounds:y,textureWidth:m,weightsScale:v};g.update({elementCount:this.getNumInstances()}),(0,I.withParameters)(this.context.gl,{clearColor:[0,0,0,0]},function(){g.run({uniforms:P,parameters:{blend:!0,depthTest:!1,blendFunc:[1,1],blendEquation:32774},clearRenderTarget:!0,attributes:o.getAttributes(),moduleSettings:o.getModuleSettings()})}),this._updateMaxWeightValue(),h.setParameters((a={},ge(a,10240,9729),ge(a,10241,9729),a))},n._debouncedUpdateWeightmap=function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,a=this.state.updateTimer,u=this.props.debounceTimeout;o?(a=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(a),a=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),u)),this.setState({updateTimer:a})},n._worldToCommonBounds=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=a.useLayerCoordinateSystem,s=u===void 0?!1:u,l=Jo(o,4),f=l[0],c=l[1],g=l[2],p=l[3],m=this.context.viewport,h=this.state.textureSize,v=this.props.coordinateSystem,y=s&&(v===q.COORDINATE_SYSTEM.LNGLAT_OFFSETS||v===q.COORDINATE_SYSTEM.METER_OFFSETS),O=y?m.projectPosition(this.props.coordinateOrigin):[0,0],A=h*Es/m.scale,P,T;return s&&!y?(P=this.projectPosition([f,c,0]),T=this.projectPosition([g,p,0])):(P=m.projectPosition([f,c,0]),T=m.projectPosition([g,p,0])),Vo([P[0]-O[0],P[1]-O[1],T[0]-O[0],T[1]-O[1]],A,A)},n._commonToWorldBounds=function(o){var a=Jo(o,4),u=a[0],s=a[1],l=a[2],f=a[3],c=this.context.viewport,g=c.unprojectPosition([u,s]),p=c.unprojectPosition([l,f]);return g.slice(0,2).concat(p.slice(0,2))},r}($);Ht.layerName="HeatmapLayer";Ht.defaultProps=Cs;return fi(Ze);})();
732
+ `;function yn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?yn=function(r){return typeof r}:yn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},yn(e)}function ku(e,t){return Gd(e)||Kd(e,t)||Vd(e,t)||Hd()}function Hd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
733
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vd(e,t){if(e){if(typeof e=="string")return $u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $u(e,t)}}function $u(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Kd(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,a=!1,s,u;try{for(r=r.call(e);!(o=(s=r.next()).done)&&(n.push(s.value),!(t&&n.length===t));o=!0);}catch(l){a=!0,u=l}finally{try{!o&&r.return!=null&&r.return()}finally{if(a)throw u}}return n}}function Gd(e){if(Array.isArray(e))return e}function Zu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function Gt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Zu(Object(r),!0).forEach(function(n){zd(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Zu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function zd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function nt(e,t,r){return typeof Reflect<"u"&&Reflect.get?nt=Reflect.get:nt=function(o,a,s){var u=Yd(o,a);if(u){var l=Object.getOwnPropertyDescriptor(u,a);return l.get?l.get.call(s):l.value}},nt(e,t,r||e)}function Yd(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=ye(e),e!==null););return e}function kd(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Li(e,t)}function Li(e,t){return Li=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},Li(e,t)}function $d(e){var t=Qd();return function(){var n=ye(e),o;if(t){var a=ye(this).constructor;o=Reflect.construct(n,arguments,a)}else o=n.apply(this,arguments);return Zd(this,o)}}function Zd(e,t){if(t&&(yn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return qd(e)}function qd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Qd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ye(e){return ye=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},ye(e)}var Jd=2,wi={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},qu=[0,0],eg={SUM:0,MEAN:1},tg={getPosition:{type:"accessor",value:function(t){return t.position}},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:le,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},rg=["blend-minmax-webgl1","texture-formats-float32-webgl1"],ng=["texture-renderable-float32-webgl","texture-blend-float-webgl1"],ig={data:{props:["radiusPixels"]}},In=function(e){kd(r,e);var t=$d(r);function r(){var o;jd(this,r);for(var a=arguments.length,s=new Array(a),u=0;u<a;u++)s[u]=arguments[u];return o=t.call.apply(t,[this].concat(s)),o.state=void 0,o}var n=r.prototype;return n.initializeState=function(){var a=this;if(!rg.every(function(s){return a.context.device.features.has(s)})){this.setState({supported:!1}),Oe.log.error("HeatmapLayer: ".concat(this.id," is not supported on this browser"))();return}nt(ye(r.prototype),"initializeAggregationLayer",this).call(this,ig),this.setState({supported:!0,colorDomain:qu}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()},n.shouldUpdateState=function(a){var s=a.changeFlags;return s.somethingChanged},n.updateState=function(a){this.state.supported&&(nt(ye(r.prototype),"updateState",this).call(this,a),this._updateHeatmapState(a))},n._updateHeatmapState=function(a){var s=a.props,u=a.oldProps,l=this._getChangeFlags(a);(l.dataChanged||l.viewportChanged)&&(l.boundsChanged=this._updateBounds(l.dataChanged),this._updateTextureRenderingBounds()),l.dataChanged||l.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):l.viewportZoomChanged&&this._debouncedUpdateWeightmap(),s.colorRange!==u.colorRange&&this._updateColorTexture(a),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:a.context.viewport.zoom})},n.renderLayers=function(){if(!this.state.supported)return[];var a=this.state,s=a.weightsTexture,u=a.triPositionBuffer,l=a.triTexCoordBuffer,f=a.maxWeightsTexture,c=a.colorTexture,_=a.colorDomain,E=this.props,d=E.updateTriggers,h=E.intensity,p=E.threshold,g=E.aggregation,T=this.getSubLayerClass("triangle",Ui);return new T(this.getSubLayerProps({id:"triangle-layer",updateTriggers:d}),{coordinateSystem:Oe.COORDINATE_SYSTEM.DEFAULT,data:{attributes:{positions:u,texCoords:l}},vertexCount:4,maxTexture:f,colorTexture:c,aggregationMode:eg[g]||0,texture:s,intensity:h,threshold:p,colorDomain:_})},n.finalizeState=function(a){nt(ye(r.prototype),"finalizeState",this).call(this,a);var s=this.state,u=s.weightsTransform,l=s.weightsTexture,f=s.maxWeightTransform,c=s.maxWeightsTexture,_=s.triPositionBuffer,E=s.triTexCoordBuffer,d=s.colorTexture,h=s.updateTimer;u?.destroy(),l?.destroy(),f?.destroy(),c?.destroy(),_?.destroy(),E?.destroy(),d?.destroy(),h&&clearTimeout(h)},n._getAttributeManager=function(){return new Oe.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})},n._getChangeFlags=function(a){var s={},u=this.state.dimensions;s.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(a,{compareAll:!0,dimension:u.data})&&"aggregation is dirty",s.viewportChanged=a.changeFlags.viewportChanged;var l=this.state.zoom;return(!a.context.viewport||a.context.viewport.zoom!==l)&&(s.viewportZoomChanged=!0),s},n._createTextures=function(){var a=this.state,s=a.textureSize,u=a.format,l=a.type;this.setState({weightsTexture:this.context.device.createTexture(Gt({width:s,height:s,format:u,type:l},wi)),maxWeightsTexture:this.context.device.createTexture(Gt({format:u,type:l},wi))})},n._setupAttributes=function(){var a=this.getAttributeManager();a.add({positions:{size:3,type:5130,accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})},n._setupTextureParams=function(){var a=this.context.device,s=this.props.weightsTextureSize,u=Math.min(s,a.limits.maxTextureDimension2D),l=ng.every(function(d){return a.features.has(d)}),f=Wu({device:a,floatTargetSupport:l}),c=f.format,_=f.type,E=l?1:1/255;this.setState({textureSize:u,format:c,type:_,weightsScale:E}),l||Oe.log.warn("HeatmapLayer: ".concat(this.id," rendering to float texture not supported, fallingback to low precession format"))()},n.getShaders=function(a){return nt(ye(r.prototype),"getShaders",this).call(this,a==="max-weights-transform"?{vs:ju,_fs:Yu}:{vs:Gu,_fs:zu})},n._createWeightsTransform=function(){var a,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=this.state.weightsTransform,l=this.state.weightsTexture;(a=u)===null||a===void 0||a.delete(),u=new Me(this.context.device,Gt({id:"".concat(this.id,"-weights-transform"),elementCount:1,_targetTexture:l,_targetTextureVarying:"weightsTexture"},s)),this.setState({weightsTransform:u})},n._setupResources=function(){this._createTextures();var a=this.state,s=a.textureSize,u=a.weightsTexture,l=a.maxWeightsTexture,f=this.getShaders("weights-transform");this._createWeightsTransform(f);var c=this.getShaders("max-weights-transform"),_=new Me(this.context.device,Gt(Gt({id:"".concat(this.id,"-max-weights-transform"),_sourceTextures:{inTexture:u},_targetTexture:l,_targetTextureVarying:"outTexture"},c),{},{elementCount:s*s}));this.setState({weightsTexture:u,maxWeightsTexture:l,maxWeightTransform:_,zoom:null,triPositionBuffer:this.context.device.createBuffer({byteLength:48,accessor:{size:3}}),triTexCoordBuffer:this.context.device.createBuffer({byteLength:48,accessor:{size:2}})})},n.updateShaders=function(a){this._createWeightsTransform(a)},n._updateMaxWeightValue=function(){var a=this.state.maxWeightTransform;a.run({parameters:{blend:!0,depthTest:!1,blendFunc:[1,1],blendEquation:32776}})},n._updateBounds=function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,s=this.context.viewport,u=[s.unproject([0,0]),s.unproject([s.width,0]),s.unproject([s.width,s.height]),s.unproject([0,s.height])].map(function(h){return h.map(Math.fround)}),l=Uu(u),f={visibleWorldBounds:l,viewportCorners:u},c=!1;if(a||!this.state.worldBounds||!wu(this.state.worldBounds,l)){var _=this._worldToCommonBounds(l),E=this._commonToWorldBounds(_);this.props.coordinateSystem===Oe.COORDINATE_SYSTEM.LNGLAT&&(E[1]=Math.max(E[1],-85.051129),E[3]=Math.min(E[3],85.051129),E[0]=Math.max(E[0],-360),E[2]=Math.min(E[2],360));var d=this._worldToCommonBounds(E);f.worldBounds=E,f.normalizedCommonBounds=d,c=!0}return this.setState(f),c},n._updateTextureRenderingBounds=function(){var a=this.state,s=a.triPositionBuffer,u=a.triTexCoordBuffer,l=a.normalizedCommonBounds,f=a.viewportCorners,c=this.context.viewport;s.subData(Di(f,3));var _=f.map(function(E){return Xu(c.projectPosition(E),l)});u.subData(Di(_,2))},n._updateColorTexture=function(a){var s=a.props.colorRange,u=this.state.colorTexture,l=Xe(s,!1,Uint8Array);u?u.setImageData({data:l,width:s.length}):u=this.context.device.createTexture(Gt({data:l,width:s.length,height:1},wi)),this.setState({colorTexture:u})},n._updateWeightmap=function(){var a=this,s=this.props,u=s.radiusPixels,l=s.colorDomain,f=s.aggregation,c=this.state,_=c.worldBounds,E=c.textureSize,d=c.weightsScale,h=this.state.weightsTransform;this.state.isWeightMapDirty=!1;var p=this._worldToCommonBounds(_,{useLayerCoordinateSystem:!0});if(l&&f==="SUM"){var g=this.context.viewport,T=g.distanceScales.metersPerUnit[2]*(p[2]-p[0])/E;this.state.colorDomain=l.map(function(R){return R*T*d})}else this.state.colorDomain=l||qu;var m={radiusPixels:u,commonBounds:p,textureWidth:E,weightsScale:d};h.update({elementCount:this.getNumInstances()}),Y(this.context.gl,{clearColor:[0,0,0,0]},function(){h.run({uniforms:m,parameters:{blend:!0,depthTest:!1,blendFunc:[1,1],blendEquation:32774},clearRenderTarget:!0,attributes:a.getAttributes(),moduleSettings:a.getModuleSettings()})}),this._updateMaxWeightValue()},n._debouncedUpdateWeightmap=function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,s=this.state.updateTimer,u=this.props.debounceTimeout;a?(s=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(s),s=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),u)),this.setState({updateTimer:s})},n._worldToCommonBounds=function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=s.useLayerCoordinateSystem,l=u===void 0?!1:u,f=ku(a,4),c=f[0],_=f[1],E=f[2],d=f[3],h=this.context.viewport,p=this.state.textureSize,g=this.props.coordinateSystem,T=l&&(g===Oe.COORDINATE_SYSTEM.LNGLAT_OFFSETS||g===Oe.COORDINATE_SYSTEM.METER_OFFSETS),m=T?h.projectPosition(this.props.coordinateOrigin):[0,0],R=p*Jd/h.scale,S,y;return l&&!T?(S=this.projectPosition([c,_,0]),y=this.projectPosition([E,d,0])):(S=h.projectPosition([c,_,0]),y=h.projectPosition([E,d,0])),Lu([S[0]-m[0],S[1]-m[1],y[0]-m[0],y[1]-m[1]],R,R)},n._commonToWorldBounds=function(a){var s=ku(a,4),u=s[0],l=s[1],f=s[2],c=s[3],_=this.context.viewport,E=_.unprojectPosition([u,l]),d=_.unprojectPosition([f,c]);return E.slice(0,2).concat(d.slice(0,2))},r}(ge);In.layerName="HeatmapLayer";In.defaultProps=tg;return ol(Er);})();
579
734
  return __exports__;
580
735
  });