@mapvx/web-components 0.1.2 → 0.1.3
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.
- package/dist/cjs/{base-floor-selector-DFnDEEM3.cjs → base-floor-selector-6B_D7uUw.cjs} +2 -2
- package/dist/cjs/{class-map-ChMAfTFe.cjs → class-map-CfJw8pY6.cjs} +2 -2
- package/dist/cjs/{compact-floor-selector-BCeDL8I5.cjs → compact-floor-selector-CPK6sXBk.cjs} +2 -2
- package/dist/cjs/{consume-CKorNsgJ.cjs → consume-B4K_oiFc.cjs} +2 -2
- package/dist/cjs/{custom-map-1gDZnqoR.cjs → custom-map-CfhrBuF7.cjs} +3 -3
- package/dist/cjs/{floor-selector-BWaCcDvR.cjs → floor-selector-rW48Tktb.cjs} +2 -2
- package/dist/cjs/{geojson-layer-_4ssXrG_.cjs → geojson-layer-wtQbiowp.cjs} +2 -2
- package/dist/cjs/{index-DM2GszaW.cjs → index-BAYbrXBp.cjs} +2 -2
- package/dist/cjs/{index-CpmSQzi7.cjs → index-DAac9HVL.cjs} +2 -2
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/map-view-with-modal.cjs +1 -1
- package/dist/cjs/qr-modal-fSPvpyzj.cjs +16 -0
- package/dist/cjs/{route-options-BFRImfBY.cjs → route-options-BjMH6A43.cjs} +2 -2
- package/dist/cjs/route-view-totems.cjs +1 -1
- package/dist/cjs/{sdk-controller-C5n2dJ1u.cjs → sdk-controller-5LmYQQhJ.cjs} +3 -3
- package/dist/es/assets/{compact-floor-selector-T1-T8JtV.js → compact-floor-selector-WL6DewCc.js} +2 -2
- package/dist/es/assets/{components-P8ZEdF4n.js → components-BfTs1Lia.js} +9 -9
- package/dist/es/assets/{geojson-layer-Cj_7zg8v.js → geojson-layer-CeMb7DTQ.js} +2 -2
- package/dist/es/assets/globe-viewport-CFdegSgy.js +4 -0
- package/dist/es/assets/{index-CNxIfV8m.js → index-D4Krpv5a.js} +2 -2
- package/dist/es/assets/{index-DS6Va1rg.js → index-wdE7uK4l.js} +2 -2
- package/dist/es/assets/{map-view-with-modal-Z--_Drda.js → map-view-with-modal-JYZY7d5R.js} +2 -2
- package/dist/es/assets/{route-view-totems-DoAr4DQV.js → route-view-totems-Dvggb-ZM.js} +4 -4
- package/dist/es/assets/{utils-BCoCXmhx.js → utils-B4ksZYyJ.js} +3 -3
- package/dist/es/index.js +1 -1
- package/dist/es/route-view-totems.js +1 -1
- package/dist/iife/map-view-with-modal.js +2 -2
- package/dist/iife/route-view-totems.js +2 -2
- package/package.json +1 -1
- package/dist/cjs/qr-modal-BXLeCQeI.cjs +0 -20
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const t=require("./webgl-developer-tools-DyDR0yGE.cjs"),e=require("./webgl-device-DikFjUoh.cjs"),n=require("./sdk-controller-C5n2dJ1u.cjs");function i(t){return function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(t)||function(t){return!!Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}(t)}function o(t){const{input:e,inputChannels:n,output:i}={};if(!e)return"#version 300 es\nout vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}";if(!n)throw new Error("inputChannels");return`#version 300 es\nin ${function(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}(n)} ${e};\nout vec4 ${i};\nvoid main() {\n ${i} = ${function(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}(e,n)};\n}`}function s(t,e=[],n=0){const i=Math.fround(t),o=t-i;return e[n]=i,e[n+1]=o,e}function r(t,e=!0){return t??e}function a(t=[0,0,0],e=!0){return e?t.map(t=>t/255):[...t]}const l="\nlayout(std140) uniform fp64arithmeticUniforms {\n uniform float ONE;\n uniform float SPLIT;\n} fp64;\n\n/*\nAbout LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n\nThe purpose of this workaround is to prevent shader compilers from\noptimizing away necessary arithmetic operations by swapping their sequences\nor transform the equation to some 'equivalent' form.\n\nThese helpers implement Dekker/Veltkamp-style error tracking. If the compiler\nfolds constants or reassociates the arithmetic, the high/low split can stop\ntracking the rounding error correctly. That failure mode tends to look fine in\nsimple coordinate setup, but then breaks down inside iterative arithmetic such\nas fp64 Mandelbrot loops.\n\nThe method is to multiply an artifical variable, ONE, which will be known to\nthe compiler to be 1 only at runtime. The whole expression is then represented\nas a polynomial with respective to ONE. In the coefficients of all terms, only one a\nand one b should appear\n\nerr = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE\n*/\n\nfloat prevent_fp64_optimization(float value) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n return value + fp64.ONE * 0.0;\n#else\n return value;\n#endif\n}\n\n// Divide float number to high and low floats to extend fraction bits\nvec2 split(float a) {\n // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker\n // split into a constant expression and reassociate the recovery steps.\n float split = prevent_fp64_optimization(fp64.SPLIT);\n float t = prevent_fp64_optimization(a * split);\n float temp = t - a;\n float a_hi = t - temp;\n float a_lo = a - a_hi;\n return vec2(a_hi, a_lo);\n}\n\n// Divide float number again when high float uses too many fraction bits\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\n\n// Special sum operation when a > b\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * fp64.ONE;\n float err = b - (sum - a) * fp64.ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\n\n// General sum operation\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *\n a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend\n // on the split terms and cross terms staying in the original evaluation\n // order. If the compiler folds or reassociates them, the low part tends to\n // collapse to zero or NaN on some drivers.\n float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);\n float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);\n float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);\n float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err1 = (highProduct - prod) * fp64.ONE;\n float err2 = crossProduct1 * fp64.ONE * fp64.ONE;\n float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;\n float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err1 = highProduct - prod;\n float err2 = crossProduct1;\n float err3 = crossProduct2;\n float err4 = lowProduct;\n#endif\n float err = ((err1 + err2) + err3) + err4;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n // y component is for the error\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * fp64.ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",c={name:"fp64arithmetic",source:"struct Fp64ArithmeticUniforms {\n ONE: f32,\n SPLIT: f32,\n};\n\n@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;\n\nfn fp64_nan(seed: f32) -> f32 {\n let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);\n return bitcast<f32>(nanBits);\n}\n\nfn fp64_runtime_zero() -> f32 {\n return fp64arithmetic.ONE * 0.0;\n}\n\nfn prevent_fp64_optimization(value: f32) -> f32 {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n return value + fp64_runtime_zero();\n#else\n return value;\n#endif\n}\n\nfn split(a: f32) -> vec2f {\n let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());\n let t = prevent_fp64_optimization(a * splitValue);\n let temp = prevent_fp64_optimization(t - a);\n let aHi = prevent_fp64_optimization(t - temp);\n let aLo = prevent_fp64_optimization(a - aHi);\n return vec2f(aHi, aLo);\n}\n\nfn split2(a: vec2f) -> vec2f {\n var b = split(a.x);\n b.y = b.y + a.y;\n return b;\n}\n\nfn quickTwoSum(a: f32, b: f32) -> vec2f {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);\n let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);\n#else\n let sum = prevent_fp64_optimization(a + b);\n let err = prevent_fp64_optimization(b - (sum - a));\n#endif\n return vec2f(sum, err);\n}\n\nfn twoSum(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a + b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) +\n prevent_fp64_optimization(b - v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSub(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a - b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) -\n prevent_fp64_optimization(b + v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSqr(a: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * a);\n let aFp64 = split(a);\n let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);\n let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);\n let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err =\n (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +\n crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +\n lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n#else\n let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);\n#endif\n return vec2f(prod, err);\n}\n\nfn twoProd(a: f32, b: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * b);\n let aFp64 = split(a);\n let bFp64 = split(b);\n let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);\n let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);\n let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);\n let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err1 = (highProduct - prod) * fp64arithmetic.ONE;\n let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err4 =\n lowProduct *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE;\n#else\n let err1 = highProduct - prod;\n let err2 = crossProduct1;\n let err3 = crossProduct2;\n let err4 = lowProduct;\n#endif\n let err12InputA = prevent_fp64_optimization(err1);\n let err12InputB = prevent_fp64_optimization(err2);\n let err12 = prevent_fp64_optimization(err12InputA + err12InputB);\n let err123InputA = prevent_fp64_optimization(err12);\n let err123InputB = prevent_fp64_optimization(err3);\n let err123 = prevent_fp64_optimization(err123InputA + err123InputB);\n let err1234InputA = prevent_fp64_optimization(err123);\n let err1234InputB = prevent_fp64_optimization(err4);\n let err = prevent_fp64_optimization(err1234InputA + err1234InputB);\n return vec2f(prod, err);\n}\n\nfn sum_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSum(a.x, b.x);\n let t = twoSum(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn sub_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSub(a.x, b.x);\n let t = twoSub(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn mul_fp64(a: vec2f, b: vec2f) -> vec2f {\n var prod = twoProd(a.x, b.x);\n let crossProduct1 = prevent_fp64_optimization(a.x * b.y);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct1);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n let crossProduct2 = prevent_fp64_optimization(a.y * b.x);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct2);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nfn div_fp64(a: vec2f, b: vec2f) -> vec2f {\n let xn = prevent_fp64_optimization(1.0 / b.x);\n let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));\n let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);\n let prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nfn sqrt_fp64(a: vec2f) -> vec2f {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2f(0.0, 0.0);\n }\n if (a.x < 0.0) {\n let nanValue = fp64_nan(a.x);\n return vec2f(nanValue, nanValue);\n }\n\n let x = prevent_fp64_optimization(1.0 / sqrt(a.x));\n let yn = prevent_fp64_optimization(a.x * x);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;\n#else\n let ynSqr = twoSqr(yn);\n#endif\n let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);\n let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2f(yn, 0.0), prod);\n#endif\n}\n",fs:l,vs:l,defaultUniforms:{ONE:1,SPLIT:4097},uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:s,fp64LowPart:function(t){return t-Math.fround(t)},fp64ifyMatrix4:function(t){const e=new Float32Array(32);for(let n=0;n<4;++n)for(let i=0;i<4;++i){const o=4*n+i;s(t[4*i+n],e,2*o)}return e}},u="layout(std140) uniform floatColorsUniforms {\n float useByteColors;\n} floatColors;\n\nvec3 floatColors_normalize(vec3 inputColor) {\n return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 floatColors_normalize(vec4 inputColor) {\n return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 floatColors_premultiplyAlpha(vec4 inputColor) {\n return vec4(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nvec4 floatColors_unpremultiplyAlpha(vec4 inputColor) {\n return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0);\n}\n\nvec4 floatColors_premultiply_alpha(vec4 inputColor) {\n return floatColors_premultiplyAlpha(inputColor);\n}\n\nvec4 floatColors_unpremultiply_alpha(vec4 inputColor) {\n return floatColors_unpremultiplyAlpha(inputColor);\n}\n",d={name:"floatColors",props:{},uniforms:{},vs:u,fs:u,source:"struct floatColorsUniforms {\n useByteColors: f32\n};\n\n@group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms;\n\nfn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> {\n return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);\n}\n\nfn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> {\n return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);\n}\n\nfn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nfn floatColors_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return select(\n vec4<f32>(0.0),\n vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a),\n inputColor.a > 0.0\n );\n}\n\nfn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return floatColors_premultiplyAlpha(inputColor);\n}\n\nfn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return floatColors_unpremultiplyAlpha(inputColor);\n}\n",uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}},f={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},vs:"layout(std140) uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useByteColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nout vec4 picking_vRGBcolor_Avalid;\n\n// Normalize unsigned byte color to 0-1 range\nvec3 picking_normalizeColor(vec3 color) {\n return picking.useByteColors > 0.5 ? color / 255.0 : color;\n}\n\n// Normalize unsigned byte color to 0-1 range\nvec4 picking_normalizeColor(vec4 color) {\n return picking.useByteColors > 0.5 ? color / 255.0 : color;\n}\n\nbool picking_isColorZero(vec3 color) {\n return dot(color, vec3(1.0)) < 0.00001;\n}\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.00001;\n}\n\n// Check if this vertex is highlighted \nbool isVertexHighlighted(vec3 vertexColor) {\n vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n return\n bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\n\n// Set the current picking color\nvoid picking_setPickingColor(vec3 pickingColor) {\n pickingColor = picking_normalizeColor(pickingColor);\n\n if (bool(picking.isActive)) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!bool(picking.isAttribute)) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec2 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec3 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n",fs:"layout(std140) uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useByteColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n // If we are still picking, we don't highlight\n if (picking.isActive > 0.5) {\n return color;\n }\n\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n // Blend in highlight color based on its alpha value\n float highLightAlpha = picking.highlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (bool(picking.isActive)) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highlightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highlightColor);\n}\n",getUniforms:function(t={},e){const n={},i=r(t.useByteColors,!0);if(void 0===t.highlightedObjectColor);else if(null===t.highlightedObjectColor)n.isHighlightActive=!1;else{n.isHighlightActive=!0;const e=t.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=e}t.highlightColor&&(n.highlightColor=function(t,e=!0){const n=a(t.slice(0,3),e),i=Number.isFinite(t[3]),o=i?t[3]:1;return[n[0],n[1],n[2],e&&i?o/255:o]}(t.highlightColor,i));void 0!==t.isActive&&(n.isActive=Boolean(t.isActive),n.isAttribute=Boolean(t.isAttribute));void 0!==t.useByteColors&&(n.useByteColors=Boolean(t.useByteColors));return n}};class p extends t.Resource{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(t,e){super(t,e,p.defaultProps),this.shaderLayout=e.shaderLayout}static defaultProps={...t.Resource.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}class h{static defaultProps={...e.RenderPipeline.defaultProps};static getDefaultPipelineFactory(t){const e=t.getModuleData("@luma.gl/core");return e.defaultPipelineFactory||=new h(t),e.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(t){this.device=t}createRenderPipeline(n){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(n);const i={...e.RenderPipeline.defaultProps,...n},o=this._renderPipelineCache,s=this._hashRenderPipeline(i);let r=o[s]?.resource;if(r)o[s].useCount++,this.device.props.debugFactories&&t.log.log(3,`${this}: ${o[s].resource} reused, count=${o[s].useCount}, (id=${n.id})`)();else{const e="webgl"===this.device.type&&this.device.props._sharePipelines?this.createSharedRenderPipeline(i):void 0;r=this.device.createRenderPipeline({...i,id:i.id?`${i.id}-cached`:t.uid("unnamed-cached"),_sharedRenderPipeline:e}),r.hash=s,o[s]={resource:r,useCount:1},this.device.props.debugFactories&&t.log.log(3,`${this}: ${r} created, count=${o[s].useCount}`)()}return r}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);const n={...p.defaultProps,...e},i=this._computePipelineCache,o=this._hashComputePipeline(n);let s=i[o]?.resource;return s?(i[o].useCount++,this.device.props.debugFactories&&t.log.log(3,`${this}: ${i[o].resource} reused, count=${i[o].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...n,id:n.id?`${n.id}-cached`:void 0}),s.hash=o,i[o]={resource:s,useCount:1},this.device.props.debugFactories&&t.log.log(3,`${this}: ${s} created, count=${i[o].useCount}`)()),s}release(e){if(!this.device.props._cachePipelines)return void e.destroy();const n=this._getCache(e),i=e.hash;n[i].useCount--,0===n[i].useCount?(this._destroyPipeline(e),this.device.props.debugFactories&&t.log.log(3,`${this}: ${e} released and destroyed`)()):n[i].useCount<0?(t.log.error(`${this}: ${e} released, useCount < 0, resetting`)(),n[i].useCount=0):this.device.props.debugFactories&&t.log.log(3,`${this}: ${e} released, count=${n[i].useCount}`)()}createSharedRenderPipeline(t){const e=this._hashSharedRenderPipeline(t);let n=this._sharedRenderPipelineCache[e];if(!n){n={resource:this.device._createSharedRenderPipelineWebGL(t),useCount:0},this._sharedRenderPipelineCache[e]=n}return n.useCount++,n.resource}releaseSharedRenderPipeline(t){if(!t.sharedRenderPipeline)return;const e=this._hashSharedRenderPipeline(t.sharedRenderPipeline.props),n=this._sharedRenderPipelineCache[e];n&&(n.useCount--,0===n.useCount&&(n.resource.destroy(),delete this._sharedRenderPipelineCache[e]))}_destroyPipeline(t){const n=this._getCache(t);return!!this.device.props._destroyPipelines&&(delete n[t.hash],t.destroy(),t instanceof e.RenderPipeline&&this.releaseSharedRenderPipeline(t),!0)}_getCache(t){let n;if(t instanceof p&&(n=this._computePipelineCache),t instanceof e.RenderPipeline&&(n=this._renderPipelineCache),!n)throw new Error(`${this}`);if(!n[t.hash])throw new Error(`${this}: ${t} matched incorrect entry`);return n}_hashComputePipeline(t){const{type:e}=this.device;return`${e}/C/${this._getHash(t.shader.source)}SL${this._getHash(JSON.stringify(t.shaderLayout))}`}_hashRenderPipeline(t){const e=t.vs?this._getHash(t.vs.source):0,n=t.fs?this._getHash(t.fs.source):0,i=this._getWebGLVaryingHash(t),o=this._getHash(JSON.stringify(t.shaderLayout)),s=this._getHash(JSON.stringify(t.bufferLayout)),{type:r}=this.device;if("webgl"===r){const a=this._getHash(JSON.stringify(t.parameters));return`${r}/R/${e}/${n}V${i}T${t.topology}P${a}SL${o}BL${s}`}{const a=this._getHash(JSON.stringify({vertexEntryPoint:t.vertexEntryPoint,fragmentEntryPoint:t.fragmentEntryPoint})),l=this._getHash(JSON.stringify(t.parameters)),c=this._getWebGPUAttachmentHash(t);return`${r}/R/${e}/${n}V${i}T${t.topology}EP${a}P${l}SL${o}BL${s}A${c}`}}_hashSharedRenderPipeline(t){return`webgl/S/${t.vs?this._getHash(t.vs.source):0}/${t.fs?this._getHash(t.fs.source):0}V${this._getWebGLVaryingHash(t)}`}_getHash(t){return void 0===this._hashes[t]&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}_getWebGLVaryingHash(t){const{varyings:e=[],bufferMode:n=null}=t;return this._getHash(JSON.stringify({varyings:e,bufferMode:n}))}_getWebGPUAttachmentHash(t){const e=t.colorAttachmentFormats??[this.device.preferredColorFormat],n=t.parameters?.depthWriteEnabled?t.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:e,depthStencilAttachmentFormat:n}))}}class g{static defaultProps={...e.Shader.defaultProps};static getDefaultShaderFactory(t){const e=t.getModuleData("@luma.gl/core");return e.defaultShaderFactory||=new g(t),e.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(t){this.device=t}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);const n=this._hashShader(e);let i=this._cache[n];if(i)i.useCount++,this.device.props.debugFactories&&t.log.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{const o=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[n]=i={resource:o,useCount:1},this.device.props.debugFactories&&t.log.log(3,`${this}: Created new shader ${o.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders)return void e.destroy();const n=this._hashShader(e),i=this._cache[n];if(i)if(i.useCount--,0===i.useCount)this.device.props._destroyShaders&&(delete this._cache[n],i.resource.destroy(),this.device.props.debugFactories&&t.log.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&t.log.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(t){return`${t.stage}:${t.source}`}}function m(t,n={}){const i={...t},o=n.layout??"std140",s={};let r=0;for(const[e,a]of Object.entries(i))r=x(s,e,a,r,o);return r=e.alignTo(r,b(i,o)),{layout:o,byteLength:4*r,uniformTypes:i,fields:s}}function v(t,n){const i=e.resolveVariableShaderTypeAlias(t),o=e.getVariableShaderTypeInfo(i),s=/^mat(\d)x(\d)<.+>$/.exec(i);if(s){const t=Number(s[1]),r=Number(s[2]),a=P(r,i,o.type),l=function(t,n,i){return"std140"===i?4:e.alignTo(t,n)}(a.size,a.alignment,n);return{alignment:a.alignment,size:t*l,components:t*r,columns:t,rows:r,columnStride:l,shaderType:i,type:o.type}}const r=/^vec(\d)<.+>$/.exec(i);return r?P(Number(r[1]),i,o.type):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:i,type:o.type}}function y(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function x(t,n,i,o,s){if("string"==typeof i){const r=v(i,s),a=e.alignTo(o,r.alignment);return t[n]={offset:a,...r},a+r.size}if(Array.isArray(i)){if(Array.isArray(i[0]))throw new Error(`Nested arrays are not supported for ${n}`);const r=i[0],a=i[1],l=C(r,s),c=e.alignTo(o,b(i,s));for(let e=0;e<a;e++)x(t,`${n}[${e}]`,r,c+e*l,s);return c+l*a}if(y(i)){const r=b(i,s);let a=e.alignTo(o,r);for(const[e,o]of Object.entries(i))a=x(t,`${n}.${e}`,o,a,s);return e.alignTo(a,r)}throw new Error(`Unsupported CompositeShaderType for ${n}`)}function _(t,n){if("string"==typeof t)return v(t,n).size;if(Array.isArray(t)){const e=t[0],i=t[1];if(Array.isArray(e))throw new Error("Nested arrays are not supported");return C(e,n)*i}let i=0;for(const o of Object.values(t)){const t=o;i=e.alignTo(i,b(t,n)),i+=_(t,n)}return e.alignTo(i,b(t,n))}function b(t,e){if("string"==typeof t)return v(t,e).alignment;if(Array.isArray(t)){const n=b(t[0],e);return L(e)?Math.max(n,4):n}let n=1;for(const i of Object.values(t)){const t=b(i,e);n=Math.max(n,t)}return function(t){return"std140"===t||"wgsl-uniform"===t}(e)?Math.max(n,4):n}function P(t,e,n,i){return{alignment:2===t?2:4,size:3===t?3:t,components:t,columns:1,rows:t,columnStride:3===t?3:t,shaderType:e,type:n}}function C(t,n){return function(t,n,i){return e.alignTo(t,L(i)?4:n)}(_(t,n),b(t,n),n)}function L(t){return"std140"===t||"wgsl-uniform"===t}function w(t){return Array.isArray(t)?0===t.length||"number"==typeof t[0]:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(t)}class S{layout;constructor(t){this.layout=t}has(t){return Boolean(this.layout.fields[t])}get(t){const e=this.layout.fields[t];return e?{offset:e.offset,size:e.size}:void 0}getFlatUniformValues(t){const e={};for(const[n,i]of Object.entries(t)){const t=this.layout.uniformTypes[n];t?this._flattenCompositeValue(e,n,t,i):this.layout.fields[n]&&(e[n]=i)}return e}getData(t){const n=e.getScratchArrayBuffer(this.layout.byteLength);new Uint8Array(n,0,this.layout.byteLength).fill(0);const i={i32:new Int32Array(n),u32:new Uint32Array(n),f32:new Float32Array(n),f16:new Uint16Array(n)},o=this.getFlatUniformValues(t);for(const[e,s]of Object.entries(o))this._writeLeafValue(i,e,s);return new Uint8Array(n,0,this.layout.byteLength)}_flattenCompositeValue(e,n,i,o){if(void 0!==o)if("string"==typeof i||this.layout.fields[n])e[n]=o;else{if(Array.isArray(i)){const s=i[0],r=i[1];if(Array.isArray(s))throw new Error(`Nested arrays are not supported for ${n}`);if("string"==typeof s&&w(o))return void this._flattenPackedArray(e,n,s,r,o);if(!Array.isArray(o))return void t.log.warn(`Unsupported uniform array value for ${n}:`,o)();for(let t=0;t<Math.min(o.length,r);t++){const i=o[t];void 0!==i&&this._flattenCompositeValue(e,`${n}[${t}]`,s,i)}return}if(y(i)&&function(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}(o))for(const[t,s]of Object.entries(o)){if(void 0===s)continue;const o=`${n}.${t}`;this._flattenCompositeValue(e,o,i[t],s)}else t.log.warn(`Unsupported uniform value for ${n}:`,o)()}}_flattenPackedArray(t,e,n,i,o){const s=o,r=v(n,this.layout.layout).components;for(let a=0;a<i;a++){const n=a*r;if(n>=s.length)break;t[`${e}[${a}]`]=1===r?Number(s[n]):A(o,n,n+r)}}_writeLeafValue(e,n,i){const o=this.layout.fields[n];if(!o)return void t.log.warn(`Uniform ${n} not found in layout`)();const{type:s,components:r,columns:a,rows:l,offset:c,columnStride:u}=o,d=e[s];if(1===r)return void(d[c]=Number(i));const f=i;if(1===a){for(let t=0;t<r;t++)d[c+t]=Number(f[t]??0);return}let p=0;for(let t=0;t<a;t++){const e=c+t*u;for(let t=0;t<l;t++)d[e+t]=Number(f[p++]??0)}}}function A(t,e,n){return Array.prototype.slice.call(t,e,n)}class O{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(t){if(this.name=t?.name||"unnamed",t?.name&&t?.shaderLayout){const e=t?.shaderLayout.bindings?.find(e=>"uniform"===e.type&&e.name===t?.name);if(!e)throw new Error(t?.name);const n=e;for(const t of n.uniforms||[])this.bindingLayout[t.name]=t}}setUniforms(t){for(const[e,n]of Object.entries(t))this._setUniform(e,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${e}=${n}`)}setNeedsRedraw(t){this.needsRedraw=this.needsRedraw||t}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(t,e){var n;(function(t,e,n=16){if(t===e)return!0;const i=t,o=e;if(!w(i)||!w(o))return!1;if(i.length!==o.length)return!1;const s=Math.min(n,128);if(i.length>s)return!1;for(let r=0;r<i.length;++r)if(o[r]!==i[r])return!1;return!0})(this.uniforms[t],e)||(this.uniforms[t]=w(n=e)?n.slice():n,this.modifiedUniforms[t]=!0,this.modified=!0)}}class T{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(t,e){this.device=t;for(const[n,i]of Object.entries(e)){const e=n,o=m(i.uniformTypes??{},{layout:i.layout??I(t)}),s=new S(o);this.shaderBlockLayouts.set(e,o),this.shaderBlockWriters.set(e,s);const r=new O({name:n});r.setUniforms(s.getFlatUniformValues(i.defaultUniforms||{})),this.uniformBlocks.set(e,r)}}destroy(){for(const t of this.uniformBuffers.values())t.destroy()}setUniforms(t){for(const[e,n]of Object.entries(t)){const t=e,i=this.shaderBlockWriters.get(t),o=i?.getFlatUniformValues(n||{});this.uniformBlocks.get(t)?.setUniforms(o||{})}this.updateUniformBuffers()}getUniformBufferByteLength(t){const e=this.shaderBlockLayouts.get(t)?.byteLength||0;return Math.max(e,1024)}getUniformBufferData(t){const e=this.uniformBlocks.get(t)?.getAllUniforms()||{},n=this.shaderBlockWriters.get(t);return n?.getData(e)||new Uint8Array(0)}createUniformBuffer(e,n){n&&this.setUniforms(n);const i=this.getUniformBufferByteLength(e),o=this.device.createBuffer({usage:t.Buffer.UNIFORM|t.Buffer.COPY_DST,byteLength:i}),s=this.getUniformBufferData(e);return o.write(s),o}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){const n=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:t.Buffer.UNIFORM|t.Buffer.COPY_DST,byteLength:n});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||=n}return e&&t.log.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){const n=this.uniformBlocks.get(e);let i=this.uniformBuffers.get(e),o=!1;if(i&&n?.needsRedraw){o||=n.needsRedraw;const s=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i?.write(s);const r=this.uniformBlocks.get(e)?.getAllUniforms();t.log.log(4,`Writing to uniform buffer ${String(e)}`,s,r)()}return o}}function I(t){return"webgpu"===t.type?"wgsl-uniform":"std140"}const E="precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct UniformLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nlayout(std140) uniform lightingUniforms {\n int enabled;\n int directionalLightCount;\n int pointLightCount;\n int spotLightCount;\n vec3 ambientColor;\n UniformLight lights[5];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n UniformLight light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nSpotLight lighting_getSpotLight(int index) {\n UniformLight light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n UniformLight light =\n lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfloat getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {\n vec3 light_direction = normalize(positionWorldspace - spotLight.position);\n float coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), light_direction)\n );\n float distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n\n// #endif\n",M={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[{color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},5]},defaultUniforms:B(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:"// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nconst MAX_LIGHTS: i32 = 5;\n\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct UniformLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n directionalLightCount: i32,\n pointLightCount: i32,\n spotLightCount: i32,\n ambientColor: vec3<f32>,\n lights: array<UniformLight, 5>,\n};\n\n@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n let light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nfn lighting_getSpotLight(index: i32) -> SpotLight {\n let light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {\n let lightDirection = normalize(positionWorldspace - spotLight.position);\n let coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), lightDirection)\n );\n let distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n",vs:E,fs:E,getUniforms:function(t,e={}){if(!(t=t?{...t}:t))return B();t.lights&&(t={...t,...R(t.lights),lights:void 0});const{useByteColors:n,ambientLight:i,pointLights:o,spotLights:s,directionalLights:r}=t||{};if(!(i||o&&o.length>0||s&&s.length>0||r&&r.length>0))return{...B(),enabled:0};const a={...B(),...z({useByteColors:n,ambientLight:i,pointLights:o,spotLights:s,directionalLights:r})};void 0!==t.enabled&&(a.enabled=t.enabled?1:0);return a}};function z({useByteColors:e,ambientLight:n,pointLights:i=[],spotLights:o=[],directionalLights:s=[]}){const r=k();let a=0,l=0,c=0,u=0;for(const t of i){if(a>=5)break;r[a]={...r[a],color:F(t,e),position:t.position,attenuation:t.attenuation||[1,0,0]},a++,l++}for(const t of o){if(a>=5)break;r[a]={...r[a],color:F(t,e),position:t.position,direction:t.direction,attenuation:t.attenuation||[1,0,0],coneCos:N(t)},a++,c++}for(const t of s){if(a>=5)break;r[a]={...r[a],color:F(t,e),direction:t.direction},a++,u++}return i.length+o.length+s.length>5&&t.log.warn("MAX_LIGHTS exceeded, truncating to 5")(),{ambientColor:F(n,e),directionalLightCount:u,pointLightCount:l,spotLightCount:c,lights:r}}function R(t){const e={pointLights:[],spotLights:[],directionalLights:[]};for(const n of t||[])switch(n.type){case"ambient":e.ambientLight=n;break;case"directional":e.directionalLights?.push(n);break;case"point":e.pointLights?.push(n);break;case"spot":e.spotLights?.push(n)}return e}function F(t={},e){const{color:n=[0,0,0],intensity:i=1}=t;return a(n,r(e,!0)).map(t=>t*i)}function B(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:k()}}function k(){return Array.from({length:5},()=>({color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}))}function N(t){const e=t.innerConeAngle??0,n=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(n)]}const D="layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n",U="layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (material.unlit) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.spotLightCount; i++) {\n SpotLight spotLight = lighting_getSpotLight(i);\n vec3 light_position_worldspace = spotLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.directionalLightCount; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n",j="struct phongMaterialUniforms {\n unlit: u32,\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (\n lambertian * phongMaterial.diffuse * surfaceColor +\n specular * floatColors_normalize(phongMaterial.specularColor)\n ) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (phongMaterial.unlit != 0u) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n } \n \n return lightColor;\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled != 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n",G={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:U.replace("phongMaterial","gouraudMaterial"),fs:D.replace("phongMaterial","gouraudMaterial"),source:j.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[M,d],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:[38.25,38.25,38.25]},getUniforms:t=>({...G.defaultUniforms,...t})},V={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[M,d],source:j,vs:D,fs:U,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:[38.25,38.25,38.25]},getUniforms:t=>({...V.defaultUniforms,...t})},W={name:"color",dependencies:[],source:"\n\n@must_use\nfn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {\n return vec4(fragColor.rgb * fragColor.a, fragColor.a); \n};\n",getUniforms:t=>({})},$={name:"project32",dependencies:[t.project],source:"// Define a structure to hold both the clip-space position and the common position.\nstruct ProjectResult {\n clipPosition: vec4<f32>,\n commonPosition: vec4<f32>,\n};\n\n// This function mimics the GLSL version with the 'out' parameter by returning both values.\nfn project_position_to_clipspace_and_commonspace(\n position: vec3<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> ProjectResult {\n // Compute the projected position.\n let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low);\n\n // Start with the provided offset.\n var finalOffset: vec3<f32> = offset;\n\n // Get whether a rotation is needed and the rotation matrix.\n let rotationResult = project_needs_rotation(projectedPosition);\n\n // If rotation is needed, update the offset.\n if (rotationResult.needsRotation) {\n finalOffset = rotationResult.transform * offset;\n }\n\n // Compute the common position.\n let commonPosition: vec4<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0);\n\n // Convert to clip-space.\n let clipPosition: vec4<f32> = project_common_position_to_clipspace(commonPosition);\n\n return ProjectResult(clipPosition, commonPosition);\n}\n\n// A convenience overload that returns only the clip-space position.\nfn project_position_to_clipspace(\n position: vec3<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> vec4<f32> {\n return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;\n}\n",vs:"vec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"},H={...f,source:"struct pickingUniforms {\n isActive: f32,\n isAttribute: f32,\n isHighlightActive: f32,\n useByteColors: f32,\n highlightedObjectColor: vec3<f32>,\n highlightColor: vec4<f32>,\n};\n\n@group(0) @binding(auto) var<uniform> picking: pickingUniforms;\n\nfn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {\n return select(color, color / 255.0, picking.useByteColors > 0.5);\n}\n\nfn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {\n return select(color, color / 255.0, picking.useByteColors > 0.5);\n}\n\nfn picking_isColorZero(color: vec3<f32>) -> bool {\n return dot(color, vec3<f32>(1.0)) < 0.00001;\n}\n\nfn picking_isColorValid(color: vec3<f32>) -> bool {\n return dot(color, vec3<f32>(1.0)) > 0.00001;\n}\n",defaultUniforms:{...f.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n ","vs:DECKGL_FILTER_COLOR":"\n picking_setPickingColor(geometry.pickingColor);\n ","fs:DECKGL_FILTER_COLOR":{order:99,injection:"\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n "}}},Y=[0,0,0];function K(e,n,i=!1){const o=n.projectPosition(e);if(i&&n instanceof t.WebMercatorViewport){const[t,i,s=0]=e,r=n.getDistanceScales([t,i]);o[2]=s*r.unitsPerMeter[2]}return o}function q(e,{viewport:n,modelMatrix:i,coordinateSystem:o,coordinateOrigin:s,offsetMode:r}){let[a,l,c=0]=e;switch(i&&([a,l,c]=t.transformMat4([],[a,l,c,1],i)),o){case"default":return q(e,{viewport:n,modelMatrix:i,coordinateSystem:n.isGeospatial?"lnglat":"cartesian",coordinateOrigin:s,offsetMode:r});case"lnglat":return K([a,l,c],n,r);case"lnglat-offsets":return K([a+s[0],l+s[1],c+(s[2]||0)],n,r);case"meter-offsets":return K(t.addMetersToLngLat(s,[a,l,c]),n,r);case"cartesian":return n.isGeospatial?[a+s[0],l+s[1],c+s[2]]:n.projectPosition([a,l,c]);default:throw new Error(`Invalid coordinateSystem: ${o}`)}}const Z={};function X(t="id"){Z[t]=Z[t]||1;return`${t}-${Z[t]++}`}class J{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||X("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&t.Buffer.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(const t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(t){return t.byteLength/12}}function Q(e,n){if(n instanceof J)return n;const i=function(e,n){if(!n.indices)return;const i=n.indices.value;return e.createBuffer({usage:t.Buffer.INDEX,data:i})}(e,n),{attributes:o,bufferLayout:s}=function(e,n){const i=[],o={};for(const[r,a]of Object.entries(n.attributes)){let n=r;switch(r){case"POSITION":n="positions";break;case"NORMAL":n="normals";break;case"TEXCOORD_0":n="texCoords";break;case"TEXCOORD_1":n="texCoords1";break;case"COLOR_0":n="colors"}if(a){o[n]=e.createBuffer({data:a.value,id:`${r}-buffer`});const{value:s,size:l,normalized:c}=a;if(void 0===l)throw new Error(`Attribute ${r} is missing a size`);i.push({name:n,format:t.vertexFormatDecoder.getVertexFormatFromAttribute(s,l,c)})}}const s=n._calculateVertexCount(n.attributes,n.indices);return{attributes:o,bufferLayout:i,vertexCount:s}}(e,n);return new J({topology:n.topology||"triangle-list",bufferLayout:s,vertexCount:n.vertexCount,indices:i,attributes:o})}const tt="__debugFramebufferState";function et(t,e,n){if("webgl"!==t.device.type)return;const i=(o=t.device,o.userData[tt]||={flushing:!1,queuedFramebuffers:[]},o.userData[tt]);var o;i.flushing||(!function(t){const e=t.props.framebuffer;return!e||null===e.handle}(t)?e&&"colorAttachments"in e&&null!==e.handle&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e)):function(t,e,n){if(0===n.queuedFramebuffers.length)return;const i=t.device,{gl:o}=i,s=o.getParameter(36010),r=o.getParameter(36006),[a,l]=t.device.getDefaultCanvasContext().getDrawingBufferSize();let c=it(e.top,8);const u=it(e.left,8);n.flushing=!0;try{for(const t of n.queuedFramebuffers){const[n,i,s,r,d]=nt({framebuffer:t,targetWidth:a,targetHeight:l,topPx:c,leftPx:u,minimap:e.minimap});o.bindFramebuffer(36008,t.handle),o.bindFramebuffer(36009,null),o.blitFramebuffer(0,0,t.width,t.height,n,i,s,r,16384,9728),c+=d+8}}finally{o.bindFramebuffer(36008,s),o.bindFramebuffer(36009,r),n.flushing=!1}}(t,n,i))}function nt(t){const{framebuffer:e,targetWidth:n,targetHeight:i,topPx:o,leftPx:s}=t,r=Math.max(Math.floor(n/4),1),a=Math.max(Math.floor(i/4),1),l=Math.min(r/e.width,a/e.height),c=Math.max(Math.floor(e.width*l),1),u=Math.max(Math.floor(e.height*l),1),d=s,f=Math.max(i-o-u,0);return[d,f,d+c,f+u,u]}function it(t,e){if(!t)return e;const n=Number.parseInt(t,10);return Number.isFinite(n)?n:e}function ot(t,e,n){if(t===e)return!0;if(!n||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!ot(t[i],e[i],n-1))return!1;return!0}if(Array.isArray(e))return!1;if("object"==typeof t&&"object"==typeof e){const i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(const s of i){if(!e.hasOwnProperty(s))return!1;if(!ot(t[s],e[s],n-1))return!1}return!0}return!1}class st{bufferLayouts;constructor(t){this.bufferLayouts=t}getBufferLayout(t){return this.bufferLayouts.find(e=>e.name===t)||null}getAttributeNamesForBuffer(t){return t.attributes?t.attributes?.map(t=>t.attribute):[t.name]}mergeBufferLayouts(t,e){const n=[...t];for(const i of e){const t=n.findIndex(t=>t.name===i.name);t<0?n.push(i):n[t]=i}return n}getBufferIndex(e){const n=this.bufferLayouts.findIndex(t=>t.name===e);return-1===n&&t.log.warn(`BufferLayout: Missing buffer for "${e}".`)(),n}}function rt(t,e){let n=1/0;for(const i of t){const t=e[i];void 0!==t&&(n=Math.min(n,t))}return n}function at(t,e){if(!t||!e.some(t=>t.bindingLayout?.length))return t;const n={...t,bindings:t.bindings.map(t=>({...t}))};"attributes"in(t||{})&&(n.attributes=t?.attributes||[]);for(const i of e)for(const t of i.bindingLayout||[])for(const e of ct(t.name)){const i=n.bindings.find(t=>t.name===e);0===i?.group&&(i.group=t.group)}return n}function lt(t){return Boolean(t.uniformTypes&&!function(t){for(const e in t)return!1;return!0}(t.uniformTypes))}function ct(t){const e=new Set([t,`${t}Uniforms`]);return t.endsWith("Uniforms")||e.add(`${t}Sampler`),[...e]}function ut(t,e={}){const n={bindings:{},uniforms:{}};return Object.keys(t).forEach(o=>{const s=t[o];var r;Object.prototype.hasOwnProperty.call(e,o)||(i(r=s)||"number"==typeof r||"boolean"==typeof r)?n.uniforms[o]=s:n.bindings[o]=s}),n}class dt{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,n){Object.assign(this.options,n);const i=t.getShaderModuleDependencies(Object.values(e).filter(vt));for(const t of i)e[t.name]=t;t.log.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[o,s]of Object.entries(e))s&&(this._addModule(s),s.name&&o!==s.name&&!this.options.disableWarnings&&t.log.warn(`Module name: ${o} vs ${s.name}`)())}destroy(){}setProps(e){for(const n of Object.keys(e)){const i=n,o=e[i]||{},s=this.modules[i];if(s){const t=this.moduleUniforms[i],e=this.moduleBindings[i],n=s.getUniforms?.(o,t)||o,{uniforms:r,bindings:a}=ut(n,s.uniformTypes);this.moduleUniforms[i]=ft(t,r,s.uniformTypes),this.moduleBindings[i]={...e,...a}}else this.options.disableWarnings||t.log.warn(`Module ${n} not found`)()}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const t={};for(const e of Object.values(this.moduleBindings))Object.assign(t,e);return t}getDebugTable(){const t={};for(const[e,n]of Object.entries(this.moduleUniforms))for(const[i,o]of Object.entries(n))t[`${e}.${i}`]={type:this.modules[e].uniformTypes?.[i],value:String(o)};return t}_addModule(t){const e=t.name;this.moduleUniforms[e]=ft({},t.defaultUniforms||{},t.uniformTypes),this.moduleBindings[e]={}}}function ft(t={},e={},n={}){const i={...t};for(const[o,s]of Object.entries(e))void 0!==s&&(i[o]=pt(t[o],s,n[o]));return i}function pt(t,e,n){if(!n||"string"==typeof n)return ht(e);if(Array.isArray(n)){if(gt(e)||!Array.isArray(e))return ht(e);const i=Array.isArray(t)&&!gt(t)?[...t]:[],o=i.slice();for(let t=0;t<e.length;t++){const s=e[t];void 0!==s&&(o[t]=pt(i[t],s,n[0]))}return o}if(!mt(e))return ht(e);const i=n,o=mt(t)?t:{},s={...o};for(const[r,a]of Object.entries(e))void 0!==a&&(s[r]=pt(o[r],a,i[r]));return s}function ht(t){if(ArrayBuffer.isView(t))return Array.prototype.slice.call(t);if(Array.isArray(t)){if(gt(t))return t.slice();return t.map(t=>void 0===t?void 0:ht(t))}return mt(t)?Object.fromEntries(Object.entries(t).map(([t,e])=>[t,void 0===e?void 0:ht(e)])):t}function gt(t){return ArrayBuffer.isView(t)||Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function mt(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function vt(t){return Boolean(t?.dependencies)}const yt={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function xt(t){return t?Array.isArray(t)?t[0]??null:t:null}function _t(e){if(t.isExternalImage(e))return t.getExternalImageSize(e);if("object"==typeof e&&"width"in e&&"height"in e)return{width:e.width,height:e.height};throw new Error("Unsupported mip-level data")}function bt(t){return"object"==typeof t&&null!==t&&"data"in t&&"width"in t&&"height"in t}function Pt(t){return ArrayBuffer.isView(t)}function Ct(t){const{textureFormat:e,format:n}=t;if(e&&n&&e!==n)throw new Error(`Conflicting texture formats "${e}" and "${n}" provided for the same mip level`);return e??n}function Lt(t){const e=yt[t];if(void 0===e)throw new Error(`Invalid cube face: ${t}`);return e}function wt(t,e){return 6*t+Lt(e)}function St(t){throw new Error("setTexture1DData not supported in WebGL.")}function At(e,n,i,o){const s=(r=n,Array.isArray(r)?r:[r]);var r;const a=e,l=[];for(let c=0;c<s.length;c++){const e=s[c];if(t.isExternalImage(e))l.push({type:"external-image",image:e,z:a,mipLevel:c});else if(bt(e))l.push({type:"texture-data",data:e,textureFormat:Ct(e),z:a,mipLevel:c});else{if(!Pt(e)||!i)throw new Error("Unsupported 2D mip-level payload");l.push({type:"texture-data",data:{data:e,width:Math.max(1,i.width>>c),height:Math.max(1,i.height>>c),...o?{format:o}:{}},textureFormat:o,z:a,mipLevel:c})}}return l}function Ot(t){const e=[];for(let n=0;n<t.length;n++)e.push(...At(n,t[n]));return e}function Tt(t){const e=[];for(let n=0;n<t.length;n++)e.push(...At(n,t[n]));return e}function It(t){const e=[];for(const[n,i]of Object.entries(t)){const t=Lt(n);e.push(...At(t,i))}return e}function Et(t){const e=[];return t.forEach((t,n)=>{for(const[i,o]of Object.entries(t)){const t=wt(n,i);e.push(...At(t,o))}}),e}class Mt{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){const t=this._texture?.width??this.props.width??"?",e=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${t}x${e}px:(${this.isReady?"ready":"loading..."})`}constructor(t,e){this.device=t;const n=X("dynamic-texture"),i=e;this.props={...Mt.defaultProps,id:n,...e,data:null},this.id=this.props.id,this.ready=new Promise((t,e)=>{this.resolveReady=t,this.rejectReady=e}),this.initAsync(i)}async initAsync(e){try{const n=await this._loadAllData(e);this._checkNotDestroyed();const i=n.data?function(t){if(!t.data)return[];const e=t.width&&t.height?{width:t.width,height:t.height}:void 0,n="format"in t?t.format:void 0;switch(t.dimension){case"1d":return St();case"2d":return At(0,t.data,e,n);case"3d":return Ot(t.data);case"2d-array":return Tt(t.data);case"cube":return It(t.data);case"cube-array":return Et(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}({...n,width:e.width,height:e.height,format:e.format}):[],o="format"in e&&void 0!==e.format,s="usage"in e&&void 0!==e.usage,r=()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};const t=function(t){const{dimension:e,data:n}=t;if(!n)return null;switch(e){case"1d":{const t=xt(n);if(!t)return null;const{width:e}=_t(t);return{width:e,height:1}}case"2d":{const t=xt(n);return t?_t(t):null}case"3d":case"2d-array":{if(!Array.isArray(n)||0===n.length)return null;const t=xt(n[0]);return t?_t(t):null}case"cube":{const t=Object.keys(n)[0]??null;if(!t)return null;const e=xt(n[t]);return e?_t(e):null}case"cube-array":{if(!Array.isArray(n)||0===n.length)return null;const t=n[0],e=Object.keys(t)[0]??null;if(!e)return null;const i=xt(t[e]);return i?_t(i):null}default:return null}}(n);return t||{width:this.props.width||1,height:this.props.height||1}},a=r();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);const l=function(t,e,n,i){if(0===e.length)return{subresources:e,mipLevels:1,format:i.format,hasExplicitMipChain:!1};const o=new Map;for(const u of e){const t=o.get(u.z)??[];t.push(u),o.set(u.z,t)}const s=e.some(t=>t.mipLevel>0);let r=i.format,a=Number.POSITIVE_INFINITY;const l=[];for(const[u,d]of o){const e=[...d].sort((t,e)=>t.mipLevel-e.mipLevel),i=e[0];if(!i||0!==i.mipLevel)throw new Error(`DynamicTexture: slice ${u} is missing mip level 0`);const o=Rt(t,i);if(o.width!==n.width||o.height!==n.height)throw new Error(`DynamicTexture: slice ${u} base level dimensions ${o.width}x${o.height} do not match expected ${n.width}x${n.height}`);const s=zt(i);if(s){if(r&&r!==s)throw new Error(`DynamicTexture: slice ${u} base level format "${s}" does not match texture format "${r}"`);r=s}const c=r&&t.isTextureFormatCompressed(r)?Ft(t,o.width,o.height,r):t.getMipLevelCount(o.width,o.height);let f=0;for(let n=0;n<e.length;n++){const i=e[n];if(!i||i.mipLevel!==n)break;if(n>=c)break;const s=Rt(t,i),a=Math.max(1,o.width>>n),u=Math.max(1,o.height>>n);if(s.width!==a||s.height!==u)break;const d=zt(i);if(d&&(r||(r=d),d!==r))break;f++,l.push(i)}a=Math.min(a,f)}const c=Number.isFinite(a)?Math.max(1,a):1;return{subresources:l.filter(t=>t.mipLevel<c),mipLevels:c,format:r,hasExplicitMipChain:s}}(this.device,i,a,{format:o?e.format:void 0}),c=l.format??this.props.format,u={...this.props,...a,format:c,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(c)&&!s&&(u.usage=t.Texture.SAMPLE|t.Texture.COPY_DST);const d=this.props.mipmaps&&!l.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(c);if("webgpu"===this.device.type&&d){const e="3d"===this.props.dimension?t.Texture.SAMPLE|t.Texture.STORAGE|t.Texture.COPY_DST|t.Texture.COPY_SRC:t.Texture.SAMPLE|t.Texture.RENDER|t.Texture.COPY_DST|t.Texture.COPY_SRC;u.usage|=e}const f=this.device.getMipLevelCount(u.width,u.height),p=l.hasExplicitMipChain?l.mipLevels:"auto"===this.props.mipLevels?f:Math.max(1,Math.min(f,this.props.mipLevels??1)),h={...u,mipLevels:p};this._texture=this.device.createTexture(h),this._sampler=this.texture.sampler,this._view=this.texture.view,l.subresources.length&&this._setTextureSubresources(l.subresources),!this.props.mipmaps||l.hasExplicitMipChain||d||t.log.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),d&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),t.log.info(0,`${this} created`)()}catch(n){const t=n instanceof Error?n:new Error(String(n));this.rejectReady(t)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){"webgl"===this.device.type?this.texture.generateMipmapsWebGL():"webgpu"===this.device.type?this.device.generateMipmapsWebGPU(this.texture):t.log.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();const n=e instanceof t.Sampler?e:this.device.createSampler(e);this.texture.setSampler(n),this._sampler=n}async readBuffer(e={}){this.isReady||await this.ready;const n=e.width??this.texture.width,i=e.height??this.texture.height,o=e.depthOrArrayLayers??this.texture.depth,s=this.texture.computeMemoryLayout({width:n,height:i,depthOrArrayLayers:o}),r=this.device.createBuffer({byteLength:s.byteLength,usage:t.Buffer.COPY_DST|t.Buffer.MAP_READ});this.texture.readBuffer({...e,width:n,height:i,depthOrArrayLayers:o},r);const a=this.device.createFence();return await a.signaled,a.destroy(),r}async readAsync(t={}){this.isReady||await this.ready;const e=t.width??this.texture.width,n=t.height??this.texture.height,i=t.depthOrArrayLayers??this.texture.depth,o=this.texture.computeMemoryLayout({width:e,height:n,depthOrArrayLayers:i}),s=await this.readBuffer(t),r=await s.readAsync(0,o.byteLength);return s.destroy(),r.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;const n=this.texture;return this._texture=n.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,n.destroy(),t.log.info(`${this} resized`),!0}getCubeFaceIndex(t){const e=yt[t];if(void 0===e)throw new Error(`Invalid cube face: ${t}`);return e}getCubeArrayFaceIndex(t,e){return 6*t+this.getCubeFaceIndex(e)}setTexture1DData(t){if(this._checkReady(),"1d"!==this.texture.props.dimension)throw new Error(`${this} is not 1d`);const e=St();this._setTextureSubresources(e)}setTexture2DData(t,e=0){if(this._checkReady(),"2d"!==this.texture.props.dimension)throw new Error(`${this} is not 2d`);const n=At(e,t);this._setTextureSubresources(n)}setTexture3DData(t){if("3d"!==this.texture.props.dimension)throw new Error(`${this} is not 3d`);const e=Ot(t);this._setTextureSubresources(e)}setTextureArrayData(t){if("2d-array"!==this.texture.props.dimension)throw new Error(`${this} is not 2d-array`);const e=Tt(t);this._setTextureSubresources(e)}setTextureCubeData(t){if("cube"!==this.texture.props.dimension)throw new Error(`${this} is not cube`);const e=It(t);this._setTextureSubresources(e)}setTextureCubeArrayData(t){if("cube-array"!==this.texture.props.dimension)throw new Error(`${this} is not cube-array`);const e=Et(t);this._setTextureSubresources(e)}_setTextureSubresources(t){for(const e of t){const{z:t,mipLevel:n}=e;switch(e.type){case"external-image":const{image:i,flipY:o}=e;this.texture.copyExternalImage({image:i,z:t,mipLevel:n,flipY:o});break;case"texture-data":const{data:s,textureFormat:r}=e;if(r&&r!==this.texture.format)throw new Error(`${this} mip level ${n} uses format "${r}" but texture format is "${this.texture.format}"`);this.texture.writeData(s.data,{x:0,y:0,z:t,width:s.width,height:s.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(t){const e=await Bt(t.data);return{dimension:t.dimension??"2d",data:e??null}}_checkNotDestroyed(){this.destroyed&&t.log.warn(`${this} already destroyed`)}_checkReady(){this.isReady||t.log.warn(`${this} Cannot perform this operation before ready`)}static defaultProps={...t.Texture.defaultProps,dimension:"2d",data:null,mipmaps:!1}}function zt(t){if("texture-data"===t.type)return t.textureFormat??Ct(t.data)}function Rt(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function Ft(t,e,n,i){const{blockWidth:o=1,blockHeight:s=1}=t.getTextureFormatInfo(i);let r=1;for(let a=1;;a++){const t=Math.max(1,e>>a),i=Math.max(1,n>>a);if(t<o||i<s)break;r++}return r}async function Bt(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(Bt));if(t&&"object"==typeof t&&t.constructor===Object){const e=t,n=await Promise.all(Object.values(e).map(Bt)),i=Object.keys(e),o={};for(let t=0;t<i.length;t++)o[i[t]]=n[t];return o}return t}const kt="render pipeline initialization failed";class Nt{static defaultProps={...e.RenderPipeline.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:t.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(t,e){this.props={...Nt.defaultProps,...e},e=this.props,this.id=e.id||X("model"),this.device=t,Object.assign(this.userData,e.userData),this.material=e.material||null;const n=Object.fromEntries(this.props.modules?.map(t=>[t.name,t])||[]),i=e.shaderInputs||new dt(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(i);const o=function(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}(t),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];this.props.shaderLayout=at(this.props.shaderLayout,s)||null;if("webgpu"===this.device.type&&this.props.source){const{source:e,getUniforms:n,bindingTable:i}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:o,...this.props,modules:s});this.source=e,this._getModuleUniforms=n,this._bindingTable=i;const r=t.getShaderLayout?.(this.source);this.props.shaderLayout=at(this.props.shaderLayout||r||null,s)||null}else{const{vs:t,fs:e,getUniforms:n}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:o,...this.props,modules:s});this.vs=t,this.fs=e,this._getModuleUniforms=n,this._bindingTable=[]}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,e.geometry&&this.setGeometry(e.geometry),this.pipelineFactory=e.pipelineFactory||h.getDefaultPipelineFactory(this.device),this.shaderFactory=e.shaderFactory||g.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in e&&(this.isInstanced=e.isInstanced),e.instanceCount&&this.setInstanceCount(e.instanceCount),e.vertexCount&&this.setVertexCount(e.vertexCount),e.indexBuffer&&this.setIndexBuffer(e.indexBuffer),e.attributes&&this.setAttributes(e.attributes),e.constantAttributes&&this.setConstantAttributes(e.constantAttributes),e.bindings&&this.setBindings(e.bindings),e.transformFeedback&&(this.transformFeedback=e.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const t=this._needsRedraw;return this._needsRedraw=!1,t}setNeedsRedraw(t){this._needsRedraw||=t}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const n=this._areBindingsLoading();if(n)return t.log.info(2,`>>> DRAWING ABORTED ${this.id}: ${n} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i,o=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),o=this.pipeline.isErrored,o)t.log.info(2,`>>> DRAWING ABORTED ${this.id}: ${kt}`)(),i=!1;else{const t=this._getBindings(),n=this._getBindGroups(),{indexBuffer:o}=this.vertexArray,s=o?o.byteLength/("uint32"===o.indexType?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:s,transformFeedback:this.transformFeedback||void 0,bindings:t,bindGroups:n,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw=o?kt:"waiting for resource initialization",i}setGeometry(t){this._gpuGeometry?.destroy();const e=t&&Q(this.device,t);if(e){this.setTopology(e.topology||"triangle-list");const t=new st(this.bufferLayout);this.bufferLayout=t.mergeBufferLayouts(e.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(e)}this._gpuGeometry=e}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){const e=new st(this.bufferLayout);this.bufferLayout=this._gpuGeometry?e.mergeBufferLayouts(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){ot(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(t){this.instanceCount=t,void 0===this.isInstanced&&t>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(t){this.vertexCount=t,this.setNeedsRedraw("vertexCount")}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new T(this.device,this.shaderInputs.modules);for(const[e,n]of Object.entries(this.shaderInputs.modules))if(lt(n)&&!this.material?.ownsModule(e)){const t=this._uniformStore.getManagedUniformBuffer(e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw("shaderInputs")}setMaterial(t){this.material=t,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(t){Object.assign(this.bindings,t),this.setNeedsRedraw("bindings")}setTransformFeedback(t){this.transformFeedback=t,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,n){const i=n?.disableWarnings??this.props.disableWarnings;e.indices&&t.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=function(t,e){const n=Object.fromEntries(t.attributes.map(t=>[t.name,t.location])),i=e.slice();return i.sort((t,e)=>{const i=t.attributes?t.attributes.map(t=>t.attribute):[t.name],o=e.attributes?e.attributes.map(t=>t.attribute):[e.name];return rt(i,n)-rt(o,n)}),i}(this.pipeline.shaderLayout,this.bufferLayout);const o=new st(this.bufferLayout);for(const[s,r]of Object.entries(e)){const e=o.getBufferLayout(s);if(!e){i||t.log.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}const n=o.getAttributeNamesForBuffer(e);let a=!1;for(const t of n){const e=this._attributeInfos[t];if(e){const t="webgpu"===this.device.type?o.getBufferIndex(e.bufferName):e.location;this.vertexArray.setBuffer(t,r),a=!0}}a||i||t.log.warn(`Model(${this.id}): Ignoring buffer "${r.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,n){for(const[i,o]of Object.entries(e)){const e=this._attributeInfos[i];e?this.vertexArray.setConstantWebGL(e.location,o):(n?.disableWarnings??this.props.disableWarnings)||t.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const t of Object.values(this.bindings))if(t instanceof Mt&&!t.isReady)return t.id;for(const t of Object.values(this.material?.bindings||{}))if(t instanceof Mt&&!t.isReady)return t.id;return!1}_getBindings(){const t={};for(const[e,n]of Object.entries(this.bindings))n instanceof Mt?n.isReady&&(t[e]=n.texture):t[e]=n;return t}_getBindGroups(){const t=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},n=t.bindings.length?e.normalizeBindingsByGroup(t,this._getBindings()):{0:this._getBindings()};if(!this.material)return n;for(const[e,i]of Object.entries(this.material.getBindingsByGroup())){const t=Number(e);n[t]={...n[t]||{},...i}}return n}_getBindGroupCacheKeys(){const t=this.material?.getBindGroupCacheKey(3);return t?{3:t}:{}}_getBindingsUpdateTimestamp(){let n=0;for(const i of Object.values(this.bindings))i instanceof e.TextureView?n=Math.max(n,i.texture.updateTimestamp):i instanceof t.Buffer||i instanceof t.Texture?n=Math.max(n,i.updateTimestamp):i instanceof Mt?n=i.texture?Math.max(n,i.texture.updateTimestamp):1/0:i instanceof t.Sampler||(n=Math.max(n,i.buffer.updateTimestamp));return Math.max(n,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(t){const e={...t.attributes};for(const[n]of Object.entries(e))this.pipeline.shaderLayout.attributes.find(t=>t.name===n)||"positions"===n||delete e[n];this.vertexCount=t.vertexCount,this.setIndexBuffer(t.indices||null),this.setAttributes(t.attributes,{disableWarnings:!0}),this.setAttributes(e,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate||=t,this.setNeedsRedraw(t)}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null,i=null;this.pipeline&&(t.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.pipeline.vs,i=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const o=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let s=null;this.source?s=o:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:o,fs:s}),this._attributeInfos=e.getAttributeInfosFromLayouts(this.pipeline.shaderLayout,this.bufferLayout),n&&this.shaderFactory.release(n),i&&i!==n&&this.shaderFactory.release(i)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=t.log.level>3?0:1e4;t.log.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,t.log.group(2,`>>> DRAWING MODEL ${this.id}`,{collapsed:t.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(t){const e={},n="Values";if(0===t.attributes.length&&!t.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(const i of t.attributes)i&&(e[`in ${i.location} ${i.name}: ${i.type}`]={[n]:i.stepMode||"vertex"});for(const i of t.varyings||[])e[`out ${i.location} ${i.name}`]={[n]:JSON.stringify(i)};return e}(this.pipeline.shaderLayout,this.id);t.log.table(2,e)();const n=this.shaderInputs.getDebugTable();t.log.table(2,n)();const i=this._getAttributeDebugTable();t.log.table(2,this._attributeInfos)(),t.log.table(2,i)(),t.log.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(t){const e=this.device.props.debugFramebuffers;if(this._drawCount++,!e)return;const n=t.props.framebuffer;et(t,n,{id:n?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){const t={};for(const[e,n]of Object.entries(this._attributeInfos)){const i=this.vertexArray.attributes[n.location];t[n.location]={name:e,type:n.shaderType,values:i?this._getBufferOrConstantValues(i,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:e}=this.vertexArray,n="uint32"===e.indexType?new Uint32Array(e.debugData):new Uint16Array(e.debugData);t.indices={name:"indices",type:e.indexType,values:n.toString()}}return t}_getBufferOrConstantValues(e,n){const i=t.dataTypeDecoder.getTypedArrayConstructor(n);return(e instanceof t.Buffer?new i(e.debugData):e).toString()}_getNonMaterialBindings(t){if(!this.material)return t;const e={};for(const[n,i]of Object.entries(t))this.material.ownsBinding(n)||(e[n]=i);return e}}class Dt{device;model;transformFeedback;static defaultProps={...Nt.defaultProps,outputs:void 0,feedbackBuffers:void 0};static isSupported(t){return"webgl"===t?.info?.type}constructor(t,e=Dt.defaultProps){if(!Dt.isSupported(t))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=t,this.model=new Nt(this.device,{id:e.id||"buffer-transform-model",fs:e.fs||o(),topology:e.topology||"point-list",varyings:e.outputs||e.varyings,...e}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:e.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(t){t?.inputBuffers&&this.model.setAttributes(t.inputBuffers),t?.outputBuffers&&this.transformFeedback.setBuffers(t.outputBuffers);const e=this.device.beginRenderPass(t);this.model.draw(e),e.end()}getBuffer(t){return this.transformFeedback.getBuffer(t)}readAsync(e){const n=this.getBuffer(e);if(!n)throw new Error("BufferTransform#getBuffer");if(n instanceof t.Buffer)return n.readAsync();const{buffer:i,byteOffset:o=0,byteLength:s=i.byteLength}=n;return i.readAsync(o,s)}}class Ut{id;topology;vertexCount;indices;attributes;userData={};constructor(t){const{attributes:e={},indices:n=null,vertexCount:i=null}=t;this.id=t.id||X("geometry"),this.topology=t.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(const[o,s]of Object.entries(e)){const t=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(t.value))throw new Error(`${this._print(o)}: must be typed array or object with value as typed array`);if("POSITION"!==o&&"positions"!==o||t.size||(t.size=3),"indices"===o){if(this.indices)throw new Error("Multiple indices detected");this.indices=t}else this.attributes[o]=t}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||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,e){return this}_calculateVertexCount(t,e){if(e)return e.value.length;let n=1/0;for(const i of Object.values(t)){const{value:t,size:e,constant:o}=i;!o&&t&&void 0!==e&&e>=1&&(n=Math.min(n,t.length/e))}return n}}const jt=t.dataTypeDecoder.getDataType.bind(t.dataTypeDecoder);function Gt(t,e,n){if(e.size>4)return null;const i="webgpu"===n&&"uint8"===e.type?"unorm8":e.type;return{attribute:t,format:e.size>1?`${i}x${e.size}`:e.type,byteOffset:e.offset||0}}function Vt(t){return t.stride||t.size*t.bytesPerElement}function Wt(e,n){n.offset&&t.defaultLogger.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const i=Vt(e),o=(void 0!==n.vertexOffset?n.vertexOffset:e.vertexOffset||0)*i+(n.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...n,offset:o,stride:i}}class $t{constructor(t,n,i){this._buffer=null,this.device=t,this.id=n.id||"",this.size=n.size||1;const o=n.logicalType||n.type,s="float64"===o;let r,{defaultValue:a}=n;a=Number.isFinite(a)?[a]:a||new Array(this.size).fill(0),r=s?"float32":!o&&n.isIndexed?"uint32":o||"float32";let l=function(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return e.getTypedArrayConstructor(t)}}(o||r);this.doublePrecision=s,s&&!1===n.fp64&&(l=Float32Array),this.value=null,this.settings={...n,defaultType:l,defaultValue:a,logicalType:o,type:r,normalized:r.includes("norm"),size:this.size,bytesPerElement:l.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){const t=this.getAccessor();return t.vertexOffset?t.vertexOffset*Vt(t):0}get numInstances(){return this.state.numInstances}set numInstances(t){this.state.numInstances=t}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),t.defaultTypedArrayManager.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(t=this.id,e=null){const n={};if(this.state.constant){const i=this.value;if(e){const o=Wt(this.getAccessor(),e),s=o.offset/i.BYTES_PER_ELEMENT,r=o.size||this.size;n[t]=i.subarray(s,s+r)}else n[t]=i}else n[t]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${t}64Low`]=n[t]:n[`${t}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(t=this.id,e=null){const n=this.getAccessor(),i=[],o={name:this.id,byteStride:Vt(n)};if(this.doublePrecision){const o=function(t,e){const n=Wt(t,e);return{high:n,low:{...n,offset:n.offset+4*t.size}}}(n,e||{});i.push(Gt(t,{...n,...o.high},this.device.type),Gt(`${t}64Low`,{...n,...o.low},this.device.type))}else if(e){const o=Wt(n,e);i.push(Gt(t,{...n,...o},this.device.type))}else i.push(Gt(t,n,this.device.type));return o.attributes=i.filter(Boolean),o}setAccessor(t){this.state.bufferAccessor=t}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let t=null;if(this.state.constant&&this.value){const e=Array.from(this.value);t=[e,e]}else{const{value:e,numInstances:n,size:i}=this,o=n*i;if(e&&o&&e.length>=o){const n=new Array(i).fill(1/0),s=new Array(i).fill(-1/0);for(let t=0;t<o;)for(let o=0;o<i;o++){const i=e[t++];i<n[o]&&(n[o]=i),i>s[o]&&(s[o]=i)}t=[n,s]}}return this.state.bounds=t,t}setData(e){const{state:n}=this;let i;i=ArrayBuffer.isView(e)?{value:e}:e instanceof t.Buffer?{buffer:e}:e;const o={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type){if(this.doublePrecision&&i.value instanceof Float64Array)o.type="float32";else{const t=jt(i.value);o.type=o.normalized?t.replace("int","norm"):t}}o.bytesPerElement=i.value.BYTES_PER_ELEMENT,o.stride=Vt(o)}if(n.bounds=null,i.constant){let t=i.value;t=this._normalizeValue(t,[],0),this.settings.normalized&&(t=this.normalizeConstant(t));if(!(!n.constant||!this._areValuesEqual(t,this.value)))return!1;n.externalBuffer=null,n.constant=!0,this.value=ArrayBuffer.isView(t)?t:new Float32Array(t)}else if(i.buffer){const t=i.buffer;n.externalBuffer=t,n.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let e=i.value;n.externalBuffer=null,n.constant=!1,this.value=e;let{buffer:s}=this;const r=Vt(o),a=(o.vertexOffset||0)*r;if(this.doublePrecision&&e instanceof Float64Array&&(e=t.toDoublePrecisionArray(e,o)),this.settings.isIndexed){const t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}const l=e.byteLength+a+2*r;(!s||s.byteLength<l)&&(s=this._createBuffer(l)),s.write(e,a)}return this.setAccessor(o),!0}updateSubBuffer(e={}){this.state.bounds=null;const n=this.value,{startOffset:i=0,endOffset:o}=e;this.buffer.write(this.doublePrecision&&n instanceof Float64Array?t.toDoublePrecisionArray(n,{size:this.size,startIndex:i,endIndex:o}):n.subarray(i,o),i*n.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,n=!1){const{state:i}=this,o=i.allocatedValue,s=t.defaultTypedArrayManager.allocate(o,e+1,{size:this.size,type:this.settings.defaultType,copy:n});this.value=s;const{byteOffset:r}=this;let{buffer:a}=this;return(!a||a.byteLength<s.byteLength+r)&&(a=this._createBuffer(s.byteLength+r),n&&o&&a.write(o instanceof Float64Array?t.toDoublePrecisionArray(o,this):o,r)),i.allocatedValue=s,i.constant=!1,i.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){const{value:n}=e;if(!ArrayBuffer.isView(n))throw new Error(`Attribute ${this.id} value is not TypedArray`);const i=this.settings.defaultType;let o=!1;if(this.doublePrecision&&(o=n.BYTES_PER_ELEMENT<4),o)throw new Error(`Attribute ${this.id} does not support ${n.constructor.name}`);n instanceof i||!this.settings.normalized||"normalized"in e||t.defaultLogger.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(t){switch(this.settings.type){case"snorm8":return new Float32Array(t).map(t=>(t+128)/255*2-1);case"snorm16":return new Float32Array(t).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(t).map(t=>t/255);case"unorm16":return new Float32Array(t).map(t=>t/65535);default:return t}}_normalizeValue(t,e,n){const{defaultValue:i,size:o}=this.settings;if(Number.isFinite(t))return e[n]=t,e;if(!t){let t=o;for(;--t>=0;)e[n+t]=i[t];return e}switch(o){case 4:e[n+3]=Number.isFinite(t[3])?t[3]:i[3];case 3:e[n+2]=Number.isFinite(t[2])?t[2]:i[2];case 2:e[n+1]=Number.isFinite(t[1])?t[1]:i[1];case 1:e[n+0]=Number.isFinite(t[0])?t[0]:i[0];break;default:let s=o;for(;--s>=0;)e[n+s]=Number.isFinite(t[s])?t[s]:i[s]}return e}_areValuesEqual(t,e){if(!t||!e)return!1;const{size:n}=this;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();const{isIndexed:n,type:i}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(n?t.Buffer.INDEX:t.Buffer.VERTEX)|t.Buffer.COPY_DST,indexType:n?i:void 0,byteLength:e}),this._buffer}}const Ht=[],Yt=[];function Kt(t,e=0,n=1/0){let i=Ht;const o={index:-1,data:t,target:[]};return t?"function"==typeof t[Symbol.iterator]?i=t:t.length>0&&(Yt.length=t.length,i=Yt):i=Ht,(e>0||Number.isFinite(n))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,n),o.index=e-1),{iterable:i,objectInfo:o}}function qt(t){return t&&t[Symbol.asyncIterator]}function Zt(t,e){const{size:n,stride:i,offset:o,startIndices:s,nested:r}=e,a=t.BYTES_PER_ELEMENT,l=i?i/a:n,c=o?o/a:0,u=Math.floor((t.length-c)/l);return(e,{index:i,target:o})=>{if(!s){const e=i*l+c;for(let i=0;i<n;i++)o[i]=t[e+i];return o}const a=s[i],d=s[i+1]||u;let f;if(r){f=new Array(d-a);for(let e=a;e<d;e++){const i=e*l+c;o=new Array(n);for(let e=0;e<n;e++)o[e]=t[i+e];f[e-a]=o}}else if(l===n)f=t.subarray(a*n+c,d*n+c);else{f=new t.constructor((d-a)*n);let e=0;for(let i=a;i<d;i++){const o=i*l+c;for(let i=0;i<n;i++)f[e++]=t[o+i]}}return f}}const Xt=[],Jt=[[0,1/0]];const Qt={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function te(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});const n=t.type||"interpolation";return{...Qt[n],...e,...t,type:n}}class ee extends $t{constructor(t,e){super(t,e,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Jt}),this.constant=!1,this.settings.update=e.update||(e.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(t){this.state.startIndices=t}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:t=!1}={}){const e=this.state.needsRedraw;return this.state.needsRedraw=e&&!t,e}layoutChanged(){return this.state.layoutChanged}setAccessor(t){var e,n,i;(e=this.state).layoutChanged||(e.layoutChanged=(n=t,i=this.getAccessor(),!(n.type===i.type&&n.size===i.size&&Vt(n)===Vt(i)&&(n.offset||0)===(i.offset||0)))),super.setAccessor(t)}getUpdateTriggers(){const{accessor:t}=this.settings;return[this.id].concat("function"!=typeof t&&t||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(t){if(!t||!this.supportsTransition())return null;const{accessor:e}=this.settings,n=this.settings.transition;return te(Array.isArray(e)?t[e.find(e=>t[e])]:t[e],n)}setNeedsUpdate(t=this.id,e){if(this.state.needsUpdate=this.state.needsUpdate||t,this.setNeedsRedraw(t),e){const{startRow:t=0,endRow:n=1/0}=e;this.state.updateRanges=function(t,e){if(t===Jt)return t;if(e[0]<0&&(e[0]=0),e[0]>=e[1])return t;const n=[],i=t.length;let o=0;for(let s=0;s<i;s++){const i=t[s];i[1]<e[0]?(n.push(i),o=s+1):i[0]>e[1]?n.push(i):e=[Math.min(i[0],e[0]),Math.max(i[1],e[1])]}return n.splice(o,0,e),n}(this.state.updateRanges,[t,n])}else this.state.updateRanges=Jt}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=Xt}setNeedsRedraw(t=this.id){this.state.needsRedraw=this.state.needsRedraw||t}allocate(t){const{state:e,settings:n}=this;return!n.noAlloc&&(!!n.update&&(super.allocate(t,e.updateRanges!==Jt),!0))}updateBuffer({numInstances:t,data:e,props:n,context:i}){if(!this.needsUpdate())return!1;const{state:{updateRanges:o},settings:{update:s,noAlloc:r}}=this;let a=!0;if(s){for(const[r,a]of o)s.call(i,this,{data:e,startRow:r,endRow:a,props:n,numInstances:t});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(i,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(const[e,n]of o){const i=Number.isFinite(e)?this.getVertexOffset(e):0,o=Number.isFinite(n)?this.getVertexOffset(n):r||!Number.isFinite(t)?this.value.length:t*this.size;super.updateSubBuffer({startOffset:i,endOffset:o})}else;this._checkAttributeArray()}else a=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),a}setConstantValue(t,e){if(void 0===e||"function"==typeof e)return!1;const n=this.settings.transform&&t?this.settings.transform.call(t,e):e;if("webgpu"===this.device.type)return this.setConstantBufferValue(n,this.numInstances);return this.setData({constant:!0,value:n})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setConstantBufferValue(t,e){const n=this.settings.defaultType,i=this._normalizeValue(t,new n(this.size),0);if(this._hasConstantBufferValue(i,e))return this.constant=!1,this.clearNeedsUpdate(),!1;const o=new n(Math.max(e,1)*this.size);for(let r=0;r<o.length;r+=this.size)o.set(i,r);const s=this.setData({value:o});return this.constant=!1,this.clearNeedsUpdate(),s&&this.setNeedsRedraw(),s}_hasConstantBufferValue(t,e){const n=this.value,i=Math.max(e,1)*this.size;if(!ArrayBuffer.isView(n)||n.length!==i||n.length%this.size!==0)return!1;for(let o=0;o<n.length;o+=this.size)for(let e=0;e<this.size;e++)if(n[o+e]!==t[e])return!1;return!0}setExternalBuffer(t){const{state:e}=this;return t?(this.clearNeedsUpdate(),e.lastExternalBuffer===t||(e.lastExternalBuffer=t,this.setNeedsRedraw(),this.setData(t)),!0):(e.lastExternalBuffer=null,!1)}setBinaryValue(e,n=null){const{state:i,settings:o}=this;if(!e)return i.binaryValue=null,i.binaryAccessor=null,!1;if(o.noAlloc)return!1;if(i.binaryValue===e)return this.clearNeedsUpdate(),!0;i.binaryValue=e,this.setNeedsRedraw();if(o.transform||n!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});const s=e;t.assert$1(ArrayBuffer.isView(s.value),`invalid ${o.accessor}`);const r=Boolean(s.size)&&s.size!==this.size;return i.binaryAccessor=Zt(s.value,{size:s.size||this.size,stride:s.stride,offset:s.offset,startIndices:n,nested:r}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(t){const{startIndices:e}=this;return(e?t<e.length?e[t]:this.numInstances:t)*this.size}getValue(){const t=this.settings.shaderAttributes,e=super.getValue();if(!t)return e;for(const n in t)Object.assign(e,super.getValue(n,t[n]));return e}getBufferLayout(t){this.state.layoutChanged=!1;const e=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:i}=this.settings;if(n.stepMode="dynamic"===i?t?t.isInstanced?"instance":"vertex":"instance":i??"vertex",!e)return n;for(const o in e){const t=super._getBufferLayout(o,e[o]);n.attributes.push(...t.attributes)}return n}_autoUpdater(e,{data:n,startRow:i,endRow:o,props:s,numInstances:r}){const{settings:a,state:l,value:c,size:u,startIndices:d}=e,{accessor:f,transform:p}=a,h=l.binaryAccessor||("function"==typeof f?f:s[f]);t.assert$1("function"==typeof h,`accessor "${f}" is not a function`);let g=e.getVertexOffset(i);const{iterable:m,objectInfo:v}=Kt(n,i,o);for(const y of m){v.index++;let n=h(y,v);if(p&&(n=p.call(this,n)),d){const i=(v.index<d.length-1?d[v.index+1]:r)-d[v.index];if(n&&Array.isArray(n[0])){let t=g;for(const i of n)e._normalizeValue(i,c,t),t+=u}else n&&n.length>u?c.set(n,g):(e._normalizeValue(n,v.target,0),t.fillArray({target:c,source:v.target,start:g,count:i}));g+=i*u}else e._normalizeValue(n,c,g),g+=u}}_validateAttributeUpdaters(){const{settings:t}=this;if(!(t.noAlloc||"function"==typeof t.update))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:t}=this,e=Math.min(4,this.size);if(t&&t.length>=e){let n=!0;switch(e){case 4:n=n&&Number.isFinite(t[3]);case 3:n=n&&Number.isFinite(t[2]);case 2:n=n&&Number.isFinite(t[1]);case 1:n=n&&Number.isFinite(t[0]);break;default:n=!1}if(!n)throw new Error(`Illegal attribute generated for ${this.id}`)}}}function ne(t){const{source:e,target:n,start:i=0,size:o,getData:s}=t,r=t.end||n.length,a=e.length,l=r-i;if(a>l)return void n.set(e.subarray(0,l),i);if(n.set(e,i),!s)return;let c=a;for(;c<l;){const t=s(c,e);for(let e=0;e<o;e++)n[i+c]=t[e]||0,c++}}function ie(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${t}"`)}}function oe(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function se(t){t.push(t.shift())}function re({device:t,source:e,target:n}){return(!n||n.byteLength<e.byteLength)&&(n?.destroy(),n=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),n}function ae({device:t,buffer:e,attribute:n,fromLength:i,toLength:o,fromStartIndices:s,getData:r=t=>t}){const a=n.doublePrecision&&n.value instanceof Float64Array?2:1,l=n.size*a,c=n.byteOffset,u=n.settings.bytesPerElement<4?c/n.settings.bytesPerElement*4:c,d=n.startIndices,f=s&&d,p=n.isConstant;if(!f&&e&&i>=o)return e;const h=n.value instanceof Float64Array?Float32Array:n.value.constructor,g=p?n.value:new h(n.getBuffer().readSyncWebGL(c,o*h.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!p){const t=r;r=(e,i)=>n.normalizeConstant(t(e,i))}const m=p?(t,e)=>r(g,e):(t,e)=>r(g.subarray(t+c,t+c+l),e),v=e?new Float32Array(e.readSyncWebGL(u,4*i).buffer):new Float32Array(0),y=new Float32Array(o);return function({source:t,target:e,size:n,getData:i,sourceStartIndices:o,targetStartIndices:s}){if(!o||!s)return ne({source:t,target:e,size:n,getData:i}),e;let r=0,a=0;const l=i&&((t,e)=>i(t+a,e)),c=Math.min(o.length,s.length);for(let u=1;u<c;u++){const i=o[u]*n,c=s[u]*n;ne({source:t.subarray(r,i),target:e,start:a,end:c,size:n,getData:l}),r=i,a=c}a<e.length&&ne({source:[],target:e,start:a,size:n,getData:l})}({source:v,target:y,sourceStartIndices:s,targetStartIndices:d,size:l,getData:m}),(!e||e.byteLength<y.byteLength+u)&&(e?.destroy(),e=t.createBuffer({byteLength:y.byteLength+u,usage:35050})),e.write(y,u),e}class le{constructor({device:e,attribute:n,timeline:i}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new t.Transition(i),this.attribute=n,this.attributeInTransition=function(t){const{device:e,settings:n,value:i}=t,o=new ee(e,n);return o.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:n.normalized}),o}(n),this.currentStartIndices=n.startIndices}get inProgress(){return this.transition.inProgress}start(t,e,n=1/0){this.settings=t,this.currentStartIndices=this.attribute.startIndices,this.currentLength=function(t,e){const{doublePrecision:n,settings:i,value:o,size:s}=t,r=n&&o instanceof Float64Array?2:1;let a=0;const{shaderAttributes:l}=t.settings;if(l)for(const c of Object.values(l))a=Math.max(a,c.vertexOffset??0);return(i.noAlloc?o.length:(e+a)*s)*r}(this.attribute,e),this.transition.start({...t,duration:n})}update(){const t=this.transition.update();return t&&this.onUpdate(),t}setBuffer(t){this.attributeInTransition.setData({buffer:t,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(const t of this.buffers)t.destroy();this.buffers.length=0}}const ce={name:"interpolation",vs:"layout(std140) uniform interpolationUniforms {\n float time;\n} interpolation;\n",uniformTypes:{time:"f32"}},ue="#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vCurrent;\n\nvoid main(void) {\n vCurrent = mix(aFrom, aTo, interpolation.time);\n gl_Position = vec4(0.0);\n}\n",de="#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aFrom64Low;\nin ATTRIBUTE_TYPE aTo;\nin ATTRIBUTE_TYPE aTo64Low;\nout ATTRIBUTE_TYPE vCurrent;\nout ATTRIBUTE_TYPE vCurrent64Low;\n\nvec2 mix_fp64(vec2 a, vec2 b, float x) {\n vec2 range = sub_fp64(b, a);\n return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));\n}\n\nvoid main(void) {\n for (int i=0; i<ATTRIBUTE_SIZE; i++) {\n vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time);\n vCurrent[i] = value.x;\n vCurrent64Low[i] = value.y;\n }\n gl_Position = vec4(0.0);\n}\n";function fe(t){return t.doublePrecision&&t.value instanceof Float64Array}const pe={name:"spring",vs:"layout(std140) uniform springUniforms {\n float damping;\n float stiffness;\n} spring;\n",uniformTypes:{damping:"f32",stiffness:"f32"}},he="#version 300 es\n#define SHADER_NAME spring-transition-vertex-shader\n\n#define EPSILON 0.00001\n\nin ATTRIBUTE_TYPE aPrev;\nin ATTRIBUTE_TYPE aCur;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vNext;\nout float vIsTransitioningFlag;\n\nATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {\n ATTRIBUTE_TYPE velocity = cur - prev;\n ATTRIBUTE_TYPE delta = dest - cur;\n ATTRIBUTE_TYPE force = delta * spring.stiffness;\n ATTRIBUTE_TYPE resistance = velocity * spring.damping;\n return force - resistance + velocity + cur;\n}\n\nvoid main(void) {\n bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;\n vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;\n\n vNext = getNextValue(aCur, aPrev, aTo);\n gl_Position = vec4(0, 0, 0, 1);\n gl_PointSize = 100.0;\n}\n",ge="#version 300 es\n#define SHADER_NAME spring-transition-is-transitioning-fragment-shader\n\nin float vIsTransitioningFlag;\n\nout vec4 fragColor;\n\nvoid main(void) {\n if (vIsTransitioningFlag == 0.0) {\n discard;\n }\n fragColor = vec4(1.0);\n}";const me={interpolation:class extends le{constructor({device:t,attribute:e,timeline:n}){super({device:t,attribute:e,timeline:n}),this.type="interpolation",this.transform=function(t,e){const n=e.size,i=ie(n),o=oe(n),s=e.getBufferLayout();if(fe(e))return new Dt(t,{vs:de,bufferLayout:[{name:"aFrom",byteStride:8*n,attributes:[{attribute:"aFrom",format:o,byteOffset:0},{attribute:"aFrom64Low",format:o,byteOffset:4*n}]},{name:"aTo",byteStride:8*n,attributes:[{attribute:"aTo",format:o,byteOffset:0},{attribute:"aTo64Low",format:o,byteOffset:4*n}]}],modules:[c,ce],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:n},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0});return new Dt(t,{vs:ue,bufferLayout:[{name:"aFrom",format:o},{name:"aTo",format:s.attributes[0].format}],modules:[ce],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}(t,e)}start(t,e){const n=this.currentLength,i=this.currentStartIndices;if(super.start(t,e,t.duration),t.duration<=0)return void this.transition.cancel();const{buffers:o,attribute:s}=this;se(o),o[0]=ae({device:this.device,buffer:o[0],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:t.enter}),o[1]=re({device:this.device,source:o[0],target:o[1]}),this.setBuffer(o[1]);const{transform:r}=this,a=r.model;let l=Math.floor(this.currentLength/s.size);fe(s)&&(l/=2),a.setVertexCount(l),s.isConstant?(a.setAttributes({aFrom:o[0]}),a.setConstantAttributes({aTo:s.value})):a.setAttributes({aFrom:o[0],aTo:s.getBuffer()}),r.transformFeedback.setBuffers({vCurrent:o[1]})}onUpdate(){const{duration:t,easing:e}=this.settings,{time:n}=this.transition;let i=n/t;e&&(i=e(i));const{model:o}=this.transform,s={time:i};o.shaderInputs.setProps({interpolation:s}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},spring:class extends le{constructor({device:t,attribute:e,timeline:n}){super({device:t,attribute:e,timeline:n}),this.type="spring",this.texture=function(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}(t),this.framebuffer=function(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}(t,this.texture),this.transform=function(t,e){const n=ie(e.size),i=oe(e.size);return new Dt(t,{vs:he,fs:ge,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[pe],defines:{ATTRIBUTE_TYPE:n},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}(t,e)}start(t,e){const n=this.currentLength,i=this.currentStartIndices;super.start(t,e);const{buffers:o,attribute:s}=this;for(let a=0;a<2;a++)o[a]=ae({device:this.device,buffer:o[a],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:t.enter});o[2]=re({device:this.device,source:o[0],target:o[2]}),this.setBuffer(o[1]);const{model:r}=this.transform;r.setVertexCount(Math.floor(this.currentLength/s.size)),s.isConstant?r.setConstantAttributes({aTo:s.value}):r.setAttributes({aTo:s.getBuffer()})}onUpdate(){const{buffers:t,transform:e,framebuffer:n,transition:i}=this,o=this.settings;e.model.setAttributes({aPrev:t[0],aCur:t[1]}),e.transformFeedback.setBuffers({vNext:t[2]});const s={stiffness:o.stiffness,damping:o.damping};e.model.shaderInputs.setProps({spring:s}),e.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),se(t),this.setBuffer(t[1]);this.device.readPixelsToArrayWebGL(n)[0]>0||i.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}};class ve{constructor(t,{id:e,timeline:n}){if(!t)throw new Error("AttributeTransitionManager is constructed without device");this.id=e,this.device=t,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const t in this.transitions)this._removeTransition(t)}update({attributes:t,transitions:e,numInstances:n}){this.numInstances=n||1;for(const i in t){const n=t[i],o=n.getTransitionSetting(e);o&&this._updateAttribute(i,n,o)}for(const i in this.transitions){const n=t[i];n&&n.getTransitionSetting(e)||this._removeTransition(i)}}hasAttribute(t){const e=this.transitions[t];return e&&e.inProgress}getAttributes(){const t={};for(const e in this.transitions){const n=this.transitions[e];n.inProgress&&(t[e]=n.attributeInTransition)}return t}run(){if(0===this.numInstances)return!1;for(const e in this.transitions){this.transitions[e].update()&&(this.needsRedraw=!0)}const t=this.needsRedraw;return this.needsRedraw=!1,t}_removeTransition(t){this.transitions[t].delete(),delete this.transitions[t]}_updateAttribute(e,n,i){const o=this.transitions[e];let s=!o||o.type!==i.type;if(s){o&&this._removeTransition(e);const r=me[i.type];r?this.transitions[e]=new r({attribute:n,timeline:this.timeline,device:this.device}):(t.defaultLogger.error(`unsupported transition type '${i.type}'`)(),s=!1)}(s||n.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}}const ye="attributeManager.invalidate";class xe{constructor(e,{id:n="attribute-manager",stats:i,timeline:o}={}){this.mergeBoundsMemoized=t.memoize(t.mergeBounds),this.id=n,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new ve(e,{id:`${n}-transitions`,timeline:o}),Object.seal(this)}finalize(){for(const t in this.attributes)this.attributes[t].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(t={clearRedrawFlags:!1}){const e=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!t.clearRedrawFlags,e&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(t){this._add(t)}addInstanced(t){this._add(t,{stepMode:"instance"})}remove(t){for(const e of t)void 0!==this.attributes[e]&&(this.attributes[e].delete(),delete this.attributes[e])}invalidate(e,n){const i=this._invalidateTrigger(e,n);t.debug(ye,this,e,i)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);t.debug(ye,this,"all")}update({data:e,numInstances:n,startIndices:i=null,transitions:o,props:s={},buffers:r={},context:a={}}){let l=!1;t.debug("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const c in this.attributes){const o=this.attributes[c],u=o.settings.accessor;o.startIndices=i,o.numInstances=n,s[c]&&t.defaultLogger.removed(`props.${c}`,`data.attributes.${c}`)(),o.setExternalBuffer(r[c])||o.setBinaryValue("string"==typeof u?r[u]:void 0,e.startIndices)||"string"==typeof u&&!r[u]&&o.setConstantValue(a,s[u])||o.needsUpdate()&&(l=!0,this._updateAttribute({attribute:o,numInstances:n,data:e,props:s,context:a})),this.needsRedraw=this.needsRedraw||o.needsRedraw()}l&&t.debug("attributeManager.updateEnd",this,n),this.stats&&(this.stats.get("Update Attributes").timeEnd(),l&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:n,transitions:o})}updateTransition(){const{attributeTransitionManager:t}=this,e=t.run();return this.needsRedraw=this.needsRedraw||e,e}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(t){const e=t.map(t=>this.attributes[t]?.getBounds());return this.mergeBoundsMemoized(e)}getChangedAttributes(t={clearChangedFlags:!1}){const{attributes:e,attributeTransitionManager:n}=this,i={...n.getAttributes()};for(const o in e){const s=e[o];s.needsRedraw(t)&&!n.hasAttribute(o)&&(i[o]=s)}return i}getBufferLayouts(t){return Object.values(this.getAttributes()).map(e=>e.getBufferLayout(t))}_add(t,e){for(const n in t){const i=t[n],o={...i,id:n,size:(i.isIndexed?1:i.size)||1,...e};this.attributes[n]=new ee(this.device,o)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const t={};for(const e in this.attributes){this.attributes[e].getUpdateTriggers().forEach(n=>{t[n]||(t[n]=[]),t[n].push(e)})}this.updateTriggers=t}_invalidateTrigger(t,e){const{attributes:n,updateTriggers:i}=this,o=i[t];return o&&o.forEach(t=>{const i=n[t];i&&i.setNeedsUpdate(i.id,e)}),o}_updateAttribute(e){const{attribute:n,numInstances:i}=e;if(t.debug("attribute.updateStart",n),n.constant)return void n.setConstantValue(e.context,n.value);n.allocate(i)&&t.debug("attribute.allocate",n,i);n.updateBuffer(e)&&(this.needsRedraw=!0,t.debug("attribute.updateEnd",n,i))}}class _e extends t.Transition{get value(){return this._value}_onUpdate(){const{time:e,settings:{fromValue:n,toValue:i,duration:o,easing:s}}=this,r=s(e/o);this._value=t.lerp$1(n,i,r)}}const be=1e-5;function Pe(t,e,n,i,o){const s=e-t;return(n-e)*o+-s*i+s+e}function Ce(t,e){if(Array.isArray(t)){let n=0;for(let i=0;i<t.length;i++){const o=t[i]-e[i];n+=o*o}return Math.sqrt(n)}return Math.abs(t-e)}class Le extends t.Transition{get value(){return this._currValue}_onUpdate(){const{fromValue:t,toValue:e,damping:n,stiffness:i}=this.settings,{_prevValue:o=t,_currValue:s=t}=this;let r=function(t,e,n,i,o){if(Array.isArray(n)){const s=[];for(let r=0;r<n.length;r++)s[r]=Pe(t[r],e[r],n[r],i,o);return s}return Pe(t,e,n,i,o)}(o,s,e,n,i);const a=Ce(r,e),l=Ce(r,s);a<be&&l<be&&(r=e,this.end()),this._prevValue=s,this._currValue=r}}const we={interpolation:_e,spring:Le};class Se{constructor(t){this.transitions=new Map,this.timeline=t}get active(){return this.transitions.size>0}add(e,n,i,o){const{transitions:s}=this;if(s.has(e)){const t=s.get(e),{value:i=t.settings.fromValue}=t;n=i,this.remove(e)}if(!(o=te(o)))return;const r=we[o.type];if(!r)return void t.defaultLogger.error(`unsupported transition type '${o.type}'`)();const a=new r(this.timeline);a.start({...o,fromValue:n,toValue:i}),s.set(e,a)}remove(t){const{transitions:e}=this;e.has(t)&&(e.get(t).cancel(),e.delete(t))}update(){const t={};for(const[e,n]of this.transitions)n.update(),t[e]=n.value,n.inProgress||this.remove(e);return t}clear(){for(const t of this.transitions.keys())this.remove(t)}}function Ae(e,n){const i=Te({newProps:e,oldProps:n,propTypes:e[t.PROP_TYPES_SYMBOL],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),o=function(t,e){if(null===e)return"oldProps is null, initial diff";let n=!1;const{dataComparator:i,_dataDiff:o}=t;i?i(t.data,e.data)||(n="Data comparator detected a change"):t.data!==e.data&&(n="A new data container was supplied");n&&o&&(n=o(t.data,e.data)||n);return n}(e,n);let s=!1;return o||(s=function(t,e){if(null===e)return{all:!0};if("all"in t.updateTriggers){if(Me(t,e,"all"))return{all:!0}}const n={};let i=!1;for(const o in t.updateTriggers)if("all"!==o){Me(t,e,o)&&(n[o]=!0,i=!0)}return!!i&&n}(e,n)),{dataChanged:o,propsChanged:i,updateTriggersChanged:s,extensionsChanged:Ee(e,n),transitionsChanged:Oe(e,n)}}function Oe(e,n){if(!e.transitions)return!1;const i={},o=e[t.PROP_TYPES_SYMBOL];let s=!1;for(const t in e.transitions){const r=o[t],a=r&&r.type;("number"===a||"color"===a||"array"===a)&&Ie(e[t],n[t],r)&&(i[t]=!0,s=!0)}return!!s&&i}function Te({newProps:t,oldProps:e,ignoreProps:n={},propTypes:i={},triggerName:o="props"}){if(e===t)return!1;if("object"!=typeof t||null===t)return`${o} changed shallowly`;if("object"!=typeof e||null===e)return`${o} changed shallowly`;for(const s of Object.keys(t))if(!(s in n)){if(!(s in e))return`${o}.${s} added`;const n=Ie(t[s],e[s],i[s]);if(n)return`${o}.${s} ${n}`}for(const s of Object.keys(e))if(!(s in n)){if(!(s in t))return`${o}.${s} dropped`;if(!Object.hasOwnProperty.call(t,s)){const n=Ie(t[s],e[s],i[s]);if(n)return`${o}.${s} ${n}`}}return!1}function Ie(t,e,n){let i=n&&n.equal;return i&&!i(t,e,n)?"changed deeply":i||(i=t&&e&&t.equals,!i||i.call(t,e))?i||e===t?null:"changed shallowly":"changed deeply"}function Ee(t,e){if(null===e)return!0;const n=e.extensions,{extensions:i}=t;if(i===n)return!1;if(!n||!i)return!0;if(i.length!==n.length)return!0;for(let o=0;o<i.length;o++)if(!i[o].equals(n[o]))return!0;return!1}function Me(t,e,n){let i=t.updateTriggers[n];i=null==i?{}:i;let o=e.updateTriggers[n];o=null==o?{}:o;return Te({oldProps:o,newProps:i,triggerName:n})}function ze(t){if(null===(e=t)||"object"!=typeof e)throw new Error("count(): argument not an object");var e;if("function"==typeof t.count)return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(function(t){return null!==t&&"object"==typeof t&&t.constructor===Object}(t))return Object.keys(t).length;throw new Error("count(): argument not a container")}function Re(t,e){if(!e)return t;const n={...t,...e};if("defines"in e&&(n.defines={...t.defines,...e.defines}),"modules"in e&&(n.modules=(t.modules||[]).concat(e.modules),e.modules.some(t=>"project64"===t.name))){const t=n.modules.findIndex(t=>"project32"===t.name);t>=0&&n.modules.splice(t,1)}if("inject"in e)if(t.inject){const i={...t.inject};for(const t in e.inject)i[t]=(i[t]||"")+e.inject[t];n.inject=i}else n.inject=e.inject;return n}const Fe={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Be={};const ke={boolean:{validate:(t,e)=>!0,equal:(t,e,n)=>Boolean(t)===Boolean(e)},number:{validate:(t,e)=>Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)},color:{validate:(t,e)=>e.optional&&!t||Ue(t)&&(3===t.length||4===t.length),equal:(e,n,i)=>t.deepEqual(e,n,1)},accessor:{validate(t,e){const n=je(t);return"function"===n||n===je(e.value)},equal:(e,n,i)=>"function"==typeof n||t.deepEqual(e,n,1)},array:{validate:(t,e)=>e.optional&&!t||Ue(t),equal(e,n,i){const{compare:o}=i,s=Number.isInteger(o)?o:o?1:0;return o?t.deepEqual(e,n,s):e===n}},object:{equal(e,n,i){if(i.ignore)return!0;const{compare:o}=i,s=Number.isInteger(o)?o:o?1:0;return o?t.deepEqual(e,n,s):e===n}},function:{validate:(t,e)=>e.optional&&!t||"function"==typeof t,equal:(t,e,n)=>!n.compare&&!1!==n.ignore||t===e},data:{transform:(t,e,n)=>{if(!t)return t;const{dataTransform:i}=n.props;return i?i(t):"string"==typeof t.shape&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(e,n,i)=>{const o=i.context;return o&&o.device?function(e,n,i,o){if(i instanceof t.Texture)return i;i.constructor&&"Object"!==i.constructor.name&&(i={data:i});let s=null;i.compressed&&(s={minFilter:"linear",mipmapFilter:i.data.length>1?"nearest":"linear"});const{width:r,height:a}=i.data,l=n.createTexture({...i,sampler:{...Fe,...s,...o},mipLevels:n.getMipLevelCount(r,a)});return"webgl"===n.type?l.generateMipmapsWebGL():"webgpu"===n.type&&n.generateMipmapsWebGPU(l),Be[l.id]=e,l}(i.id,o.device,e,{...n.parameters,...i.props.textureParameters}):null},release:(e,n,i)=>{var o,s;o=i.id,(s=e)&&s instanceof t.Texture&&Be[s.id]===o&&(s.delete(),delete Be[s.id])}}};function Ne(t,e){switch(je(e)){case"object":return De(t,e);case"array":return De(t,{type:"array",value:e,compare:!1});case"boolean":return De(t,{type:"boolean",value:e});case"number":return De(t,{type:"number",value:e});case"function":return De(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function De(t,e){return"type"in e?{name:t,...ke[e.type],...e}:"value"in e?{name:t,type:je(e.value),...e}:{name:t,type:"object",value:e}}function Ue(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function je(t){return Ue(t)?"array":null===t?"null":typeof t}const Ge="_mergedDefaultProps";function Ve(e,n){if(!(e instanceof Ke.constructor))return{};let i=Ge;if(n)for(const t of n){const e=t.constructor;e&&(i+=`:${e.extensionName||e.name}`)}const o=He(e,i);return o||(e[i]=function(e,n){const i=e.prototype;if(!i)return null;const o=Object.getPrototypeOf(e),s=Ve(o),r=He(e,"defaultProps")||{},a=function(t){const e={},n={},i={};for(const[o,s]of Object.entries(t)){const t=s?.deprecatedFor;if(t)i[o]=Array.isArray(t)?t:[t];else{const t=Ne(o,s);e[o]=t,n[o]=t.value}}return{propTypes:e,defaultProps:n,deprecatedProps:i}}(r),l=Object.assign(Object.create(null),s,a.defaultProps),c=Object.assign(Object.create(null),s?.[t.PROP_TYPES_SYMBOL],a.propTypes),u=Object.assign(Object.create(null),s?.[t.DEPRECATED_PROPS_SYMBOL],a.deprecatedProps);for(const d of n){const e=Ve(d.constructor);e&&(Object.assign(l,e),Object.assign(c,e[t.PROP_TYPES_SYMBOL]),Object.assign(u,e[t.DEPRECATED_PROPS_SYMBOL]))}(function(e,n){const i=function(e){const n=e.componentName;n||t.defaultLogger.warn(`${e.name}.componentName not specified`)();return n||e.name}(n);Object.defineProperties(e,{id:{writable:!0,value:i}})})(l,e),function(e,n){const i={},o={};for(const t in n){const e=n[t],{name:s,value:r}=e;e.async&&(i[s]=r,o[s]=We(s))}e[t.ASYNC_DEFAULTS_SYMBOL]=i,e[t.ASYNC_ORIGINAL_SYMBOL]={},Object.defineProperties(e,o)}(l,c),function(e,n){for(const i in n)Object.defineProperty(e,i,{enumerable:!1,set(e){const o=`${this.id}: ${i}`;for(const t of n[i])$e(this,t)||(this[t]=e);t.defaultLogger.deprecated(o,n[i].join("/"))()}})}(l,u),l[t.PROP_TYPES_SYMBOL]=c,l[t.DEPRECATED_PROPS_SYMBOL]=u,0!==n.length||$e(e,"_propTypes")||(e._propTypes=c);return l}(e,n||[]))}function We(e){return{enumerable:!0,set(n){"string"==typeof n||n instanceof Promise||qt(n)?this[t.ASYNC_ORIGINAL_SYMBOL][e]=n:this[t.ASYNC_RESOLVED_SYMBOL][e]=n},get(){if(this[t.ASYNC_RESOLVED_SYMBOL]){if(e in this[t.ASYNC_RESOLVED_SYMBOL]){return this[t.ASYNC_RESOLVED_SYMBOL][e]||this[t.ASYNC_DEFAULTS_SYMBOL][e]}if(e in this[t.ASYNC_ORIGINAL_SYMBOL]){const n=this[t.COMPONENT_SYMBOL]&&this[t.COMPONENT_SYMBOL].internalState;if(n&&n.hasAsyncProp(e))return n.getAsyncProp(e)||this[t.ASYNC_DEFAULTS_SYMBOL][e]}}return this[t.ASYNC_DEFAULTS_SYMBOL][e]}}}function $e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function He(t,e){return $e(t,e)&&t[e]}let Ye=0;class Ke{constructor(...e){this.props=function(e,n){let i;for(let t=n.length-1;t>=0;t--){const e=n[t];"extensions"in e&&(i=e.extensions)}const o=Ve(e.constructor,i),s=Object.create(o);s[t.COMPONENT_SYMBOL]=e,s[t.ASYNC_ORIGINAL_SYMBOL]={},s[t.ASYNC_RESOLVED_SYMBOL]={};for(let t=0;t<n.length;++t){const e=n[t];for(const t in e)s[t]=e[t]}return Object.freeze(s),s}(this,e),this.id=this.props.id,this.count=Ye++}clone(e){const{props:n}=this,i={};for(const o in n[t.ASYNC_DEFAULTS_SYMBOL])o in n[t.ASYNC_RESOLVED_SYMBOL]?i[o]=n[t.ASYNC_RESOLVED_SYMBOL][o]:o in n[t.ASYNC_ORIGINAL_SYMBOL]&&(i[o]=n[t.ASYNC_ORIGINAL_SYMBOL][o]);return new this.constructor({...n,...i,...e})}}Ke.componentName="Component",Ke.defaultProps={};const qe=Object.freeze({});class Ze{constructor(t){this.component=t,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const t in this.asyncProps){const e=this.asyncProps[t];e&&e.type&&e.type.release&&e.type.release(e.resolvedValue,e.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||qe}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(t){return t in this.asyncProps}getAsyncProp(t){const e=this.asyncProps[t];return e&&e.resolvedValue}isAsyncPropLoading(t){if(t){const e=this.asyncProps[t];return Boolean(e&&e.pendingLoadCount>0&&e.pendingLoadCount!==e.resolvedLoadCount)}for(const e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(t,e){this._watchPromise(t,Promise.resolve(e))}setAsyncProps(e){this.component=e[t.COMPONENT_SYMBOL]||this.component;const n=e[t.ASYNC_RESOLVED_SYMBOL]||{},i=e[t.ASYNC_ORIGINAL_SYMBOL]||e,o=e[t.ASYNC_DEFAULTS_SYMBOL]||{};for(const t in n){const e=n[t];this._createAsyncPropData(t,o[t]),this._updateAsyncProp(t,e),n[t]=this.getAsyncProp(t)}for(const t in i){const e=i[t];this._createAsyncPropData(t,o[t]),this._updateAsyncProp(t,e)}}_fetch(t,e){return null}_onResolve(t,e){}_onError(t,e){}_updateAsyncProp(t,e){this._didAsyncInputValueChange(t,e)&&("string"==typeof e&&(e=this._fetch(t,e)),e instanceof Promise?this._watchPromise(t,e):qt(e)?this._resolveAsyncIterable(t,e):this._setPropValue(t,e))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const t in this.asyncProps)Object.defineProperty(this.oldAsyncProps,t,{enumerable:!0,value:this.oldProps[t]})}}_didAsyncInputValueChange(t,e){const n=this.asyncProps[t];return e!==n.resolvedValue&&e!==n.lastValue&&(n.lastValue=e,!0)}_setPropValue(t,e){this._freezeAsyncOldProps();const n=this.asyncProps[t];n&&(e=this._postProcessValue(n,e),n.resolvedValue=e,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(t,e,n){const i=this.asyncProps[t];i&&n>=i.resolvedLoadCount&&void 0!==e&&(this._freezeAsyncOldProps(),i.resolvedValue=e,i.resolvedLoadCount=n,this.onAsyncPropUpdated(t,e))}_watchPromise(t,e){const n=this.asyncProps[t];if(n){n.pendingLoadCount++;const i=n.pendingLoadCount;e.then(e=>{this.component&&(e=this._postProcessValue(n,e),this._setAsyncPropValue(t,e,i),this._onResolve(t,e))}).catch(e=>{this._onError(t,e)})}}async _resolveAsyncIterable(t,e){if("data"!==t)return void this._setPropValue(t,e);const n=this.asyncProps[t];if(!n)return;n.pendingLoadCount++;const i=n.pendingLoadCount;let o=[],s=0;for await(const r of e){if(!this.component)return;const{dataTransform:e}=this.component.props;o=e?e(r,o):o.concat(r),Object.defineProperty(o,"__diff",{enumerable:!1,value:[{startRow:s,endRow:o.length}]}),s=o.length,this._setAsyncPropValue(t,o,i)}this._onResolve(t,o)}_postProcessValue(t,e){const n=t.type;return n&&this.component&&(n.release&&n.release(t.resolvedValue,n,this.component),n.transform)?n.transform(e,n,this.component):e}_createAsyncPropData(e,n){if(!this.asyncProps[e]){const i=this.component&&this.component.props[t.PROP_TYPES_SYMBOL];this.asyncProps[e]={type:i&&i[e],lastValue:null,resolvedValue:n,pendingLoadCount:0,resolvedLoadCount:0}}}}class Xe extends Ze{constructor({attributeManager:t,layer:e}){super(e),this.attributeManager=t,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(t,e){const n=this.layer,i=n?.props.fetch;return i?i(e,{propName:t,layer:n}):super._fetch(t,e)}_onResolve(t,e){const n=this.layer;if(n){const i=n.props.onDataLoad;"data"===t&&i&&i(e,{propName:t,layer:n})}}_onError(t,e){const n=this.layer;n&&n.raiseError(e,`loading ${t} of ${this.layer}`)}}const Je=2**24-1,Qe=Object.freeze([]),tn=t.memoize(({oldViewport:t,viewport:e})=>t.equals(e));let en=new Uint8ClampedArray(0);const nn={data:{type:"data",value:Qe,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(e,{propName:n,layer:i,loaders:o,loadOptions:s,signal:r})=>{const{resourceManager:a}=i.context;s=s||i.getLoadOptions(),o=o||i.props.loaders,r&&(s={...s,core:{...s?.core,fetch:{...s?.core?.fetch,signal:r}}});let l=a.contains(e);return l||s||(a.add({resourceId:e,data:t.load(e,o),persistent:!1}),l=!0),l?a.subscribe({resourceId:e,onChange:t=>i.internalState?.reloadAsyncProp(n,t),consumerId:i.id,requestId:n}):t.load(e,o,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,100*-t]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class on extends Ke{constructor(){super(...arguments),this.internalState=null,this.lifecycle=t.LIFECYCLE.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let t=this;for(;t.parent;)t=t.parent;return t}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){t.assert$1(this.internalState);const n=this.internalState.viewport||this.context.viewport,i=q(e,{viewport:n,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[o,s,r]=t.worldToPixels(i,n.pixelProjectionMatrix);return 2===e.length?[o,s]:[o,s,r]}unproject(e){t.assert$1(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,n){t.assert$1(this.internalState);return function(e,n){const{viewport:i,coordinateSystem:o,coordinateOrigin:s,modelMatrix:r,fromCoordinateSystem:a,fromCoordinateOrigin:l}=function(t){const{viewport:e,modelMatrix:n,coordinateOrigin:i}=t;let{coordinateSystem:o,fromCoordinateSystem:s,fromCoordinateOrigin:r}=t;return"default"===o&&(o=e.isGeospatial?"lnglat":"cartesian"),void 0===s?s=o:"default"===s&&(s=e.isGeospatial?"lnglat":"cartesian"),void 0===r&&(r=i),{viewport:e,coordinateSystem:o,coordinateOrigin:i,modelMatrix:n,fromCoordinateSystem:s,fromCoordinateOrigin:r}}(n),{autoOffset:c=!0}=n,{geospatialOrigin:u=Y,shaderCoordinateOrigin:d=Y,offsetMode:f=!1}=c?t.getOffsetOrigin(i,o,s):{},p=q(e,{viewport:i,modelMatrix:r,coordinateSystem:a,coordinateOrigin:l,offsetMode:f});if(f){const e=i.projectPosition(u||d);t.sub(p,p,e)}return p}(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...n})}get isComposite(){return!1}get isDrawable(){return!0}setState(t){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,t),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return!!this.internalState&&!this.internalState.isAsyncPropLoading()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const t=this.state;return t&&(t.models||t.model&&[t.model])||[]}setShaderModuleProps(...t){for(const e of this.getModels())e.shaderInputs.setProps(...t)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:t}=this.props;return"default"===t||"lnglat"===t||"cartesian"===t}onHover(t,e){return this.props.onHover&&this.props.onHover(t,e)||!1}onClick(t,e){return this.props.onClick&&this.props.onClick(t,e)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(t,e=[]){return e[0]=t+1&255,e[1]=t+1>>8&255,e[2]=t+1>>8>>8&255,e}decodePickingColor(e){t.assert$1(e instanceof Uint8Array);const[n,i,o]=e;return n+256*i+65536*o-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:ze(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(t){t=Re(t,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const e of this.props.extensions)t=Re(t,e.getShaders.call(this,e));return t}shouldUpdateState(t){return t.changeFlags.propsOrDataChanged}updateState(t){const e=this.getAttributeManager(),{dataChanged:n}=t.changeFlags;if(n&&e)if(Array.isArray(n))for(const i of n)e.invalidateAll(i);else e.invalidateAll();if(e){const{props:n}=t,i=this.internalState.hasPickingBuffer,o=Number.isInteger(n.highlightedObjectIndex)||Boolean(n.pickable)||n.extensions.some(t=>t.getNeedsPickingBuffer.call(this,t));if(i!==o){this.internalState.hasPickingBuffer=o;const{pickingColors:t,instancePickingColors:n}=e.attributes,i=t||n;i&&(o&&i.constant&&(i.constant=!1,e.invalidate(i.id)),i.value||o||(i.constant=!0,i.value=[0,0,0]))}}}finalizeState(t){for(const n of this.getModels())n.destroy();const e=this.getAttributeManager();e&&e.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(t){for(const e of this.getModels())e.draw(t.renderPass)}getPickingInfo({info:t,mode:e,sourceLayer:n}){const{index:i}=t;return i>=0&&Array.isArray(this.props.data)&&(t.object=this.props.data[i]),t}raiseError(t,e){e&&(t=new Error(`${e}: ${t.message}`,{cause:t})),this.props.onError?.(t)||this.context?.onError?.(t,this)}getNeedsRedraw(t={clearRedrawFlags:!1}){return this._getNeedsRedraw(t)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(t){if(!this.internalState)return;const e=this.internalState.viewport;this.internalState.viewport=t,e&&tn({oldViewport:e,viewport:t})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(t="all"){const e=this.getAttributeManager();e&&("all"===t?e.invalidateAll():e.invalidate(t))}updateAttributes(t){let e=!1;for(const n in t)t[n].layoutChanged()&&(e=!0);for(const n of this.getModels())this._setModelAttributes(n,t,e)}_updateAttributes(){const t=this.getAttributeManager();if(!t)return;const e=this.props,n=this.getNumInstances(),i=this.getStartIndices();t.update({data:e.data,numInstances:n,startIndices:i,props:e,transitions:e.transitions,buffers:e.data.attributes,context:this});const o=t.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(o)}_updateAttributeTransition(){const t=this.getAttributeManager();t&&t.updateTransition()}_updateUniformTransition(){const{uniformTransitions:t}=this.internalState;if(t.active){const e=t.update(),n=Object.create(this.props);for(const t in e)Object.defineProperty(n,t,{value:e[t]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:n}){if(e.constant)return;const i=Math.floor(en.length/4);this.internalState.usesPickingColorCache=!0;const o=n>0&&0===en[0];if(i<n||o){n>Je&&t.defaultLogger.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),en=t.defaultTypedArrayManager.allocate(en,n,{size:4,copy:!0,maxCount:Math.max(n,Je)});const e=Math.floor(en.length/4),s=[0,0,0];for(let t=o?0:i;t<e;t++)this.encodePickingColor(t,s),en[4*t+0]=s[0],en[4*t+1]=s[1],en[4*t+2]=s[2],en[4*t+3]=0}e.value=en.subarray(0,4*n)}_setModelAttributes(e,n,i=!1){if(!Object.keys(n).length)return;if(i){const t=this.getAttributeManager();e.setBufferLayout(t.getBufferLayouts(e)),n=t.getAttributes()}const o=e.userData?.excludeAttributes||{},s={},r={};for(const a in n){if(o[a])continue;const i=n[a].getValue();for(const o in i){const l=i[o];l instanceof t.Buffer?n[a].settings.isIndexed?e.setIndexBuffer(l):s[o]=l:l&&(r[o]=l)}}e.setAttributes(s),e.setConstantAttributes(r)}disablePickingIndex(t){const e=this.props.data;if(!("attributes"in e))return void this._disablePickingIndex(t);const{pickingColors:n,instancePickingColors:i}=this.getAttributeManager().attributes,o=n||i,s=o&&e.attributes&&e.attributes[o.id];if(s&&s.value){const n=s.value,i=this.encodePickingColor(t);for(let t=0;t<e.length;t++){const e=o.getVertexOffset(t);n[e]===i[0]&&n[e+1]===i[1]&&n[e+2]===i[2]&&this._disablePickingIndex(t)}}else this._disablePickingIndex(t)}_disablePickingIndex(t){const{pickingColors:e,instancePickingColors:n}=this.getAttributeManager().attributes,i=e||n;if(!i)return;const o=i.getVertexOffset(t),s=i.getVertexOffset(t+1);i.buffer.write(new Uint8Array(s-o),o)}restorePickingColors(){const{pickingColors:t,instancePickingColors:e}=this.getAttributeManager().attributes,n=t||e;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==en.buffer&&(n.value=en.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){t.assert$1(!this.internalState),t.debug("layer.initialize",this);const e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new Xe({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(t.defaultLogger.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Se(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){t.debug("layer.matched",this,this===e);const{state:n,internalState:i}=e;this!==e&&(this.internalState=i,this.state=n,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if(t.debug("layer.update",this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();const n=this.props,i=this.context,o=this.internalState,s=i.viewport,r=this._updateUniformTransition();o.propsInTransition=r,i.viewport=o.viewport||s,this.props=r;try{const t=this._getUpdateParams(),e=this.getModels();if(i.device)this.updateState(t);else try{this.updateState(t)}catch(a){}for(const i of this.props.extensions)i.updateState.call(this,t,i);this.setNeedsRedraw(),this._updateAttributes();const n=this.getModels()[0]!==e[0];this._postUpdate(t,n)}finally{i.viewport=s,this.props=n,this._clearChangeFlags(),o.needsUpdate=!1,o.resetOldProps()}}_finalize(){t.debug("layer.finalize",this),this.finalizeState(this.context);for(const t of this.props.extensions)t.finalizeState.call(this,this.context,t)}_drawLayer({renderPass:t,shaderModuleProps:n=null,uniforms:i={},parameters:o={}}){this._updateAttributeTransition();const s=this.props,r=this.context;this.props=this.internalState.propsInTransition||s;try{n&&this.setShaderModuleProps(n);const{getPolygonOffset:s}=this.props,a=s&&s(i)||[0,0];r.device instanceof e.WebGLDevice&&r.device.setParametersWebGL({polygonOffset:a});const l=r.device instanceof e.WebGLDevice?null:function(t){const{blendConstant:e,...n}=t;return e?{pipelineParameters:n,renderPassParameters:{blendConstant:e}}:{pipelineParameters:n}}(o);if(function(t,e,n,i){for(const o of t)"webgpu"===o.device.type?(sn(o,e),o.setParameters({...o.parameters,...i?.pipelineParameters})):o.setParameters(n)}(this.getModels(),t,o,l),r.device instanceof e.WebGLDevice)r.device.withParametersWebGL(o,()=>{const e={renderPass:t,shaderModuleProps:n,uniforms:i,parameters:o,context:r};for(const t of this.props.extensions)t.draw.call(this,e,t);this.draw(e)});else{l?.renderPassParameters&&t.setParameters(l.renderPassParameters);const e={renderPass:t,shaderModuleProps:n,uniforms:i,parameters:o,context:r};for(const t of this.props.extensions)t.draw.call(this,e,t);this.draw(e)}}finally{this.props=s}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:n}=this.internalState;for(const o in e)if(e[o]){let i=!1;if("dataChanged"===o){const t=e[o],s=n[o];t&&Array.isArray(s)&&(n.dataChanged=Array.isArray(t)?s.concat(t):t,i=!0)}n[o]||(n[o]=e[o],i=!0),i&&t.debug("layer.changeFlag",this,o,e)}const i=Boolean(n.dataChanged||n.updateTriggersChanged||n.propsChanged||n.extensionsChanged);n.propsOrDataChanged=i,n.somethingChanged=i||n.viewportChanged||n.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(t,e){const n=Ae(t,e);if(n.updateTriggersChanged)for(const i in n.updateTriggersChanged)n.updateTriggersChanged[i]&&this.invalidateAttribute(i);if(n.transitionsChanged)for(const i in n.transitionsChanged)this.internalState.uniformTransitions.add(i,e[i],t[i],t.transitions?.[i]);return this.setChangeFlags(n)}validateProps(){!function(e){const n=e[t.PROP_TYPES_SYMBOL];for(const t in n){const i=n[t],{validate:o}=i;if(o&&!o(e[t],i))throw new Error(`Invalid prop ${t}: ${e[t]}`)}}(this.props)}updateAutoHighlight(t){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(t)}_updateAutoHighlight(t){const e={highlightedObjectColor:t.picked?t.color:null},{highlightColor:n}=this.props;t.picked&&"function"==typeof n&&(e.highlightColor=n(t)),this.setShaderModuleProps({picking:e}),this.setNeedsRedraw()}_getAttributeManager(){const t=this.context;return new xe(t.device,{id:this.props.id,stats:t.stats,timeline:t.timeline})}_postUpdate(t,e){const{props:n,oldProps:i}=t,o=this.state.model;o?.isInstanced&&o.setInstanceCount(this.getNumInstances());const{autoHighlight:s,highlightedObjectIndex:r,highlightColor:a}=n;if(e||i.autoHighlight!==s||i.highlightedObjectIndex!==r||i.highlightColor!==a){const t={};Array.isArray(a)&&(t.highlightColor=a),(e||i.autoHighlight!==s||r!==i.highlightedObjectIndex)&&(t.highlightedObjectColor=Number.isFinite(r)&&r>=0?this.encodePickingColor(r):null),this.setShaderModuleProps({picking:t})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(t){if(!this.internalState)return!1;let e=!1;e=e||this.internalState.needsRedraw&&this.id;const n=this.getAttributeManager(),i=!!n&&n.getNeedsRedraw(t);if(e=e||i,e)for(const o of this.props.extensions)o.onNeedsRedraw.call(this,o);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!t.clearRedrawFlags,e}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}function sn(t,e){const n=e.props.framebuffer||(e.framebuffer??null);if(!n)return;const i=n.colorAttachments.map(t=>t?.texture?.format??null),o=n.depthStencilAttachment?.texture?.format,s=t;(function(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0})(s.props.colorAttachmentFormats,i)&&s.props.depthStencilAttachmentFormat===o||(s.props.colorAttachmentFormats=i,s.props.depthStencilAttachmentFormat=o,s._setPipelineNeedsUpdate("attachment formats"))}on.defaultProps=nn,on.layerName="Layer";class rn extends on{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(t=>t.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(t){}setState(t){super.setState(t),this.setNeedsUpdate()}getPickingInfo({info:t}){const{object:e}=t;return e&&e.__source&&e.__source.parent&&e.__source.parent.id===this.id?(t.object=e.__source.object,t.index=e.__source.index,t):t}filterSubLayer(t){return!0}shouldRenderSubLayer(t,e){return e&&e.length}getSubLayerClass(t,e){const{_subLayerProps:n}=this.props;return n&&n[t]&&n[t].type||e}getSubLayerRow(t,e,n){return t.__source={parent:this,object:e,index:n},t}getSubLayerAccessor(t){if("function"==typeof t){const e={index:-1,data:this.props.data,target:[]};return(n,i)=>n&&n.__source?(e.index=n.__source.index,t(n.__source.object,e)):t(n,i)}return t}getSubLayerProps(e={}){const{opacity:n,pickable:i,visible:o,parameters:s,getPolygonOffset:r,highlightedObjectIndex:a,autoHighlight:l,highlightColor:c,coordinateSystem:u,coordinateOrigin:d,wrapLongitude:f,positionFormat:p,modelMatrix:h,extensions:g,fetch:m,operation:v,_subLayerProps:y}=this.props,x={id:"",updateTriggers:{},opacity:n,pickable:i,visible:o,parameters:s,getPolygonOffset:r,highlightedObjectIndex:a,autoHighlight:l,highlightColor:c,coordinateSystem:u,coordinateOrigin:d,wrapLongitude:f,positionFormat:p,modelMatrix:h,extensions:g,fetch:m,operation:v},_=y&&e.id&&y[e.id],b=_&&_.updateTriggers,P=e.id||"sublayer";if(_){const n=this.props[t.PROP_TYPES_SYMBOL],i=e.type?e.type._propTypes:{};for(const t in _){const e=i[t]||n[t];e&&"accessor"===e.type&&(_[t]=this.getSubLayerAccessor(_[t]))}}Object.assign(x,e,_),x.id=`${this.props.id}-${P}`,x.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...b};for(const t of g){const e=t.getSubLayerProps.call(this,t);e&&Object.assign(x,e,{updateTriggers:Object.assign(x.updateTriggers,e.updateTriggers)})}return x}_updateAutoHighlight(t){for(const e of this.getSubLayers())e.updateAutoHighlight(t)}_getAttributeManager(){return null}_postUpdate(e,n){let i=this.internalState.subLayers;const o=!i||this.needsUpdate();if(o){const e=this.renderLayers();i=t.flatten(e,Boolean),this.internalState.subLayers=i}t.debug("compositeLayer.renderLayers",this,o,i);for(const t of i)t.parent=this}}rn.layerName="CompositeLayer";class an{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:n={}}=e;this.typedArrayManager=t.defaultTypedArrayManager,this.attributes={},this._attributeDefs=n,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:n,buffers:i={},getGeometry:o,geometryBuffer:s,positionFormat:r,dataChanged:a,normalize:l=!0}=this.opts;if(this.data=n,this.getGeometry=o,this.positionSize=s&&s.size||("XY"===r?2:3),this.buffers=i,this.normalize=l,s&&(t.assert$1(n.startIndices),this.getGeometry=this.getGeometryFromBuffer(s),l||(i.vertexPositions=s)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(const t of a)this._rebuildGeometry(t);else this._rebuildGeometry()}updatePartialGeometry({startRow:t,endRow:e}){this._rebuildGeometry({startRow:t,endRow:e})}getGeometryFromBuffer(t){const e=t.value||t;return ArrayBuffer.isView(e)?Zt(e,{size:this.positionSize,offset:t.offset,stride:t.stride,startIndices:this.data.startIndices}):null}_allocate(t,e){const{attributes:n,buffers:i,_attributeDefs:o,typedArrayManager:s}=this;for(const r in o)if(r in i)s.release(n[r]),n[r]=null;else{const i=o[r];i.copy=e,n[r]=s.allocate(n[r],t,i)}}_forEachGeometry(t,e,n){const{data:i,getGeometry:o}=this,{iterable:s,objectInfo:r}=Kt(i,e,n);for(const a of s){r.index++;t(o?o(a,r):null,r.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:n,vertexStarts:i,instanceCount:o}=this;const{data:s,geometryBuffer:r}=this,{startRow:a=0,endRow:l=1/0}=e||{},c={};if(e||(n=[0],i=[0]),this.normalize||!r)this._forEachGeometry((t,e)=>{const n=t&&this.normalizeGeometry(t);c[e]=n,i[e+1]=i[e]+(n?this.getGeometrySize(n):0)},a,l),o=i[i.length-1];else if(i=s.startIndices,o=i[s.length]||0,ArrayBuffer.isView(r))o=o||r.length/this.positionSize;else if(r instanceof t.Buffer){const t=4*this.positionSize;o=o||r.byteLength/t}else if(r.buffer){const t=r.stride||4*this.positionSize;o=o||r.buffer.byteLength/t}else if(r.value){const t=r.value,e=r.stride/t.BYTES_PER_ELEMENT||this.positionSize;o=o||t.length/e}this._allocate(o,Boolean(e)),this.indexStarts=n,this.vertexStarts=i,this.instanceCount=o;const u={};this._forEachGeometry((t,e)=>{const s=c[e]||t;u.vertexStart=i[e],u.indexStart=n[e];const r=e<i.length-1?i[e+1]:o;u.geometrySize=r-i[e],u.geometryIndex=e,this.updateGeometryAttributes(s,u)},a,l),this.vertexCount=n[n.length-1]}}const ln="layout(std140) uniform arcUniforms {\n bool greatCircle;\n bool useShortestPath;\n float numSegments;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int widthUnits;\n} arc;\n",cn={name:"arc",vs:ln,fs:ln,uniformTypes:{greatCircle:"f32",useShortestPath:"f32",numSegments:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",widthUnits:"i32"}},un=[0,0,0,255],dn={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getSourceColor:{type:"accessor",value:un},getTargetColor:{type:"accessor",value:un},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}};class fn extends on{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME arc-layer-vertex-shader\nin vec4 instanceSourceColors;\nin vec4 instanceTargetColors;\nin vec3 instanceSourcePositions;\nin vec3 instanceSourcePositions64Low;\nin vec3 instanceTargetPositions;\nin vec3 instanceTargetPositions64Low;\nin vec3 instancePickingColors;\nin float instanceWidths;\nin float instanceHeights;\nin float instanceTilts;\nout vec4 vColor;\nout vec2 uv;\nout float isValid;\nfloat paraboloid(float distance, float sourceZ, float targetZ, float ratio) {\nfloat deltaZ = targetZ - sourceZ;\nfloat dh = distance * instanceHeights;\nif (dh == 0.0) {\nreturn sourceZ + deltaZ * ratio;\n}\nfloat unitZ = deltaZ / dh;\nfloat p2 = unitZ * unitZ + 1.0;\nfloat dir = step(deltaZ, 0.0);\nfloat z0 = mix(sourceZ, targetZ, dir);\nfloat r = mix(ratio, 1.0 - ratio, dir);\nreturn sqrt(r * (p2 - r)) * dh + z0;\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\nvec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);\ndir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\nreturn dir_screenspace * offset_direction * width / 2.0;\n}\nfloat getSegmentRatio(float index) {\nreturn smoothstep(0.0, 1.0, index / (arc.numSegments - 1.0));\n}\nvec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) {\nfloat distance = length(source.xy - target.xy);\nfloat z = paraboloid(distance, source.z, target.z, segmentRatio);\nfloat tiltAngle = radians(instanceTilts);\nvec2 tiltDirection = normalize(target.xy - source.xy);\nvec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);\nreturn vec3(\nmix(source.xy, target.xy, segmentRatio) + tilt,\nz * cos(tiltAngle)\n);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\nvec2 sourceRadians = radians(source);\nvec2 targetRadians = radians(target);\nvec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);\nvec2 shd_sq = sin_half_delta * sin_half_delta;\nfloat a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;\nreturn 2.0 * asin(sqrt(a));\n}\nvec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) {\nvec2 lngLat;\nif(abs(angularDist - PI) < 0.001) {\nlngLat = (1.0 - t) * source.xy + t * target.xy;\n} else {\nfloat a = sin((1.0 - t) * angularDist);\nfloat b = sin(t * angularDist);\nvec3 p = source3D.yxz * a + target3D.yxz * b;\nlngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));\n}\nfloat z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);\nreturn vec3(lngLat, z);\n}\nvoid main(void) {\ngeometry.worldPosition = instanceSourcePositions;\ngeometry.worldPositionAlt = instanceTargetPositions;\nfloat segmentIndex = float(gl_VertexID / 2);\nfloat segmentSide = mod(float(gl_VertexID), 2.) == 0. ? -1. : 1.;\nfloat segmentRatio = getSegmentRatio(segmentIndex);\nfloat prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));\nfloat nextSegmentRatio = getSegmentRatio(min(arc.numSegments - 1.0, segmentIndex + 1.0));\nfloat indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\nisValid = 1.0;\nuv = vec2(segmentRatio, segmentSide);\ngeometry.uv = uv;\ngeometry.pickingColor = instancePickingColors;\nvec4 curr;\nvec4 next;\nvec3 source;\nvec3 target;\nif ((arc.greatCircle || project.projectionMode == PROJECTION_MODE_GLOBE) && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nsource = project_globe_(vec3(instanceSourcePositions.xy, 0.0));\ntarget = project_globe_(vec3(instanceTargetPositions.xy, 0.0));\nfloat angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);\nvec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);\nvec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);\nvec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);\nif (abs(currPos.x - prevPos.x) > 180.0) {\nindexDir = -1.0;\nisValid = 0.0;\n} else if (abs(currPos.x - nextPos.x) > 180.0) {\nindexDir = 1.0;\nisValid = 0.0;\n}\nnextPos = indexDir < 0.0 ? prevPos : nextPos;\nnextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;\nif (isValid == 0.0) {\nnextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0;\nfloat t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x);\ncurrPos = mix(currPos, nextPos, t);\nsegmentRatio = mix(segmentRatio, nextSegmentRatio, t);\n}\nvec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio);\nvec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio);\ncurr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position);\nnext = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n} else {\nvec3 source_world = instanceSourcePositions;\nvec3 target_world = instanceTargetPositions;\nif (arc.useShortestPath) {\nsource_world.x = mod(source_world.x + 180., 360.0) - 180.;\ntarget_world.x = mod(target_world.x + 180., 360.0) - 180.;\nfloat deltaLng = target_world.x - source_world.x;\nif (deltaLng > 180.) target_world.x -= 360.;\nif (deltaLng < -180.) source_world.x -= 360.;\n}\nsource = project_position(source_world, instanceSourcePositions64Low);\ntarget = project_position(target_world, instanceTargetPositions64Low);\nfloat antiMeridianX = 0.0;\nif (arc.useShortestPath) {\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nantiMeridianX = -(project.coordinateOrigin.x + 180.) / 360. * TILE_SIZE;\n}\nfloat thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x);\nif (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) {\nisValid = 0.0;\nindexDir = sign(segmentRatio - thresholdRatio);\nsegmentRatio = thresholdRatio;\n}\n}\nnextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;\nvec3 currPos = interpolateFlat(source, target, segmentRatio);\nvec3 nextPos = interpolateFlat(source, target, nextSegmentRatio);\nif (arc.useShortestPath) {\nif (nextPos.x < antiMeridianX) {\ncurrPos.x += TILE_SIZE;\nnextPos.x += TILE_SIZE;\n}\n}\ncurr = project_common_position_to_clipspace(vec4(currPos, 1.0));\nnext = project_common_position_to_clipspace(vec4(nextPos, 1.0));\ngeometry.position = vec4(currPos, 1.0);\n}\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceWidths * arc.widthScale, arc.widthUnits),\narc.widthMinPixels, arc.widthMaxPixels\n);\nvec3 offset = vec3(\ngetExtrusionOffset((next.xy - curr.xy) * indexDir, segmentSide, widthPixels),\n0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\nDECKGL_FILTER_GL_POSITION(curr, geometry);\ngl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);\nvec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio);\nvColor = vec4(color.rgb, color.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME arc-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 uv;\nin float isValid;\nout vec4 fragColor;\nvoid main(void) {\nif (isValid == 0.0) {\ndiscard;\n}\nfragColor = vColor;\ngeometry.uv = uv;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[$,H,cn]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:un},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:un},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{widthUnits:n,widthScale:i,widthMinPixels:o,widthMaxPixels:s,greatCircle:r,wrapLongitude:a,numSegments:l}=this.props,c={numSegments:l,widthUnits:t.UNIT[n],widthScale:i,widthMinPixels:o,widthMaxPixels:s,greatCircle:r,useShortestPath:a},u=this.state.model;u.shaderInputs.setProps({arc:c}),u.setVertexCount(2*l),u.draw(this.context.renderPass)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-strip",isInstanced:!0})}}fn.layerName="ArcLayer",fn.defaultProps=dn;const pn=new Uint32Array([0,2,1,0,3,2]),hn=new Float32Array([0,1,0,0,1,0,1,1]);function gn(t,e){if(!e)return function(t){const e=new Float64Array(12);for(let n=0;n<t.length;n++)e[3*n+0]=t[n][0],e[3*n+1]=t[n][1],e[3*n+2]=t[n][2]||0;return{vertexCount:6,positions:e,indices:pn,texCoords:hn}}(t);const n=Math.max(Math.abs(t[0][0]-t[3][0]),Math.abs(t[1][0]-t[2][0])),i=Math.max(Math.abs(t[1][1]-t[0][1]),Math.abs(t[2][1]-t[3][1])),o=Math.ceil(n/e)+1,s=Math.ceil(i/e)+1,r=(o-1)*(s-1)*6,a=new Uint32Array(r),l=new Float32Array(o*s*2),c=new Float64Array(o*s*3);let u=0,d=0;for(let f=0;f<o;f++){const e=f/(o-1);for(let n=0;n<s;n++){const i=n/(s-1),o=mn(t,e,i);c[3*u+0]=o[0],c[3*u+1]=o[1],c[3*u+2]=o[2]||0,l[2*u+0]=e,l[2*u+1]=1-i,f>0&&n>0&&(a[d++]=u-s,a[d++]=u-s-1,a[d++]=u-1,a[d++]=u-s,a[d++]=u-1,a[d++]=u),u++}}return{vertexCount:r,positions:c,indices:a,texCoords:l}}function mn(e,n,i){return t.lerp$1(t.lerp$1(e[0],e[1],i),t.lerp$1(e[3],e[2],i),n)}const vn="layout(std140) uniform bitmapUniforms {\n vec4 bounds;\n float coordinateConversion;\n float desaturate;\n vec3 tintColor;\n vec4 transparentColor;\n} bitmap;\n",yn={name:"bitmap",vs:vn,fs:vn,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}};class xn extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME bitmap-layer-vertex-shader\n\nin vec2 texCoords;\nin vec3 positions;\nin vec3 positions64Low;\n\nout vec2 vTexCoord;\nout vec2 vTexPos;\n\nconst vec3 pickingColor = vec3(1.0, 0.0, 0.0);\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = pickingColor;\n\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vTexCoord = texCoords;\n\n if (bitmap.coordinateConversion < -0.5) {\n vTexPos = geometry.position.xy + project.commonOrigin.xy;\n } else if (bitmap.coordinateConversion > 0.5) {\n vTexPos = geometry.worldPosition.xy;\n }\n\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME bitmap-layer-fragment-shader\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D bitmapTexture;\n\nin vec2 vTexCoord;\nin vec2 vTexPos;\n\nout vec4 fragColor;\n\n/* projection utils */\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / PI / 2.0;\n\n// from degrees to Web Mercator\nvec2 lnglat_to_mercator(vec2 lnglat) {\n float x = lnglat.x;\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nvec2 mercator_to_lnglat(vec2 xy) {\n xy /= WORLD_SCALE;\n return degrees(vec2(\n xy.x - PI,\n atan(exp(xy.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n/* End projection utils */\n\n// apply desaturation\nvec3 color_desaturate(vec3 color) {\n float luminance = (color.r + color.g + color.b) * 0.333333333;\n return mix(color, vec3(luminance), bitmap.desaturate);\n}\n\n// apply tint\nvec3 color_tint(vec3 color) {\n return color * bitmap.tintColor;\n}\n\n// blend with background color\nvec4 apply_opacity(vec3 color, float alpha) {\n if (bitmap.transparentColor.a == 0.0) {\n return vec4(color, alpha);\n }\n float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha);\n float highLightRatio = alpha / blendedAlpha;\n vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n}\n\nvec2 getUV(vec2 pos) {\n return vec2(\n (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]),\n (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3])\n );\n}\n\n\nvec3 packUVsIntoRGB(vec2 uv) {\n // Extract the top 8 bits. We want values to be truncated down so we can add a fraction\n vec2 uv8bit = floor(uv * 256.);\n\n // Calculate the normalized remainders of u and v parts that do not fit into 8 bits\n // Scale and clamp to 0-1 range\n vec2 uvFraction = fract(uv * 256.);\n vec2 uvFraction4bit = floor(uvFraction * 16.);\n\n // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates\n float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.;\n\n return vec3(uv8bit, fractions) / 255.;\n}\n\n\nvoid main(void) {\n vec2 uv = vTexCoord;\n if (bitmap.coordinateConversion < -0.5) {\n vec2 lnglat = mercator_to_lnglat(vTexPos);\n uv = getUV(lnglat);\n } else if (bitmap.coordinateConversion > 0.5) {\n vec2 commonPos = lnglat_to_mercator(vTexPos);\n uv = getUV(commonPos);\n }\n vec4 bitmapColor = texture(bitmapTexture, uv);\n\n fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity);\n\n geometry.uv = uv;\n DECKGL_FILTER_COLOR(fragColor, geometry);\n\n if (bool(picking.isActive) && !bool(picking.isAttribute)) {\n // Since instance information is not used, we can use picking color for pixel index\n fragColor.rgb = packUVsIntoRGB(uv);\n }\n}\n",modules:[$,H,yn]})}initializeState(){const t=this.getAttributeManager();t.remove(["instancePickingColors"]);const e=!0;t.add({indices:{size:1,isIndexed:!0,update:t=>t.value=this.state.mesh.indices,noAlloc:e},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:t=>t.value=this.state.mesh.positions,noAlloc:e},texCoords:{size:2,update:t=>t.value=this.state.mesh.texCoords,noAlloc:e}})}updateState({props:t,oldProps:e,changeFlags:n}){const i=this.getAttributeManager();if(n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll()),t.bounds!==e.bounds){const t=this.state.mesh,e=this._createMesh();this.state.model.setVertexCount(e.vertexCount);for(const n in e)t&&t[n]!==e[n]&&i.invalidate(n);this.setState({mesh:e,...this._getCoordinateUniforms()})}else t._imageCoordinateSystem!==e._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(t){const{image:e}=this.props,n=t.info;if(!n.color||!e)return n.bitmap=null,n;const{width:i,height:o}=e;n.index=0;const s=function(t){const[e,n,i]=t;return[(e+(15&i)/16)/256,(n+(240&i)/256)/256]}(n.color);return n.bitmap={size:{width:i,height:o},uv:s,pixel:[Math.floor(s[0]*i),Math.floor(s[1]*o)]},n}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(t){super._updateAutoHighlight({...t,color:this.encodePickingColor(0)})}_createMesh(){const{bounds:t}=this.props;let e=t;return _n(t)&&(e=[[t[0],t[1]],[t[0],t[3]],[t[2],t[3]],[t[2],t[1]]]),gn(e,this.context.viewport.resolution)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(t){const{shaderModuleProps:e}=t,{model:n,coordinateConversion:i,bounds:o,disablePicking:s}=this.state,{image:r,desaturate:a,transparentColor:l,tintColor:c}=this.props;if((!e.picking.isActive||!s)&&r&&n){const t={bitmapTexture:r,bounds:o,coordinateConversion:i,desaturate:a,tintColor:c.slice(0,3).map(t=>t/255),transparentColor:l.map(t=>t/255)};n.shaderInputs.setProps({bitmap:t}),n.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if("default"!==e){const{bounds:n}=this.props;if(!_n(n))throw new Error("_imageCoordinateSystem only supports rectangular bounds");const i=this.context.viewport.resolution?"lnglat":"cartesian";if(e="lnglat"===e?"lnglat":"cartesian","lnglat"===e&&"cartesian"===i)return{coordinateConversion:-1,bounds:n};if("cartesian"===e&&"lnglat"===i){const e=t.lngLatToWorld([n[0],n[1]]),i=t.lngLatToWorld([n[2],n[3]]);return{coordinateConversion:1,bounds:[e[0],e[1],i[0],i[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}}function _n(t){return Number.isFinite(t[0])}xn.layerName="BitmapLayer",xn.defaultProps={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}};const bn="layout(std140) uniform iconUniforms {\n float sizeScale;\n vec2 iconsTextureDim;\n float sizeBasis;\n float sizeMinPixels;\n float sizeMaxPixels;\n bool billboard;\n highp int sizeUnits;\n float alphaCutoff;\n} icon;\n",Pn={name:"icon",vs:bn,fs:bn,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}},Cn=()=>{},Ln={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},wn={x:0,y:0,width:0,height:0};function Sn(t,e,n,i){const o=Math.min(n/e.width,i/e.height),s=Math.floor(e.width*o),r=Math.floor(e.height*o);return 1===o?{image:e,width:s,height:r}:(t.canvas.height=r,t.canvas.width=s,t.clearRect(0,0,s,r),t.drawImage(e,0,0,e.width,e.height,0,0,s,r),{image:t.canvas,width:s,height:r})}function An(t){return t&&(t.id||t.url)}function On(t){const{device:e}=t;"webgl"===e.type?t.generateMipmapsWebGL():"webgpu"===e.type&&e.generateMipmapsWebGPU(t)}function Tn(t,e,n){for(let i=0;i<e.length;i++){const{icon:o,xOffset:s}=e[i];t[An(o)]={...o,x:s,y:n}}}class In{constructor(t,{onUpdate:e=Cn,onError:n=Cn}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=4,this._canvasWidth=1024,this._canvasHeight=0,this._canvas=null,this.device=t,this.onUpdate=e,this.onError=n}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(t){const e=this._autoPacking?An(t):t;return this._mapping[e]||wn}setProps({loadOptions:t,autoPacking:e,iconAtlas:n,iconMapping:i,textureParameters:o}){t&&(this._loadOptions=t),void 0!==e&&(this._autoPacking=e),i&&(this._mapping=i),n&&(this._texture?.delete(),this._texture=null,this._externalTexture=n),o&&(this._samplerParameters=o)}get isLoaded(){return 0===this._pendingCount}packIcons(t,e){if(!this._autoPacking||"undefined"==typeof document)return;const n=Object.values(function(t,e,n){if(!t||!e)return null;n=n||{};const i={},{iterable:o,objectInfo:s}=Kt(t);for(const r of o){s.index++;const t=e(r,s),o=An(t);if(!t)throw new Error("Icon is missing.");if(!t.url)throw new Error("Icon url is missing.");i[o]||n[o]&&t.url===n[o].url||(i[o]={...t,source:r,sourceIndex:s.index})}return i}(t,e,this._mapping)||{});if(n.length>0){const{mapping:t,xOffset:e,yOffset:i,rowHeight:o,canvasHeight:s}=function({icons:t,buffer:e,mapping:n={},xOffset:i=0,yOffset:o=0,rowHeight:s=0,canvasWidth:r}){let a=[];for(let c=0;c<t.length;c++){const l=t[c];if(!n[An(l)]){const{height:t,width:c}=l;i+c+e>r&&(Tn(n,a,o),i=0,o=s+o+e,s=0,a=[]),a.push({icon:l,xOffset:i}),i=i+c+e,s=Math.max(s,t)}}return a.length>0&&Tn(n,a,o),{mapping:n,rowHeight:s,xOffset:i,yOffset:o,canvasWidth:r,canvasHeight:(l=s+o+e,Math.pow(2,Math.ceil(Math.log2(l))))};var l}({icons:n,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=o,this._mapping=t,this._xOffset=e,this._yOffset=i,this._canvasHeight=s,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||Ln,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)})),this._texture.height!==this._canvasHeight&&(this._texture=function(t,e,n,i){const{width:o,height:s,device:r}=t,a=r.createTexture({format:"rgba8unorm",width:e,height:n,sampler:i,mipLevels:r.getMipLevelCount(e,n)}),l=r.createCommandEncoder();l.copyTextureToTexture({sourceTexture:t,destinationTexture:a,width:o,height:s});const c=l.finish();return r.submit(c),On(a),t.destroy(),a}(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||Ln)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(n)}}_loadIcons(e){const n=this._canvas.getContext("2d",{willReadFrequently:!0});for(const i of e)this._pendingCount++,t.load(i.url,this._loadOptions).then(t=>{const e=An(i),o=this._mapping[e],{x:s,y:r,width:a,height:l}=o,{image:c,width:u,height:d}=Sn(n,t,a,l),f=s+(a-u)/2,p=r+(l-d)/2;this._texture?.copyExternalImage({image:c,x:f,y:p,width:u,height:d}),o.x=f,o.y=p,o.width=u,o.height=d,this._texture&&On(this._texture),this.onUpdate(u!==a||d!==l)}).catch(t=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:t})}).finally(()=>{this._pendingCount--})}}const En=[0,0,0,255],Mn={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeBasis:"height",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:En},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}};class zn extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),\nicon.sizeMinPixels, icon.sizeMaxPixels\n);\nfloat iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y;\nfloat instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nif (icon.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / icon.iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME icon-layer-fragment-shader\nprecision highp float;\nuniform sampler2D iconsTexture;\nin float vColorMode;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nvec4 texColor = texture(iconsTexture, vTextureCoords);\nvec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);\nfloat a = texColor.a * layer.opacity * vColor.a;\nif (a < icon.alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color, a);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:'struct IconUniforms {\n sizeScale: f32,\n iconsTextureDim: vec2<f32>,\n sizeBasis: f32,\n sizeMinPixels: f32,\n sizeMaxPixels: f32,\n billboard: i32,\n sizeUnits: i32,\n alphaCutoff: f32\n};\n\n@group(0) @binding(auto) var<uniform> icon: IconUniforms;\n@group(0) @binding(auto) var iconsTexture : texture_2d<f32>;\n@group(0) @binding(auto) var iconsTextureSampler : sampler;\n\nfn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> {\n let angle_radian = angle_deg * PI / 180.0;\n let c = cos(angle_radian);\n let s = sin(angle_radian);\n let rotation = mat2x2<f32>(vec2<f32>(c, s), vec2<f32>(-s, c));\n return rotation * vertex;\n}\n\nstruct Attributes {\n @location(0) positions: vec2<f32>,\n\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceSizes: f32,\n @location(4) instanceAngles: f32,\n @location(5) instanceColors: vec4<f32>,\n @location(6) instancePickingColors: vec3<f32>,\n @location(7) instanceIconFrames: vec4<f32>,\n @location(8) instanceColorModes: f32,\n @location(9) instanceOffsets: vec2<f32>,\n @location(10) instancePixelOffset: vec2<f32>,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n\n @location(0) vColorMode: f32,\n @location(1) vColor: vec4<f32>,\n @location(2) vTextureCoords: vec2<f32>,\n @location(3) uv: vec2<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(inp: Attributes) -> Varyings {\n // write geometry fields used by filters + FS\n geometry.worldPosition = inp.instancePositions;\n geometry.uv = inp.positions;\n geometry.pickingColor = inp.instancePickingColors;\n\n var outp: Varyings;\n outp.uv = inp.positions;\n\n let iconSize = inp.instanceIconFrames.zw;\n\n // convert size in meters to pixels, then clamp\n let sizePixels = clamp(\n project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits),\n icon.sizeMinPixels, icon.sizeMaxPixels\n );\n\n // scale icon height to match instanceSize\n let iconConstraint = select(iconSize.y, iconSize.x, icon.sizeBasis == 0.0);\n let instanceScale = select(sizePixels / iconConstraint, 0.0, iconConstraint == 0.0);\n\n // scale and rotate vertex in "pixel" units; then add per-instance pixel offset\n var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets;\n pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale;\n pixelOffset = pixelOffset + inp.instancePixelOffset;\n pixelOffset.y = pixelOffset.y * -1.0;\n\n if (icon.billboard != 0) {\n var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0)); // TODO, &geometry.position);\n // DECKGL_FILTER_GL_POSITION(pos, geometry);\n\n var offset = vec3<f32>(pixelOffset, 0.0);\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipOffset = project_pixel_size_to_clipspace(offset.xy);\n pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w);\n outp.position = pos;\n } else {\n var offset_common = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);\n // DECKGL_FILTER_SIZE(offset_common, geometry);\n var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offset_common); // TODO, &geometry.position);\n // DECKGL_FILTER_GL_POSITION(pos, geometry);\n outp.position = pos;\n }\n\n let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5;\n outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim;\n\n outp.vColor = inp.instanceColors;\n // DECKGL_FILTER_COLOR(outp.vColor, geometry);\n\n outp.vColorMode = inp.instanceColorModes;\n outp.pickingColor = inp.instancePickingColors;\n\n return outp;\n}\n\n@fragment\nfn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {\n // expose to deck.gl filter hooks\n geometry.uv = inp.uv;\n\n let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords);\n\n // if colorMode == 0, use pixel color from the texture\n // if colorMode == 1 (or picking), use texture as transparency mask\n let rgb = mix(texColor.rgb, inp.vColor.rgb, inp.vColorMode);\n let a = texColor.a * layer.opacity * inp.vColor.a;\n\n if (a < icon.alphaCutoff) {\n discard;\n }\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inp.pickingColor)) {\n discard;\n }\n return vec4<f32>(inp.pickingColor, 1.0);\n }\n\n var fragColor = deckgl_premultiplied_alpha(vec4<f32>(rgb, a));\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return fragColor;\n}\n',modules:[$,W,H,Pn]})}initializeState(){this.state={iconManager:new In(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceIconDefs:{size:7,accessor:"getIcon",transform:this.getInstanceIconDef,shaderAttributes:{instanceOffsets:{size:2,elementOffset:0},instanceIconFrames:{size:4,elementOffset:2},instanceColorModes:{size:1,elementOffset:6}}},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:En},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(t){super.updateState(t);const{props:e,oldProps:n,changeFlags:i}=t,o=this.getAttributeManager(),{iconAtlas:s,iconMapping:r,data:a,getIcon:l,textureParameters:c}=e,{iconManager:u}=this.state;if("string"==typeof s)return;const d=s||this.internalState.isAsyncPropLoading("iconAtlas");u.setProps({loadOptions:e.loadOptions,autoPacking:!d,iconAtlas:s,iconMapping:d?r:null,textureParameters:c}),d?n.iconMapping!==e.iconMapping&&o.invalidate("getIcon"):(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getIcon))&&u.packIcons(a,l),i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),o.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(t){super.finalizeState(t),this.state.iconManager.finalize()}draw({uniforms:e}){const{sizeScale:n,sizeBasis:i,sizeMinPixels:o,sizeMaxPixels:s,sizeUnits:r,billboard:a,alphaCutoff:l}=this.props,{iconManager:c}=this.state,u=c.getTexture();if(u){const e=this.state.model,c={iconsTexture:u,iconsTextureDim:[u.width,u.height],sizeUnits:t.UNIT[r],sizeScale:n,sizeBasis:"height"===i?1:0,sizeMinPixels:o,sizeMaxPixels:s,billboard:a,alphaCutoff:l};e.shaderInputs.setProps({icon:c}),e.draw(this.context.renderPass)}}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([-1,-1,1,-1,-1,1,1,1])}}}),isInstanced:!0})}_onUpdate(t){t?(this.getAttributeManager()?.invalidate("getIcon"),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){const n=this.getCurrentLayer()?.props.onIconError;n?n(e):t.defaultLogger.error(e.error.message)()}getInstanceIconDef(t){const{x:e,y:n,width:i,height:o,mask:s,anchorX:r=i/2,anchorY:a=o/2}=this.state.iconManager.getIconMapping(t);return[i/2-r,o/2-a,e,n,i,o,s?1:0]}}zn.defaultProps=Mn,zn.layerName="IconLayer";const Rn="layout(std140) uniform pointCloudUniforms {\n float radiusPixels;\n highp int sizeUnits;\n} pointCloud;\n",Fn={name:"pointCloud",source:"",vs:Rn,fs:Rn,uniformTypes:{radiusPixels:"f32",sizeUnits:"i32"}},Bn=[0,0,0,255],kn=[0,0,1],Nn={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:kn},getColor:{type:"accessor",value:Bn},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};class Dn extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceNormals;\nin vec4 instanceColors;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec3 instancePickingColors;\nout vec4 vColor;\nout vec2 unitPosition;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.normal = project_normal(instanceNormals);\nunitPosition = positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\nvec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\nvec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, instanceColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 unitPosition;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition.xy;\nfloat distToCenter = length(unitPosition);\nif (distToCenter > 1.0) {\ndiscard;\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"struct PointCloudUniforms {\n radiusPixels: f32,\n sizeUnits: i32,\n};\n\n@group(0) @binding(0)\nvar<uniform> pointCloudUniforms: PointCloudUniforms;\n\nstruct ConstantAttributes {\n instanceNormals: vec3<f32>,\n instanceColors: vec4<f32>,\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instancePickingColors: vec3<f32>\n};\n\nconst constants = ConstantAttributes(\n vec3<f32>(1.0, 0.0, 0.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec3<f32>(0.0),\n vec3<f32>(0.0),\n vec3<f32>(0.0)\n);\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @builtin(vertex_index) vertexIndex : u32,\n @location(0) positions: vec3<f32>,\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceNormals: vec3<f32>,\n @location(4) instanceColors: vec4<f32>,\n @location(5) instancePickingColors: vec3<f32>\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) unitPosition: vec2<f32>,\n @location(2) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n geometry.worldPosition = attributes.instancePositions;\n\n let centerResult = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = centerResult.commonPosition;\n geometry.normal = project_normal(attributes.instanceNormals);\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = attributes.instancePickingColors;\n\n // Find the center of the point and add the current vertex\n let offset = vec3<f32>(\n attributes.positions.xy *\n project_unit_size_to_pixel(pointCloudUniforms.radiusPixels, pointCloudUniforms.sizeUnits),\n 0.0\n );\n // DECKGL_FILTER_SIZE(offset, geometry);\n\n varyings.position = centerResult.clipPosition;\n // DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position.x += clipPixels.x;\n varyings.position.y += clipPixels.y;\n\n // Apply lighting\n let lightColor = lighting_getLightColor2(attributes.instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vColor = vec4(lightColor, attributes.instanceColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(vColor, geometry);\n varyings.pickingColor = attributes.instancePickingColors;\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n // var geometry: Geometry;\n // geometry.uv = unitPosition.xy;\n\n let distToCenter = length(varyings.unitPosition);\n if (distToCenter > 1.0) {\n discard;\n }\n\n var fragColor: vec4<f32>;\n\n fragColor = varyings.vColor;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(varyings.pickingColor)) {\n discard;\n }\n return vec4<f32>(varyings.pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n}\n",modules:[$,W,G,H,Fn]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:kn},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:Bn}})}updateState(t){const{changeFlags:e,props:n}=t;super.updateState(t),e.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),e.dataChanged&&function(t){const{header:e,attributes:n}=t;if(e&&n&&(t.length=e.vertexCount,n.POSITION&&(n.instancePositions=n.POSITION),n.NORMAL&&(n.instanceNormals=n.NORMAL),n.COLOR_0)){const{size:t,value:e}=n.COLOR_0;n.instanceColors={size:t,type:"unorm8",value:e}}}(n.data)}draw({uniforms:e}){const{pointSize:n,sizeUnits:i}=this.props,o=this.state.model,s={sizeUnits:t.UNIT[i],radiusPixels:n};o.shaderInputs.setProps({pointCloud:s}),o.draw(this.context.renderPass)}_getModel(){const t=[];for(let e=0;e<3;e++){const n=e/3*Math.PI*2;t.push(2*Math.cos(n),2*Math.sin(n),0)}return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-list",attributes:{positions:new Float32Array(t)}}),isInstanced:!0})}}Dn.layerName="PointCloudLayer",Dn.defaultProps=Nn;const Un="layout(std140) uniform scatterplotUniforms {\n float radiusScale;\n float radiusMinPixels;\n float radiusMaxPixels;\n float lineWidthScale;\n float lineWidthMinPixels;\n float lineWidthMaxPixels;\n float stroked;\n float filled;\n bool antialiasing;\n bool billboard;\n highp int radiusUnits;\n highp int lineWidthUnits;\n} scatterplot;\n",jn={name:"scatterplot",vs:Un,fs:Un,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}},Gn=[0,0,0,255],Vn={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:Gn},getLineColor:{type:"accessor",value:Gn},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class Wn extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-vertex-shader\nin vec3 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceRadius;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nin vec2 instancePixelOffset;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout vec2 unitPosition;\nout float innerUnitRadius;\nout float outerRadiusPixels;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nouterRadiusPixels = clamp(\nproject_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),\nscatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n);\nfloat lineWidthPixels = clamp(\nproject_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),\nscatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n);\nouterRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\nfloat edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;\nunitPosition = edgePadding * positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\ninnerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;\nif (scatterplot.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = edgePadding * positions * outerRadiusPixels;\noffset.xy += instancePixelOffset;\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);\noffset.xy += project_pixel_size(instancePixelOffset);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin vec2 unitPosition;\nin float innerUnitRadius;\nin float outerRadiusPixels;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition;\nfloat distToCenter = length(unitPosition) * outerRadiusPixels;\nfloat inCircle = scatterplot.antialiasing ?\nsmoothedge(distToCenter, outerRadiusPixels) :\nstep(distToCenter, outerRadiusPixels);\nif (inCircle == 0.0) {\ndiscard;\n}\nif (scatterplot.stroked > 0.5) {\nfloat isLine = scatterplot.antialiasing ?\nsmoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :\nstep(innerUnitRadius * outerRadiusPixels, distToCenter);\nif (scatterplot.filled > 0.5) {\nfragColor = mix(vFillColor, vLineColor, isLine);\n} else {\nif (isLine == 0.0) {\ndiscard;\n}\nfragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);\n}\n} else if (scatterplot.filled < 0.5) {\ndiscard;\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= inCircle;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"// Main shaders\n\nstruct ScatterplotUniforms {\n radiusScale: f32,\n radiusMinPixels: f32,\n radiusMaxPixels: f32,\n lineWidthScale: f32,\n lineWidthMinPixels: f32,\n lineWidthMaxPixels: f32,\n stroked: f32,\n filled: i32,\n antialiasing: i32,\n billboard: i32,\n radiusUnits: i32,\n lineWidthUnits: i32,\n};\n\nstruct ConstantAttributeUniforms {\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4<f32>,\n instanceLineColors: vec4<f32>,\n instancePickingColors: vec3<f32>,\n instancePixelOffset: vec2<f32>,\n\n instancePositionsConstant: i32,\n instancePositions64LowConstant: i32,\n instanceRadiusConstant: i32,\n instanceLineWidthsConstant: i32,\n instanceFillColorsConstant: i32,\n instanceLineColorsConstant: i32,\n instancePickingColorsConstant: i32,\n instancePixelOffsetConstant: i32\n};\n\n@group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms;\n\nstruct ConstantAttributes {\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4<f32>,\n instanceLineColors: vec4<f32>,\n instancePickingColors: vec3<f32>,\n instancePixelOffset: vec2<f32>\n};\n\nconst constants = ConstantAttributes(\n vec3<f32>(0.0),\n vec3<f32>(0.0),\n 0.0,\n 0.0,\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec3<f32>(0.0),\n vec2<f32>(0.0)\n);\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @builtin(vertex_index) vertexIndex : u32,\n @location(0) positions: vec3<f32>,\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceRadius: f32,\n @location(4) instanceLineWidths: f32,\n @location(5) instanceFillColors: vec4<f32>,\n @location(6) instanceLineColors: vec4<f32>,\n @location(7) instancePickingColors: vec3<f32>,\n @location(8) instancePixelOffset: vec2<f32>\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vFillColor: vec4<f32>,\n @location(1) vLineColor: vec4<f32>,\n @location(2) unitPosition: vec2<f32>,\n @location(3) innerUnitRadius: f32,\n @location(4) outerRadiusPixels: f32,\n @location(5) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n // Draw an inline geometry constant array clip space triangle to verify that rendering works.\n // var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));\n // if (attributes.instanceIndex == 0) {\n // varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0);\n // return varyings;\n // }\n\n geometry.worldPosition = attributes.instancePositions;\n\n // Multiply out radius and clamp to limits\n varyings.outerRadiusPixels = clamp(\n project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits),\n scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n );\n\n // Multiply out line width and clamp to limits\n let lineWidthPixels = clamp(\n project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits),\n scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n );\n\n // outer radius needs to offset by half stroke width\n varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\n // Expand geometry to accommodate edge smoothing\n let edgePadding = select(\n (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,\n 1.0,\n scatterplot.antialiasing != 0\n );\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = edgePadding * attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = attributes.instancePickingColors;\n\n varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;\n\n if (scatterplot.billboard != 0) {\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels;\n offset = vec3<f32>(offset.xy + attributes.instancePixelOffset, offset.z);\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position = vec4<f32>(varyings.position.x + clipPixels.x, varyings.position.y + clipPixels.y, varyings.position.z, varyings.position.w);\n } else {\n var offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels);\n offset = vec3<f32>(offset.xy + project_pixel_size_vec2(attributes.instancePixelOffset), offset.z);\n // DECKGL_FILTER_SIZE(offset, geometry);\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n }\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry);\n varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry);\n varyings.pickingColor = attributes.instancePickingColors;\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n // var geometry: Geometry;\n // geometry.uv = unitPosition;\n\n let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels;\n let inCircle = select(\n smoothedge(distToCenter, varyings.outerRadiusPixels),\n step(distToCenter, varyings.outerRadiusPixels),\n scatterplot.antialiasing != 0\n );\n\n if (inCircle == 0.0) {\n discard;\n }\n\n var fragColor: vec4<f32>;\n\n if (scatterplot.stroked != 0) {\n let isLine = select(\n smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n scatterplot.antialiasing != 0\n );\n\n if (scatterplot.filled != 0) {\n fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine);\n } else {\n if (isLine == 0.0) {\n discard;\n }\n fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine);\n }\n } else if (scatterplot.filled == 0) {\n discard;\n } else {\n fragColor = varyings.vFillColor;\n }\n\n fragColor.a *= inCircle;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(varyings.pickingColor)) {\n discard;\n }\n return vec4<f32>(varyings.pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n // return vec4<f32>(0, 0, 1, 1);\n}\n",modules:[$,W,H,jn]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:n,radiusScale:i,radiusMinPixels:o,radiusMaxPixels:s,stroked:r,filled:a,billboard:l,antialiasing:c,lineWidthUnits:u,lineWidthScale:d,lineWidthMinPixels:f,lineWidthMaxPixels:p}=this.props,h={stroked:r,filled:a,billboard:l,antialiasing:c,radiusUnits:t.UNIT[n],radiusScale:i,radiusMinPixels:o,radiusMaxPixels:s,lineWidthUnits:t.UNIT[u],lineWidthScale:d,lineWidthMinPixels:f,lineWidthMaxPixels:p},g=this.state.model;g.shaderInputs.setProps({scatterplot:h}),g.draw(this.context.renderPass)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0])}}}),isInstanced:!0})}}Wn.defaultProps=Vn,Wn.layerName="ScatterplotLayer";const $n=1,Hn=-1;function Yn(t,e,n={}){const i=function(t,e={}){return Math.sign(function(t,e={}){const{start:n=0,end:i=t.length,plane:o="xy"}=e,s=e.size||2;let r=0;const a=Kn[o[0]],l=Kn[o[1]];for(let c=n,u=i-s;c<i;c+=s)r+=(t[c+a]-t[u+a])*(t[c+l]+t[u+l]),u=c;return r/2}(t,e))}(t,n);return i!==e&&(function(t,e){const{start:n=0,end:i=t.length,size:o=2}=e,s=(i-n)/o,r=Math.floor(s/2);for(let a=0;a<r;++a){const e=n+a*o,i=n+(s-1-a)*o;for(let n=0;n<o;++n){const o=t[e+n];t[e+n]=t[i+n],t[i+n]=o}}}(t,n),!0)}const Kn={x:0,y:1,z:2};function qn(t,e){const n=e.length,i=t.length;if(i>0){let o=!0;for(let s=0;s<n;s++)if(t[i-n+s]!==e[s]){o=!1;break}if(o)return!1}for(let o=0;o<n;o++)t[i+o]=e[o];return!0}function Zn(t,e){const n=e.length;for(let i=0;i<n;i++)t[i]=e[i]}function Xn(t,e,n,i,o=[]){const s=i+e*n;for(let r=0;r<n;r++)o[r]=t[s+r];return o}function Jn(t,e,n,i,o=[]){let s,r;if(8&n)s=(i[3]-t[1])/(e[1]-t[1]),r=3;else if(4&n)s=(i[1]-t[1])/(e[1]-t[1]),r=1;else if(2&n)s=(i[2]-t[0])/(e[0]-t[0]),r=2;else{if(!(1&n))return null;s=(i[0]-t[0])/(e[0]-t[0]),r=0}for(let a=0;a<t.length;a++)o[a]=(1&r)===a?i[r]:s*(e[a]-t[a])+t[a];return o}function Qn(t,e){let n=0;return t[0]<e[0]?n|=1:t[0]>e[2]&&(n|=2),t[1]<e[1]?n|=4:t[1]>e[3]&&(n|=8),n}function ti(t,e){const{size:n=2,broken:i=!1,gridResolution:o=10,gridOffset:s=[0,0],startIndex:r=0,endIndex:a=t.length}=e||{},l=(a-r)/n;let c=[];const u=[c],d=Xn(t,0,n,r);let f,p;const h=ii(d,o,s,[]),g=[];qn(c,d);for(let m=1;m<l;m++){for(f=Xn(t,m,n,r,f),p=Qn(f,h);p;){Jn(d,f,p,h,g);const t=Qn(g,h);t&&(Jn(d,g,t,h,g),p=t),qn(c,g),Zn(d,g),oi(h,o,p),i&&c.length>n&&(c=[],u.push(c),qn(c,d)),p=Qn(f,h)}qn(c,f),Zn(d,f)}return i?u:u[0]}function ei(t,e=null,n){if(!t.length)return[];const{size:i=2,gridResolution:o=10,gridOffset:s=[0,0],edgeTypes:r=!1}=n||{},a=[],l=[{pos:t,types:r?new Array(t.length/i).fill(1):null,holes:e||[]}],c=[[],[]];let u=[];for(;l.length;){const{pos:t,types:e,holes:n}=l.shift();si(t,i,n[0]||t.length,c),u=ii(c[0],o,s,u);const d=Qn(c[1],u);if(d){let o=ni(t,e,i,0,n[0]||t.length,u,d);const s={pos:o[0].pos,types:o[0].types,holes:[]},a={pos:o[1].pos,types:o[1].types,holes:[]};l.push(s,a);for(let l=0;l<n.length;l++)o=ni(t,e,i,n[l],n[l+1]||t.length,u,d),o[0]&&(s.holes.push(s.pos.length),s.pos=ri(s.pos,o[0].pos),r&&(s.types=ri(s.types,o[0].types))),o[1]&&(a.holes.push(a.pos.length),a.pos=ri(a.pos,o[1].pos),r&&(a.types=ri(a.types,o[1].types)))}else{const i={positions:t};r&&(i.edgeTypes=e),n.length&&(i.holeIndices=n),a.push(i)}}return a}function ni(t,e,n,i,o,s,r){const a=(o-i)/n,l=[],c=[],u=[],d=[],f=[];let p,h,g;const m=Xn(t,a-1,n,i);let v=Math.sign(8&r?m[1]-s[3]:m[0]-s[2]),y=e&&e[a-1],x=0,_=0;for(let b=0;b<a;b++)p=Xn(t,b,n,i,p),h=Math.sign(8&r?p[1]-s[3]:p[0]-s[2]),g=e&&e[i/n+b],h&&v&&v!==h&&(Jn(m,p,r,s,f),qn(l,f)&&u.push(y),qn(c,f)&&d.push(y)),h<=0?(qn(l,p)&&u.push(g),x-=h):u.length&&(u[u.length-1]=0),h>=0?(qn(c,p)&&d.push(g),_+=h):d.length&&(d[d.length-1]=0),Zn(m,p),v=h,y=g;return[x?{pos:l,types:e&&u}:null,_?{pos:c,types:e&&d}:null]}function ii(t,e,n,i){const o=Math.floor((t[0]-n[0])/e)*e+n[0],s=Math.floor((t[1]-n[1])/e)*e+n[1];return i[0]=o,i[1]=s,i[2]=o+e,i[3]=s+e,i}function oi(t,e,n){8&n?(t[1]+=e,t[3]+=e):4&n?(t[1]-=e,t[3]-=e):2&n?(t[0]+=e,t[2]+=e):1&n&&(t[0]-=e,t[2]-=e)}function si(t,e,n,i){let o=1/0,s=-1/0,r=1/0,a=-1/0;for(let l=0;l<n;l+=e){const e=t[l],n=t[l+1];o=e<o?e:o,s=e>s?e:s,r=n<r?n:r,a=n>a?n:a}return i[0][0]=o,i[0][1]=r,i[1][0]=s,i[1][1]=a,i}function ri(t,e){for(let n=0;n<e.length;n++)t.push(e[n]);return t}function ai(t,e,n,i){let o=-1,s=-1;for(let r=n+1;r<i;r+=e){const e=Math.abs(t[r]);e>o&&(o=e,s=r-1)}return s}function li(t,e,n,i,o=85.051129){const s=t[n],r=t[i-e];if(Math.abs(s-r)>180){const i=Xn(t,0,e,n);i[0]+=360*Math.round((r-s)/360),qn(t,i),i[1]=Math.sign(i[1])*o,qn(t,i),i[0]=s,qn(t,i)}}function ci(t,e,n,i){let o,s=t[0];for(let r=n;r<i;r+=e){o=t[r];const e=o-s;(e>180||e<-180)&&(o-=360*Math.round(e/360)),t[r]=s=o}}function ui(t,e){let n;const i=t.length/e;for(let s=0;s<i&&(n=t[s*e],(n+180)%360==0);s++);const o=360*-Math.round(n/360);if(0!==o)for(let s=0;s<i;s++)t[s*e]+=o}class di extends Ut{constructor(e){const{indices:n,attributes:i}=function(e){const{radius:n,height:i=1,nradial:o=10}=e;let{vertices:s}=e;s&&(t.defaultLogger.assert(s.length>=o),s=s.flatMap(t=>[t[0],t[1]]),Yn(s,Hn));const r=i>0,a=o+1,l=r?3*a+1:o,c=2*Math.PI/o,u=new Uint16Array(r?3*o*2:0),d=new Float32Array(3*l),f=new Float32Array(3*l);let p=0;if(r){for(let t=0;t<a;t++){const e=t*c,r=t%o,a=Math.sin(e),l=Math.cos(e);for(let t=0;t<2;t++)d[p+0]=s?s[2*r]:l*n,d[p+1]=s?s[2*r+1]:a*n,d[p+2]=(.5-t)*i,f[p+0]=s?s[2*r]:l,f[p+1]=s?s[2*r+1]:a,p+=3}d[p+0]=d[p-3],d[p+1]=d[p-2],d[p+2]=d[p-1],p+=3}for(let t=r?0:1;t<a;t++){const e=Math.floor(t/2)*Math.sign(.5-t%2),r=e*c,a=(e+o)%o,l=Math.sin(r),u=Math.cos(r);d[p+0]=s?s[2*a]:u*n,d[p+1]=s?s[2*a+1]:l*n,d[p+2]=i/2,f[p+2]=1,p+=3}if(r){let t=0;for(let e=0;e<o;e++)u[t++]=2*e+0,u[t++]=2*e+2,u[t++]=2*e+0,u[t++]=2*e+1,u[t++]=2*e+1,u[t++]=2*e+3}return{indices:u,attributes:{POSITION:{size:3,value:d},NORMAL:{size:3,value:f}}}}(e);super({...e,indices:n,attributes:i})}}const fi="layout(std140) uniform columnUniforms {\n float radius;\n float angle;\n vec2 offset;\n bool extruded;\n bool stroked;\n bool isStroke;\n float coverage;\n float elevationScale;\n float edgeDistance;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int radiusUnits;\n highp int widthUnits;\n} column;\n",pi={name:"column",vs:fi,fs:fi,uniformTypes:{radius:"f32",angle:"f32",offset:"vec2<f32>",extruded:"f32",stroked:"f32",isStroke:"f32",coverage:"f32",elevationScale:"f32",edgeDistance:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",radiusUnits:"i32",widthUnits:"i32"}},hi=[0,0,0,255],gi={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:t=>t.position},getFillColor:{type:"accessor",value:hi},getLineColor:{type:"accessor",value:hi},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class mi extends on{getShaders(){const t={},{flatShading:e}=this.props;return e&&(t.FLAT_SHADING=1),super.getShaders({vs:"#version 300 es\n#define SHADER_NAME column-layer-vertex-shader\nin vec3 positions;\nin vec3 normals;\nin vec3 instancePositions;\nin float instanceElevations;\nin vec3 instancePositions64Low;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin float instanceStrokeWidths;\nin vec3 instancePickingColors;\nout vec4 vColor;\n#ifdef FLAT_SHADING\nout vec3 cameraPosition;\nout vec4 position_commonspace;\n#endif\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nvec4 color = column.isStroke ? instanceLineColors : instanceFillColors;\nmat2 rotationMatrix = mat2(cos(column.angle), sin(column.angle), -sin(column.angle), cos(column.angle));\nfloat elevation = 0.0;\nfloat strokeOffsetRatio = 1.0;\nif (column.extruded) {\nelevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale;\n} else if (column.stroked) {\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceStrokeWidths * column.widthScale, column.widthUnits),\ncolumn.widthMinPixels, column.widthMaxPixels) / 2.0;\nfloat halfOffset = project_pixel_size(widthPixels) / project_size(column.edgeDistance * column.coverage * column.radius);\nif (column.isStroke) {\nstrokeOffsetRatio -= sign(positions.z) * halfOffset;\n} else {\nstrokeOffsetRatio -= halfOffset;\n}\n}\nfloat shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);\nfloat dotRadius = column.radius * column.coverage * shouldRender;\ngeometry.pickingColor = instancePickingColors;\nvec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);\nvec3 centroidPosition64Low = instancePositions64Low;\nvec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + column.offset) * dotRadius;\nif (column.radiusUnits == UNIT_METERS) {\noffset = project_size(offset);\n} else if (column.radiusUnits == UNIT_PIXELS) {\noffset = project_pixel_size(offset);\n}\nvec3 pos = vec3(offset, 0.);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);\ngeometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (column.extruded && !column.isStroke) {\n#ifdef FLAT_SHADING\ncameraPosition = project.cameraPosition;\nposition_commonspace = geometry.position;\nvColor = vec4(color.rgb, color.a * layer.opacity);\n#else\nvec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, color.a * layer.opacity);\n#endif\n} else {\nvColor = vec4(color.rgb, color.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME column-layer-fragment-shader\nprecision highp float;\nout vec4 fragColor;\nin vec4 vColor;\n#ifdef FLAT_SHADING\nin vec3 cameraPosition;\nin vec4 position_commonspace;\n#endif\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\n#ifdef FLAT_SHADING\nif (column.extruded && !column.isStroke && !bool(picking.isActive)) {\nvec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\nfragColor.rgb = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal);\n}\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:t,modules:[$,e?V:G,H,pi]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:hi},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:hi},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(t){super.updateState(t);const{props:e,oldProps:n,changeFlags:i}=t,o=i.extensionsChanged||e.flatShading!==n.flatShading;o&&(this.state.models?.forEach(t=>t.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());const s=this.getNumInstances();this.state.fillModel.setInstanceCount(s),this.state.wireframeModel.setInstanceCount(s),(o||e.diskResolution!==n.diskResolution||e.vertices!==n.vertices||(e.extruded||e.stroked)!==(n.extruded||n.stroked))&&this._updateGeometry(e)}getGeometry(t,e,n){const i=new di({radius:1,height:n?2:0,vertices:e,nradial:t});let o=0;if(e)for(let s=0;s<t;s++){const n=e[s];o+=Math.sqrt(n[0]*n[0]+n[1]*n[1])/t}else o=1;return this.setState({edgeDistance:Math.cos(Math.PI/t)*o}),i}_getModels(){const t=this.getShaders(),e=this.getAttributeManager().getBufferLayouts(),n=new Nt(this.context.device,{...t,id:`${this.props.id}-fill`,bufferLayout:e,isInstanced:!0}),i=new Nt(this.context.device,{...t,id:`${this.props.id}-wireframe`,bufferLayout:e,isInstanced:!0});return{fillModel:n,wireframeModel:i,models:[i,n]}}_updateGeometry({diskResolution:t,vertices:e,extruded:n,stroked:i}){const o=this.getGeometry(t,e,n||i);this.setState({fillVertexCount:o.attributes.POSITION.value.length/3});const s=this.state.fillModel,r=this.state.wireframeModel,{POSITION:a,NORMAL:l}=o.attributes,c=new Ut({topology:"triangle-strip",attributes:{POSITION:a,NORMAL:l}});s.setGeometry(c),r.setGeometry(o),r.setTopology("line-list")}draw({uniforms:e}){const{lineWidthUnits:n,lineWidthScale:i,lineWidthMinPixels:o,lineWidthMaxPixels:s,radiusUnits:r,elevationScale:a,extruded:l,filled:c,stroked:u,wireframe:d,offset:f,coverage:p,radius:h,angle:g}=this.props,m=this.state.fillModel,v=this.state.wireframeModel,{fillVertexCount:y,edgeDistance:x}=this.state,_={radius:h,angle:g/180*Math.PI,offset:f,extruded:l,stroked:u,coverage:p,elevationScale:a,edgeDistance:x,radiusUnits:t.UNIT[r],widthUnits:t.UNIT[n],widthScale:i,widthMinPixels:o,widthMaxPixels:s};l&&d&&(v.shaderInputs.setProps({column:{..._,isStroke:!0}}),v.draw(this.context.renderPass)),c&&(m.setVertexCount(y),m.shaderInputs.setProps({column:{..._,isStroke:!1}}),m.draw(this.context.renderPass)),!l&&u&&(m.setVertexCount(2*y/3),m.shaderInputs.setProps({column:{..._,isStroke:!0}}),m.draw(this.context.renderPass))}}function vi(t,e,n,i){let o;if(Array.isArray(t[0])){const n=t.length*e;o=new Array(n);for(let i=0;i<t.length;i++)for(let n=0;n<e;n++)o[i*e+n]=t[i][n]||0}else o=t;return n?ti(o,{size:e,gridResolution:n}):i?function(t,e){const{size:n=2,startIndex:i=0,endIndex:o=t.length,normalize:s=!0}=e||{},r=t.slice(i,o);ci(r,n,0,o-i);const a=ti(r,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(s)for(const l of a)ui(l,n);return a}(o,{size:e}):o}mi.layerName="ColumnLayer",mi.defaultProps=gi;class yi extends an{constructor(t){super({...t,attributes:{positions:{size:3,padding:18,initialize:!0,type:t.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(t){return this.attributes[t]}getGeometryFromBuffer(t){return this.normalize?super.getGeometryFromBuffer(t):null}normalizeGeometry(t){return this.normalize?vi(t,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):t}getGeometrySize(t){if(xi(t)){let e=0;for(const n of t)e+=this.getGeometrySize(n);return e}const e=this.getPathLength(t);return e<2?0:this.isClosed(t)?e<3?0:e+2:e}updateGeometryAttributes(t,e){if(0!==e.geometrySize)if(t&&xi(t))for(const n of t){const t=this.getGeometrySize(n);e.geometrySize=t,this.updateGeometryAttributes(n,e),e.vertexStart+=t}else this._updateSegmentTypes(t,e),this._updatePositions(t,e)}_updateSegmentTypes(t,e){const n=this.attributes.segmentTypes,i=!!t&&this.isClosed(t),{vertexStart:o,geometrySize:s}=e;n.fill(0,o,o+s),i?(n[o]=4,n[o+s-2]=4):(n[o]+=1,n[o+s-2]+=2),n[o+s-1]=4}_updatePositions(t,e){const{positions:n}=this.attributes;if(!n||!t)return;const{vertexStart:i,geometrySize:o}=e,s=new Array(3);for(let r=i,a=0;a<o;r++,a++)this.getPointOnPath(t,a,s),n[3*r]=s[0],n[3*r+1]=s[1],n[3*r+2]=s[2]}getPathLength(t){return t.length/this.positionSize}getPointOnPath(t,e,n=[]){const{positionSize:i}=this;e*i>=t.length&&(e+=1-t.length/i);const o=e*i;return n[0]=t[o],n[1]=t[o+1],n[2]=3===i&&t[o+2]||0,n}isClosed(t){if(!this.normalize)return Boolean(this.opts.loop);const{positionSize:e}=this,n=t.length-e;return t[0]===t[n]&&t[1]===t[n+1]&&(2===e||t[2]===t[n+2])}}function xi(t){return Array.isArray(t[0])}const _i="layout(std140) uniform pathUniforms {\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n float jointType;\n float capType;\n float miterLimit;\n bool billboard;\n highp int widthUnits;\n} path;\n",bi={name:"path",vs:_i,fs:_i,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}},Pi=[0,0,0,255],Ci={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:Pi},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},Li={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t};class wi extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME path-layer-vertex-shader\nin vec2 positions;\nin float instanceTypes;\nin vec3 instanceStartPositions;\nin vec3 instanceEndPositions;\nin vec3 instanceLeftPositions;\nin vec3 instanceRightPositions;\nin vec3 instanceLeftPositions64Low;\nin vec3 instanceStartPositions64Low;\nin vec3 instanceEndPositions64Low;\nin vec3 instanceRightPositions64Low;\nin float instanceStrokeWidths;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nuniform float opacity;\nout vec4 vColor;\nout vec2 vCornerOffset;\nout float vMiterLength;\nout vec2 vPathPosition;\nout float vPathLength;\nout float vJointType;\nconst float EPSILON = 0.001;\nconst vec3 ZERO_OFFSET = vec3(0.0);\nfloat flipIfTrue(bool flag) {\nreturn -(float(flag) * 2. - 1.);\n}\nvec3 getLineJoinOffset(\nvec3 prevPoint, vec3 currPoint, vec3 nextPoint,\nvec2 width\n) {\nbool isEnd = positions.x > 0.0;\nfloat sideOfPath = positions.y;\nfloat isJoint = float(sideOfPath == 0.0);\nvec3 deltaA3 = (currPoint - prevPoint);\nvec3 deltaB3 = (nextPoint - currPoint);\nmat3 rotationMatrix;\nbool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);\nif (needsRotation) {\ndeltaA3 = deltaA3 * rotationMatrix;\ndeltaB3 = deltaB3 * rotationMatrix;\n}\nvec2 deltaA = deltaA3.xy / width;\nvec2 deltaB = deltaB3.xy / width;\nfloat lenA = length(deltaA);\nfloat lenB = length(deltaB);\nvec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\nvec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\nvec2 perpA = vec2(-dirA.y, dirA.x);\nvec2 perpB = vec2(-dirB.y, dirB.x);\nvec2 tangent = dirA + dirB;\ntangent = length(tangent) > 0. ? normalize(tangent) : perpA;\nvec2 miterVec = vec2(-tangent.y, tangent.x);\nvec2 dir = isEnd ? dirA : dirB;\nvec2 perp = isEnd ? perpA : perpB;\nfloat L = isEnd ? lenA : lenB;\nfloat sinHalfA = abs(dot(miterVec, perp));\nfloat cosHalfA = abs(dot(dirA, miterVec));\nfloat turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\nfloat cornerPosition = sideOfPath * turnDirection;\nfloat miterSize = 1.0 / max(sinHalfA, EPSILON);\nmiterSize = mix(\nmin(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\nmiterSize,\nstep(0.0, cornerPosition)\n);\nvec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))\n* (sideOfPath + isJoint * turnDirection);\nbool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\nbool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\nbool isCap = isStartCap || isEndCap;\nif (isCap) {\noffsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);\nvJointType = path.capType;\n} else {\nvJointType = path.jointType;\n}\nvPathLength = L;\nvCornerOffset = offsetVec;\nvMiterLength = dot(vCornerOffset, miterVec * turnDirection);\nvMiterLength = isCap ? isJoint : vMiterLength;\nvec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\nvPathPosition = vec2(\ndot(offsetFromStartOfPath, perp),\ndot(offsetFromStartOfPath, dir)\n);\ngeometry.uv = vPathPosition;\nfloat isValid = step(instanceTypes, 3.5);\nvec3 offset = vec3(offsetVec * width * isValid, 0.0);\nif (needsRotation) {\noffset = rotationMatrix * offset;\n}\nreturn offset;\n}\nvoid clipLine(inout vec4 position, vec4 refPosition) {\nif (position.w < EPSILON) {\nfloat r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\nposition = refPosition + (position - refPosition) * r;\n}\n}\nvoid main() {\ngeometry.pickingColor = instancePickingColors;\nvColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\nfloat isEnd = positions.x;\nvec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);\nvec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);\nvec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\nvec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);\nvec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);\nvec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);\ngeometry.worldPosition = currPosition;\nvec2 widthPixels = vec2(clamp(\nproject_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),\npath.widthMinPixels, path.widthMaxPixels) / 2.0);\nvec3 width;\nif (path.billboard) {\nvec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);\nvec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\nvec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);\nclipLine(prevPositionScreen, currPositionScreen);\nclipLine(nextPositionScreen, currPositionScreen);\nclipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\nwidth = vec3(widthPixels, 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(\nprevPositionScreen.xyz / prevPositionScreen.w,\ncurrPositionScreen.xyz / currPositionScreen.w,\nnextPositionScreen.xyz / nextPositionScreen.w,\nproject_pixel_size_to_clipspace(width.xy)\n);\nDECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);\ngl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);\n} else {\nprevPosition = project_position(prevPosition, prevPosition64Low);\ncurrPosition = project_position(currPosition, currPosition64Low);\nnextPosition = project_position(nextPosition, nextPosition64Low);\nwidth = vec3(project_pixel_size(widthPixels), 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);\ngeometry.position = vec4(currPosition + offset, 1.0);\ngl_Position = project_common_position_to_clipspace(geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME path-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 vCornerOffset;\nin float vMiterLength;\nin vec2 vPathPosition;\nin float vPathLength;\nin float vJointType;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vPathPosition;\nif (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {\nif (vJointType > 0.5 && length(vCornerOffset) > 1.0) {\ndiscard;\n}\nif (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {\ndiscard;\n}\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[$,H,bi]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const t=!0;this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:Li,accessor:"getPath",update:this.calculatePositions,noAlloc:t,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:t},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:Li,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:Li,defaultValue:Pi},instancePickingColors:{size:4,type:"uint8",accessor:(t,{index:e,target:n})=>this.encodePickingColor(t&&t.__source?t.__source.index:e,n)}}),this.setState({pathTesselator:new yi({fp64:this.use64bitPositions()})})}updateState(t){super.updateState(t);const{props:e,changeFlags:n}=t,i=this.getAttributeManager();if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPath)){const{pathTesselator:t}=this.state,o=e.data.attributes||{};t.updateGeometry({data:e.data,geometryBuffer:o.getPath,buffers:o,normalize:!e._pathType,loop:"loop"===e._pathType,getGeometry:e.getPath,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:n.dataChanged}),this.setState({numInstances:t.instanceCount,startIndices:t.vertexStarts}),n.dataChanged||i.invalidateAll()}n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll())}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n}=e,i=this.props.data;return i[0]&&i[0].__source&&(e.object=i.find(t=>t.__source.index===n)),e}disablePickingIndex(t){const e=this.props.data;if(e[0]&&e[0].__source)for(let n=0;n<e.length;n++)e[n].__source.index===t&&this._disablePickingIndex(n);else super.disablePickingIndex(t)}draw({uniforms:e}){const{jointRounded:n,capRounded:i,billboard:o,miterLimit:s,widthUnits:r,widthScale:a,widthMinPixels:l,widthMaxPixels:c}=this.props,u=this.state.model,d={jointType:Number(n),capType:Number(i),billboard:o,widthUnits:t.UNIT[r],widthScale:a,miterLimit:s,widthMinPixels:l,widthMaxPixels:c};u.shaderInputs.setProps({path:d}),u.draw(this.context.renderPass)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-list",attributes:{indices:new Uint16Array([0,1,2,1,4,2,1,3,4,3,5,4]),positions:{value:new Float32Array([0,0,0,-1,0,1,1,-1,1,1,1,0]),size:2}}}),isInstanced:!0})}calculatePositions(t){const{pathTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("positions")}calculateSegmentTypes(t){const{pathTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("segmentTypes")}}wi.defaultProps=Ci,wi.layerName="PathLayer";var Si,Ai={exports:{}};var Oi=function(){if(Si)return Ai.exports;function t(t,n,o){o=o||2;var s,r,a,u,d,p,h,g=n&&n.length,m=g?n[0]*o:t.length,v=e(t,0,m,o,!0),y=[];if(!v||v.next===v.prev)return y;if(g&&(v=function(t,n,i,o){var s,r,a,u=[];for(s=0,r=n.length;s<r;s++)(a=e(t,n[s]*o,s<r-1?n[s+1]*o:t.length,o,!1))===a.next&&(a.steiner=!0),u.push(f(a));for(u.sort(l),s=0;s<u.length;s++)i=c(u[s],i);return i}(t,n,v,o)),t.length>80*o){s=a=t[0],r=u=t[1];for(var x=o;x<m;x+=o)(d=t[x])<s&&(s=d),(p=t[x+1])<r&&(r=p),d>a&&(a=d),p>u&&(u=p);h=0!==(h=Math.max(a-s,u-r))?32767/h:0}return i(v,y,o,s,r,h,0),y}function e(t,e,n,i,o){var s,r;if(o===w(t,e,n,i)>0)for(s=e;s<n;s+=i)r=P(s,t[s],t[s+1],r);else for(s=n-i;s>=e;s-=i)r=P(s,t[s],t[s+1],r);return r&&m(r,r.next)&&(C(r),r=r.next),r}function n(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!m(i,i.next)&&0!==g(i.prev,i,i.next))i=i.next;else{if(C(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function i(t,e,l,c,u,f,p){if(t){!p&&f&&function(t,e,n,i){var o=t;do{0===o.z&&(o.z=d(o.x,o.y,e,n,i)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,function(t){var e,n,i,o,s,r,a,l,c=1;do{for(n=t,t=null,s=null,r=0;n;){for(r++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ);e++);for(l=c;a>0||l>0&&i;)0!==a&&(0===l||!i||n.z<=i.z)?(o=n,n=n.nextZ,a--):(o=i,i=i.nextZ,l--),s?s.nextZ=o:t=o,o.prevZ=s,s=o;n=i}s.nextZ=null,c*=2}while(r>1)}(o)}(t,c,u,f);for(var h,g,m=t;t.prev!==t.next;)if(h=t.prev,g=t.next,f?s(t,c,u,f):o(t))e.push(h.i/l|0),e.push(t.i/l|0),e.push(g.i/l|0),C(t),t=g.next,m=g.next;else if((t=g)===m){p?1===p?i(t=r(n(t),e,l),e,l,c,u,f,2):2===p&&a(t,e,l,c,u,f):i(n(t),e,l,c,u,f,1);break}}}function o(t){var e=t.prev,n=t,i=t.next;if(g(e,n,i)>=0)return!1;for(var o=e.x,s=n.x,r=i.x,a=e.y,l=n.y,c=i.y,u=o<s?o<r?o:r:s<r?s:r,d=a<l?a<c?a:c:l<c?l:c,f=o>s?o>r?o:r:s>r?s:r,h=a>l?a>c?a:c:l>c?l:c,m=i.next;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=h&&p(o,a,s,l,r,c,m.x,m.y)&&g(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function s(t,e,n,i){var o=t.prev,s=t,r=t.next;if(g(o,s,r)>=0)return!1;for(var a=o.x,l=s.x,c=r.x,u=o.y,f=s.y,h=r.y,m=a<l?a<c?a:c:l<c?l:c,v=u<f?u<h?u:h:f<h?f:h,y=a>l?a>c?a:c:l>c?l:c,x=u>f?u>h?u:h:f>h?f:h,_=d(m,v,e,n,i),b=d(y,x,e,n,i),P=t.prevZ,C=t.nextZ;P&&P.z>=_&&C&&C.z<=b;){if(P.x>=m&&P.x<=y&&P.y>=v&&P.y<=x&&P!==o&&P!==r&&p(a,u,l,f,c,h,P.x,P.y)&&g(P.prev,P,P.next)>=0)return!1;if(P=P.prevZ,C.x>=m&&C.x<=y&&C.y>=v&&C.y<=x&&C!==o&&C!==r&&p(a,u,l,f,c,h,C.x,C.y)&&g(C.prev,C,C.next)>=0)return!1;C=C.nextZ}for(;P&&P.z>=_;){if(P.x>=m&&P.x<=y&&P.y>=v&&P.y<=x&&P!==o&&P!==r&&p(a,u,l,f,c,h,P.x,P.y)&&g(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;C&&C.z<=b;){if(C.x>=m&&C.x<=y&&C.y>=v&&C.y<=x&&C!==o&&C!==r&&p(a,u,l,f,c,h,C.x,C.y)&&g(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function r(t,e,i){var o=t;do{var s=o.prev,r=o.next.next;!m(s,r)&&v(s,o,o.next,r)&&_(s,r)&&_(r,s)&&(e.push(s.i/i|0),e.push(o.i/i|0),e.push(r.i/i|0),C(o),C(o.next),o=t=r),o=o.next}while(o!==t);return n(o)}function a(t,e,o,s,r,a){var l=t;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&h(l,c)){var u=b(l,c);return l=n(l,l.next),u=n(u,u.next),i(l,e,o,s,r,a,0),void i(u,e,o,s,r,a,0)}c=c.next}l=l.next}while(l!==t)}function l(t,e){return t.x-e.x}function c(t,e){var i=function(t,e){var n,i=e,o=t.x,s=t.y,r=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){var a=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=o&&a>r&&(r=a,n=i.x<i.next.x?i:i.next,a===o))return n}i=i.next}while(i!==e);if(!n)return null;var l,c=n,d=n.x,f=n.y,h=1/0;i=n;do{o>=i.x&&i.x>=d&&o!==i.x&&p(s<f?o:r,s,d,f,s<f?r:o,s,i.x,i.y)&&(l=Math.abs(s-i.y)/(o-i.x),_(i,t)&&(l<h||l===h&&(i.x>n.x||i.x===n.x&&u(n,i)))&&(n=i,h=l)),i=i.next}while(i!==c);return n}(t,e);if(!i)return e;var o=b(i,t);return n(o,o.next),n(i,i.next)}function u(t,e){return g(t.prev,t,e.prev)<0&&g(e.next,t,t.next)<0}function d(t,e,n,i,o){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function f(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function p(t,e,n,i,o,s,r,a){return(o-r)*(e-a)>=(t-r)*(s-a)&&(t-r)*(i-a)>=(n-r)*(e-a)&&(n-r)*(s-a)>=(o-r)*(i-a)}function h(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&v(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(_(t,e)&&_(e,t)&&function(t,e){var n=t,i=!1,o=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&o<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(g(t.prev,t,e.prev)||g(t,e.prev,e))||m(t,e)&&g(t.prev,t,t.next)>0&&g(e.prev,e,e.next)>0)}function g(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function v(t,e,n,i){var o=x(g(t,e,n)),s=x(g(t,e,i)),r=x(g(n,i,t)),a=x(g(n,i,e));return o!==s&&r!==a||(!(0!==o||!y(t,n,e))||(!(0!==s||!y(t,i,e))||(!(0!==r||!y(n,t,i))||!(0!==a||!y(n,e,i)))))}function y(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function x(t){return t>0?1:t<0?-1:0}function _(t,e){return g(t.prev,t,t.next)<0?g(t,e,t.next)>=0&&g(t,t.prev,e)>=0:g(t,e,t.prev)<0||g(t,t.next,e)<0}function b(t,e){var n=new L(t.i,t.x,t.y),i=new L(e.i,e.x,e.y),o=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=o,o.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function P(t,e,n,i){var o=new L(t,e,n);return i?(o.next=i.next,o.prev=i,i.next.prev=o,i.next=o):(o.prev=o,o.next=o),o}function C(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function L(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function w(t,e,n,i){for(var o=0,s=e,r=n-i;s<n;s+=i)o+=(t[r]-t[s])*(t[s+1]+t[r+1]),r=s;return o}return Si=1,Ai.exports=t,Ai.exports.default=t,t.deviation=function(t,e,n,i){var o=e&&e.length,s=o?e[0]*n:t.length,r=Math.abs(w(t,0,s,n));if(o)for(var a=0,l=e.length;a<l;a++){var c=e[a]*n,u=a<l-1?e[a+1]*n:t.length;r-=Math.abs(w(t,c,u,n))}var d=0;for(a=0;a<i.length;a+=3){var f=i[a]*n,p=i[a+1]*n,h=i[a+2]*n;d+=Math.abs((t[f]-t[h])*(t[p+1]-t[f+1])-(t[f]-t[p])*(t[h+1]-t[f+1]))}return 0===r&&0===d?0:Math.abs((d-r)/r)},t.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,o=0;o<t.length;o++){for(var s=0;s<t[o].length;s++)for(var r=0;r<e;r++)n.vertices.push(t[o][s][r]);o>0&&(i+=t[o-1].length,n.holes.push(i))}return n},Ai.exports}();const Ti=n.getDefaultExportFromCjs(Oi),Ii=$n,Ei=Hn,Mi={};function zi(t){return"positions"in t?t.positions:t}function Ri(t){return"holeIndices"in t?t.holeIndices:null}function Fi(t,e,n,i,o){let s=e;const r=n.length;for(let a=0;a<r;a++)for(let e=0;e<i;e++)t[s++]=n[a][e]||0;if(!function(t){const e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]&&e[2]===n[2]}(n))for(let a=0;a<i;a++)t[s++]=n[0][a]||0;return Mi.start=e,Mi.end=s,Mi.size=i,Yn(t,o,Mi),s}function Bi(t,e,n,i,o=0,s,r){const a=(s=s||n.length)-o;if(a<=0)return e;let l=e;for(let c=0;c<a;c++)t[l++]=n[o+c];if(!function(t,e,n,i){for(let o=0;o<e;o++)if(t[n+o]!==t[i-e+o])return!1;return!0}(n,i,o,s))for(let c=0;c<i;c++)t[l++]=n[o+c];return Mi.start=e,Mi.end=l,Mi.size=i,Yn(t,r,Mi),l}function ki(t,e){!function(t){if(t=t&&t.positions||t,!Array.isArray(t)&&!ArrayBuffer.isView(t))throw new Error("invalid polygon")}(t);const n=[],i=[];if("positions"in t){const{positions:o,holeIndices:s}=t;if(s){let t=0;for(let r=0;r<=s.length;r++)t=Bi(n,t,o,e,s[r-1],s[r],0===r?Ii:Ei),i.push(t);return i.pop(),{positions:n,holeIndices:i}}t=o}if(!function(t){return Array.isArray(t[0])}(t))return Bi(n,0,t,e,0,n.length,Ii),n;if(!function(t){return t.length>=1&&t[0].length>=2&&Number.isFinite(t[0][0])}(t)){let o=0;for(const[s,r]of t.entries())o=Fi(n,o,r,e,0===s?Ii:Ei),i.push(o);return i.pop(),{positions:n,holeIndices:i}}return Fi(n,0,t,e,Ii),n}function Ni(t,e,n){const i=t.length/3;let o=0;for(let s=0;s<i;s++){const r=(s+1)%i;o+=t[3*s+e]*t[3*r+n],o-=t[3*r+e]*t[3*s+n]}return Math.abs(o/2)}function Di(t,e,n,i){const o=t.length/3;for(let s=0;s<o;s++){const o=3*s,r=t[o+0],a=t[o+1],l=t[o+2];t[o+e]=r,t[o+n]=a,t[o+i]=l}}class Ui extends an{constructor(t){const{fp64:e,IndexType:n=Uint32Array}=t;super({...t,attributes:{positions:{size:3,type:e?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:n,size:1}}})}get(t){const{attributes:e}=this;return"indices"===t?e.indices&&e.indices.subarray(0,this.vertexCount):e[t]}updateGeometry(t){super.updateGeometry(t);const e=this.buffers.indices;if(e)this.vertexCount=(e.value||e).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(t){if(this.normalize){const e=ki(t,this.positionSize);return this.opts.resolution?ei(zi(e),Ri(e),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?function(t,e=null,n){const{size:i=2,normalize:o=!0,edgeTypes:s=!1}=n||{};e=e||[];const r=[],a=[];let l=0,c=0;for(let d=0;d<=e.length;d++){const o=e[d]||t.length,s=c,u=ai(t,i,l,o);for(let e=u;e<o;e++)r[c++]=t[e];for(let e=l;e<u;e++)r[c++]=t[e];ci(r,i,s,c),li(r,i,s,c,n?.maxLatitude),l=o,a[d]=c}a.pop();const u=ei(r,a,{size:i,gridResolution:360,gridOffset:[-180,-180],edgeTypes:s});if(o)for(const d of u)ui(d.positions,i);return u}(zi(e),Ri(e),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):e}return t}getGeometrySize(t){if(ji(t)){let e=0;for(const n of t)e+=this.getGeometrySize(n);return e}return zi(t).length/this.positionSize}getGeometryFromBuffer(t){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(t):null}updateGeometryAttributes(t,e){if(t&&ji(t))for(const n of t){const t=this.getGeometrySize(n);e.geometrySize=t,this.updateGeometryAttributes(n,e),e.vertexStart+=t,e.indexStart=this.indexStarts[e.geometryIndex+1]}else{const n=t;this._updateIndices(n,e),this._updatePositions(n,e),this._updateVertexValid(n,e)}}_updateIndices(t,{geometryIndex:e,vertexStart:n,indexStart:i}){const{attributes:o,indexStarts:s,typedArrayManager:r}=this;let a=o.indices;if(!a||!t)return;let l=i;const c=function(t,e,n,i){let o=Ri(t);o&&(o=o.map(t=>t/e));let s=zi(t);const r=i&&3===e;if(n){const t=s.length;s=s.slice();const i=[];for(let o=0;o<t;o+=e){i[0]=s[o],i[1]=s[o+1],r&&(i[2]=s[o+2]);const t=n(i);s[o]=t[0],s[o+1]=t[1],r&&(s[o+2]=t[2])}}if(r){const t=Ni(s,0,1),e=Ni(s,0,2),i=Ni(s,1,2);if(!t&&!e&&!i)return[];t>e&&t>i||(e>i?(n||(s=s.slice()),Di(s,0,2,1)):(n||(s=s.slice()),Di(s,2,0,1)))}return Ti(s,o,e)}(t,this.positionSize,this.opts.preproject,this.opts.full3d);a=r.allocate(a,i+c.length,{copy:!0});for(let u=0;u<c.length;u++)a[l++]=c[u]+n;s[e+1]=i+c.length,o.indices=a}_updatePositions(t,{vertexStart:e,geometrySize:n}){const{attributes:{positions:i},positionSize:o}=this;if(!i||!t)return;const s=zi(t);for(let r=e,a=0;a<n;r++,a++){const t=s[a*o],e=s[a*o+1],n=o>2?s[a*o+2]:0;i[3*r]=t,i[3*r+1]=e,i[3*r+2]=n}}_updateVertexValid(t,{vertexStart:e,geometrySize:n}){const{positionSize:i}=this,o=this.attributes.vertexValid,s=t&&Ri(t);if(t&&t.edgeTypes?o.set(t.edgeTypes,e):o.fill(1,e,e+n),s)for(let r=0;r<s.length;r++)o[e+s[r]/i-1]=0;o[e+n-1]=0}}function ji(t){return Array.isArray(t)&&t.length>0&&!Number.isFinite(t[0])}const Gi="layout(std140) uniform solidPolygonUniforms {\n bool extruded;\n bool isWireframe;\n float elevationScale;\n} solidPolygon;\n",Vi={name:"solidPolygon",vs:Gi,fs:Gi,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}},Wi="in vec4 fillColors;\nin vec4 lineColors;\nin vec3 pickingColors;\nout vec4 vColor;\nstruct PolygonProps {\nvec3 positions;\nvec3 positions64Low;\nvec3 normal;\nfloat elevations;\n};\nvec3 project_offset_normal(vec3 vector) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\nreturn normalize(vector * project.commonUnitsPerWorldUnit);\n}\nreturn project_normal(vector);\n}\nvoid calculatePosition(PolygonProps props) {\nvec3 pos = props.positions;\nvec3 pos64Low = props.positions64Low;\nvec3 normal = props.normal;\nvec4 colors = solidPolygon.isWireframe ? lineColors : fillColors;\ngeometry.worldPosition = props.positions;\ngeometry.pickingColor = pickingColors;\nif (solidPolygon.extruded) {\npos.z += props.elevations * solidPolygon.elevationScale;\n}\ngl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (solidPolygon.extruded) {\n#ifdef IS_SIDE_VERTEX\nnormal = project_offset_normal(normal);\n#else\nnormal = project_normal(normal);\n#endif\ngeometry.normal = normal;\nvec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, colors.a * layer.opacity);\n} else {\nvColor = vec4(colors.rgb, colors.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",$i=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader\nin vec3 vertexPositions;\nin vec3 vertexPositions64Low;\nin float elevations;\n${Wi}\nvoid main(void) {\nPolygonProps props;\nprops.positions = vertexPositions;\nprops.positions64Low = vertexPositions64Low;\nprops.elevations = elevations;\nprops.normal = vec3(0.0, 0.0, 1.0);\ncalculatePosition(props);\n}\n`,Hi=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader-side\n#define IS_SIDE_VERTEX\nin vec2 positions;\nin vec3 vertexPositions;\nin vec3 nextVertexPositions;\nin vec3 vertexPositions64Low;\nin vec3 nextVertexPositions64Low;\nin float elevations;\nin float instanceVertexValid;\n${Wi}\nvoid main(void) {\nif(instanceVertexValid < 0.5){\ngl_Position = vec4(0.);\nreturn;\n}\nPolygonProps props;\nvec3 pos;\nvec3 pos64Low;\nvec3 nextPos;\nvec3 nextPos64Low;\n#if RING_WINDING_ORDER_CW == 1\npos = vertexPositions;\npos64Low = vertexPositions64Low;\nnextPos = nextVertexPositions;\nnextPos64Low = nextVertexPositions64Low;\n#else\npos = nextVertexPositions;\npos64Low = nextVertexPositions64Low;\nnextPos = vertexPositions;\nnextPos64Low = vertexPositions64Low;\n#endif\nprops.positions = mix(pos, nextPos, positions.x);\nprops.positions64Low = mix(pos64Low, nextPos64Low, positions.x);\nprops.normal = vec3(\npos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),\nnextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),\n0.0);\nprops.elevations = elevations * positions.y;\ncalculatePosition(props);\n}\n`,Yi=[0,0,0,255],Ki={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:Yi},getLineColor:{type:"accessor",value:Yi},material:!0},qi={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t};class Zi extends on{getShaders(t){return super.getShaders({vs:"top"===t?$i:Hi,fs:"#version 300 es\n#define SHADER_NAME solid-polygon-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:{RING_WINDING_ORDER_CW:this.props._normalize||"CCW"!==this.props._windingOrder?1:0},modules:[$,G,H,Vi]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const{viewport:t}=this.context;let{coordinateSystem:e}=this.props;const{_full3d:n}=this.props;let i;t.isGeospatial&&"default"===e&&(e="lnglat"),"lnglat"===e&&(i=n?t.projectPosition.bind(t):t.projectFlat.bind(t)),this.setState({numInstances:0,polygonTesselator:new Ui({preproject:i,fp64:this.use64bitPositions(),IndexType:Uint32Array})});const o=this.getAttributeManager(),s=!0;o.remove(["instancePickingColors"]),o.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:qi,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:s},elevations:{size:1,stepMode:"dynamic",transition:qi,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:qi,accessor:"getFillColor",defaultValue:Yi},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:qi,accessor:"getLineColor",defaultValue:Yi},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(t,{index:e,target:n})=>this.encodePickingColor(t&&t.__source?t.__source.index:e,n)}})}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n}=e,i=this.props.data;return i[0]&&i[0].__source&&(e.object=i.find(t=>t.__source.index===n)),e}disablePickingIndex(t){const e=this.props.data;if(e[0]&&e[0].__source)for(let n=0;n<e.length;n++)e[n].__source.index===t&&this._disablePickingIndex(n);else super.disablePickingIndex(t)}draw({uniforms:t}){const{extruded:e,filled:n,wireframe:i,elevationScale:o}=this.props,{topModel:s,sideModel:r,wireframeModel:a,polygonTesselator:l}=this.state,c={extruded:Boolean(e),elevationScale:o,isWireframe:!1};a&&i&&(a.setInstanceCount(l.instanceCount-1),a.shaderInputs.setProps({solidPolygon:{...c,isWireframe:!0}}),a.draw(this.context.renderPass)),r&&n&&(r.setInstanceCount(l.instanceCount-1),r.shaderInputs.setProps({solidPolygon:c}),r.draw(this.context.renderPass)),s&&n&&(s.setVertexCount(l.vertexCount),s.shaderInputs.setProps({solidPolygon:c}),s.draw(this.context.renderPass))}updateState(t){super.updateState(t),this.updateGeometry(t);const{props:e,oldProps:n,changeFlags:i}=t,o=this.getAttributeManager();(i.extensionsChanged||e.filled!==n.filled||e.extruded!==n.extruded)&&(this.state.models?.forEach(t=>t.destroy()),this.setState(this._getModels()),o.invalidateAll())}updateGeometry({props:t,oldProps:e,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPolygon)){const{polygonTesselator:e}=this.state,i=t.data.attributes||{};e.updateGeometry({data:t.data,normalize:t._normalize,geometryBuffer:i.getPolygon,buffers:i,getGeometry:t.getPolygon,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:n.dataChanged,full3d:t._full3d}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),n.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){const{id:t,filled:e,extruded:n}=this.props;let i,o,s;if(e){const e=this.getShaders("top");e.defines.NON_INSTANCED_MODEL=1;const n=this.getAttributeManager().getBufferLayouts({isInstanced:!1});i=new Nt(this.context.device,{...e,id:`${t}-top`,topology:"triangle-list",bufferLayout:n,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(n){const e=this.getAttributeManager().getBufferLayouts({isInstanced:!0});o=new Nt(this.context.device,{...this.getShaders("side"),id:`${t}-side`,bufferLayout:e,geometry:new Ut({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),s=new Nt(this.context.device,{...this.getShaders("side"),id:`${t}-wireframe`,bufferLayout:e,geometry:new Ut({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[o,s,i].filter(Boolean),topModel:i,sideModel:o,wireframeModel:s}}calculateIndices(t){const{polygonTesselator:e}=this.state;t.startIndices=e.indexStarts,t.value=e.get("indices")}calculatePositions(t){const{polygonTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("positions")}calculateVertexValid(t){t.value=this.state.polygonTesselator.get("vertexValid")}}function Xi({data:t,getIndex:e,dataRange:n,replace:i}){const{startRow:o=0,endRow:s=1/0}=n,r=t.length;let a=r,l=r;for(let d=0;d<r;d++){const n=e(t[d]);if(a>d&&n>=o&&(a=d),n>=s){l=d;break}}let c=a;const u=l-a!==i.length?t.slice(l):void 0;for(let d=0;d<i.length;d++)t[c++]=i[d];if(u){for(let e=0;e<u.length;e++)t[c++]=u[e];t.length=c}return{startRow:a,endRow:a+i.length}}Zi.defaultProps=Ki,Zi.layerName="SolidPolygonLayer";const Ji=[0,0,0,255],Qi={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:t=>t.polygon},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:Ji},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0};class to extends rn{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&t.defaultLogger.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:t}){const e=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getPolygon);if(e&&Array.isArray(t.dataChanged)){const e=this.state.paths.slice(),n=t.dataChanged.map(t=>Xi({data:e,getIndex:t=>t.__source.index,dataRange:t,replace:this._getPaths(t)}));this.setState({paths:e,pathsDiff:n})}else e&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(t={}){const{data:e,getPolygon:n,positionFormat:i,_normalize:o}=this.props,s=[],r="XY"===i?2:3,{startRow:a,endRow:l}=t,{iterable:c,objectInfo:u}=Kt(e,a,l);for(const d of c){u.index++;let t=n(d,u);o&&(t=ki(t,r));const{holeIndices:e}=t,i=t.positions||t;if(e)for(let n=0;n<=e.length;n++){const t=i.slice(e[n-1]||0,e[n]||i.length);s.push(this.getSubLayerRow({path:t},d,u.index))}else s.push(this.getSubLayerRow({path:i},d,u.index))}return s}renderLayers(){const{data:t,_dataDiff:e,stroked:n,filled:i,extruded:o,wireframe:s,_normalize:r,_windingOrder:a,elevationScale:l,transitions:c,positionFormat:u}=this.props,{lineWidthUnits:d,lineWidthScale:f,lineWidthMinPixels:p,lineWidthMaxPixels:h,lineJointRounded:g,lineMiterLimit:m,lineDashJustified:v}=this.props,{getFillColor:y,getLineColor:x,getLineWidth:_,getLineDashArray:b,getElevation:P,getPolygon:C,updateTriggers:L,material:w}=this.props,{paths:S,pathsDiff:A}=this.state,O=this.getSubLayerClass("fill",Zi),T=this.getSubLayerClass("stroke",wi),I=this.shouldRenderSubLayer("fill",S)&&new O({_dataDiff:e,extruded:o,elevationScale:l,filled:i,wireframe:s,_normalize:r,_windingOrder:a,getElevation:P,getFillColor:y,getLineColor:o&&s?x:Ji,material:w,transitions:c},this.getSubLayerProps({id:"fill",updateTriggers:L&&{getPolygon:L.getPolygon,getElevation:L.getElevation,getFillColor:L.getFillColor,lineColors:o&&s,getLineColor:L.getLineColor}}),{data:t,positionFormat:u,getPolygon:C});return[!o&&I,!o&&n&&this.shouldRenderSubLayer("stroke",S)&&new T({_dataDiff:A&&(()=>A),widthUnits:d,widthScale:f,widthMinPixels:p,widthMaxPixels:h,jointRounded:g,miterLimit:m,dashJustified:v,_pathType:"loop",transitions:c&&{getWidth:c.getLineWidth,getColor:c.getLineColor,getPath:c.getPolygon},getColor:this.getSubLayerAccessor(x),getWidth:this.getSubLayerAccessor(_),getDashArray:this.getSubLayerAccessor(b)},this.getSubLayerProps({id:"stroke",updateTriggers:L&&{getWidth:L.getLineWidth,getColor:L.getLineColor,getDashArray:L.getLineDashArray}}),{data:S,positionFormat:u,getPath:t=>t.path}),o&&I]}}to.layerName="PolygonLayer",to.defaultProps=Qi;const eo="layout(std140) uniform sdfUniforms {\n float gamma;\n bool enabled;\n float buffer;\n float outlineBuffer;\n vec4 outlineColor;\n} sdf;\n",no={name:"sdf",vs:eo,fs:eo,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}},io={none:0,start:1,center:2,end:3},oo={name:"text",vs:`layout(std140) uniform textUniforms {\n highp vec2 cutoffPixels;\n highp ivec2 align;\n highp float fontSize;\n bool flipY;\n} text;\n\n#define ALIGN_MODE_START ${io.start}\n#define ALIGN_MODE_CENTER ${io.center}\n#define ALIGN_MODE_END ${io.end}\n`,getUniforms:({contentCutoffPixels:t=[0,0],contentAlignHorizontal:e="none",contentAlignVertical:n="none",fontSize:i,viewport:o})=>({cutoffPixels:t,align:[io[e],io[n]],fontSize:i,flipY:o?.flipY??!1}),uniformTypes:{cutoffPixels:"vec2<f32>",align:"vec2<i32>",fontSize:"f32",flipY:"f32"}},so=.75;class ro extends zn{getShaders(){const t=super.getShaders();return{...t,modules:[...t.modules,oo,no],vs:"#version 300 es\n#define SHADER_NAME multi-icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nin vec4 instanceClipRect;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nfloat getPixelOffsetFromAlignment(float anchor, float extent, float clipStart, float clipEnd, int mode) {\nif (clipEnd < clipStart) return 0.0;\nif (mode == ALIGN_MODE_START) {\nreturn max(- (anchor + clipStart), 0.0);\n}\nif (mode == ALIGN_MODE_CENTER) {\nfloat _min = max(0., anchor + clipStart);\nfloat _max = min(extent, anchor + clipEnd);\nreturn _min < _max ? (_min + _max) / 2.0 - anchor : 0.0;\n}\nif (mode == ALIGN_MODE_END) {\nreturn min(extent - (anchor + clipEnd), 0.);\n}\nreturn 0.0;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),\nicon.sizeMinPixels, icon.sizeMaxPixels\n);\nfloat instanceScale = sizePixels / text.fontSize;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nvec2 anchorPosScreen;\nif (icon.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nanchorPosScreen = gl_Position.xy / gl_Position.w;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nif (text.flipY) {\noffset_common.y *= -1.;\n}\nDECKGL_FILTER_SIZE(offset_common, geometry);\nvec4 anchorPos = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0));\nanchorPosScreen = anchorPos.xy / anchorPos.w;\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nanchorPosScreen = vec2(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 * project.viewportSize / project.devicePixelRatio;\nvec2 xy = project_size_to_pixel(instanceClipRect.xy);\nvec2 wh = project_size_to_pixel(instanceClipRect.zw);\nif (text.flipY) {\nxy.y = -xy.y - wh.y;\n}\nif (text.align.x > 0 || text.align.y > 0) {\nvec2 viewportPixels = project.viewportSize / project.devicePixelRatio;\nvec2 scrollPixels = vec2(\ngetPixelOffsetFromAlignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x),\n-getPixelOffsetFromAlignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y)\n);\npixelOffset += scrollPixels;\ngl_Position.xy += project_pixel_size_to_clipspace(scrollPixels);\n}\nif (instanceClipRect.z >= 0.) {\nif (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) {\ngl_Position = vec4(0.0);\n}\nelse if (text.cutoffPixels.x > 0.) {\nfloat vpWidth = project.viewportSize.x / project.devicePixelRatio;\nfloat l = max(anchorPosScreen.x + xy.x, 0.0);\nfloat r = min(anchorPosScreen.x + xy.x + wh.x, vpWidth);\nif (r - l < text.cutoffPixels.x) {\ngl_Position = vec4(0.0);\n}\n}\n}\nif (instanceClipRect.w >= 0.) {\nif (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) {\ngl_Position = vec4(0.0);\n}\nelse if (text.cutoffPixels.y > 0.) {\nfloat vpHeight = project.viewportSize.y / project.devicePixelRatio;\nfloat t = max(anchorPosScreen.y - xy.y - wh.y, 0.0);\nfloat b = min(anchorPosScreen.y - xy.y, vpHeight);\nif (b - t < text.cutoffPixels.y) {\ngl_Position = vec4(0.0);\n}\n}\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / icon.iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME multi-icon-layer-fragment-shader\nprecision highp float;\nuniform sampler2D iconsTexture;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nif (!bool(picking.isActive)) {\nfloat alpha = texture(iconsTexture, vTextureCoords).a;\nvec4 color = vColor;\nif (sdf.enabled) {\nfloat distance = alpha;\nalpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);\nif (sdf.outlineBuffer > 0.0) {\nfloat inFill = alpha;\nfloat inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);\ncolor = mix(sdf.outlineColor, vColor, inFill);\nalpha = inBorder;\n}\n}\nfloat a = alpha * color.a;\nif (a < icon.alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color.rgb, a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){super.initializeState();const t=this.getAttributeManager();t.attributes.instanceIconDefs.settings.update=this.calculateInstanceIconDefs,t.addInstanced({instancePickingColors:{type:"uint8",size:4,accessor:(t,{index:e,target:n})=>this.encodePickingColor(e,n)},instanceClipRect:{size:4,accessor:"getContentBox",defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);const{props:n,oldProps:i,changeFlags:o}=e,{outlineColor:s}=n;if(o.updateTriggersChanged&&(o.updateTriggersChanged.getIcon||o.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate("instanceIconDefs"),s!==i.outlineColor){const t=[s[0]/255,s[1]/255,s[2]/255,(s[3]??255)/255];this.setState({outlineColor:t})}!n.sdf&&n.outlineWidth&&t.defaultLogger.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(t){const{sdf:e,smoothing:n,fontSize:i,outlineWidth:o,contentCutoffPixels:s,contentAlignHorizontal:r,contentAlignVertical:a}=this.props,{outlineColor:l}=this.state,c=o?Math.max(n,so*(1-o)):-1,u=this.state.model,d={buffer:so,outlineBuffer:c,gamma:n,enabled:Boolean(e),outlineColor:l},f={contentCutoffPixels:s,contentAlignHorizontal:r,contentAlignVertical:a,fontSize:i,viewport:this.context.viewport};if(u.shaderInputs.setProps({sdf:d,text:f}),super.draw(t),e&&o){const{iconManager:t}=this.state;t.getTexture()&&(u.shaderInputs.setProps({sdf:{...d,outlineBuffer:so}}),u.draw(this.context.renderPass))}}calculateInstanceIconDefs(t,{startRow:e,endRow:n}){const{data:i,getIcon:o,getIconOffsets:s}=this.props;let r=t.getVertexOffset(e);const a=t.value,{iterable:l,objectInfo:c}=Kt(i,e,n);for(const u of l){c.index++;const e=o(u,c),n=s(u,c);if(e){let i=0;for(const o of Array.from(e)){const e=super.getInstanceIconDef(o);e[0]=n[2*i],e[1]+=n[2*i+1],e[6]=1,a.set(e,r),r+=t.size,i++}}}}}ro.defaultProps={getIconOffsets:{type:"accessor",value:t=>t.offsets},getContentBox:{type:"accessor",value:[0,0,-1,-1]},fontSize:1,alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none"},ro.layerName="MultiIconLayer";const ao=1e20;class lo{constructor({fontSize:t=24,buffer:e=3,radius:n=8,cutoff:i=.25,fontFamily:o="sans-serif",fontWeight:s="normal",fontStyle:r="normal",lang:a=null}={}){this.buffer=e,this.cutoff=i,this.radius=n,this.lang=a;const l=this.size=t+4*e,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${r} ${s} ${t}px ${o}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:i,actualBoundingBoxLeft:o,actualBoundingBoxRight:s}=this.ctx.measureText(t),r=Math.ceil(n),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-o))),l=Math.min(this.size-this.buffer,r+Math.ceil(i)),c=a+2*this.buffer,u=l+2*this.buffer,d=Math.max(c*u,0),f=new Uint8ClampedArray(d),p={data:f,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:r,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:h,buffer:g,gridInner:m,gridOuter:v}=this;this.lang&&(h.lang=this.lang),h.clearRect(g,g,a,l),h.fillText(t,g,g+r);const y=h.getImageData(g,g,a,l);v.fill(ao,0,d),m.fill(0,0,d);for(let x=0;x<l;x++)for(let t=0;t<a;t++){const e=y.data[4*(x*a+t)+3]/255;if(0===e)continue;const n=(x+g)*c+t+g;if(1===e)v[n]=0,m[n]=ao;else{const t=.5-e;v[n]=t>0?t*t:0,m[n]=t<0?t*t:0}}co(v,0,0,c,u,c,this.f,this.v,this.z),co(m,g,g,a,l,c,this.f,this.v,this.z);for(let x=0;x<d;x++){const t=Math.sqrt(v[x])-Math.sqrt(m[x]);f[x]=Math.round(255-255*(t/this.radius+this.cutoff))}return p}}function co(t,e,n,i,o,s,r,a,l){for(let c=e;c<e+i;c++)uo(t,n*s+c,s,o,r,a,l);for(let c=n;c<n+o;c++)uo(t,c*s+e,1,i,r,a,l)}function uo(t,e,n,i,o,s,r){s[0]=0,r[0]=-ao,r[1]=ao,o[0]=t[e];for(let a=1,l=0,c=0;a<i;a++){o[a]=t[e+a*n];const i=a*a;do{const t=s[l];c=(o[a]-o[t]+i-t*t)/(a-t)/2}while(c<=r[l]&&--l>-1);l++,s[l]=a,r[l]=c,r[l+1]=ao}for(let a=0,l=0;a<i;a++){for(;r[l+1]<a;)l++;const i=s[l],c=a-i;t[e+a*n]=o[i]+c*c}}const fo=[];function po(t,e,n,i){let o=0;for(let s=e;s<n;s++){const e=t[s];o+=i[e]?.advance||0}return o}function ho(t,e,n,i,o,s){let r=e,a=0;for(let l=e;l<n;l++){const e=po(t,l,l+1,o);a+e>i&&(r<l&&s.push(l),r=l,a=0),a+=e}return a}function go(t,e,n,i,o=0,s){void 0===s&&(s=t.length);const r=[];return"break-all"===e?ho(t,o,s,n,i,r):function(t,e,n,i,o,s){let r=e,a=e,l=e,c=0;for(let u=e;u<n;u++)if(" "===t[u]?l=u+1:" "!==t[u+1]&&u+1!==n||(l=u+1),l>a){let e=po(t,a,l,o);c+e>i&&(r<a&&(s.push(a),r=a,c=0),e>i&&(e=ho(t,a,l,i,o,s),r=s[s.length-1])),a=l,c+=e}}(t,o,s,n,i,r),r}function mo(e,n,i,o,s,r){let a=0,l=0;for(let t=n;t<i;t++){const n=o[e[t]];n&&(l=Math.max(l,n.height))}for(let c=n;c<i;c++){const n=e[c],i=o[n];i?(s[c]=a+i.anchorX,a+=i.advance):(t.defaultLogger.warn(`Missing character: ${n} (${n.codePointAt(0)})`)(),s[c]=a,a+=32)}r[0]=a,r[1]=l}class vo{constructor(t=5){this._cache={},this._order=[],this.limit=t}get(t){const e=this._cache[t];return e&&(this._deleteOrder(t),this._appendOrder(t)),e}set(t,e){this._cache[t]?(this.delete(t),this._cache[t]=e,this._appendOrder(t)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[t]=e,this._appendOrder(t))}delete(t){this._cache[t]&&(delete this._cache[t],this._deleteOrder(t))}_deleteOrder(t){const e=this._order.indexOf(t);e>=0&&this._order.splice(e,1)}_appendOrder(t){this._order.push(t)}}const yo={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:function(){const t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1};let xo=new vo(3);function _o(t,e,n,i){t.font=`${i} ${n}px ${e}`,t.fillStyle="#000",t.textBaseline="alphabetic",t.textAlign="left"}class bo{constructor(){this.props={...yo}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}setProps(t={}){Object.assign(this.props,t),t._getFontRenderer&&(this._getFontRenderer=t._getFontRenderer),this._key=this._getKey();const e=function(t,e){let n;n="string"==typeof e?new Set(Array.from(e)):new Set(e);const i=xo.get(t);if(!i)return n;for(const o in i.mapping)n.has(o)&&n.delete(o);return n}(this._key,this.props.characterSet),n=xo.get(this._key);if(n&&0===e.size)return void(this._atlas!==n&&(this._atlas=n));const i=this._generateFontAtlas(e,n);this._atlas=i,xo.set(this._key,i)}_generateFontAtlas(t,e){const{fontFamily:n,fontWeight:i,fontSize:o,buffer:s,sdf:r,radius:a,cutoff:l}=this.props;let c=e&&e.data;c||(c=document.createElement("canvas"),c.width=1024);const u=c.getContext("2d",{willReadFrequently:!0});_o(u,n,o,i);const d=t=>function(t,e,n){if(void 0===n){const n=t.measureText("A");return n.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(n.fontBoundingBoxAscent),descent:Math.ceil(n.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:.9*e,descent:.3*e}}const i=t.measureText(n);return i.actualBoundingBoxAscent?{advance:i.width,width:Math.ceil(i.actualBoundingBoxRight-i.actualBoundingBoxLeft),ascent:Math.ceil(i.actualBoundingBoxAscent),descent:Math.ceil(i.actualBoundingBoxDescent)}:{advance:i.width,width:i.width,ascent:.9*e,descent:.3*e}}(u,o,t);let f;this._getFontRenderer?f=this._getFontRenderer(this.props):r&&(f={measure:d,draw:Po(this.props)});const{mapping:p,canvasHeight:h,xOffset:g,yOffsetMin:m,yOffsetMax:v}=function({characterSet:t,measureText:e,buffer:n,maxCanvasWidth:i,mapping:o={},xOffset:s=0,yOffsetMin:r=0,yOffsetMax:a=0}){let l=s,c=r,u=a;for(const f of t)if(!o[f]){const{advance:t,width:s,ascent:r,descent:a}=e(f),d=r+a;l+s+2*n>i&&(l=0,c=u),o[f]={x:l+n,y:c+n,width:s,height:d,advance:t,anchorX:s/2,anchorY:r},l+=s+2*n,u=Math.max(u,c+d+2*n)}return{mapping:o,xOffset:l,yOffsetMin:c,yOffsetMax:u,canvasHeight:(d=u,Math.pow(2,Math.ceil(Math.log2(d))))};var d}({measureText:t=>f?f.measure(t):d(t),buffer:s,characterSet:t,maxCanvasWidth:1024,...e&&{mapping:e.mapping,xOffset:e.xOffset,yOffsetMin:e.yOffsetMin,yOffsetMax:e.yOffsetMax}});if(c.height!==h){const t=c.height>0?u.getImageData(0,0,c.width,c.height):null;c.height=h,t&&u.putImageData(t,0,0)}if(_o(u,n,o,i),f)for(const x of t){const t=p[x],{data:e,left:n=0,top:i=0}=f.draw(x),o=t.x-n,s=t.y-i,r=Math.max(0,Math.round(o)),a=Math.max(0,Math.round(s)),l=Math.min(e.width,c.width-r),d=Math.min(e.height,c.height-a);u.putImageData(e,r,a,0,0,l,d),t.x+=r-o,t.y+=a-s}else for(const x of t){const t=p[x];u.fillText(x,t.x,t.y+t.anchorY)}const y=f?f.measure():d();return{baselineOffset:(y.ascent-y.descent)/2,xOffset:g,yOffsetMin:m,yOffsetMax:v,mapping:p,data:c,width:c.width,height:c.height}}_getKey(){const{fontFamily:t,fontWeight:e,fontSize:n,buffer:i,sdf:o,radius:s,cutoff:r}=this.props;return o?`${t} ${e} ${n} ${i} ${s} ${r}`:`${t} ${e} ${n} ${i}`}}function Po({fontSize:t,buffer:e,radius:n,cutoff:i,fontFamily:o,fontWeight:s}){const r=new lo({fontSize:t,buffer:e,radius:n,cutoff:i,fontFamily:o,fontWeight:`${s}`});return t=>{const{data:n,width:i,height:o}=r.draw(t),s=new ImageData(i,o);return function(t,e){for(let n=0;n<t.length;n++)e.data[4*n+3]=t[n]}(n,s),{data:s,left:e,top:e}}}const Co="layout(std140) uniform textBackgroundUniforms {\n bool billboard;\n float sizeScale;\n float sizeMinPixels;\n float sizeMaxPixels;\n vec4 borderRadius;\n vec4 padding;\n highp int sizeUnits;\n bool stroked;\n} textBackground;\n",Lo={name:"textBackground",vs:Co,fs:Co,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}},wo={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,fontSize:1,borderRadius:{type:"object",value:0},padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getClipRect:{type:"accessor",value:[0,0,-1,-1]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}};class So extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME text-background-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceRects;\nin vec4 instanceClipRect;\nin float instanceSizes;\nin float instanceAngles;\nin vec2 instancePixelOffsets;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout float vLineWidth;\nout vec2 uv;\nout vec2 dimensions;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = radians(angle);\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvLineWidth = instanceLineWidths;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits),\ntextBackground.sizeMinPixels, textBackground.sizeMaxPixels\n);\nfloat instanceScale = sizePixels / text.fontSize;\ndimensions = instanceRects.zw * instanceScale + textBackground.padding.xy + textBackground.padding.zw;\nvec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * instanceScale + mix(-textBackground.padding.xy, textBackground.padding.zw, positions);\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles);\npixelOffset += instancePixelOffsets;\npixelOffset.y *= -1.0;\nvec2 xy = project_size_to_pixel(instanceClipRect.xy);\nvec2 wh = project_size_to_pixel(instanceClipRect.zw);\nif (text.flipY) {\nxy.y = -xy.y - wh.y;\n}\nif (instanceClipRect.z >= 0.0) {\ndimensions.x = wh.x;\npixelOffset.x = xy.x + uv.x * wh.x + mix(-textBackground.padding.x, textBackground.padding.z, uv.x);\n}\nif (instanceClipRect.w >= 0.0) {\ndimensions.y = wh.y;\npixelOffset.y = xy.y + uv.y * wh.y + mix(-textBackground.padding.y, textBackground.padding.w, uv.y);\n}\nif (textBackground.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nif (text.flipY) {\noffset_common.y *= -1.;\n}\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME text-background-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin float vLineWidth;\nin vec2 uv;\nin vec2 dimensions;\nout vec4 fragColor;\nfloat round_rect(vec2 p, vec2 size, vec4 radii) {\nvec2 pixelPositionCB = (p - 0.5) * size;\nvec2 sizeCB = size * 0.5;\nfloat maxBorderRadius = min(size.x, size.y) * 0.5;\nvec4 borderRadius = vec4(min(radii, maxBorderRadius));\nborderRadius.xy =\n(pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw;\nborderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y;\nvec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x;\nreturn -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x);\n}\nfloat rect(vec2 p, vec2 size) {\nvec2 pixelPosition = p * size;\nreturn min(min(pixelPosition.x, size.x - pixelPosition.x),\nmin(pixelPosition.y, size.y - pixelPosition.y));\n}\nvec4 get_stroked_fragColor(float dist) {\nfloat isBorder = smoothedge(dist, vLineWidth);\nreturn mix(vFillColor, vLineColor, isBorder);\n}\nvoid main(void) {\ngeometry.uv = uv;\nif (textBackground.borderRadius != vec4(0.0)) {\nfloat distToEdge = round_rect(uv, dimensions, textBackground.borderRadius);\nfloat shapeAlpha = smoothedge(-distToEdge, 0.0);\nif (shapeAlpha == 0.0) {\ndiscard;\n}\nif (textBackground.stroked) {\nfragColor = get_stroked_fragColor(distToEdge);\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= shapeAlpha;\n} else {\nif (textBackground.stroked) {\nfloat distToEdge = rect(uv, dimensions);\nfragColor = get_stroked_fragColor(distToEdge);\n} else {\nfragColor = vFillColor;\n}\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[$,H,Lo,oo]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instanceClipRect:{size:4,accessor:"getClipRect",defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(t){super.updateState(t);const{changeFlags:e}=t;e.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{billboard:n,sizeScale:i,sizeUnits:o,sizeMinPixels:s,sizeMaxPixels:r,getLineWidth:a,fontSize:l}=this.props;let{padding:c,borderRadius:u}=this.props;c.length<4&&(c=[c[0],c[1],c[0],c[1]]),Array.isArray(u)||(u=[u,u,u,u]);const d=this.state.model,f={billboard:n,stroked:Boolean(a),borderRadius:u,padding:c,sizeUnits:t.UNIT[o],sizeScale:i,sizeMinPixels:s,sizeMaxPixels:r},p={fontSize:l,viewport:this.context.viewport};d.shaderInputs.setProps({textBackground:f,text:p}),d.draw(this.context.renderPass)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array([0,0,1,0,0,1,1,1])}}}),isInstanced:!0})}}So.defaultProps=wo,So.layerName="TextBackgroundLayer";const Ao={start:1,middle:0,end:-1},Oo={top:1,center:0,bottom:-1},To=[0,0,0,255],Io={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:To},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:yo.characterSet},fontFamily:yo.fontFamily,fontWeight:yo.fontWeight,lineHeight:1,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:To},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none",getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:To},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},getContentBox:{type:"accessor",value:[0,0,-1,-1]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}};class Eo extends rn{constructor(){super(...arguments),this.getBoundingRect=(t,e)=>{const{size:[n,i]}=this.transformParagraph(t,e),{getTextAnchor:o,getAlignmentBaseline:s}=this.props;return[(Ao["function"==typeof o?o(t,e):o]-1)*n/2,(Oo["function"==typeof s?s(t,e):s]-1)*i/2,n,i]},this.getIconOffsets=(t,e)=>{const{getTextAnchor:n,getAlignmentBaseline:i}=this.props,{x:o,y:s,rowWidth:r,size:[,a]}=this.transformParagraph(t,e),l=Ao["function"==typeof n?n(t,e):n],c=Oo["function"==typeof i?i(t,e):i],u=o.length,d=new Array(2*u);let f=0;for(let p=0;p<u;p++)d[f++]=(l-1)*r[p]/2+o[p],d[f++]=(c-1)*a/2+s[p];return d}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new bo},this.props.maxWidth>0&&t.defaultLogger.once(1,"v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(t){const{props:e,oldProps:n,changeFlags:i}=t;(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getText))&&this._updateText();(this._updateFontAtlas()||e.lineHeight!==n.lineHeight||e.wordBreak!==n.wordBreak||e.maxWidth!==n.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:t}){return t.object=t.index>=0?this.props.data[t.index]:null,t}_updateFontAtlas(){const{fontSettings:t,fontFamily:e,fontWeight:n,_getFontRenderer:i}=this.props,{fontAtlasManager:o,characterSet:s}=this.state,r={...t,characterSet:s,fontFamily:e,fontWeight:n,_getFontRenderer:i};if(!o.mapping)return o.setProps(r),!0;for(const a in r)if(r[a]!==o.props[a])return o.setProps(r),!0;return!1}_updateText(){const{data:t,characterSet:e}=this.props,n=t.attributes?.getText;let i,{getText:o}=this.props,s=t.startIndices;const r="auto"===e&&new Set;if(n&&s){const{texts:e,characterCount:a}=function({value:t,length:e,stride:n,offset:i,startIndices:o,characterSet:s}){const r=t.BYTES_PER_ELEMENT,a=n?n/r:1,l=i?i/r:0,c=o[e]||Math.ceil((t.length-l)/a),u=s&&new Set,d=new Array(e);let f=t;if(a>1||l>0){f=new(0,t.constructor)(c);for(let e=0;e<c;e++)f[e]=t[e*a+l]}for(let p=0;p<e;p++){const t=o[p],e=o[p+1]||c,n=f.subarray(t,e);d[p]=String.fromCodePoint.apply(null,n),u&&n.forEach(u.add,u)}if(u)for(const p of u)s.add(String.fromCodePoint(p));return{texts:d,characterCount:c}}({...ArrayBuffer.isView(n)?{value:n}:n,length:t.length,startIndices:s,characterSet:r});i=a,o=(t,{index:n})=>e[n]}else{const{iterable:e,objectInfo:n}=Kt(t);s=[0],i=0;for(const t of e){n.index++;const e=Array.from(o(t,n)||"");r&&e.forEach(r.add,r),i+=e.length,s.push(i)}}this.setState({getText:o,startIndices:s,numInstances:i,characterSet:r||e})}transformParagraph(t,e){const{fontAtlasManager:n}=this.state,i=n.mapping,{baselineOffset:o}=n.atlas,{fontSize:s}=n.props,r=this.state.getText,{wordBreak:a,lineHeight:l,maxWidth:c}=this.props;return function(t,e,n,i,o,s){const r=Array.from(t),a=r.length,l=new Array(a),c=new Array(a),u=new Array(a),d=("break-word"===i||"break-all"===i)&&isFinite(o)&&o>0,f=[0,0],p=[0,0];let h=0,g=e+n/2,m=0,v=0;for(let y=0;y<=a;y++){const t=r[y];if("\n"!==t&&y!==a||(v=y),v>m){const t=d?go(r,i,o,s,m,v):fo;for(let e=0;e<=t.length;e++){const i=0===e?m:t[e-1],o=e<t.length?t[e]:v;mo(r,i,o,s,l,p);for(let t=i;t<o;t++)c[t]=g,u[t]=p[0];h++,g+=n,f[0]=Math.max(f[0],p[0])}m=v}"\n"===t&&(l[m]=0,c[m]=0,u[m]=0,m++)}return f[1]=h*n,{x:l,y:c,rowWidth:u,size:f}}(r(t,e)||"",o,l*s,a,c*s,i)}renderLayers(){const{startIndices:t,numInstances:e,getText:n,fontAtlasManager:{atlas:i,mapping:o},styleVersion:s}=this.state,{data:r,_dataDiff:a,getPosition:l,getColor:c,getSize:u,getAngle:d,getPixelOffset:f,getBackgroundColor:p,getBorderColor:h,getBorderWidth:g,getContentBox:m,backgroundBorderRadius:v,backgroundPadding:y,background:x,billboard:_,fontSettings:b,outlineWidth:P,outlineColor:C,sizeScale:L,sizeUnits:w,sizeMinPixels:S,sizeMaxPixels:A,contentCutoffPixels:O,contentAlignHorizontal:T,contentAlignVertical:I,transitions:E,updateTriggers:M}=this.props,z=this.getSubLayerClass("characters",ro),R=this.getSubLayerClass("background",So),{fontSize:F}=this.state.fontAtlasManager.props;return[x&&new R({getFillColor:p,getLineColor:h,getLineWidth:g,borderRadius:v,padding:y,getPosition:l,getSize:u,getAngle:d,getPixelOffset:f,getClipRect:m,billboard:_,sizeScale:L,sizeUnits:w,sizeMinPixels:S,sizeMaxPixels:A,fontSize:F,transitions:E&&{getPosition:E.getPosition,getAngle:E.getAngle,getSize:E.getSize,getFillColor:E.getBackgroundColor,getLineColor:E.getBorderColor,getLineWidth:E.getBorderWidth,getPixelOffset:E.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:M.getPosition,getAngle:M.getAngle,getSize:M.getSize,getFillColor:M.getBackgroundColor,getLineColor:M.getBorderColor,getLineWidth:M.getBorderWidth,getPixelOffset:M.getPixelOffset,getBoundingRect:{getText:M.getText,getTextAnchor:M.getTextAnchor,getAlignmentBaseline:M.getAlignmentBaseline,styleVersion:s}}}),{data:r.attributes&&r.attributes.background?{length:r.length,attributes:r.attributes.background}:r,_dataDiff:a,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new z({sdf:b.sdf,smoothing:Number.isFinite(b.smoothing)?b.smoothing:yo.smoothing,outlineWidth:P/(b.radius||yo.radius),outlineColor:C,iconAtlas:i,iconMapping:o,getPosition:l,getColor:c,getSize:u,getAngle:d,getPixelOffset:f,getContentBox:m,billboard:_,sizeScale:L,sizeUnits:w,sizeMinPixels:S,sizeMaxPixels:A,fontSize:F,contentCutoffPixels:O,contentAlignHorizontal:T,contentAlignVertical:I,transitions:E&&{getPosition:E.getPosition,getAngle:E.getAngle,getColor:E.getColor,getSize:E.getSize,getPixelOffset:E.getPixelOffset,getContentBox:E.getContentBox}},this.getSubLayerProps({id:"characters",updateTriggers:{all:M.getText,getPosition:M.getPosition,getAngle:M.getAngle,getColor:M.getColor,getSize:M.getSize,getPixelOffset:M.getPixelOffset,getContentBox:M.getContentBox,getIconOffsets:{getTextAnchor:M.getTextAnchor,getAlignmentBaseline:M.getAlignmentBaseline,styleVersion:s}}}),{data:r,_dataDiff:a,startIndices:t,numInstances:e,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(e){!function(e){t.defaultLogger.assert(Number.isFinite(e)&&e>=3,"Invalid cache limit"),xo=new vo(e)}(e)}}Eo.defaultProps=Io,Eo.layerName="TextLayer";const Mo={circle:{type:Wn,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:zn,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:Eo,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},zo={type:wi,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},Ro={type:Zi,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Fo({type:t,props:e}){const n={};for(const i in e)n[i]=t.defaultProps[e[i]];return n}function Bo(t,e){const{transitions:n,updateTriggers:i}=t.props,o={updateTriggers:{},transitions:n&&{getPosition:n.geometry}};for(const s in e){const r=e[s];let a=t.props[s];s.startsWith("get")&&(a=t.getSubLayerAccessor(a),o.updateTriggers[r]=i[s],n&&(o.transitions[r]=n[s])),o[r]=a}return o}function ko(e,n,i={}){const o={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:s=0,endRow:r=e.length}=i;for(let a=s;a<r;a++){const i=e[a],{geometry:s}=i;if(s)if("GeometryCollection"===s.type){t.defaultLogger.assert(Array.isArray(s.geometries),"GeoJSON does not have geometries array");const{geometries:e}=s;for(let t=0;t<e.length;t++){No(e[t],o,n,i,a)}}else No(s,o,n,i,a)}return o}function No(e,n,i,o,s){const{type:r,coordinates:a}=e,{pointFeatures:l,lineFeatures:c,polygonFeatures:u,polygonOutlineFeatures:d}=n;if(function(e,n){let i=Do[e];t.defaultLogger.assert(i,`Unknown GeoJSON type ${e}`);for(;n&&--i>0;)n=n[0];return n&&Number.isFinite(n[0])}(r,a))switch(r){case"Point":l.push(i({geometry:e},o,s));break;case"MultiPoint":a.forEach(t=>{l.push(i({geometry:{type:"Point",coordinates:t}},o,s))});break;case"LineString":c.push(i({geometry:e},o,s));break;case"MultiLineString":a.forEach(t=>{c.push(i({geometry:{type:"LineString",coordinates:t}},o,s))});break;case"Polygon":u.push(i({geometry:e},o,s)),a.forEach(t=>{d.push(i({geometry:{type:"LineString",coordinates:t}},o,s))});break;case"MultiPolygon":a.forEach(t=>{u.push(i({geometry:{type:"Polygon",coordinates:t}},o,s)),t.forEach(t=>{d.push(i({geometry:{type:"LineString",coordinates:t}},o,s))})})}else t.defaultLogger.warn(`${r} coordinates are malformed`)()}const Do={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function Uo(t){return t.geometry.coordinates}function jo(t,e){const n={points:{},lines:{},polygons:{},polygonsOutline:{}},{points:i,lines:o,polygons:s}=t,r=function(t,e){const n={points:null,lines:null,polygons:null};for(const i in n){const o=t[i].globalFeatureIds.value;n[i]=new Uint8ClampedArray(4*o.length);const s=[];for(let t=0;t<o.length;t++)e(o[t],s),n[i][4*t+0]=s[0],n[i][4*t+1]=s[1],n[i][4*t+2]=s[2],n[i][4*t+3]=255}return n}(t,e);n.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:4,value:r.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},n.lines.data={length:o.pathIndices.value.length-1,startIndices:o.pathIndices.value,attributes:{...o.attributes,getPath:o.positions,instancePickingColors:{size:4,value:r.lines}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},n.lines._pathType="open";const a=s.positions.value.length/s.positions.size,l=Array(a).fill(1);for(const c of s.primitivePolygonIndices.value)l[c-1]=0;return n.polygons.data={length:s.polygonIndices.value.length-1,startIndices:s.polygonIndices.value,attributes:{...s.attributes,getPolygon:s.positions,instanceVertexValid:{size:1,value:new Uint16Array(l)},pickingColors:{size:4,value:r.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},n.polygons._normalize=!1,s.triangles&&(n.polygons.data.attributes.indices=s.triangles.value),n.polygonsOutline.data={length:s.primitivePolygonIndices.value.length-1,startIndices:s.primitivePolygonIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:4,value:r.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},n.polygonsOutline._pathType="open",n}const Go=["points","linestrings","polygons"],Vo={...Fo(Mo.circle),...Fo(Mo.icon),...Fo(Mo.text),...Fo(zo),...Fo(Ro),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};class Wo extends rn{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:t,changeFlags:e}){if(!e.dataChanged)return;const{data:n}=this.props,i=n&&"points"in n&&"polygons"in n&&"lines"in n;this.setState({binary:i}),i?this._updateStateBinary({props:t,changeFlags:e}):this._updateStateJSON({props:t,changeFlags:e})}_updateStateBinary({props:t,changeFlags:e}){const n=jo(t.data,this.encodePickingColor);this.setState({layerProps:n})}_updateStateJSON({props:e,changeFlags:n}){const i=function(e){if(Array.isArray(e))return e;switch(t.defaultLogger.assert(e.type,"GeoJSON does not have type"),e.type){case"Feature":return[e];case"FeatureCollection":return t.defaultLogger.assert(Array.isArray(e.features),"GeoJSON does not have features array"),e.features;default:return[{geometry:e}]}}(e.data),o=this.getSubLayerRow.bind(this);let s={};const r={};if(Array.isArray(n.dataChanged)){const t=this.state.features;for(const e in t)s[e]=t[e].slice(),r[e]=[];for(const e of n.dataChanged){const n=ko(i,o,e);for(const i in t)r[i].push(Xi({data:s[i],getIndex:t=>t.__source.index,dataRange:e,replace:n[i]}))}}else s=ko(i,o);const a=function(t,e){const n={points:{},lines:{},polygons:{},polygonsOutline:{}},{pointFeatures:i,lineFeatures:o,polygonFeatures:s,polygonOutlineFeatures:r}=t;return n.points.data=i,n.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),n.points.getPosition=Uo,n.lines.data=o,n.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),n.lines.getPath=Uo,n.polygons.data=s,n.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),n.polygons.getPolygon=Uo,n.polygonsOutline.data=r,n.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),n.polygonsOutline.getPath=Uo,n}(s,r);this.setState({features:s,featuresDiff:r,layerProps:a})}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n,sourceLayer:i}=e;return e.featureType=Go.find(t=>i.id.startsWith(`${this.id}-${t}-`)),n>=0&&i.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(e.index=this.props.data.points.globalFeatureIds.value[n]),e}_updateAutoHighlight(t){const e=`${this.id}-points-`,n="points"===t.featureType;for(const i of this.getSubLayers())i.id.startsWith(e)===n&&i.updateAutoHighlight(t)}_renderPolygonLayer(){const{extruded:t,wireframe:e}=this.props,{layerProps:n}=this.state,i="polygons-fill",o=this.shouldRenderSubLayer(i,n.polygons?.data)&&this.getSubLayerClass(i,Ro.type);if(o){const s=Bo(this,Ro.props),r=t&&e;return r||delete s.getLineColor,s.updateTriggers.lineColors=r,new o(s,this.getSubLayerProps({id:i,updateTriggers:s.updateTriggers}),n.polygons)}return null}_renderLineLayers(){const{extruded:t,stroked:e}=this.props,{layerProps:n}=this.state,i="polygons-stroke",o="linestrings",s=!t&&e&&this.shouldRenderSubLayer(i,n.polygonsOutline?.data)&&this.getSubLayerClass(i,zo.type),r=this.shouldRenderSubLayer(o,n.lines?.data)&&this.getSubLayerClass(o,zo.type);if(s||r){const t=Bo(this,zo.props);return[s&&new s(t,this.getSubLayerProps({id:i,updateTriggers:t.updateTriggers}),n.polygonsOutline),r&&new r(t,this.getSubLayerProps({id:o,updateTriggers:t.updateTriggers}),n.lines)]}return null}_renderPointLayers(){const{pointType:t}=this.props,{layerProps:e,binary:n}=this.state;let{highlightedObjectIndex:i}=this.props;!n&&Number.isFinite(i)&&(i=e.points.data.findIndex(t=>t.__source.index===i));const o=new Set(t.split("+")),s=[];for(const r of o){const t=`points-${r}`,o=Mo[r],a=o&&this.shouldRenderSubLayer(t,e.points?.data)&&this.getSubLayerClass(t,o.type);if(a){const l=Bo(this,o.props);let c=e.points;if("text"===r&&n){const{instancePickingColors:t,...e}=c.data.attributes;c={...c,data:{...c.data,attributes:e}}}s.push(new a(l,this.getSubLayerProps({id:t,updateTriggers:l.updateTriggers,highlightedObjectIndex:i}),c))}}return s}renderLayers(){const{extruded:t}=this.props,e=this._renderPolygonLayer();return[!t&&e,this._renderLineLayers(),this._renderPointLayers(),t&&e]}getSubLayerAccessor(t){const{binary:e}=this.state;return e&&"function"==typeof t?(e,n)=>{const{data:i,index:o}=n,s=function(t,e){if(!t)return null;const n="startIndices"in t?t.startIndices[e]:e,i=t.featureIds.value[n];return-1!==n?function(t,e,n){const i={properties:{...t.properties[e]}};for(const o in t.numericProps)i.properties[o]=t.numericProps[o].value[n];return i}(t,i,n):null}(i,o);return t(s,n)}:super.getSubLayerAccessor(t)}}Wo.layerName="GeoJsonLayer",Wo.defaultProps=Vo,exports.ArcLayer=fn,exports.BitmapLayer=xn,exports.ColumnLayer=mi,exports.CompositeLayer=rn,exports.DynamicTexture=Mt,exports.GeoJsonLayer=Wo,exports.Geometry=Ut,exports.IconLayer=zn,exports.Layer=on,exports.Model=Nt,exports.MultiIconLayer=ro,exports.PathLayer=wi,exports.PointCloudLayer=Dn,exports.PolygonLayer=to,exports.ScatterplotLayer=Wn,exports.ShaderInputs=dt,exports.SolidPolygonLayer=Zi,exports.TextBackgroundLayer=So,exports.TextLayer=Eo,exports.UniformStore=T,exports.color=W,exports.createIterable=Kt,exports.lighting=M,exports.normalizeByteColor3=a,exports.phongMaterial=V,exports.picking=H,exports.project32=$,exports.shaderModuleHasUniforms=lt,exports.uid=X;
|
|
2
|
-
//# sourceMappingURL=geojson-layer-
|
|
1
|
+
"use strict";const t=require("./webgl-developer-tools-DyDR0yGE.cjs"),e=require("./webgl-device-DikFjUoh.cjs"),n=require("./sdk-controller-5LmYQQhJ.cjs");function i(t){return function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(t)||function(t){return!!Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}(t)}function o(t){const{input:e,inputChannels:n,output:i}={};if(!e)return"#version 300 es\nout vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}";if(!n)throw new Error("inputChannels");return`#version 300 es\nin ${function(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}(n)} ${e};\nout vec4 ${i};\nvoid main() {\n ${i} = ${function(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}(e,n)};\n}`}function s(t,e=[],n=0){const i=Math.fround(t),o=t-i;return e[n]=i,e[n+1]=o,e}function r(t,e=!0){return t??e}function a(t=[0,0,0],e=!0){return e?t.map(t=>t/255):[...t]}const l="\nlayout(std140) uniform fp64arithmeticUniforms {\n uniform float ONE;\n uniform float SPLIT;\n} fp64;\n\n/*\nAbout LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n\nThe purpose of this workaround is to prevent shader compilers from\noptimizing away necessary arithmetic operations by swapping their sequences\nor transform the equation to some 'equivalent' form.\n\nThese helpers implement Dekker/Veltkamp-style error tracking. If the compiler\nfolds constants or reassociates the arithmetic, the high/low split can stop\ntracking the rounding error correctly. That failure mode tends to look fine in\nsimple coordinate setup, but then breaks down inside iterative arithmetic such\nas fp64 Mandelbrot loops.\n\nThe method is to multiply an artifical variable, ONE, which will be known to\nthe compiler to be 1 only at runtime. The whole expression is then represented\nas a polynomial with respective to ONE. In the coefficients of all terms, only one a\nand one b should appear\n\nerr = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE\n*/\n\nfloat prevent_fp64_optimization(float value) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n return value + fp64.ONE * 0.0;\n#else\n return value;\n#endif\n}\n\n// Divide float number to high and low floats to extend fraction bits\nvec2 split(float a) {\n // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker\n // split into a constant expression and reassociate the recovery steps.\n float split = prevent_fp64_optimization(fp64.SPLIT);\n float t = prevent_fp64_optimization(a * split);\n float temp = t - a;\n float a_hi = t - temp;\n float a_lo = a - a_hi;\n return vec2(a_hi, a_lo);\n}\n\n// Divide float number again when high float uses too many fraction bits\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\n\n// Special sum operation when a > b\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * fp64.ONE;\n float err = b - (sum - a) * fp64.ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\n\n// General sum operation\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *\n a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend\n // on the split terms and cross terms staying in the original evaluation\n // order. If the compiler folds or reassociates them, the low part tends to\n // collapse to zero or NaN on some drivers.\n float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);\n float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);\n float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);\n float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err1 = (highProduct - prod) * fp64.ONE;\n float err2 = crossProduct1 * fp64.ONE * fp64.ONE;\n float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;\n float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err1 = highProduct - prod;\n float err2 = crossProduct1;\n float err3 = crossProduct2;\n float err4 = lowProduct;\n#endif\n float err = ((err1 + err2) + err3) + err4;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n // y component is for the error\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * fp64.ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",c={name:"fp64arithmetic",source:"struct Fp64ArithmeticUniforms {\n ONE: f32,\n SPLIT: f32,\n};\n\n@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;\n\nfn fp64_nan(seed: f32) -> f32 {\n let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);\n return bitcast<f32>(nanBits);\n}\n\nfn fp64_runtime_zero() -> f32 {\n return fp64arithmetic.ONE * 0.0;\n}\n\nfn prevent_fp64_optimization(value: f32) -> f32 {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n return value + fp64_runtime_zero();\n#else\n return value;\n#endif\n}\n\nfn split(a: f32) -> vec2f {\n let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());\n let t = prevent_fp64_optimization(a * splitValue);\n let temp = prevent_fp64_optimization(t - a);\n let aHi = prevent_fp64_optimization(t - temp);\n let aLo = prevent_fp64_optimization(a - aHi);\n return vec2f(aHi, aLo);\n}\n\nfn split2(a: vec2f) -> vec2f {\n var b = split(a.x);\n b.y = b.y + a.y;\n return b;\n}\n\nfn quickTwoSum(a: f32, b: f32) -> vec2f {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);\n let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);\n#else\n let sum = prevent_fp64_optimization(a + b);\n let err = prevent_fp64_optimization(b - (sum - a));\n#endif\n return vec2f(sum, err);\n}\n\nfn twoSum(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a + b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) +\n prevent_fp64_optimization(b - v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSub(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a - b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) -\n prevent_fp64_optimization(b + v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSqr(a: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * a);\n let aFp64 = split(a);\n let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);\n let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);\n let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err =\n (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +\n crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +\n lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n#else\n let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);\n#endif\n return vec2f(prod, err);\n}\n\nfn twoProd(a: f32, b: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * b);\n let aFp64 = split(a);\n let bFp64 = split(b);\n let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);\n let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);\n let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);\n let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err1 = (highProduct - prod) * fp64arithmetic.ONE;\n let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err4 =\n lowProduct *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE;\n#else\n let err1 = highProduct - prod;\n let err2 = crossProduct1;\n let err3 = crossProduct2;\n let err4 = lowProduct;\n#endif\n let err12InputA = prevent_fp64_optimization(err1);\n let err12InputB = prevent_fp64_optimization(err2);\n let err12 = prevent_fp64_optimization(err12InputA + err12InputB);\n let err123InputA = prevent_fp64_optimization(err12);\n let err123InputB = prevent_fp64_optimization(err3);\n let err123 = prevent_fp64_optimization(err123InputA + err123InputB);\n let err1234InputA = prevent_fp64_optimization(err123);\n let err1234InputB = prevent_fp64_optimization(err4);\n let err = prevent_fp64_optimization(err1234InputA + err1234InputB);\n return vec2f(prod, err);\n}\n\nfn sum_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSum(a.x, b.x);\n let t = twoSum(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn sub_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSub(a.x, b.x);\n let t = twoSub(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn mul_fp64(a: vec2f, b: vec2f) -> vec2f {\n var prod = twoProd(a.x, b.x);\n let crossProduct1 = prevent_fp64_optimization(a.x * b.y);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct1);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n let crossProduct2 = prevent_fp64_optimization(a.y * b.x);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct2);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nfn div_fp64(a: vec2f, b: vec2f) -> vec2f {\n let xn = prevent_fp64_optimization(1.0 / b.x);\n let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));\n let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);\n let prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nfn sqrt_fp64(a: vec2f) -> vec2f {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2f(0.0, 0.0);\n }\n if (a.x < 0.0) {\n let nanValue = fp64_nan(a.x);\n return vec2f(nanValue, nanValue);\n }\n\n let x = prevent_fp64_optimization(1.0 / sqrt(a.x));\n let yn = prevent_fp64_optimization(a.x * x);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;\n#else\n let ynSqr = twoSqr(yn);\n#endif\n let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);\n let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2f(yn, 0.0), prod);\n#endif\n}\n",fs:l,vs:l,defaultUniforms:{ONE:1,SPLIT:4097},uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:s,fp64LowPart:function(t){return t-Math.fround(t)},fp64ifyMatrix4:function(t){const e=new Float32Array(32);for(let n=0;n<4;++n)for(let i=0;i<4;++i){const o=4*n+i;s(t[4*i+n],e,2*o)}return e}},u="layout(std140) uniform floatColorsUniforms {\n float useByteColors;\n} floatColors;\n\nvec3 floatColors_normalize(vec3 inputColor) {\n return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 floatColors_normalize(vec4 inputColor) {\n return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 floatColors_premultiplyAlpha(vec4 inputColor) {\n return vec4(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nvec4 floatColors_unpremultiplyAlpha(vec4 inputColor) {\n return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0);\n}\n\nvec4 floatColors_premultiply_alpha(vec4 inputColor) {\n return floatColors_premultiplyAlpha(inputColor);\n}\n\nvec4 floatColors_unpremultiply_alpha(vec4 inputColor) {\n return floatColors_unpremultiplyAlpha(inputColor);\n}\n",d={name:"floatColors",props:{},uniforms:{},vs:u,fs:u,source:"struct floatColorsUniforms {\n useByteColors: f32\n};\n\n@group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms;\n\nfn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> {\n return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);\n}\n\nfn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> {\n return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);\n}\n\nfn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nfn floatColors_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return select(\n vec4<f32>(0.0),\n vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a),\n inputColor.a > 0.0\n );\n}\n\nfn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return floatColors_premultiplyAlpha(inputColor);\n}\n\nfn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return floatColors_unpremultiplyAlpha(inputColor);\n}\n",uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}},f={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},vs:"layout(std140) uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useByteColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nout vec4 picking_vRGBcolor_Avalid;\n\n// Normalize unsigned byte color to 0-1 range\nvec3 picking_normalizeColor(vec3 color) {\n return picking.useByteColors > 0.5 ? color / 255.0 : color;\n}\n\n// Normalize unsigned byte color to 0-1 range\nvec4 picking_normalizeColor(vec4 color) {\n return picking.useByteColors > 0.5 ? color / 255.0 : color;\n}\n\nbool picking_isColorZero(vec3 color) {\n return dot(color, vec3(1.0)) < 0.00001;\n}\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.00001;\n}\n\n// Check if this vertex is highlighted \nbool isVertexHighlighted(vec3 vertexColor) {\n vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n return\n bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\n\n// Set the current picking color\nvoid picking_setPickingColor(vec3 pickingColor) {\n pickingColor = picking_normalizeColor(pickingColor);\n\n if (bool(picking.isActive)) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!bool(picking.isAttribute)) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec2 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec3 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n",fs:"layout(std140) uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useByteColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n // If we are still picking, we don't highlight\n if (picking.isActive > 0.5) {\n return color;\n }\n\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n // Blend in highlight color based on its alpha value\n float highLightAlpha = picking.highlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (bool(picking.isActive)) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highlightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highlightColor);\n}\n",getUniforms:function(t={},e){const n={},i=r(t.useByteColors,!0);if(void 0===t.highlightedObjectColor);else if(null===t.highlightedObjectColor)n.isHighlightActive=!1;else{n.isHighlightActive=!0;const e=t.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=e}t.highlightColor&&(n.highlightColor=function(t,e=!0){const n=a(t.slice(0,3),e),i=Number.isFinite(t[3]),o=i?t[3]:1;return[n[0],n[1],n[2],e&&i?o/255:o]}(t.highlightColor,i));void 0!==t.isActive&&(n.isActive=Boolean(t.isActive),n.isAttribute=Boolean(t.isAttribute));void 0!==t.useByteColors&&(n.useByteColors=Boolean(t.useByteColors));return n}};class p extends t.Resource{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(t,e){super(t,e,p.defaultProps),this.shaderLayout=e.shaderLayout}static defaultProps={...t.Resource.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}class h{static defaultProps={...e.RenderPipeline.defaultProps};static getDefaultPipelineFactory(t){const e=t.getModuleData("@luma.gl/core");return e.defaultPipelineFactory||=new h(t),e.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(t){this.device=t}createRenderPipeline(n){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(n);const i={...e.RenderPipeline.defaultProps,...n},o=this._renderPipelineCache,s=this._hashRenderPipeline(i);let r=o[s]?.resource;if(r)o[s].useCount++,this.device.props.debugFactories&&t.log.log(3,`${this}: ${o[s].resource} reused, count=${o[s].useCount}, (id=${n.id})`)();else{const e="webgl"===this.device.type&&this.device.props._sharePipelines?this.createSharedRenderPipeline(i):void 0;r=this.device.createRenderPipeline({...i,id:i.id?`${i.id}-cached`:t.uid("unnamed-cached"),_sharedRenderPipeline:e}),r.hash=s,o[s]={resource:r,useCount:1},this.device.props.debugFactories&&t.log.log(3,`${this}: ${r} created, count=${o[s].useCount}`)()}return r}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);const n={...p.defaultProps,...e},i=this._computePipelineCache,o=this._hashComputePipeline(n);let s=i[o]?.resource;return s?(i[o].useCount++,this.device.props.debugFactories&&t.log.log(3,`${this}: ${i[o].resource} reused, count=${i[o].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...n,id:n.id?`${n.id}-cached`:void 0}),s.hash=o,i[o]={resource:s,useCount:1},this.device.props.debugFactories&&t.log.log(3,`${this}: ${s} created, count=${i[o].useCount}`)()),s}release(e){if(!this.device.props._cachePipelines)return void e.destroy();const n=this._getCache(e),i=e.hash;n[i].useCount--,0===n[i].useCount?(this._destroyPipeline(e),this.device.props.debugFactories&&t.log.log(3,`${this}: ${e} released and destroyed`)()):n[i].useCount<0?(t.log.error(`${this}: ${e} released, useCount < 0, resetting`)(),n[i].useCount=0):this.device.props.debugFactories&&t.log.log(3,`${this}: ${e} released, count=${n[i].useCount}`)()}createSharedRenderPipeline(t){const e=this._hashSharedRenderPipeline(t);let n=this._sharedRenderPipelineCache[e];if(!n){n={resource:this.device._createSharedRenderPipelineWebGL(t),useCount:0},this._sharedRenderPipelineCache[e]=n}return n.useCount++,n.resource}releaseSharedRenderPipeline(t){if(!t.sharedRenderPipeline)return;const e=this._hashSharedRenderPipeline(t.sharedRenderPipeline.props),n=this._sharedRenderPipelineCache[e];n&&(n.useCount--,0===n.useCount&&(n.resource.destroy(),delete this._sharedRenderPipelineCache[e]))}_destroyPipeline(t){const n=this._getCache(t);return!!this.device.props._destroyPipelines&&(delete n[t.hash],t.destroy(),t instanceof e.RenderPipeline&&this.releaseSharedRenderPipeline(t),!0)}_getCache(t){let n;if(t instanceof p&&(n=this._computePipelineCache),t instanceof e.RenderPipeline&&(n=this._renderPipelineCache),!n)throw new Error(`${this}`);if(!n[t.hash])throw new Error(`${this}: ${t} matched incorrect entry`);return n}_hashComputePipeline(t){const{type:e}=this.device;return`${e}/C/${this._getHash(t.shader.source)}SL${this._getHash(JSON.stringify(t.shaderLayout))}`}_hashRenderPipeline(t){const e=t.vs?this._getHash(t.vs.source):0,n=t.fs?this._getHash(t.fs.source):0,i=this._getWebGLVaryingHash(t),o=this._getHash(JSON.stringify(t.shaderLayout)),s=this._getHash(JSON.stringify(t.bufferLayout)),{type:r}=this.device;if("webgl"===r){const a=this._getHash(JSON.stringify(t.parameters));return`${r}/R/${e}/${n}V${i}T${t.topology}P${a}SL${o}BL${s}`}{const a=this._getHash(JSON.stringify({vertexEntryPoint:t.vertexEntryPoint,fragmentEntryPoint:t.fragmentEntryPoint})),l=this._getHash(JSON.stringify(t.parameters)),c=this._getWebGPUAttachmentHash(t);return`${r}/R/${e}/${n}V${i}T${t.topology}EP${a}P${l}SL${o}BL${s}A${c}`}}_hashSharedRenderPipeline(t){return`webgl/S/${t.vs?this._getHash(t.vs.source):0}/${t.fs?this._getHash(t.fs.source):0}V${this._getWebGLVaryingHash(t)}`}_getHash(t){return void 0===this._hashes[t]&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}_getWebGLVaryingHash(t){const{varyings:e=[],bufferMode:n=null}=t;return this._getHash(JSON.stringify({varyings:e,bufferMode:n}))}_getWebGPUAttachmentHash(t){const e=t.colorAttachmentFormats??[this.device.preferredColorFormat],n=t.parameters?.depthWriteEnabled?t.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:e,depthStencilAttachmentFormat:n}))}}class g{static defaultProps={...e.Shader.defaultProps};static getDefaultShaderFactory(t){const e=t.getModuleData("@luma.gl/core");return e.defaultShaderFactory||=new g(t),e.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(t){this.device=t}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);const n=this._hashShader(e);let i=this._cache[n];if(i)i.useCount++,this.device.props.debugFactories&&t.log.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{const o=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[n]=i={resource:o,useCount:1},this.device.props.debugFactories&&t.log.log(3,`${this}: Created new shader ${o.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders)return void e.destroy();const n=this._hashShader(e),i=this._cache[n];if(i)if(i.useCount--,0===i.useCount)this.device.props._destroyShaders&&(delete this._cache[n],i.resource.destroy(),this.device.props.debugFactories&&t.log.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&t.log.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(t){return`${t.stage}:${t.source}`}}function m(t,n={}){const i={...t},o=n.layout??"std140",s={};let r=0;for(const[e,a]of Object.entries(i))r=x(s,e,a,r,o);return r=e.alignTo(r,b(i,o)),{layout:o,byteLength:4*r,uniformTypes:i,fields:s}}function v(t,n){const i=e.resolveVariableShaderTypeAlias(t),o=e.getVariableShaderTypeInfo(i),s=/^mat(\d)x(\d)<.+>$/.exec(i);if(s){const t=Number(s[1]),r=Number(s[2]),a=P(r,i,o.type),l=function(t,n,i){return"std140"===i?4:e.alignTo(t,n)}(a.size,a.alignment,n);return{alignment:a.alignment,size:t*l,components:t*r,columns:t,rows:r,columnStride:l,shaderType:i,type:o.type}}const r=/^vec(\d)<.+>$/.exec(i);return r?P(Number(r[1]),i,o.type):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:i,type:o.type}}function y(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function x(t,n,i,o,s){if("string"==typeof i){const r=v(i,s),a=e.alignTo(o,r.alignment);return t[n]={offset:a,...r},a+r.size}if(Array.isArray(i)){if(Array.isArray(i[0]))throw new Error(`Nested arrays are not supported for ${n}`);const r=i[0],a=i[1],l=C(r,s),c=e.alignTo(o,b(i,s));for(let e=0;e<a;e++)x(t,`${n}[${e}]`,r,c+e*l,s);return c+l*a}if(y(i)){const r=b(i,s);let a=e.alignTo(o,r);for(const[e,o]of Object.entries(i))a=x(t,`${n}.${e}`,o,a,s);return e.alignTo(a,r)}throw new Error(`Unsupported CompositeShaderType for ${n}`)}function _(t,n){if("string"==typeof t)return v(t,n).size;if(Array.isArray(t)){const e=t[0],i=t[1];if(Array.isArray(e))throw new Error("Nested arrays are not supported");return C(e,n)*i}let i=0;for(const o of Object.values(t)){const t=o;i=e.alignTo(i,b(t,n)),i+=_(t,n)}return e.alignTo(i,b(t,n))}function b(t,e){if("string"==typeof t)return v(t,e).alignment;if(Array.isArray(t)){const n=b(t[0],e);return L(e)?Math.max(n,4):n}let n=1;for(const i of Object.values(t)){const t=b(i,e);n=Math.max(n,t)}return function(t){return"std140"===t||"wgsl-uniform"===t}(e)?Math.max(n,4):n}function P(t,e,n,i){return{alignment:2===t?2:4,size:3===t?3:t,components:t,columns:1,rows:t,columnStride:3===t?3:t,shaderType:e,type:n}}function C(t,n){return function(t,n,i){return e.alignTo(t,L(i)?4:n)}(_(t,n),b(t,n),n)}function L(t){return"std140"===t||"wgsl-uniform"===t}function w(t){return Array.isArray(t)?0===t.length||"number"==typeof t[0]:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(t)}class S{layout;constructor(t){this.layout=t}has(t){return Boolean(this.layout.fields[t])}get(t){const e=this.layout.fields[t];return e?{offset:e.offset,size:e.size}:void 0}getFlatUniformValues(t){const e={};for(const[n,i]of Object.entries(t)){const t=this.layout.uniformTypes[n];t?this._flattenCompositeValue(e,n,t,i):this.layout.fields[n]&&(e[n]=i)}return e}getData(t){const n=e.getScratchArrayBuffer(this.layout.byteLength);new Uint8Array(n,0,this.layout.byteLength).fill(0);const i={i32:new Int32Array(n),u32:new Uint32Array(n),f32:new Float32Array(n),f16:new Uint16Array(n)},o=this.getFlatUniformValues(t);for(const[e,s]of Object.entries(o))this._writeLeafValue(i,e,s);return new Uint8Array(n,0,this.layout.byteLength)}_flattenCompositeValue(e,n,i,o){if(void 0!==o)if("string"==typeof i||this.layout.fields[n])e[n]=o;else{if(Array.isArray(i)){const s=i[0],r=i[1];if(Array.isArray(s))throw new Error(`Nested arrays are not supported for ${n}`);if("string"==typeof s&&w(o))return void this._flattenPackedArray(e,n,s,r,o);if(!Array.isArray(o))return void t.log.warn(`Unsupported uniform array value for ${n}:`,o)();for(let t=0;t<Math.min(o.length,r);t++){const i=o[t];void 0!==i&&this._flattenCompositeValue(e,`${n}[${t}]`,s,i)}return}if(y(i)&&function(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}(o))for(const[t,s]of Object.entries(o)){if(void 0===s)continue;const o=`${n}.${t}`;this._flattenCompositeValue(e,o,i[t],s)}else t.log.warn(`Unsupported uniform value for ${n}:`,o)()}}_flattenPackedArray(t,e,n,i,o){const s=o,r=v(n,this.layout.layout).components;for(let a=0;a<i;a++){const n=a*r;if(n>=s.length)break;t[`${e}[${a}]`]=1===r?Number(s[n]):A(o,n,n+r)}}_writeLeafValue(e,n,i){const o=this.layout.fields[n];if(!o)return void t.log.warn(`Uniform ${n} not found in layout`)();const{type:s,components:r,columns:a,rows:l,offset:c,columnStride:u}=o,d=e[s];if(1===r)return void(d[c]=Number(i));const f=i;if(1===a){for(let t=0;t<r;t++)d[c+t]=Number(f[t]??0);return}let p=0;for(let t=0;t<a;t++){const e=c+t*u;for(let t=0;t<l;t++)d[e+t]=Number(f[p++]??0)}}}function A(t,e,n){return Array.prototype.slice.call(t,e,n)}class O{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(t){if(this.name=t?.name||"unnamed",t?.name&&t?.shaderLayout){const e=t?.shaderLayout.bindings?.find(e=>"uniform"===e.type&&e.name===t?.name);if(!e)throw new Error(t?.name);const n=e;for(const t of n.uniforms||[])this.bindingLayout[t.name]=t}}setUniforms(t){for(const[e,n]of Object.entries(t))this._setUniform(e,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${e}=${n}`)}setNeedsRedraw(t){this.needsRedraw=this.needsRedraw||t}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(t,e){var n;(function(t,e,n=16){if(t===e)return!0;const i=t,o=e;if(!w(i)||!w(o))return!1;if(i.length!==o.length)return!1;const s=Math.min(n,128);if(i.length>s)return!1;for(let r=0;r<i.length;++r)if(o[r]!==i[r])return!1;return!0})(this.uniforms[t],e)||(this.uniforms[t]=w(n=e)?n.slice():n,this.modifiedUniforms[t]=!0,this.modified=!0)}}class T{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(t,e){this.device=t;for(const[n,i]of Object.entries(e)){const e=n,o=m(i.uniformTypes??{},{layout:i.layout??I(t)}),s=new S(o);this.shaderBlockLayouts.set(e,o),this.shaderBlockWriters.set(e,s);const r=new O({name:n});r.setUniforms(s.getFlatUniformValues(i.defaultUniforms||{})),this.uniformBlocks.set(e,r)}}destroy(){for(const t of this.uniformBuffers.values())t.destroy()}setUniforms(t){for(const[e,n]of Object.entries(t)){const t=e,i=this.shaderBlockWriters.get(t),o=i?.getFlatUniformValues(n||{});this.uniformBlocks.get(t)?.setUniforms(o||{})}this.updateUniformBuffers()}getUniformBufferByteLength(t){const e=this.shaderBlockLayouts.get(t)?.byteLength||0;return Math.max(e,1024)}getUniformBufferData(t){const e=this.uniformBlocks.get(t)?.getAllUniforms()||{},n=this.shaderBlockWriters.get(t);return n?.getData(e)||new Uint8Array(0)}createUniformBuffer(e,n){n&&this.setUniforms(n);const i=this.getUniformBufferByteLength(e),o=this.device.createBuffer({usage:t.Buffer.UNIFORM|t.Buffer.COPY_DST,byteLength:i}),s=this.getUniformBufferData(e);return o.write(s),o}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){const n=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:t.Buffer.UNIFORM|t.Buffer.COPY_DST,byteLength:n});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||=n}return e&&t.log.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){const n=this.uniformBlocks.get(e);let i=this.uniformBuffers.get(e),o=!1;if(i&&n?.needsRedraw){o||=n.needsRedraw;const s=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i?.write(s);const r=this.uniformBlocks.get(e)?.getAllUniforms();t.log.log(4,`Writing to uniform buffer ${String(e)}`,s,r)()}return o}}function I(t){return"webgpu"===t.type?"wgsl-uniform":"std140"}const E="precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct UniformLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nlayout(std140) uniform lightingUniforms {\n int enabled;\n int directionalLightCount;\n int pointLightCount;\n int spotLightCount;\n vec3 ambientColor;\n UniformLight lights[5];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n UniformLight light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nSpotLight lighting_getSpotLight(int index) {\n UniformLight light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n UniformLight light =\n lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfloat getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {\n vec3 light_direction = normalize(positionWorldspace - spotLight.position);\n float coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), light_direction)\n );\n float distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n\n// #endif\n",M={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[{color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},5]},defaultUniforms:B(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:"// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nconst MAX_LIGHTS: i32 = 5;\n\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct UniformLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n directionalLightCount: i32,\n pointLightCount: i32,\n spotLightCount: i32,\n ambientColor: vec3<f32>,\n lights: array<UniformLight, 5>,\n};\n\n@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n let light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nfn lighting_getSpotLight(index: i32) -> SpotLight {\n let light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {\n let lightDirection = normalize(positionWorldspace - spotLight.position);\n let coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), lightDirection)\n );\n let distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n",vs:E,fs:E,getUniforms:function(t,e={}){if(!(t=t?{...t}:t))return B();t.lights&&(t={...t,...R(t.lights),lights:void 0});const{useByteColors:n,ambientLight:i,pointLights:o,spotLights:s,directionalLights:r}=t||{};if(!(i||o&&o.length>0||s&&s.length>0||r&&r.length>0))return{...B(),enabled:0};const a={...B(),...z({useByteColors:n,ambientLight:i,pointLights:o,spotLights:s,directionalLights:r})};void 0!==t.enabled&&(a.enabled=t.enabled?1:0);return a}};function z({useByteColors:e,ambientLight:n,pointLights:i=[],spotLights:o=[],directionalLights:s=[]}){const r=k();let a=0,l=0,c=0,u=0;for(const t of i){if(a>=5)break;r[a]={...r[a],color:F(t,e),position:t.position,attenuation:t.attenuation||[1,0,0]},a++,l++}for(const t of o){if(a>=5)break;r[a]={...r[a],color:F(t,e),position:t.position,direction:t.direction,attenuation:t.attenuation||[1,0,0],coneCos:N(t)},a++,c++}for(const t of s){if(a>=5)break;r[a]={...r[a],color:F(t,e),direction:t.direction},a++,u++}return i.length+o.length+s.length>5&&t.log.warn("MAX_LIGHTS exceeded, truncating to 5")(),{ambientColor:F(n,e),directionalLightCount:u,pointLightCount:l,spotLightCount:c,lights:r}}function R(t){const e={pointLights:[],spotLights:[],directionalLights:[]};for(const n of t||[])switch(n.type){case"ambient":e.ambientLight=n;break;case"directional":e.directionalLights?.push(n);break;case"point":e.pointLights?.push(n);break;case"spot":e.spotLights?.push(n)}return e}function F(t={},e){const{color:n=[0,0,0],intensity:i=1}=t;return a(n,r(e,!0)).map(t=>t*i)}function B(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:k()}}function k(){return Array.from({length:5},()=>({color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}))}function N(t){const e=t.innerConeAngle??0,n=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(n)]}const D="layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n",U="layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (material.unlit) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.spotLightCount; i++) {\n SpotLight spotLight = lighting_getSpotLight(i);\n vec3 light_position_worldspace = spotLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.directionalLightCount; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n",j="struct phongMaterialUniforms {\n unlit: u32,\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (\n lambertian * phongMaterial.diffuse * surfaceColor +\n specular * floatColors_normalize(phongMaterial.specularColor)\n ) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (phongMaterial.unlit != 0u) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n } \n \n return lightColor;\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled != 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n",G={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:U.replace("phongMaterial","gouraudMaterial"),fs:D.replace("phongMaterial","gouraudMaterial"),source:j.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[M,d],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:[38.25,38.25,38.25]},getUniforms:t=>({...G.defaultUniforms,...t})},V={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[M,d],source:j,vs:D,fs:U,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:[38.25,38.25,38.25]},getUniforms:t=>({...V.defaultUniforms,...t})},W={name:"color",dependencies:[],source:"\n\n@must_use\nfn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {\n return vec4(fragColor.rgb * fragColor.a, fragColor.a); \n};\n",getUniforms:t=>({})},$={name:"project32",dependencies:[t.project],source:"// Define a structure to hold both the clip-space position and the common position.\nstruct ProjectResult {\n clipPosition: vec4<f32>,\n commonPosition: vec4<f32>,\n};\n\n// This function mimics the GLSL version with the 'out' parameter by returning both values.\nfn project_position_to_clipspace_and_commonspace(\n position: vec3<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> ProjectResult {\n // Compute the projected position.\n let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low);\n\n // Start with the provided offset.\n var finalOffset: vec3<f32> = offset;\n\n // Get whether a rotation is needed and the rotation matrix.\n let rotationResult = project_needs_rotation(projectedPosition);\n\n // If rotation is needed, update the offset.\n if (rotationResult.needsRotation) {\n finalOffset = rotationResult.transform * offset;\n }\n\n // Compute the common position.\n let commonPosition: vec4<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0);\n\n // Convert to clip-space.\n let clipPosition: vec4<f32> = project_common_position_to_clipspace(commonPosition);\n\n return ProjectResult(clipPosition, commonPosition);\n}\n\n// A convenience overload that returns only the clip-space position.\nfn project_position_to_clipspace(\n position: vec3<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> vec4<f32> {\n return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;\n}\n",vs:"vec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"},H={...f,source:"struct pickingUniforms {\n isActive: f32,\n isAttribute: f32,\n isHighlightActive: f32,\n useByteColors: f32,\n highlightedObjectColor: vec3<f32>,\n highlightColor: vec4<f32>,\n};\n\n@group(0) @binding(auto) var<uniform> picking: pickingUniforms;\n\nfn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {\n return select(color, color / 255.0, picking.useByteColors > 0.5);\n}\n\nfn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {\n return select(color, color / 255.0, picking.useByteColors > 0.5);\n}\n\nfn picking_isColorZero(color: vec3<f32>) -> bool {\n return dot(color, vec3<f32>(1.0)) < 0.00001;\n}\n\nfn picking_isColorValid(color: vec3<f32>) -> bool {\n return dot(color, vec3<f32>(1.0)) > 0.00001;\n}\n",defaultUniforms:{...f.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n ","vs:DECKGL_FILTER_COLOR":"\n picking_setPickingColor(geometry.pickingColor);\n ","fs:DECKGL_FILTER_COLOR":{order:99,injection:"\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n "}}},Y=[0,0,0];function K(e,n,i=!1){const o=n.projectPosition(e);if(i&&n instanceof t.WebMercatorViewport){const[t,i,s=0]=e,r=n.getDistanceScales([t,i]);o[2]=s*r.unitsPerMeter[2]}return o}function q(e,{viewport:n,modelMatrix:i,coordinateSystem:o,coordinateOrigin:s,offsetMode:r}){let[a,l,c=0]=e;switch(i&&([a,l,c]=t.transformMat4([],[a,l,c,1],i)),o){case"default":return q(e,{viewport:n,modelMatrix:i,coordinateSystem:n.isGeospatial?"lnglat":"cartesian",coordinateOrigin:s,offsetMode:r});case"lnglat":return K([a,l,c],n,r);case"lnglat-offsets":return K([a+s[0],l+s[1],c+(s[2]||0)],n,r);case"meter-offsets":return K(t.addMetersToLngLat(s,[a,l,c]),n,r);case"cartesian":return n.isGeospatial?[a+s[0],l+s[1],c+s[2]]:n.projectPosition([a,l,c]);default:throw new Error(`Invalid coordinateSystem: ${o}`)}}const Z={};function X(t="id"){Z[t]=Z[t]||1;return`${t}-${Z[t]++}`}class J{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||X("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&t.Buffer.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(const t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(t){return t.byteLength/12}}function Q(e,n){if(n instanceof J)return n;const i=function(e,n){if(!n.indices)return;const i=n.indices.value;return e.createBuffer({usage:t.Buffer.INDEX,data:i})}(e,n),{attributes:o,bufferLayout:s}=function(e,n){const i=[],o={};for(const[r,a]of Object.entries(n.attributes)){let n=r;switch(r){case"POSITION":n="positions";break;case"NORMAL":n="normals";break;case"TEXCOORD_0":n="texCoords";break;case"TEXCOORD_1":n="texCoords1";break;case"COLOR_0":n="colors"}if(a){o[n]=e.createBuffer({data:a.value,id:`${r}-buffer`});const{value:s,size:l,normalized:c}=a;if(void 0===l)throw new Error(`Attribute ${r} is missing a size`);i.push({name:n,format:t.vertexFormatDecoder.getVertexFormatFromAttribute(s,l,c)})}}const s=n._calculateVertexCount(n.attributes,n.indices);return{attributes:o,bufferLayout:i,vertexCount:s}}(e,n);return new J({topology:n.topology||"triangle-list",bufferLayout:s,vertexCount:n.vertexCount,indices:i,attributes:o})}const tt="__debugFramebufferState";function et(t,e,n){if("webgl"!==t.device.type)return;const i=(o=t.device,o.userData[tt]||={flushing:!1,queuedFramebuffers:[]},o.userData[tt]);var o;i.flushing||(!function(t){const e=t.props.framebuffer;return!e||null===e.handle}(t)?e&&"colorAttachments"in e&&null!==e.handle&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e)):function(t,e,n){if(0===n.queuedFramebuffers.length)return;const i=t.device,{gl:o}=i,s=o.getParameter(36010),r=o.getParameter(36006),[a,l]=t.device.getDefaultCanvasContext().getDrawingBufferSize();let c=it(e.top,8);const u=it(e.left,8);n.flushing=!0;try{for(const t of n.queuedFramebuffers){const[n,i,s,r,d]=nt({framebuffer:t,targetWidth:a,targetHeight:l,topPx:c,leftPx:u,minimap:e.minimap});o.bindFramebuffer(36008,t.handle),o.bindFramebuffer(36009,null),o.blitFramebuffer(0,0,t.width,t.height,n,i,s,r,16384,9728),c+=d+8}}finally{o.bindFramebuffer(36008,s),o.bindFramebuffer(36009,r),n.flushing=!1}}(t,n,i))}function nt(t){const{framebuffer:e,targetWidth:n,targetHeight:i,topPx:o,leftPx:s}=t,r=Math.max(Math.floor(n/4),1),a=Math.max(Math.floor(i/4),1),l=Math.min(r/e.width,a/e.height),c=Math.max(Math.floor(e.width*l),1),u=Math.max(Math.floor(e.height*l),1),d=s,f=Math.max(i-o-u,0);return[d,f,d+c,f+u,u]}function it(t,e){if(!t)return e;const n=Number.parseInt(t,10);return Number.isFinite(n)?n:e}function ot(t,e,n){if(t===e)return!0;if(!n||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!ot(t[i],e[i],n-1))return!1;return!0}if(Array.isArray(e))return!1;if("object"==typeof t&&"object"==typeof e){const i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(const s of i){if(!e.hasOwnProperty(s))return!1;if(!ot(t[s],e[s],n-1))return!1}return!0}return!1}class st{bufferLayouts;constructor(t){this.bufferLayouts=t}getBufferLayout(t){return this.bufferLayouts.find(e=>e.name===t)||null}getAttributeNamesForBuffer(t){return t.attributes?t.attributes?.map(t=>t.attribute):[t.name]}mergeBufferLayouts(t,e){const n=[...t];for(const i of e){const t=n.findIndex(t=>t.name===i.name);t<0?n.push(i):n[t]=i}return n}getBufferIndex(e){const n=this.bufferLayouts.findIndex(t=>t.name===e);return-1===n&&t.log.warn(`BufferLayout: Missing buffer for "${e}".`)(),n}}function rt(t,e){let n=1/0;for(const i of t){const t=e[i];void 0!==t&&(n=Math.min(n,t))}return n}function at(t,e){if(!t||!e.some(t=>t.bindingLayout?.length))return t;const n={...t,bindings:t.bindings.map(t=>({...t}))};"attributes"in(t||{})&&(n.attributes=t?.attributes||[]);for(const i of e)for(const t of i.bindingLayout||[])for(const e of ct(t.name)){const i=n.bindings.find(t=>t.name===e);0===i?.group&&(i.group=t.group)}return n}function lt(t){return Boolean(t.uniformTypes&&!function(t){for(const e in t)return!1;return!0}(t.uniformTypes))}function ct(t){const e=new Set([t,`${t}Uniforms`]);return t.endsWith("Uniforms")||e.add(`${t}Sampler`),[...e]}function ut(t,e={}){const n={bindings:{},uniforms:{}};return Object.keys(t).forEach(o=>{const s=t[o];var r;Object.prototype.hasOwnProperty.call(e,o)||(i(r=s)||"number"==typeof r||"boolean"==typeof r)?n.uniforms[o]=s:n.bindings[o]=s}),n}class dt{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,n){Object.assign(this.options,n);const i=t.getShaderModuleDependencies(Object.values(e).filter(vt));for(const t of i)e[t.name]=t;t.log.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[o,s]of Object.entries(e))s&&(this._addModule(s),s.name&&o!==s.name&&!this.options.disableWarnings&&t.log.warn(`Module name: ${o} vs ${s.name}`)())}destroy(){}setProps(e){for(const n of Object.keys(e)){const i=n,o=e[i]||{},s=this.modules[i];if(s){const t=this.moduleUniforms[i],e=this.moduleBindings[i],n=s.getUniforms?.(o,t)||o,{uniforms:r,bindings:a}=ut(n,s.uniformTypes);this.moduleUniforms[i]=ft(t,r,s.uniformTypes),this.moduleBindings[i]={...e,...a}}else this.options.disableWarnings||t.log.warn(`Module ${n} not found`)()}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const t={};for(const e of Object.values(this.moduleBindings))Object.assign(t,e);return t}getDebugTable(){const t={};for(const[e,n]of Object.entries(this.moduleUniforms))for(const[i,o]of Object.entries(n))t[`${e}.${i}`]={type:this.modules[e].uniformTypes?.[i],value:String(o)};return t}_addModule(t){const e=t.name;this.moduleUniforms[e]=ft({},t.defaultUniforms||{},t.uniformTypes),this.moduleBindings[e]={}}}function ft(t={},e={},n={}){const i={...t};for(const[o,s]of Object.entries(e))void 0!==s&&(i[o]=pt(t[o],s,n[o]));return i}function pt(t,e,n){if(!n||"string"==typeof n)return ht(e);if(Array.isArray(n)){if(gt(e)||!Array.isArray(e))return ht(e);const i=Array.isArray(t)&&!gt(t)?[...t]:[],o=i.slice();for(let t=0;t<e.length;t++){const s=e[t];void 0!==s&&(o[t]=pt(i[t],s,n[0]))}return o}if(!mt(e))return ht(e);const i=n,o=mt(t)?t:{},s={...o};for(const[r,a]of Object.entries(e))void 0!==a&&(s[r]=pt(o[r],a,i[r]));return s}function ht(t){if(ArrayBuffer.isView(t))return Array.prototype.slice.call(t);if(Array.isArray(t)){if(gt(t))return t.slice();return t.map(t=>void 0===t?void 0:ht(t))}return mt(t)?Object.fromEntries(Object.entries(t).map(([t,e])=>[t,void 0===e?void 0:ht(e)])):t}function gt(t){return ArrayBuffer.isView(t)||Array.isArray(t)&&(0===t.length||"number"==typeof t[0])}function mt(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function vt(t){return Boolean(t?.dependencies)}const yt={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function xt(t){return t?Array.isArray(t)?t[0]??null:t:null}function _t(e){if(t.isExternalImage(e))return t.getExternalImageSize(e);if("object"==typeof e&&"width"in e&&"height"in e)return{width:e.width,height:e.height};throw new Error("Unsupported mip-level data")}function bt(t){return"object"==typeof t&&null!==t&&"data"in t&&"width"in t&&"height"in t}function Pt(t){return ArrayBuffer.isView(t)}function Ct(t){const{textureFormat:e,format:n}=t;if(e&&n&&e!==n)throw new Error(`Conflicting texture formats "${e}" and "${n}" provided for the same mip level`);return e??n}function Lt(t){const e=yt[t];if(void 0===e)throw new Error(`Invalid cube face: ${t}`);return e}function wt(t,e){return 6*t+Lt(e)}function St(t){throw new Error("setTexture1DData not supported in WebGL.")}function At(e,n,i,o){const s=(r=n,Array.isArray(r)?r:[r]);var r;const a=e,l=[];for(let c=0;c<s.length;c++){const e=s[c];if(t.isExternalImage(e))l.push({type:"external-image",image:e,z:a,mipLevel:c});else if(bt(e))l.push({type:"texture-data",data:e,textureFormat:Ct(e),z:a,mipLevel:c});else{if(!Pt(e)||!i)throw new Error("Unsupported 2D mip-level payload");l.push({type:"texture-data",data:{data:e,width:Math.max(1,i.width>>c),height:Math.max(1,i.height>>c),...o?{format:o}:{}},textureFormat:o,z:a,mipLevel:c})}}return l}function Ot(t){const e=[];for(let n=0;n<t.length;n++)e.push(...At(n,t[n]));return e}function Tt(t){const e=[];for(let n=0;n<t.length;n++)e.push(...At(n,t[n]));return e}function It(t){const e=[];for(const[n,i]of Object.entries(t)){const t=Lt(n);e.push(...At(t,i))}return e}function Et(t){const e=[];return t.forEach((t,n)=>{for(const[i,o]of Object.entries(t)){const t=wt(n,i);e.push(...At(t,o))}}),e}class Mt{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){const t=this._texture?.width??this.props.width??"?",e=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${t}x${e}px:(${this.isReady?"ready":"loading..."})`}constructor(t,e){this.device=t;const n=X("dynamic-texture"),i=e;this.props={...Mt.defaultProps,id:n,...e,data:null},this.id=this.props.id,this.ready=new Promise((t,e)=>{this.resolveReady=t,this.rejectReady=e}),this.initAsync(i)}async initAsync(e){try{const n=await this._loadAllData(e);this._checkNotDestroyed();const i=n.data?function(t){if(!t.data)return[];const e=t.width&&t.height?{width:t.width,height:t.height}:void 0,n="format"in t?t.format:void 0;switch(t.dimension){case"1d":return St();case"2d":return At(0,t.data,e,n);case"3d":return Ot(t.data);case"2d-array":return Tt(t.data);case"cube":return It(t.data);case"cube-array":return Et(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}({...n,width:e.width,height:e.height,format:e.format}):[],o="format"in e&&void 0!==e.format,s="usage"in e&&void 0!==e.usage,r=()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};const t=function(t){const{dimension:e,data:n}=t;if(!n)return null;switch(e){case"1d":{const t=xt(n);if(!t)return null;const{width:e}=_t(t);return{width:e,height:1}}case"2d":{const t=xt(n);return t?_t(t):null}case"3d":case"2d-array":{if(!Array.isArray(n)||0===n.length)return null;const t=xt(n[0]);return t?_t(t):null}case"cube":{const t=Object.keys(n)[0]??null;if(!t)return null;const e=xt(n[t]);return e?_t(e):null}case"cube-array":{if(!Array.isArray(n)||0===n.length)return null;const t=n[0],e=Object.keys(t)[0]??null;if(!e)return null;const i=xt(t[e]);return i?_t(i):null}default:return null}}(n);return t||{width:this.props.width||1,height:this.props.height||1}},a=r();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);const l=function(t,e,n,i){if(0===e.length)return{subresources:e,mipLevels:1,format:i.format,hasExplicitMipChain:!1};const o=new Map;for(const u of e){const t=o.get(u.z)??[];t.push(u),o.set(u.z,t)}const s=e.some(t=>t.mipLevel>0);let r=i.format,a=Number.POSITIVE_INFINITY;const l=[];for(const[u,d]of o){const e=[...d].sort((t,e)=>t.mipLevel-e.mipLevel),i=e[0];if(!i||0!==i.mipLevel)throw new Error(`DynamicTexture: slice ${u} is missing mip level 0`);const o=Rt(t,i);if(o.width!==n.width||o.height!==n.height)throw new Error(`DynamicTexture: slice ${u} base level dimensions ${o.width}x${o.height} do not match expected ${n.width}x${n.height}`);const s=zt(i);if(s){if(r&&r!==s)throw new Error(`DynamicTexture: slice ${u} base level format "${s}" does not match texture format "${r}"`);r=s}const c=r&&t.isTextureFormatCompressed(r)?Ft(t,o.width,o.height,r):t.getMipLevelCount(o.width,o.height);let f=0;for(let n=0;n<e.length;n++){const i=e[n];if(!i||i.mipLevel!==n)break;if(n>=c)break;const s=Rt(t,i),a=Math.max(1,o.width>>n),u=Math.max(1,o.height>>n);if(s.width!==a||s.height!==u)break;const d=zt(i);if(d&&(r||(r=d),d!==r))break;f++,l.push(i)}a=Math.min(a,f)}const c=Number.isFinite(a)?Math.max(1,a):1;return{subresources:l.filter(t=>t.mipLevel<c),mipLevels:c,format:r,hasExplicitMipChain:s}}(this.device,i,a,{format:o?e.format:void 0}),c=l.format??this.props.format,u={...this.props,...a,format:c,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(c)&&!s&&(u.usage=t.Texture.SAMPLE|t.Texture.COPY_DST);const d=this.props.mipmaps&&!l.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(c);if("webgpu"===this.device.type&&d){const e="3d"===this.props.dimension?t.Texture.SAMPLE|t.Texture.STORAGE|t.Texture.COPY_DST|t.Texture.COPY_SRC:t.Texture.SAMPLE|t.Texture.RENDER|t.Texture.COPY_DST|t.Texture.COPY_SRC;u.usage|=e}const f=this.device.getMipLevelCount(u.width,u.height),p=l.hasExplicitMipChain?l.mipLevels:"auto"===this.props.mipLevels?f:Math.max(1,Math.min(f,this.props.mipLevels??1)),h={...u,mipLevels:p};this._texture=this.device.createTexture(h),this._sampler=this.texture.sampler,this._view=this.texture.view,l.subresources.length&&this._setTextureSubresources(l.subresources),!this.props.mipmaps||l.hasExplicitMipChain||d||t.log.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),d&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),t.log.info(0,`${this} created`)()}catch(n){const t=n instanceof Error?n:new Error(String(n));this.rejectReady(t)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){"webgl"===this.device.type?this.texture.generateMipmapsWebGL():"webgpu"===this.device.type?this.device.generateMipmapsWebGPU(this.texture):t.log.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();const n=e instanceof t.Sampler?e:this.device.createSampler(e);this.texture.setSampler(n),this._sampler=n}async readBuffer(e={}){this.isReady||await this.ready;const n=e.width??this.texture.width,i=e.height??this.texture.height,o=e.depthOrArrayLayers??this.texture.depth,s=this.texture.computeMemoryLayout({width:n,height:i,depthOrArrayLayers:o}),r=this.device.createBuffer({byteLength:s.byteLength,usage:t.Buffer.COPY_DST|t.Buffer.MAP_READ});this.texture.readBuffer({...e,width:n,height:i,depthOrArrayLayers:o},r);const a=this.device.createFence();return await a.signaled,a.destroy(),r}async readAsync(t={}){this.isReady||await this.ready;const e=t.width??this.texture.width,n=t.height??this.texture.height,i=t.depthOrArrayLayers??this.texture.depth,o=this.texture.computeMemoryLayout({width:e,height:n,depthOrArrayLayers:i}),s=await this.readBuffer(t),r=await s.readAsync(0,o.byteLength);return s.destroy(),r.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;const n=this.texture;return this._texture=n.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,n.destroy(),t.log.info(`${this} resized`),!0}getCubeFaceIndex(t){const e=yt[t];if(void 0===e)throw new Error(`Invalid cube face: ${t}`);return e}getCubeArrayFaceIndex(t,e){return 6*t+this.getCubeFaceIndex(e)}setTexture1DData(t){if(this._checkReady(),"1d"!==this.texture.props.dimension)throw new Error(`${this} is not 1d`);const e=St();this._setTextureSubresources(e)}setTexture2DData(t,e=0){if(this._checkReady(),"2d"!==this.texture.props.dimension)throw new Error(`${this} is not 2d`);const n=At(e,t);this._setTextureSubresources(n)}setTexture3DData(t){if("3d"!==this.texture.props.dimension)throw new Error(`${this} is not 3d`);const e=Ot(t);this._setTextureSubresources(e)}setTextureArrayData(t){if("2d-array"!==this.texture.props.dimension)throw new Error(`${this} is not 2d-array`);const e=Tt(t);this._setTextureSubresources(e)}setTextureCubeData(t){if("cube"!==this.texture.props.dimension)throw new Error(`${this} is not cube`);const e=It(t);this._setTextureSubresources(e)}setTextureCubeArrayData(t){if("cube-array"!==this.texture.props.dimension)throw new Error(`${this} is not cube-array`);const e=Et(t);this._setTextureSubresources(e)}_setTextureSubresources(t){for(const e of t){const{z:t,mipLevel:n}=e;switch(e.type){case"external-image":const{image:i,flipY:o}=e;this.texture.copyExternalImage({image:i,z:t,mipLevel:n,flipY:o});break;case"texture-data":const{data:s,textureFormat:r}=e;if(r&&r!==this.texture.format)throw new Error(`${this} mip level ${n} uses format "${r}" but texture format is "${this.texture.format}"`);this.texture.writeData(s.data,{x:0,y:0,z:t,width:s.width,height:s.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(t){const e=await Bt(t.data);return{dimension:t.dimension??"2d",data:e??null}}_checkNotDestroyed(){this.destroyed&&t.log.warn(`${this} already destroyed`)}_checkReady(){this.isReady||t.log.warn(`${this} Cannot perform this operation before ready`)}static defaultProps={...t.Texture.defaultProps,dimension:"2d",data:null,mipmaps:!1}}function zt(t){if("texture-data"===t.type)return t.textureFormat??Ct(t.data)}function Rt(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function Ft(t,e,n,i){const{blockWidth:o=1,blockHeight:s=1}=t.getTextureFormatInfo(i);let r=1;for(let a=1;;a++){const t=Math.max(1,e>>a),i=Math.max(1,n>>a);if(t<o||i<s)break;r++}return r}async function Bt(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(Bt));if(t&&"object"==typeof t&&t.constructor===Object){const e=t,n=await Promise.all(Object.values(e).map(Bt)),i=Object.keys(e),o={};for(let t=0;t<i.length;t++)o[i[t]]=n[t];return o}return t}const kt="render pipeline initialization failed";class Nt{static defaultProps={...e.RenderPipeline.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:t.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(t,e){this.props={...Nt.defaultProps,...e},e=this.props,this.id=e.id||X("model"),this.device=t,Object.assign(this.userData,e.userData),this.material=e.material||null;const n=Object.fromEntries(this.props.modules?.map(t=>[t.name,t])||[]),i=e.shaderInputs||new dt(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(i);const o=function(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}(t),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];this.props.shaderLayout=at(this.props.shaderLayout,s)||null;if("webgpu"===this.device.type&&this.props.source){const{source:e,getUniforms:n,bindingTable:i}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:o,...this.props,modules:s});this.source=e,this._getModuleUniforms=n,this._bindingTable=i;const r=t.getShaderLayout?.(this.source);this.props.shaderLayout=at(this.props.shaderLayout||r||null,s)||null}else{const{vs:t,fs:e,getUniforms:n}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:o,...this.props,modules:s});this.vs=t,this.fs=e,this._getModuleUniforms=n,this._bindingTable=[]}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,e.geometry&&this.setGeometry(e.geometry),this.pipelineFactory=e.pipelineFactory||h.getDefaultPipelineFactory(this.device),this.shaderFactory=e.shaderFactory||g.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in e&&(this.isInstanced=e.isInstanced),e.instanceCount&&this.setInstanceCount(e.instanceCount),e.vertexCount&&this.setVertexCount(e.vertexCount),e.indexBuffer&&this.setIndexBuffer(e.indexBuffer),e.attributes&&this.setAttributes(e.attributes),e.constantAttributes&&this.setConstantAttributes(e.constantAttributes),e.bindings&&this.setBindings(e.bindings),e.transformFeedback&&(this.transformFeedback=e.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const t=this._needsRedraw;return this._needsRedraw=!1,t}setNeedsRedraw(t){this._needsRedraw||=t}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const n=this._areBindingsLoading();if(n)return t.log.info(2,`>>> DRAWING ABORTED ${this.id}: ${n} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i,o=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),o=this.pipeline.isErrored,o)t.log.info(2,`>>> DRAWING ABORTED ${this.id}: ${kt}`)(),i=!1;else{const t=this._getBindings(),n=this._getBindGroups(),{indexBuffer:o}=this.vertexArray,s=o?o.byteLength/("uint32"===o.indexType?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:s,transformFeedback:this.transformFeedback||void 0,bindings:t,bindGroups:n,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw=o?kt:"waiting for resource initialization",i}setGeometry(t){this._gpuGeometry?.destroy();const e=t&&Q(this.device,t);if(e){this.setTopology(e.topology||"triangle-list");const t=new st(this.bufferLayout);this.bufferLayout=t.mergeBufferLayouts(e.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(e)}this._gpuGeometry=e}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){const e=new st(this.bufferLayout);this.bufferLayout=this._gpuGeometry?e.mergeBufferLayouts(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){ot(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(t){this.instanceCount=t,void 0===this.isInstanced&&t>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(t){this.vertexCount=t,this.setNeedsRedraw("vertexCount")}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new T(this.device,this.shaderInputs.modules);for(const[e,n]of Object.entries(this.shaderInputs.modules))if(lt(n)&&!this.material?.ownsModule(e)){const t=this._uniformStore.getManagedUniformBuffer(e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw("shaderInputs")}setMaterial(t){this.material=t,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(t){Object.assign(this.bindings,t),this.setNeedsRedraw("bindings")}setTransformFeedback(t){this.transformFeedback=t,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(e,n){const i=n?.disableWarnings??this.props.disableWarnings;e.indices&&t.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=function(t,e){const n=Object.fromEntries(t.attributes.map(t=>[t.name,t.location])),i=e.slice();return i.sort((t,e)=>{const i=t.attributes?t.attributes.map(t=>t.attribute):[t.name],o=e.attributes?e.attributes.map(t=>t.attribute):[e.name];return rt(i,n)-rt(o,n)}),i}(this.pipeline.shaderLayout,this.bufferLayout);const o=new st(this.bufferLayout);for(const[s,r]of Object.entries(e)){const e=o.getBufferLayout(s);if(!e){i||t.log.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}const n=o.getAttributeNamesForBuffer(e);let a=!1;for(const t of n){const e=this._attributeInfos[t];if(e){const t="webgpu"===this.device.type?o.getBufferIndex(e.bufferName):e.location;this.vertexArray.setBuffer(t,r),a=!0}}a||i||t.log.warn(`Model(${this.id}): Ignoring buffer "${r.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,n){for(const[i,o]of Object.entries(e)){const e=this._attributeInfos[i];e?this.vertexArray.setConstantWebGL(e.location,o):(n?.disableWarnings??this.props.disableWarnings)||t.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const t of Object.values(this.bindings))if(t instanceof Mt&&!t.isReady)return t.id;for(const t of Object.values(this.material?.bindings||{}))if(t instanceof Mt&&!t.isReady)return t.id;return!1}_getBindings(){const t={};for(const[e,n]of Object.entries(this.bindings))n instanceof Mt?n.isReady&&(t[e]=n.texture):t[e]=n;return t}_getBindGroups(){const t=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},n=t.bindings.length?e.normalizeBindingsByGroup(t,this._getBindings()):{0:this._getBindings()};if(!this.material)return n;for(const[e,i]of Object.entries(this.material.getBindingsByGroup())){const t=Number(e);n[t]={...n[t]||{},...i}}return n}_getBindGroupCacheKeys(){const t=this.material?.getBindGroupCacheKey(3);return t?{3:t}:{}}_getBindingsUpdateTimestamp(){let n=0;for(const i of Object.values(this.bindings))i instanceof e.TextureView?n=Math.max(n,i.texture.updateTimestamp):i instanceof t.Buffer||i instanceof t.Texture?n=Math.max(n,i.updateTimestamp):i instanceof Mt?n=i.texture?Math.max(n,i.texture.updateTimestamp):1/0:i instanceof t.Sampler||(n=Math.max(n,i.buffer.updateTimestamp));return Math.max(n,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(t){const e={...t.attributes};for(const[n]of Object.entries(e))this.pipeline.shaderLayout.attributes.find(t=>t.name===n)||"positions"===n||delete e[n];this.vertexCount=t.vertexCount,this.setIndexBuffer(t.indices||null),this.setAttributes(t.attributes,{disableWarnings:!0}),this.setAttributes(e,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate||=t,this.setNeedsRedraw(t)}_updatePipeline(){if(this._pipelineNeedsUpdate){let n=null,i=null;this.pipeline&&(t.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),n=this.pipeline.vs,i=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const o=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let s=null;this.source?s=o:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:o,fs:s}),this._attributeInfos=e.getAttributeInfosFromLayouts(this.pipeline.shaderLayout,this.bufferLayout),n&&this.shaderFactory.release(n),i&&i!==n&&this.shaderFactory.release(i)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=t.log.level>3?0:1e4;t.log.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,t.log.group(2,`>>> DRAWING MODEL ${this.id}`,{collapsed:t.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(t){const e={},n="Values";if(0===t.attributes.length&&!t.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(const i of t.attributes)i&&(e[`in ${i.location} ${i.name}: ${i.type}`]={[n]:i.stepMode||"vertex"});for(const i of t.varyings||[])e[`out ${i.location} ${i.name}`]={[n]:JSON.stringify(i)};return e}(this.pipeline.shaderLayout,this.id);t.log.table(2,e)();const n=this.shaderInputs.getDebugTable();t.log.table(2,n)();const i=this._getAttributeDebugTable();t.log.table(2,this._attributeInfos)(),t.log.table(2,i)(),t.log.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(t){const e=this.device.props.debugFramebuffers;if(this._drawCount++,!e)return;const n=t.props.framebuffer;et(t,n,{id:n?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){const t={};for(const[e,n]of Object.entries(this._attributeInfos)){const i=this.vertexArray.attributes[n.location];t[n.location]={name:e,type:n.shaderType,values:i?this._getBufferOrConstantValues(i,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:e}=this.vertexArray,n="uint32"===e.indexType?new Uint32Array(e.debugData):new Uint16Array(e.debugData);t.indices={name:"indices",type:e.indexType,values:n.toString()}}return t}_getBufferOrConstantValues(e,n){const i=t.dataTypeDecoder.getTypedArrayConstructor(n);return(e instanceof t.Buffer?new i(e.debugData):e).toString()}_getNonMaterialBindings(t){if(!this.material)return t;const e={};for(const[n,i]of Object.entries(t))this.material.ownsBinding(n)||(e[n]=i);return e}}class Dt{device;model;transformFeedback;static defaultProps={...Nt.defaultProps,outputs:void 0,feedbackBuffers:void 0};static isSupported(t){return"webgl"===t?.info?.type}constructor(t,e=Dt.defaultProps){if(!Dt.isSupported(t))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=t,this.model=new Nt(this.device,{id:e.id||"buffer-transform-model",fs:e.fs||o(),topology:e.topology||"point-list",varyings:e.outputs||e.varyings,...e}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:e.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(t){t?.inputBuffers&&this.model.setAttributes(t.inputBuffers),t?.outputBuffers&&this.transformFeedback.setBuffers(t.outputBuffers);const e=this.device.beginRenderPass(t);this.model.draw(e),e.end()}getBuffer(t){return this.transformFeedback.getBuffer(t)}readAsync(e){const n=this.getBuffer(e);if(!n)throw new Error("BufferTransform#getBuffer");if(n instanceof t.Buffer)return n.readAsync();const{buffer:i,byteOffset:o=0,byteLength:s=i.byteLength}=n;return i.readAsync(o,s)}}class Ut{id;topology;vertexCount;indices;attributes;userData={};constructor(t){const{attributes:e={},indices:n=null,vertexCount:i=null}=t;this.id=t.id||X("geometry"),this.topology=t.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(const[o,s]of Object.entries(e)){const t=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(t.value))throw new Error(`${this._print(o)}: must be typed array or object with value as typed array`);if("POSITION"!==o&&"positions"!==o||t.size||(t.size=3),"indices"===o){if(this.indices)throw new Error("Multiple indices detected");this.indices=t}else this.attributes[o]=t}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||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,e){return this}_calculateVertexCount(t,e){if(e)return e.value.length;let n=1/0;for(const i of Object.values(t)){const{value:t,size:e,constant:o}=i;!o&&t&&void 0!==e&&e>=1&&(n=Math.min(n,t.length/e))}return n}}const jt=t.dataTypeDecoder.getDataType.bind(t.dataTypeDecoder);function Gt(t,e,n){if(e.size>4)return null;const i="webgpu"===n&&"uint8"===e.type?"unorm8":e.type;return{attribute:t,format:e.size>1?`${i}x${e.size}`:e.type,byteOffset:e.offset||0}}function Vt(t){return t.stride||t.size*t.bytesPerElement}function Wt(e,n){n.offset&&t.defaultLogger.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const i=Vt(e),o=(void 0!==n.vertexOffset?n.vertexOffset:e.vertexOffset||0)*i+(n.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...n,offset:o,stride:i}}class $t{constructor(t,n,i){this._buffer=null,this.device=t,this.id=n.id||"",this.size=n.size||1;const o=n.logicalType||n.type,s="float64"===o;let r,{defaultValue:a}=n;a=Number.isFinite(a)?[a]:a||new Array(this.size).fill(0),r=s?"float32":!o&&n.isIndexed?"uint32":o||"float32";let l=function(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return e.getTypedArrayConstructor(t)}}(o||r);this.doublePrecision=s,s&&!1===n.fp64&&(l=Float32Array),this.value=null,this.settings={...n,defaultType:l,defaultValue:a,logicalType:o,type:r,normalized:r.includes("norm"),size:this.size,bytesPerElement:l.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){const t=this.getAccessor();return t.vertexOffset?t.vertexOffset*Vt(t):0}get numInstances(){return this.state.numInstances}set numInstances(t){this.state.numInstances=t}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),t.defaultTypedArrayManager.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(t=this.id,e=null){const n={};if(this.state.constant){const i=this.value;if(e){const o=Wt(this.getAccessor(),e),s=o.offset/i.BYTES_PER_ELEMENT,r=o.size||this.size;n[t]=i.subarray(s,s+r)}else n[t]=i}else n[t]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${t}64Low`]=n[t]:n[`${t}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(t=this.id,e=null){const n=this.getAccessor(),i=[],o={name:this.id,byteStride:Vt(n)};if(this.doublePrecision){const o=function(t,e){const n=Wt(t,e);return{high:n,low:{...n,offset:n.offset+4*t.size}}}(n,e||{});i.push(Gt(t,{...n,...o.high},this.device.type),Gt(`${t}64Low`,{...n,...o.low},this.device.type))}else if(e){const o=Wt(n,e);i.push(Gt(t,{...n,...o},this.device.type))}else i.push(Gt(t,n,this.device.type));return o.attributes=i.filter(Boolean),o}setAccessor(t){this.state.bufferAccessor=t}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let t=null;if(this.state.constant&&this.value){const e=Array.from(this.value);t=[e,e]}else{const{value:e,numInstances:n,size:i}=this,o=n*i;if(e&&o&&e.length>=o){const n=new Array(i).fill(1/0),s=new Array(i).fill(-1/0);for(let t=0;t<o;)for(let o=0;o<i;o++){const i=e[t++];i<n[o]&&(n[o]=i),i>s[o]&&(s[o]=i)}t=[n,s]}}return this.state.bounds=t,t}setData(e){const{state:n}=this;let i;i=ArrayBuffer.isView(e)?{value:e}:e instanceof t.Buffer?{buffer:e}:e;const o={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type){if(this.doublePrecision&&i.value instanceof Float64Array)o.type="float32";else{const t=jt(i.value);o.type=o.normalized?t.replace("int","norm"):t}}o.bytesPerElement=i.value.BYTES_PER_ELEMENT,o.stride=Vt(o)}if(n.bounds=null,i.constant){let t=i.value;t=this._normalizeValue(t,[],0),this.settings.normalized&&(t=this.normalizeConstant(t));if(!(!n.constant||!this._areValuesEqual(t,this.value)))return!1;n.externalBuffer=null,n.constant=!0,this.value=ArrayBuffer.isView(t)?t:new Float32Array(t)}else if(i.buffer){const t=i.buffer;n.externalBuffer=t,n.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let e=i.value;n.externalBuffer=null,n.constant=!1,this.value=e;let{buffer:s}=this;const r=Vt(o),a=(o.vertexOffset||0)*r;if(this.doublePrecision&&e instanceof Float64Array&&(e=t.toDoublePrecisionArray(e,o)),this.settings.isIndexed){const t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}const l=e.byteLength+a+2*r;(!s||s.byteLength<l)&&(s=this._createBuffer(l)),s.write(e,a)}return this.setAccessor(o),!0}updateSubBuffer(e={}){this.state.bounds=null;const n=this.value,{startOffset:i=0,endOffset:o}=e;this.buffer.write(this.doublePrecision&&n instanceof Float64Array?t.toDoublePrecisionArray(n,{size:this.size,startIndex:i,endIndex:o}):n.subarray(i,o),i*n.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,n=!1){const{state:i}=this,o=i.allocatedValue,s=t.defaultTypedArrayManager.allocate(o,e+1,{size:this.size,type:this.settings.defaultType,copy:n});this.value=s;const{byteOffset:r}=this;let{buffer:a}=this;return(!a||a.byteLength<s.byteLength+r)&&(a=this._createBuffer(s.byteLength+r),n&&o&&a.write(o instanceof Float64Array?t.toDoublePrecisionArray(o,this):o,r)),i.allocatedValue=s,i.constant=!1,i.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){const{value:n}=e;if(!ArrayBuffer.isView(n))throw new Error(`Attribute ${this.id} value is not TypedArray`);const i=this.settings.defaultType;let o=!1;if(this.doublePrecision&&(o=n.BYTES_PER_ELEMENT<4),o)throw new Error(`Attribute ${this.id} does not support ${n.constructor.name}`);n instanceof i||!this.settings.normalized||"normalized"in e||t.defaultLogger.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(t){switch(this.settings.type){case"snorm8":return new Float32Array(t).map(t=>(t+128)/255*2-1);case"snorm16":return new Float32Array(t).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(t).map(t=>t/255);case"unorm16":return new Float32Array(t).map(t=>t/65535);default:return t}}_normalizeValue(t,e,n){const{defaultValue:i,size:o}=this.settings;if(Number.isFinite(t))return e[n]=t,e;if(!t){let t=o;for(;--t>=0;)e[n+t]=i[t];return e}switch(o){case 4:e[n+3]=Number.isFinite(t[3])?t[3]:i[3];case 3:e[n+2]=Number.isFinite(t[2])?t[2]:i[2];case 2:e[n+1]=Number.isFinite(t[1])?t[1]:i[1];case 1:e[n+0]=Number.isFinite(t[0])?t[0]:i[0];break;default:let s=o;for(;--s>=0;)e[n+s]=Number.isFinite(t[s])?t[s]:i[s]}return e}_areValuesEqual(t,e){if(!t||!e)return!1;const{size:n}=this;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();const{isIndexed:n,type:i}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(n?t.Buffer.INDEX:t.Buffer.VERTEX)|t.Buffer.COPY_DST,indexType:n?i:void 0,byteLength:e}),this._buffer}}const Ht=[],Yt=[];function Kt(t,e=0,n=1/0){let i=Ht;const o={index:-1,data:t,target:[]};return t?"function"==typeof t[Symbol.iterator]?i=t:t.length>0&&(Yt.length=t.length,i=Yt):i=Ht,(e>0||Number.isFinite(n))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,n),o.index=e-1),{iterable:i,objectInfo:o}}function qt(t){return t&&t[Symbol.asyncIterator]}function Zt(t,e){const{size:n,stride:i,offset:o,startIndices:s,nested:r}=e,a=t.BYTES_PER_ELEMENT,l=i?i/a:n,c=o?o/a:0,u=Math.floor((t.length-c)/l);return(e,{index:i,target:o})=>{if(!s){const e=i*l+c;for(let i=0;i<n;i++)o[i]=t[e+i];return o}const a=s[i],d=s[i+1]||u;let f;if(r){f=new Array(d-a);for(let e=a;e<d;e++){const i=e*l+c;o=new Array(n);for(let e=0;e<n;e++)o[e]=t[i+e];f[e-a]=o}}else if(l===n)f=t.subarray(a*n+c,d*n+c);else{f=new t.constructor((d-a)*n);let e=0;for(let i=a;i<d;i++){const o=i*l+c;for(let i=0;i<n;i++)f[e++]=t[o+i]}}return f}}const Xt=[],Jt=[[0,1/0]];const Qt={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function te(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});const n=t.type||"interpolation";return{...Qt[n],...e,...t,type:n}}class ee extends $t{constructor(t,e){super(t,e,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Jt}),this.constant=!1,this.settings.update=e.update||(e.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(t){this.state.startIndices=t}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:t=!1}={}){const e=this.state.needsRedraw;return this.state.needsRedraw=e&&!t,e}layoutChanged(){return this.state.layoutChanged}setAccessor(t){var e,n,i;(e=this.state).layoutChanged||(e.layoutChanged=(n=t,i=this.getAccessor(),!(n.type===i.type&&n.size===i.size&&Vt(n)===Vt(i)&&(n.offset||0)===(i.offset||0)))),super.setAccessor(t)}getUpdateTriggers(){const{accessor:t}=this.settings;return[this.id].concat("function"!=typeof t&&t||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(t){if(!t||!this.supportsTransition())return null;const{accessor:e}=this.settings,n=this.settings.transition;return te(Array.isArray(e)?t[e.find(e=>t[e])]:t[e],n)}setNeedsUpdate(t=this.id,e){if(this.state.needsUpdate=this.state.needsUpdate||t,this.setNeedsRedraw(t),e){const{startRow:t=0,endRow:n=1/0}=e;this.state.updateRanges=function(t,e){if(t===Jt)return t;if(e[0]<0&&(e[0]=0),e[0]>=e[1])return t;const n=[],i=t.length;let o=0;for(let s=0;s<i;s++){const i=t[s];i[1]<e[0]?(n.push(i),o=s+1):i[0]>e[1]?n.push(i):e=[Math.min(i[0],e[0]),Math.max(i[1],e[1])]}return n.splice(o,0,e),n}(this.state.updateRanges,[t,n])}else this.state.updateRanges=Jt}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=Xt}setNeedsRedraw(t=this.id){this.state.needsRedraw=this.state.needsRedraw||t}allocate(t){const{state:e,settings:n}=this;return!n.noAlloc&&(!!n.update&&(super.allocate(t,e.updateRanges!==Jt),!0))}updateBuffer({numInstances:t,data:e,props:n,context:i}){if(!this.needsUpdate())return!1;const{state:{updateRanges:o},settings:{update:s,noAlloc:r}}=this;let a=!0;if(s){for(const[r,a]of o)s.call(i,this,{data:e,startRow:r,endRow:a,props:n,numInstances:t});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(i,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(const[e,n]of o){const i=Number.isFinite(e)?this.getVertexOffset(e):0,o=Number.isFinite(n)?this.getVertexOffset(n):r||!Number.isFinite(t)?this.value.length:t*this.size;super.updateSubBuffer({startOffset:i,endOffset:o})}else;this._checkAttributeArray()}else a=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),a}setConstantValue(t,e){if(void 0===e||"function"==typeof e)return!1;const n=this.settings.transform&&t?this.settings.transform.call(t,e):e;if("webgpu"===this.device.type)return this.setConstantBufferValue(n,this.numInstances);return this.setData({constant:!0,value:n})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setConstantBufferValue(t,e){const n=this.settings.defaultType,i=this._normalizeValue(t,new n(this.size),0);if(this._hasConstantBufferValue(i,e))return this.constant=!1,this.clearNeedsUpdate(),!1;const o=new n(Math.max(e,1)*this.size);for(let r=0;r<o.length;r+=this.size)o.set(i,r);const s=this.setData({value:o});return this.constant=!1,this.clearNeedsUpdate(),s&&this.setNeedsRedraw(),s}_hasConstantBufferValue(t,e){const n=this.value,i=Math.max(e,1)*this.size;if(!ArrayBuffer.isView(n)||n.length!==i||n.length%this.size!==0)return!1;for(let o=0;o<n.length;o+=this.size)for(let e=0;e<this.size;e++)if(n[o+e]!==t[e])return!1;return!0}setExternalBuffer(t){const{state:e}=this;return t?(this.clearNeedsUpdate(),e.lastExternalBuffer===t||(e.lastExternalBuffer=t,this.setNeedsRedraw(),this.setData(t)),!0):(e.lastExternalBuffer=null,!1)}setBinaryValue(e,n=null){const{state:i,settings:o}=this;if(!e)return i.binaryValue=null,i.binaryAccessor=null,!1;if(o.noAlloc)return!1;if(i.binaryValue===e)return this.clearNeedsUpdate(),!0;i.binaryValue=e,this.setNeedsRedraw();if(o.transform||n!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});const s=e;t.assert$1(ArrayBuffer.isView(s.value),`invalid ${o.accessor}`);const r=Boolean(s.size)&&s.size!==this.size;return i.binaryAccessor=Zt(s.value,{size:s.size||this.size,stride:s.stride,offset:s.offset,startIndices:n,nested:r}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(t){const{startIndices:e}=this;return(e?t<e.length?e[t]:this.numInstances:t)*this.size}getValue(){const t=this.settings.shaderAttributes,e=super.getValue();if(!t)return e;for(const n in t)Object.assign(e,super.getValue(n,t[n]));return e}getBufferLayout(t){this.state.layoutChanged=!1;const e=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:i}=this.settings;if(n.stepMode="dynamic"===i?t?t.isInstanced?"instance":"vertex":"instance":i??"vertex",!e)return n;for(const o in e){const t=super._getBufferLayout(o,e[o]);n.attributes.push(...t.attributes)}return n}_autoUpdater(e,{data:n,startRow:i,endRow:o,props:s,numInstances:r}){const{settings:a,state:l,value:c,size:u,startIndices:d}=e,{accessor:f,transform:p}=a,h=l.binaryAccessor||("function"==typeof f?f:s[f]);t.assert$1("function"==typeof h,`accessor "${f}" is not a function`);let g=e.getVertexOffset(i);const{iterable:m,objectInfo:v}=Kt(n,i,o);for(const y of m){v.index++;let n=h(y,v);if(p&&(n=p.call(this,n)),d){const i=(v.index<d.length-1?d[v.index+1]:r)-d[v.index];if(n&&Array.isArray(n[0])){let t=g;for(const i of n)e._normalizeValue(i,c,t),t+=u}else n&&n.length>u?c.set(n,g):(e._normalizeValue(n,v.target,0),t.fillArray({target:c,source:v.target,start:g,count:i}));g+=i*u}else e._normalizeValue(n,c,g),g+=u}}_validateAttributeUpdaters(){const{settings:t}=this;if(!(t.noAlloc||"function"==typeof t.update))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:t}=this,e=Math.min(4,this.size);if(t&&t.length>=e){let n=!0;switch(e){case 4:n=n&&Number.isFinite(t[3]);case 3:n=n&&Number.isFinite(t[2]);case 2:n=n&&Number.isFinite(t[1]);case 1:n=n&&Number.isFinite(t[0]);break;default:n=!1}if(!n)throw new Error(`Illegal attribute generated for ${this.id}`)}}}function ne(t){const{source:e,target:n,start:i=0,size:o,getData:s}=t,r=t.end||n.length,a=e.length,l=r-i;if(a>l)return void n.set(e.subarray(0,l),i);if(n.set(e,i),!s)return;let c=a;for(;c<l;){const t=s(c,e);for(let e=0;e<o;e++)n[i+c]=t[e]||0,c++}}function ie(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${t}"`)}}function oe(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function se(t){t.push(t.shift())}function re({device:t,source:e,target:n}){return(!n||n.byteLength<e.byteLength)&&(n?.destroy(),n=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),n}function ae({device:t,buffer:e,attribute:n,fromLength:i,toLength:o,fromStartIndices:s,getData:r=t=>t}){const a=n.doublePrecision&&n.value instanceof Float64Array?2:1,l=n.size*a,c=n.byteOffset,u=n.settings.bytesPerElement<4?c/n.settings.bytesPerElement*4:c,d=n.startIndices,f=s&&d,p=n.isConstant;if(!f&&e&&i>=o)return e;const h=n.value instanceof Float64Array?Float32Array:n.value.constructor,g=p?n.value:new h(n.getBuffer().readSyncWebGL(c,o*h.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!p){const t=r;r=(e,i)=>n.normalizeConstant(t(e,i))}const m=p?(t,e)=>r(g,e):(t,e)=>r(g.subarray(t+c,t+c+l),e),v=e?new Float32Array(e.readSyncWebGL(u,4*i).buffer):new Float32Array(0),y=new Float32Array(o);return function({source:t,target:e,size:n,getData:i,sourceStartIndices:o,targetStartIndices:s}){if(!o||!s)return ne({source:t,target:e,size:n,getData:i}),e;let r=0,a=0;const l=i&&((t,e)=>i(t+a,e)),c=Math.min(o.length,s.length);for(let u=1;u<c;u++){const i=o[u]*n,c=s[u]*n;ne({source:t.subarray(r,i),target:e,start:a,end:c,size:n,getData:l}),r=i,a=c}a<e.length&&ne({source:[],target:e,start:a,size:n,getData:l})}({source:v,target:y,sourceStartIndices:s,targetStartIndices:d,size:l,getData:m}),(!e||e.byteLength<y.byteLength+u)&&(e?.destroy(),e=t.createBuffer({byteLength:y.byteLength+u,usage:35050})),e.write(y,u),e}class le{constructor({device:e,attribute:n,timeline:i}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new t.Transition(i),this.attribute=n,this.attributeInTransition=function(t){const{device:e,settings:n,value:i}=t,o=new ee(e,n);return o.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:n.normalized}),o}(n),this.currentStartIndices=n.startIndices}get inProgress(){return this.transition.inProgress}start(t,e,n=1/0){this.settings=t,this.currentStartIndices=this.attribute.startIndices,this.currentLength=function(t,e){const{doublePrecision:n,settings:i,value:o,size:s}=t,r=n&&o instanceof Float64Array?2:1;let a=0;const{shaderAttributes:l}=t.settings;if(l)for(const c of Object.values(l))a=Math.max(a,c.vertexOffset??0);return(i.noAlloc?o.length:(e+a)*s)*r}(this.attribute,e),this.transition.start({...t,duration:n})}update(){const t=this.transition.update();return t&&this.onUpdate(),t}setBuffer(t){this.attributeInTransition.setData({buffer:t,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(const t of this.buffers)t.destroy();this.buffers.length=0}}const ce={name:"interpolation",vs:"layout(std140) uniform interpolationUniforms {\n float time;\n} interpolation;\n",uniformTypes:{time:"f32"}},ue="#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vCurrent;\n\nvoid main(void) {\n vCurrent = mix(aFrom, aTo, interpolation.time);\n gl_Position = vec4(0.0);\n}\n",de="#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aFrom64Low;\nin ATTRIBUTE_TYPE aTo;\nin ATTRIBUTE_TYPE aTo64Low;\nout ATTRIBUTE_TYPE vCurrent;\nout ATTRIBUTE_TYPE vCurrent64Low;\n\nvec2 mix_fp64(vec2 a, vec2 b, float x) {\n vec2 range = sub_fp64(b, a);\n return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));\n}\n\nvoid main(void) {\n for (int i=0; i<ATTRIBUTE_SIZE; i++) {\n vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time);\n vCurrent[i] = value.x;\n vCurrent64Low[i] = value.y;\n }\n gl_Position = vec4(0.0);\n}\n";function fe(t){return t.doublePrecision&&t.value instanceof Float64Array}const pe={name:"spring",vs:"layout(std140) uniform springUniforms {\n float damping;\n float stiffness;\n} spring;\n",uniformTypes:{damping:"f32",stiffness:"f32"}},he="#version 300 es\n#define SHADER_NAME spring-transition-vertex-shader\n\n#define EPSILON 0.00001\n\nin ATTRIBUTE_TYPE aPrev;\nin ATTRIBUTE_TYPE aCur;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vNext;\nout float vIsTransitioningFlag;\n\nATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {\n ATTRIBUTE_TYPE velocity = cur - prev;\n ATTRIBUTE_TYPE delta = dest - cur;\n ATTRIBUTE_TYPE force = delta * spring.stiffness;\n ATTRIBUTE_TYPE resistance = velocity * spring.damping;\n return force - resistance + velocity + cur;\n}\n\nvoid main(void) {\n bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;\n vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;\n\n vNext = getNextValue(aCur, aPrev, aTo);\n gl_Position = vec4(0, 0, 0, 1);\n gl_PointSize = 100.0;\n}\n",ge="#version 300 es\n#define SHADER_NAME spring-transition-is-transitioning-fragment-shader\n\nin float vIsTransitioningFlag;\n\nout vec4 fragColor;\n\nvoid main(void) {\n if (vIsTransitioningFlag == 0.0) {\n discard;\n }\n fragColor = vec4(1.0);\n}";const me={interpolation:class extends le{constructor({device:t,attribute:e,timeline:n}){super({device:t,attribute:e,timeline:n}),this.type="interpolation",this.transform=function(t,e){const n=e.size,i=ie(n),o=oe(n),s=e.getBufferLayout();if(fe(e))return new Dt(t,{vs:de,bufferLayout:[{name:"aFrom",byteStride:8*n,attributes:[{attribute:"aFrom",format:o,byteOffset:0},{attribute:"aFrom64Low",format:o,byteOffset:4*n}]},{name:"aTo",byteStride:8*n,attributes:[{attribute:"aTo",format:o,byteOffset:0},{attribute:"aTo64Low",format:o,byteOffset:4*n}]}],modules:[c,ce],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:n},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0});return new Dt(t,{vs:ue,bufferLayout:[{name:"aFrom",format:o},{name:"aTo",format:s.attributes[0].format}],modules:[ce],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}(t,e)}start(t,e){const n=this.currentLength,i=this.currentStartIndices;if(super.start(t,e,t.duration),t.duration<=0)return void this.transition.cancel();const{buffers:o,attribute:s}=this;se(o),o[0]=ae({device:this.device,buffer:o[0],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:t.enter}),o[1]=re({device:this.device,source:o[0],target:o[1]}),this.setBuffer(o[1]);const{transform:r}=this,a=r.model;let l=Math.floor(this.currentLength/s.size);fe(s)&&(l/=2),a.setVertexCount(l),s.isConstant?(a.setAttributes({aFrom:o[0]}),a.setConstantAttributes({aTo:s.value})):a.setAttributes({aFrom:o[0],aTo:s.getBuffer()}),r.transformFeedback.setBuffers({vCurrent:o[1]})}onUpdate(){const{duration:t,easing:e}=this.settings,{time:n}=this.transition;let i=n/t;e&&(i=e(i));const{model:o}=this.transform,s={time:i};o.shaderInputs.setProps({interpolation:s}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},spring:class extends le{constructor({device:t,attribute:e,timeline:n}){super({device:t,attribute:e,timeline:n}),this.type="spring",this.texture=function(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}(t),this.framebuffer=function(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}(t,this.texture),this.transform=function(t,e){const n=ie(e.size),i=oe(e.size);return new Dt(t,{vs:he,fs:ge,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[pe],defines:{ATTRIBUTE_TYPE:n},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}(t,e)}start(t,e){const n=this.currentLength,i=this.currentStartIndices;super.start(t,e);const{buffers:o,attribute:s}=this;for(let a=0;a<2;a++)o[a]=ae({device:this.device,buffer:o[a],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:t.enter});o[2]=re({device:this.device,source:o[0],target:o[2]}),this.setBuffer(o[1]);const{model:r}=this.transform;r.setVertexCount(Math.floor(this.currentLength/s.size)),s.isConstant?r.setConstantAttributes({aTo:s.value}):r.setAttributes({aTo:s.getBuffer()})}onUpdate(){const{buffers:t,transform:e,framebuffer:n,transition:i}=this,o=this.settings;e.model.setAttributes({aPrev:t[0],aCur:t[1]}),e.transformFeedback.setBuffers({vNext:t[2]});const s={stiffness:o.stiffness,damping:o.damping};e.model.shaderInputs.setProps({spring:s}),e.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),se(t),this.setBuffer(t[1]);this.device.readPixelsToArrayWebGL(n)[0]>0||i.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}};class ve{constructor(t,{id:e,timeline:n}){if(!t)throw new Error("AttributeTransitionManager is constructed without device");this.id=e,this.device=t,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const t in this.transitions)this._removeTransition(t)}update({attributes:t,transitions:e,numInstances:n}){this.numInstances=n||1;for(const i in t){const n=t[i],o=n.getTransitionSetting(e);o&&this._updateAttribute(i,n,o)}for(const i in this.transitions){const n=t[i];n&&n.getTransitionSetting(e)||this._removeTransition(i)}}hasAttribute(t){const e=this.transitions[t];return e&&e.inProgress}getAttributes(){const t={};for(const e in this.transitions){const n=this.transitions[e];n.inProgress&&(t[e]=n.attributeInTransition)}return t}run(){if(0===this.numInstances)return!1;for(const e in this.transitions){this.transitions[e].update()&&(this.needsRedraw=!0)}const t=this.needsRedraw;return this.needsRedraw=!1,t}_removeTransition(t){this.transitions[t].delete(),delete this.transitions[t]}_updateAttribute(e,n,i){const o=this.transitions[e];let s=!o||o.type!==i.type;if(s){o&&this._removeTransition(e);const r=me[i.type];r?this.transitions[e]=new r({attribute:n,timeline:this.timeline,device:this.device}):(t.defaultLogger.error(`unsupported transition type '${i.type}'`)(),s=!1)}(s||n.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}}const ye="attributeManager.invalidate";class xe{constructor(e,{id:n="attribute-manager",stats:i,timeline:o}={}){this.mergeBoundsMemoized=t.memoize(t.mergeBounds),this.id=n,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new ve(e,{id:`${n}-transitions`,timeline:o}),Object.seal(this)}finalize(){for(const t in this.attributes)this.attributes[t].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(t={clearRedrawFlags:!1}){const e=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!t.clearRedrawFlags,e&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(t){this._add(t)}addInstanced(t){this._add(t,{stepMode:"instance"})}remove(t){for(const e of t)void 0!==this.attributes[e]&&(this.attributes[e].delete(),delete this.attributes[e])}invalidate(e,n){const i=this._invalidateTrigger(e,n);t.debug(ye,this,e,i)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);t.debug(ye,this,"all")}update({data:e,numInstances:n,startIndices:i=null,transitions:o,props:s={},buffers:r={},context:a={}}){let l=!1;t.debug("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const c in this.attributes){const o=this.attributes[c],u=o.settings.accessor;o.startIndices=i,o.numInstances=n,s[c]&&t.defaultLogger.removed(`props.${c}`,`data.attributes.${c}`)(),o.setExternalBuffer(r[c])||o.setBinaryValue("string"==typeof u?r[u]:void 0,e.startIndices)||"string"==typeof u&&!r[u]&&o.setConstantValue(a,s[u])||o.needsUpdate()&&(l=!0,this._updateAttribute({attribute:o,numInstances:n,data:e,props:s,context:a})),this.needsRedraw=this.needsRedraw||o.needsRedraw()}l&&t.debug("attributeManager.updateEnd",this,n),this.stats&&(this.stats.get("Update Attributes").timeEnd(),l&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:n,transitions:o})}updateTransition(){const{attributeTransitionManager:t}=this,e=t.run();return this.needsRedraw=this.needsRedraw||e,e}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(t){const e=t.map(t=>this.attributes[t]?.getBounds());return this.mergeBoundsMemoized(e)}getChangedAttributes(t={clearChangedFlags:!1}){const{attributes:e,attributeTransitionManager:n}=this,i={...n.getAttributes()};for(const o in e){const s=e[o];s.needsRedraw(t)&&!n.hasAttribute(o)&&(i[o]=s)}return i}getBufferLayouts(t){return Object.values(this.getAttributes()).map(e=>e.getBufferLayout(t))}_add(t,e){for(const n in t){const i=t[n],o={...i,id:n,size:(i.isIndexed?1:i.size)||1,...e};this.attributes[n]=new ee(this.device,o)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const t={};for(const e in this.attributes){this.attributes[e].getUpdateTriggers().forEach(n=>{t[n]||(t[n]=[]),t[n].push(e)})}this.updateTriggers=t}_invalidateTrigger(t,e){const{attributes:n,updateTriggers:i}=this,o=i[t];return o&&o.forEach(t=>{const i=n[t];i&&i.setNeedsUpdate(i.id,e)}),o}_updateAttribute(e){const{attribute:n,numInstances:i}=e;if(t.debug("attribute.updateStart",n),n.constant)return void n.setConstantValue(e.context,n.value);n.allocate(i)&&t.debug("attribute.allocate",n,i);n.updateBuffer(e)&&(this.needsRedraw=!0,t.debug("attribute.updateEnd",n,i))}}class _e extends t.Transition{get value(){return this._value}_onUpdate(){const{time:e,settings:{fromValue:n,toValue:i,duration:o,easing:s}}=this,r=s(e/o);this._value=t.lerp$1(n,i,r)}}const be=1e-5;function Pe(t,e,n,i,o){const s=e-t;return(n-e)*o+-s*i+s+e}function Ce(t,e){if(Array.isArray(t)){let n=0;for(let i=0;i<t.length;i++){const o=t[i]-e[i];n+=o*o}return Math.sqrt(n)}return Math.abs(t-e)}class Le extends t.Transition{get value(){return this._currValue}_onUpdate(){const{fromValue:t,toValue:e,damping:n,stiffness:i}=this.settings,{_prevValue:o=t,_currValue:s=t}=this;let r=function(t,e,n,i,o){if(Array.isArray(n)){const s=[];for(let r=0;r<n.length;r++)s[r]=Pe(t[r],e[r],n[r],i,o);return s}return Pe(t,e,n,i,o)}(o,s,e,n,i);const a=Ce(r,e),l=Ce(r,s);a<be&&l<be&&(r=e,this.end()),this._prevValue=s,this._currValue=r}}const we={interpolation:_e,spring:Le};class Se{constructor(t){this.transitions=new Map,this.timeline=t}get active(){return this.transitions.size>0}add(e,n,i,o){const{transitions:s}=this;if(s.has(e)){const t=s.get(e),{value:i=t.settings.fromValue}=t;n=i,this.remove(e)}if(!(o=te(o)))return;const r=we[o.type];if(!r)return void t.defaultLogger.error(`unsupported transition type '${o.type}'`)();const a=new r(this.timeline);a.start({...o,fromValue:n,toValue:i}),s.set(e,a)}remove(t){const{transitions:e}=this;e.has(t)&&(e.get(t).cancel(),e.delete(t))}update(){const t={};for(const[e,n]of this.transitions)n.update(),t[e]=n.value,n.inProgress||this.remove(e);return t}clear(){for(const t of this.transitions.keys())this.remove(t)}}function Ae(e,n){const i=Te({newProps:e,oldProps:n,propTypes:e[t.PROP_TYPES_SYMBOL],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),o=function(t,e){if(null===e)return"oldProps is null, initial diff";let n=!1;const{dataComparator:i,_dataDiff:o}=t;i?i(t.data,e.data)||(n="Data comparator detected a change"):t.data!==e.data&&(n="A new data container was supplied");n&&o&&(n=o(t.data,e.data)||n);return n}(e,n);let s=!1;return o||(s=function(t,e){if(null===e)return{all:!0};if("all"in t.updateTriggers){if(Me(t,e,"all"))return{all:!0}}const n={};let i=!1;for(const o in t.updateTriggers)if("all"!==o){Me(t,e,o)&&(n[o]=!0,i=!0)}return!!i&&n}(e,n)),{dataChanged:o,propsChanged:i,updateTriggersChanged:s,extensionsChanged:Ee(e,n),transitionsChanged:Oe(e,n)}}function Oe(e,n){if(!e.transitions)return!1;const i={},o=e[t.PROP_TYPES_SYMBOL];let s=!1;for(const t in e.transitions){const r=o[t],a=r&&r.type;("number"===a||"color"===a||"array"===a)&&Ie(e[t],n[t],r)&&(i[t]=!0,s=!0)}return!!s&&i}function Te({newProps:t,oldProps:e,ignoreProps:n={},propTypes:i={},triggerName:o="props"}){if(e===t)return!1;if("object"!=typeof t||null===t)return`${o} changed shallowly`;if("object"!=typeof e||null===e)return`${o} changed shallowly`;for(const s of Object.keys(t))if(!(s in n)){if(!(s in e))return`${o}.${s} added`;const n=Ie(t[s],e[s],i[s]);if(n)return`${o}.${s} ${n}`}for(const s of Object.keys(e))if(!(s in n)){if(!(s in t))return`${o}.${s} dropped`;if(!Object.hasOwnProperty.call(t,s)){const n=Ie(t[s],e[s],i[s]);if(n)return`${o}.${s} ${n}`}}return!1}function Ie(t,e,n){let i=n&&n.equal;return i&&!i(t,e,n)?"changed deeply":i||(i=t&&e&&t.equals,!i||i.call(t,e))?i||e===t?null:"changed shallowly":"changed deeply"}function Ee(t,e){if(null===e)return!0;const n=e.extensions,{extensions:i}=t;if(i===n)return!1;if(!n||!i)return!0;if(i.length!==n.length)return!0;for(let o=0;o<i.length;o++)if(!i[o].equals(n[o]))return!0;return!1}function Me(t,e,n){let i=t.updateTriggers[n];i=null==i?{}:i;let o=e.updateTriggers[n];o=null==o?{}:o;return Te({oldProps:o,newProps:i,triggerName:n})}function ze(t){if(null===(e=t)||"object"!=typeof e)throw new Error("count(): argument not an object");var e;if("function"==typeof t.count)return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(function(t){return null!==t&&"object"==typeof t&&t.constructor===Object}(t))return Object.keys(t).length;throw new Error("count(): argument not a container")}function Re(t,e){if(!e)return t;const n={...t,...e};if("defines"in e&&(n.defines={...t.defines,...e.defines}),"modules"in e&&(n.modules=(t.modules||[]).concat(e.modules),e.modules.some(t=>"project64"===t.name))){const t=n.modules.findIndex(t=>"project32"===t.name);t>=0&&n.modules.splice(t,1)}if("inject"in e)if(t.inject){const i={...t.inject};for(const t in e.inject)i[t]=(i[t]||"")+e.inject[t];n.inject=i}else n.inject=e.inject;return n}const Fe={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Be={};const ke={boolean:{validate:(t,e)=>!0,equal:(t,e,n)=>Boolean(t)===Boolean(e)},number:{validate:(t,e)=>Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)},color:{validate:(t,e)=>e.optional&&!t||Ue(t)&&(3===t.length||4===t.length),equal:(e,n,i)=>t.deepEqual(e,n,1)},accessor:{validate(t,e){const n=je(t);return"function"===n||n===je(e.value)},equal:(e,n,i)=>"function"==typeof n||t.deepEqual(e,n,1)},array:{validate:(t,e)=>e.optional&&!t||Ue(t),equal(e,n,i){const{compare:o}=i,s=Number.isInteger(o)?o:o?1:0;return o?t.deepEqual(e,n,s):e===n}},object:{equal(e,n,i){if(i.ignore)return!0;const{compare:o}=i,s=Number.isInteger(o)?o:o?1:0;return o?t.deepEqual(e,n,s):e===n}},function:{validate:(t,e)=>e.optional&&!t||"function"==typeof t,equal:(t,e,n)=>!n.compare&&!1!==n.ignore||t===e},data:{transform:(t,e,n)=>{if(!t)return t;const{dataTransform:i}=n.props;return i?i(t):"string"==typeof t.shape&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(e,n,i)=>{const o=i.context;return o&&o.device?function(e,n,i,o){if(i instanceof t.Texture)return i;i.constructor&&"Object"!==i.constructor.name&&(i={data:i});let s=null;i.compressed&&(s={minFilter:"linear",mipmapFilter:i.data.length>1?"nearest":"linear"});const{width:r,height:a}=i.data,l=n.createTexture({...i,sampler:{...Fe,...s,...o},mipLevels:n.getMipLevelCount(r,a)});return"webgl"===n.type?l.generateMipmapsWebGL():"webgpu"===n.type&&n.generateMipmapsWebGPU(l),Be[l.id]=e,l}(i.id,o.device,e,{...n.parameters,...i.props.textureParameters}):null},release:(e,n,i)=>{var o,s;o=i.id,(s=e)&&s instanceof t.Texture&&Be[s.id]===o&&(s.delete(),delete Be[s.id])}}};function Ne(t,e){switch(je(e)){case"object":return De(t,e);case"array":return De(t,{type:"array",value:e,compare:!1});case"boolean":return De(t,{type:"boolean",value:e});case"number":return De(t,{type:"number",value:e});case"function":return De(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function De(t,e){return"type"in e?{name:t,...ke[e.type],...e}:"value"in e?{name:t,type:je(e.value),...e}:{name:t,type:"object",value:e}}function Ue(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function je(t){return Ue(t)?"array":null===t?"null":typeof t}const Ge="_mergedDefaultProps";function Ve(e,n){if(!(e instanceof Ke.constructor))return{};let i=Ge;if(n)for(const t of n){const e=t.constructor;e&&(i+=`:${e.extensionName||e.name}`)}const o=He(e,i);return o||(e[i]=function(e,n){const i=e.prototype;if(!i)return null;const o=Object.getPrototypeOf(e),s=Ve(o),r=He(e,"defaultProps")||{},a=function(t){const e={},n={},i={};for(const[o,s]of Object.entries(t)){const t=s?.deprecatedFor;if(t)i[o]=Array.isArray(t)?t:[t];else{const t=Ne(o,s);e[o]=t,n[o]=t.value}}return{propTypes:e,defaultProps:n,deprecatedProps:i}}(r),l=Object.assign(Object.create(null),s,a.defaultProps),c=Object.assign(Object.create(null),s?.[t.PROP_TYPES_SYMBOL],a.propTypes),u=Object.assign(Object.create(null),s?.[t.DEPRECATED_PROPS_SYMBOL],a.deprecatedProps);for(const d of n){const e=Ve(d.constructor);e&&(Object.assign(l,e),Object.assign(c,e[t.PROP_TYPES_SYMBOL]),Object.assign(u,e[t.DEPRECATED_PROPS_SYMBOL]))}(function(e,n){const i=function(e){const n=e.componentName;n||t.defaultLogger.warn(`${e.name}.componentName not specified`)();return n||e.name}(n);Object.defineProperties(e,{id:{writable:!0,value:i}})})(l,e),function(e,n){const i={},o={};for(const t in n){const e=n[t],{name:s,value:r}=e;e.async&&(i[s]=r,o[s]=We(s))}e[t.ASYNC_DEFAULTS_SYMBOL]=i,e[t.ASYNC_ORIGINAL_SYMBOL]={},Object.defineProperties(e,o)}(l,c),function(e,n){for(const i in n)Object.defineProperty(e,i,{enumerable:!1,set(e){const o=`${this.id}: ${i}`;for(const t of n[i])$e(this,t)||(this[t]=e);t.defaultLogger.deprecated(o,n[i].join("/"))()}})}(l,u),l[t.PROP_TYPES_SYMBOL]=c,l[t.DEPRECATED_PROPS_SYMBOL]=u,0!==n.length||$e(e,"_propTypes")||(e._propTypes=c);return l}(e,n||[]))}function We(e){return{enumerable:!0,set(n){"string"==typeof n||n instanceof Promise||qt(n)?this[t.ASYNC_ORIGINAL_SYMBOL][e]=n:this[t.ASYNC_RESOLVED_SYMBOL][e]=n},get(){if(this[t.ASYNC_RESOLVED_SYMBOL]){if(e in this[t.ASYNC_RESOLVED_SYMBOL]){return this[t.ASYNC_RESOLVED_SYMBOL][e]||this[t.ASYNC_DEFAULTS_SYMBOL][e]}if(e in this[t.ASYNC_ORIGINAL_SYMBOL]){const n=this[t.COMPONENT_SYMBOL]&&this[t.COMPONENT_SYMBOL].internalState;if(n&&n.hasAsyncProp(e))return n.getAsyncProp(e)||this[t.ASYNC_DEFAULTS_SYMBOL][e]}}return this[t.ASYNC_DEFAULTS_SYMBOL][e]}}}function $e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function He(t,e){return $e(t,e)&&t[e]}let Ye=0;class Ke{constructor(...e){this.props=function(e,n){let i;for(let t=n.length-1;t>=0;t--){const e=n[t];"extensions"in e&&(i=e.extensions)}const o=Ve(e.constructor,i),s=Object.create(o);s[t.COMPONENT_SYMBOL]=e,s[t.ASYNC_ORIGINAL_SYMBOL]={},s[t.ASYNC_RESOLVED_SYMBOL]={};for(let t=0;t<n.length;++t){const e=n[t];for(const t in e)s[t]=e[t]}return Object.freeze(s),s}(this,e),this.id=this.props.id,this.count=Ye++}clone(e){const{props:n}=this,i={};for(const o in n[t.ASYNC_DEFAULTS_SYMBOL])o in n[t.ASYNC_RESOLVED_SYMBOL]?i[o]=n[t.ASYNC_RESOLVED_SYMBOL][o]:o in n[t.ASYNC_ORIGINAL_SYMBOL]&&(i[o]=n[t.ASYNC_ORIGINAL_SYMBOL][o]);return new this.constructor({...n,...i,...e})}}Ke.componentName="Component",Ke.defaultProps={};const qe=Object.freeze({});class Ze{constructor(t){this.component=t,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const t in this.asyncProps){const e=this.asyncProps[t];e&&e.type&&e.type.release&&e.type.release(e.resolvedValue,e.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||qe}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(t){return t in this.asyncProps}getAsyncProp(t){const e=this.asyncProps[t];return e&&e.resolvedValue}isAsyncPropLoading(t){if(t){const e=this.asyncProps[t];return Boolean(e&&e.pendingLoadCount>0&&e.pendingLoadCount!==e.resolvedLoadCount)}for(const e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(t,e){this._watchPromise(t,Promise.resolve(e))}setAsyncProps(e){this.component=e[t.COMPONENT_SYMBOL]||this.component;const n=e[t.ASYNC_RESOLVED_SYMBOL]||{},i=e[t.ASYNC_ORIGINAL_SYMBOL]||e,o=e[t.ASYNC_DEFAULTS_SYMBOL]||{};for(const t in n){const e=n[t];this._createAsyncPropData(t,o[t]),this._updateAsyncProp(t,e),n[t]=this.getAsyncProp(t)}for(const t in i){const e=i[t];this._createAsyncPropData(t,o[t]),this._updateAsyncProp(t,e)}}_fetch(t,e){return null}_onResolve(t,e){}_onError(t,e){}_updateAsyncProp(t,e){this._didAsyncInputValueChange(t,e)&&("string"==typeof e&&(e=this._fetch(t,e)),e instanceof Promise?this._watchPromise(t,e):qt(e)?this._resolveAsyncIterable(t,e):this._setPropValue(t,e))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const t in this.asyncProps)Object.defineProperty(this.oldAsyncProps,t,{enumerable:!0,value:this.oldProps[t]})}}_didAsyncInputValueChange(t,e){const n=this.asyncProps[t];return e!==n.resolvedValue&&e!==n.lastValue&&(n.lastValue=e,!0)}_setPropValue(t,e){this._freezeAsyncOldProps();const n=this.asyncProps[t];n&&(e=this._postProcessValue(n,e),n.resolvedValue=e,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(t,e,n){const i=this.asyncProps[t];i&&n>=i.resolvedLoadCount&&void 0!==e&&(this._freezeAsyncOldProps(),i.resolvedValue=e,i.resolvedLoadCount=n,this.onAsyncPropUpdated(t,e))}_watchPromise(t,e){const n=this.asyncProps[t];if(n){n.pendingLoadCount++;const i=n.pendingLoadCount;e.then(e=>{this.component&&(e=this._postProcessValue(n,e),this._setAsyncPropValue(t,e,i),this._onResolve(t,e))}).catch(e=>{this._onError(t,e)})}}async _resolveAsyncIterable(t,e){if("data"!==t)return void this._setPropValue(t,e);const n=this.asyncProps[t];if(!n)return;n.pendingLoadCount++;const i=n.pendingLoadCount;let o=[],s=0;for await(const r of e){if(!this.component)return;const{dataTransform:e}=this.component.props;o=e?e(r,o):o.concat(r),Object.defineProperty(o,"__diff",{enumerable:!1,value:[{startRow:s,endRow:o.length}]}),s=o.length,this._setAsyncPropValue(t,o,i)}this._onResolve(t,o)}_postProcessValue(t,e){const n=t.type;return n&&this.component&&(n.release&&n.release(t.resolvedValue,n,this.component),n.transform)?n.transform(e,n,this.component):e}_createAsyncPropData(e,n){if(!this.asyncProps[e]){const i=this.component&&this.component.props[t.PROP_TYPES_SYMBOL];this.asyncProps[e]={type:i&&i[e],lastValue:null,resolvedValue:n,pendingLoadCount:0,resolvedLoadCount:0}}}}class Xe extends Ze{constructor({attributeManager:t,layer:e}){super(e),this.attributeManager=t,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(t,e){const n=this.layer,i=n?.props.fetch;return i?i(e,{propName:t,layer:n}):super._fetch(t,e)}_onResolve(t,e){const n=this.layer;if(n){const i=n.props.onDataLoad;"data"===t&&i&&i(e,{propName:t,layer:n})}}_onError(t,e){const n=this.layer;n&&n.raiseError(e,`loading ${t} of ${this.layer}`)}}const Je=2**24-1,Qe=Object.freeze([]),tn=t.memoize(({oldViewport:t,viewport:e})=>t.equals(e));let en=new Uint8ClampedArray(0);const nn={data:{type:"data",value:Qe,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(e,{propName:n,layer:i,loaders:o,loadOptions:s,signal:r})=>{const{resourceManager:a}=i.context;s=s||i.getLoadOptions(),o=o||i.props.loaders,r&&(s={...s,core:{...s?.core,fetch:{...s?.core?.fetch,signal:r}}});let l=a.contains(e);return l||s||(a.add({resourceId:e,data:t.load(e,o),persistent:!1}),l=!0),l?a.subscribe({resourceId:e,onChange:t=>i.internalState?.reloadAsyncProp(n,t),consumerId:i.id,requestId:n}):t.load(e,o,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,100*-t]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class on extends Ke{constructor(){super(...arguments),this.internalState=null,this.lifecycle=t.LIFECYCLE.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let t=this;for(;t.parent;)t=t.parent;return t}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){t.assert$1(this.internalState);const n=this.internalState.viewport||this.context.viewport,i=q(e,{viewport:n,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[o,s,r]=t.worldToPixels(i,n.pixelProjectionMatrix);return 2===e.length?[o,s]:[o,s,r]}unproject(e){t.assert$1(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,n){t.assert$1(this.internalState);return function(e,n){const{viewport:i,coordinateSystem:o,coordinateOrigin:s,modelMatrix:r,fromCoordinateSystem:a,fromCoordinateOrigin:l}=function(t){const{viewport:e,modelMatrix:n,coordinateOrigin:i}=t;let{coordinateSystem:o,fromCoordinateSystem:s,fromCoordinateOrigin:r}=t;return"default"===o&&(o=e.isGeospatial?"lnglat":"cartesian"),void 0===s?s=o:"default"===s&&(s=e.isGeospatial?"lnglat":"cartesian"),void 0===r&&(r=i),{viewport:e,coordinateSystem:o,coordinateOrigin:i,modelMatrix:n,fromCoordinateSystem:s,fromCoordinateOrigin:r}}(n),{autoOffset:c=!0}=n,{geospatialOrigin:u=Y,shaderCoordinateOrigin:d=Y,offsetMode:f=!1}=c?t.getOffsetOrigin(i,o,s):{},p=q(e,{viewport:i,modelMatrix:r,coordinateSystem:a,coordinateOrigin:l,offsetMode:f});if(f){const e=i.projectPosition(u||d);t.sub(p,p,e)}return p}(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...n})}get isComposite(){return!1}get isDrawable(){return!0}setState(t){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,t),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return!!this.internalState&&!this.internalState.isAsyncPropLoading()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const t=this.state;return t&&(t.models||t.model&&[t.model])||[]}setShaderModuleProps(...t){for(const e of this.getModels())e.shaderInputs.setProps(...t)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:t}=this.props;return"default"===t||"lnglat"===t||"cartesian"===t}onHover(t,e){return this.props.onHover&&this.props.onHover(t,e)||!1}onClick(t,e){return this.props.onClick&&this.props.onClick(t,e)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(t,e=[]){return e[0]=t+1&255,e[1]=t+1>>8&255,e[2]=t+1>>8>>8&255,e}decodePickingColor(e){t.assert$1(e instanceof Uint8Array);const[n,i,o]=e;return n+256*i+65536*o-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:ze(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(t){t=Re(t,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const e of this.props.extensions)t=Re(t,e.getShaders.call(this,e));return t}shouldUpdateState(t){return t.changeFlags.propsOrDataChanged}updateState(t){const e=this.getAttributeManager(),{dataChanged:n}=t.changeFlags;if(n&&e)if(Array.isArray(n))for(const i of n)e.invalidateAll(i);else e.invalidateAll();if(e){const{props:n}=t,i=this.internalState.hasPickingBuffer,o=Number.isInteger(n.highlightedObjectIndex)||Boolean(n.pickable)||n.extensions.some(t=>t.getNeedsPickingBuffer.call(this,t));if(i!==o){this.internalState.hasPickingBuffer=o;const{pickingColors:t,instancePickingColors:n}=e.attributes,i=t||n;i&&(o&&i.constant&&(i.constant=!1,e.invalidate(i.id)),i.value||o||(i.constant=!0,i.value=[0,0,0]))}}}finalizeState(t){for(const n of this.getModels())n.destroy();const e=this.getAttributeManager();e&&e.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(t){for(const e of this.getModels())e.draw(t.renderPass)}getPickingInfo({info:t,mode:e,sourceLayer:n}){const{index:i}=t;return i>=0&&Array.isArray(this.props.data)&&(t.object=this.props.data[i]),t}raiseError(t,e){e&&(t=new Error(`${e}: ${t.message}`,{cause:t})),this.props.onError?.(t)||this.context?.onError?.(t,this)}getNeedsRedraw(t={clearRedrawFlags:!1}){return this._getNeedsRedraw(t)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(t){if(!this.internalState)return;const e=this.internalState.viewport;this.internalState.viewport=t,e&&tn({oldViewport:e,viewport:t})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(t="all"){const e=this.getAttributeManager();e&&("all"===t?e.invalidateAll():e.invalidate(t))}updateAttributes(t){let e=!1;for(const n in t)t[n].layoutChanged()&&(e=!0);for(const n of this.getModels())this._setModelAttributes(n,t,e)}_updateAttributes(){const t=this.getAttributeManager();if(!t)return;const e=this.props,n=this.getNumInstances(),i=this.getStartIndices();t.update({data:e.data,numInstances:n,startIndices:i,props:e,transitions:e.transitions,buffers:e.data.attributes,context:this});const o=t.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(o)}_updateAttributeTransition(){const t=this.getAttributeManager();t&&t.updateTransition()}_updateUniformTransition(){const{uniformTransitions:t}=this.internalState;if(t.active){const e=t.update(),n=Object.create(this.props);for(const t in e)Object.defineProperty(n,t,{value:e[t]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:n}){if(e.constant)return;const i=Math.floor(en.length/4);this.internalState.usesPickingColorCache=!0;const o=n>0&&0===en[0];if(i<n||o){n>Je&&t.defaultLogger.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),en=t.defaultTypedArrayManager.allocate(en,n,{size:4,copy:!0,maxCount:Math.max(n,Je)});const e=Math.floor(en.length/4),s=[0,0,0];for(let t=o?0:i;t<e;t++)this.encodePickingColor(t,s),en[4*t+0]=s[0],en[4*t+1]=s[1],en[4*t+2]=s[2],en[4*t+3]=0}e.value=en.subarray(0,4*n)}_setModelAttributes(e,n,i=!1){if(!Object.keys(n).length)return;if(i){const t=this.getAttributeManager();e.setBufferLayout(t.getBufferLayouts(e)),n=t.getAttributes()}const o=e.userData?.excludeAttributes||{},s={},r={};for(const a in n){if(o[a])continue;const i=n[a].getValue();for(const o in i){const l=i[o];l instanceof t.Buffer?n[a].settings.isIndexed?e.setIndexBuffer(l):s[o]=l:l&&(r[o]=l)}}e.setAttributes(s),e.setConstantAttributes(r)}disablePickingIndex(t){const e=this.props.data;if(!("attributes"in e))return void this._disablePickingIndex(t);const{pickingColors:n,instancePickingColors:i}=this.getAttributeManager().attributes,o=n||i,s=o&&e.attributes&&e.attributes[o.id];if(s&&s.value){const n=s.value,i=this.encodePickingColor(t);for(let t=0;t<e.length;t++){const e=o.getVertexOffset(t);n[e]===i[0]&&n[e+1]===i[1]&&n[e+2]===i[2]&&this._disablePickingIndex(t)}}else this._disablePickingIndex(t)}_disablePickingIndex(t){const{pickingColors:e,instancePickingColors:n}=this.getAttributeManager().attributes,i=e||n;if(!i)return;const o=i.getVertexOffset(t),s=i.getVertexOffset(t+1);i.buffer.write(new Uint8Array(s-o),o)}restorePickingColors(){const{pickingColors:t,instancePickingColors:e}=this.getAttributeManager().attributes,n=t||e;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==en.buffer&&(n.value=en.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){t.assert$1(!this.internalState),t.debug("layer.initialize",this);const e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new Xe({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(t.defaultLogger.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Se(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){t.debug("layer.matched",this,this===e);const{state:n,internalState:i}=e;this!==e&&(this.internalState=i,this.state=n,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if(t.debug("layer.update",this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();const n=this.props,i=this.context,o=this.internalState,s=i.viewport,r=this._updateUniformTransition();o.propsInTransition=r,i.viewport=o.viewport||s,this.props=r;try{const t=this._getUpdateParams(),e=this.getModels();if(i.device)this.updateState(t);else try{this.updateState(t)}catch(a){}for(const i of this.props.extensions)i.updateState.call(this,t,i);this.setNeedsRedraw(),this._updateAttributes();const n=this.getModels()[0]!==e[0];this._postUpdate(t,n)}finally{i.viewport=s,this.props=n,this._clearChangeFlags(),o.needsUpdate=!1,o.resetOldProps()}}_finalize(){t.debug("layer.finalize",this),this.finalizeState(this.context);for(const t of this.props.extensions)t.finalizeState.call(this,this.context,t)}_drawLayer({renderPass:t,shaderModuleProps:n=null,uniforms:i={},parameters:o={}}){this._updateAttributeTransition();const s=this.props,r=this.context;this.props=this.internalState.propsInTransition||s;try{n&&this.setShaderModuleProps(n);const{getPolygonOffset:s}=this.props,a=s&&s(i)||[0,0];r.device instanceof e.WebGLDevice&&r.device.setParametersWebGL({polygonOffset:a});const l=r.device instanceof e.WebGLDevice?null:function(t){const{blendConstant:e,...n}=t;return e?{pipelineParameters:n,renderPassParameters:{blendConstant:e}}:{pipelineParameters:n}}(o);if(function(t,e,n,i){for(const o of t)"webgpu"===o.device.type?(sn(o,e),o.setParameters({...o.parameters,...i?.pipelineParameters})):o.setParameters(n)}(this.getModels(),t,o,l),r.device instanceof e.WebGLDevice)r.device.withParametersWebGL(o,()=>{const e={renderPass:t,shaderModuleProps:n,uniforms:i,parameters:o,context:r};for(const t of this.props.extensions)t.draw.call(this,e,t);this.draw(e)});else{l?.renderPassParameters&&t.setParameters(l.renderPassParameters);const e={renderPass:t,shaderModuleProps:n,uniforms:i,parameters:o,context:r};for(const t of this.props.extensions)t.draw.call(this,e,t);this.draw(e)}}finally{this.props=s}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:n}=this.internalState;for(const o in e)if(e[o]){let i=!1;if("dataChanged"===o){const t=e[o],s=n[o];t&&Array.isArray(s)&&(n.dataChanged=Array.isArray(t)?s.concat(t):t,i=!0)}n[o]||(n[o]=e[o],i=!0),i&&t.debug("layer.changeFlag",this,o,e)}const i=Boolean(n.dataChanged||n.updateTriggersChanged||n.propsChanged||n.extensionsChanged);n.propsOrDataChanged=i,n.somethingChanged=i||n.viewportChanged||n.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(t,e){const n=Ae(t,e);if(n.updateTriggersChanged)for(const i in n.updateTriggersChanged)n.updateTriggersChanged[i]&&this.invalidateAttribute(i);if(n.transitionsChanged)for(const i in n.transitionsChanged)this.internalState.uniformTransitions.add(i,e[i],t[i],t.transitions?.[i]);return this.setChangeFlags(n)}validateProps(){!function(e){const n=e[t.PROP_TYPES_SYMBOL];for(const t in n){const i=n[t],{validate:o}=i;if(o&&!o(e[t],i))throw new Error(`Invalid prop ${t}: ${e[t]}`)}}(this.props)}updateAutoHighlight(t){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(t)}_updateAutoHighlight(t){const e={highlightedObjectColor:t.picked?t.color:null},{highlightColor:n}=this.props;t.picked&&"function"==typeof n&&(e.highlightColor=n(t)),this.setShaderModuleProps({picking:e}),this.setNeedsRedraw()}_getAttributeManager(){const t=this.context;return new xe(t.device,{id:this.props.id,stats:t.stats,timeline:t.timeline})}_postUpdate(t,e){const{props:n,oldProps:i}=t,o=this.state.model;o?.isInstanced&&o.setInstanceCount(this.getNumInstances());const{autoHighlight:s,highlightedObjectIndex:r,highlightColor:a}=n;if(e||i.autoHighlight!==s||i.highlightedObjectIndex!==r||i.highlightColor!==a){const t={};Array.isArray(a)&&(t.highlightColor=a),(e||i.autoHighlight!==s||r!==i.highlightedObjectIndex)&&(t.highlightedObjectColor=Number.isFinite(r)&&r>=0?this.encodePickingColor(r):null),this.setShaderModuleProps({picking:t})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(t){if(!this.internalState)return!1;let e=!1;e=e||this.internalState.needsRedraw&&this.id;const n=this.getAttributeManager(),i=!!n&&n.getNeedsRedraw(t);if(e=e||i,e)for(const o of this.props.extensions)o.onNeedsRedraw.call(this,o);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!t.clearRedrawFlags,e}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}function sn(t,e){const n=e.props.framebuffer||(e.framebuffer??null);if(!n)return;const i=n.colorAttachments.map(t=>t?.texture?.format??null),o=n.depthStencilAttachment?.texture?.format,s=t;(function(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0})(s.props.colorAttachmentFormats,i)&&s.props.depthStencilAttachmentFormat===o||(s.props.colorAttachmentFormats=i,s.props.depthStencilAttachmentFormat=o,s._setPipelineNeedsUpdate("attachment formats"))}on.defaultProps=nn,on.layerName="Layer";class rn extends on{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(t=>t.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(t){}setState(t){super.setState(t),this.setNeedsUpdate()}getPickingInfo({info:t}){const{object:e}=t;return e&&e.__source&&e.__source.parent&&e.__source.parent.id===this.id?(t.object=e.__source.object,t.index=e.__source.index,t):t}filterSubLayer(t){return!0}shouldRenderSubLayer(t,e){return e&&e.length}getSubLayerClass(t,e){const{_subLayerProps:n}=this.props;return n&&n[t]&&n[t].type||e}getSubLayerRow(t,e,n){return t.__source={parent:this,object:e,index:n},t}getSubLayerAccessor(t){if("function"==typeof t){const e={index:-1,data:this.props.data,target:[]};return(n,i)=>n&&n.__source?(e.index=n.__source.index,t(n.__source.object,e)):t(n,i)}return t}getSubLayerProps(e={}){const{opacity:n,pickable:i,visible:o,parameters:s,getPolygonOffset:r,highlightedObjectIndex:a,autoHighlight:l,highlightColor:c,coordinateSystem:u,coordinateOrigin:d,wrapLongitude:f,positionFormat:p,modelMatrix:h,extensions:g,fetch:m,operation:v,_subLayerProps:y}=this.props,x={id:"",updateTriggers:{},opacity:n,pickable:i,visible:o,parameters:s,getPolygonOffset:r,highlightedObjectIndex:a,autoHighlight:l,highlightColor:c,coordinateSystem:u,coordinateOrigin:d,wrapLongitude:f,positionFormat:p,modelMatrix:h,extensions:g,fetch:m,operation:v},_=y&&e.id&&y[e.id],b=_&&_.updateTriggers,P=e.id||"sublayer";if(_){const n=this.props[t.PROP_TYPES_SYMBOL],i=e.type?e.type._propTypes:{};for(const t in _){const e=i[t]||n[t];e&&"accessor"===e.type&&(_[t]=this.getSubLayerAccessor(_[t]))}}Object.assign(x,e,_),x.id=`${this.props.id}-${P}`,x.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...b};for(const t of g){const e=t.getSubLayerProps.call(this,t);e&&Object.assign(x,e,{updateTriggers:Object.assign(x.updateTriggers,e.updateTriggers)})}return x}_updateAutoHighlight(t){for(const e of this.getSubLayers())e.updateAutoHighlight(t)}_getAttributeManager(){return null}_postUpdate(e,n){let i=this.internalState.subLayers;const o=!i||this.needsUpdate();if(o){const e=this.renderLayers();i=t.flatten(e,Boolean),this.internalState.subLayers=i}t.debug("compositeLayer.renderLayers",this,o,i);for(const t of i)t.parent=this}}rn.layerName="CompositeLayer";class an{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:n={}}=e;this.typedArrayManager=t.defaultTypedArrayManager,this.attributes={},this._attributeDefs=n,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:n,buffers:i={},getGeometry:o,geometryBuffer:s,positionFormat:r,dataChanged:a,normalize:l=!0}=this.opts;if(this.data=n,this.getGeometry=o,this.positionSize=s&&s.size||("XY"===r?2:3),this.buffers=i,this.normalize=l,s&&(t.assert$1(n.startIndices),this.getGeometry=this.getGeometryFromBuffer(s),l||(i.vertexPositions=s)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(const t of a)this._rebuildGeometry(t);else this._rebuildGeometry()}updatePartialGeometry({startRow:t,endRow:e}){this._rebuildGeometry({startRow:t,endRow:e})}getGeometryFromBuffer(t){const e=t.value||t;return ArrayBuffer.isView(e)?Zt(e,{size:this.positionSize,offset:t.offset,stride:t.stride,startIndices:this.data.startIndices}):null}_allocate(t,e){const{attributes:n,buffers:i,_attributeDefs:o,typedArrayManager:s}=this;for(const r in o)if(r in i)s.release(n[r]),n[r]=null;else{const i=o[r];i.copy=e,n[r]=s.allocate(n[r],t,i)}}_forEachGeometry(t,e,n){const{data:i,getGeometry:o}=this,{iterable:s,objectInfo:r}=Kt(i,e,n);for(const a of s){r.index++;t(o?o(a,r):null,r.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:n,vertexStarts:i,instanceCount:o}=this;const{data:s,geometryBuffer:r}=this,{startRow:a=0,endRow:l=1/0}=e||{},c={};if(e||(n=[0],i=[0]),this.normalize||!r)this._forEachGeometry((t,e)=>{const n=t&&this.normalizeGeometry(t);c[e]=n,i[e+1]=i[e]+(n?this.getGeometrySize(n):0)},a,l),o=i[i.length-1];else if(i=s.startIndices,o=i[s.length]||0,ArrayBuffer.isView(r))o=o||r.length/this.positionSize;else if(r instanceof t.Buffer){const t=4*this.positionSize;o=o||r.byteLength/t}else if(r.buffer){const t=r.stride||4*this.positionSize;o=o||r.buffer.byteLength/t}else if(r.value){const t=r.value,e=r.stride/t.BYTES_PER_ELEMENT||this.positionSize;o=o||t.length/e}this._allocate(o,Boolean(e)),this.indexStarts=n,this.vertexStarts=i,this.instanceCount=o;const u={};this._forEachGeometry((t,e)=>{const s=c[e]||t;u.vertexStart=i[e],u.indexStart=n[e];const r=e<i.length-1?i[e+1]:o;u.geometrySize=r-i[e],u.geometryIndex=e,this.updateGeometryAttributes(s,u)},a,l),this.vertexCount=n[n.length-1]}}const ln="layout(std140) uniform arcUniforms {\n bool greatCircle;\n bool useShortestPath;\n float numSegments;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int widthUnits;\n} arc;\n",cn={name:"arc",vs:ln,fs:ln,uniformTypes:{greatCircle:"f32",useShortestPath:"f32",numSegments:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",widthUnits:"i32"}},un=[0,0,0,255],dn={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getSourceColor:{type:"accessor",value:un},getTargetColor:{type:"accessor",value:un},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}};class fn extends on{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME arc-layer-vertex-shader\nin vec4 instanceSourceColors;\nin vec4 instanceTargetColors;\nin vec3 instanceSourcePositions;\nin vec3 instanceSourcePositions64Low;\nin vec3 instanceTargetPositions;\nin vec3 instanceTargetPositions64Low;\nin vec3 instancePickingColors;\nin float instanceWidths;\nin float instanceHeights;\nin float instanceTilts;\nout vec4 vColor;\nout vec2 uv;\nout float isValid;\nfloat paraboloid(float distance, float sourceZ, float targetZ, float ratio) {\nfloat deltaZ = targetZ - sourceZ;\nfloat dh = distance * instanceHeights;\nif (dh == 0.0) {\nreturn sourceZ + deltaZ * ratio;\n}\nfloat unitZ = deltaZ / dh;\nfloat p2 = unitZ * unitZ + 1.0;\nfloat dir = step(deltaZ, 0.0);\nfloat z0 = mix(sourceZ, targetZ, dir);\nfloat r = mix(ratio, 1.0 - ratio, dir);\nreturn sqrt(r * (p2 - r)) * dh + z0;\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\nvec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);\ndir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\nreturn dir_screenspace * offset_direction * width / 2.0;\n}\nfloat getSegmentRatio(float index) {\nreturn smoothstep(0.0, 1.0, index / (arc.numSegments - 1.0));\n}\nvec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) {\nfloat distance = length(source.xy - target.xy);\nfloat z = paraboloid(distance, source.z, target.z, segmentRatio);\nfloat tiltAngle = radians(instanceTilts);\nvec2 tiltDirection = normalize(target.xy - source.xy);\nvec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);\nreturn vec3(\nmix(source.xy, target.xy, segmentRatio) + tilt,\nz * cos(tiltAngle)\n);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\nvec2 sourceRadians = radians(source);\nvec2 targetRadians = radians(target);\nvec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);\nvec2 shd_sq = sin_half_delta * sin_half_delta;\nfloat a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;\nreturn 2.0 * asin(sqrt(a));\n}\nvec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) {\nvec2 lngLat;\nif(abs(angularDist - PI) < 0.001) {\nlngLat = (1.0 - t) * source.xy + t * target.xy;\n} else {\nfloat a = sin((1.0 - t) * angularDist);\nfloat b = sin(t * angularDist);\nvec3 p = source3D.yxz * a + target3D.yxz * b;\nlngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));\n}\nfloat z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);\nreturn vec3(lngLat, z);\n}\nvoid main(void) {\ngeometry.worldPosition = instanceSourcePositions;\ngeometry.worldPositionAlt = instanceTargetPositions;\nfloat segmentIndex = float(gl_VertexID / 2);\nfloat segmentSide = mod(float(gl_VertexID), 2.) == 0. ? -1. : 1.;\nfloat segmentRatio = getSegmentRatio(segmentIndex);\nfloat prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));\nfloat nextSegmentRatio = getSegmentRatio(min(arc.numSegments - 1.0, segmentIndex + 1.0));\nfloat indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\nisValid = 1.0;\nuv = vec2(segmentRatio, segmentSide);\ngeometry.uv = uv;\ngeometry.pickingColor = instancePickingColors;\nvec4 curr;\nvec4 next;\nvec3 source;\nvec3 target;\nif ((arc.greatCircle || project.projectionMode == PROJECTION_MODE_GLOBE) && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nsource = project_globe_(vec3(instanceSourcePositions.xy, 0.0));\ntarget = project_globe_(vec3(instanceTargetPositions.xy, 0.0));\nfloat angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);\nvec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);\nvec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);\nvec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);\nif (abs(currPos.x - prevPos.x) > 180.0) {\nindexDir = -1.0;\nisValid = 0.0;\n} else if (abs(currPos.x - nextPos.x) > 180.0) {\nindexDir = 1.0;\nisValid = 0.0;\n}\nnextPos = indexDir < 0.0 ? prevPos : nextPos;\nnextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;\nif (isValid == 0.0) {\nnextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0;\nfloat t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x);\ncurrPos = mix(currPos, nextPos, t);\nsegmentRatio = mix(segmentRatio, nextSegmentRatio, t);\n}\nvec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio);\nvec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio);\ncurr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position);\nnext = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n} else {\nvec3 source_world = instanceSourcePositions;\nvec3 target_world = instanceTargetPositions;\nif (arc.useShortestPath) {\nsource_world.x = mod(source_world.x + 180., 360.0) - 180.;\ntarget_world.x = mod(target_world.x + 180., 360.0) - 180.;\nfloat deltaLng = target_world.x - source_world.x;\nif (deltaLng > 180.) target_world.x -= 360.;\nif (deltaLng < -180.) source_world.x -= 360.;\n}\nsource = project_position(source_world, instanceSourcePositions64Low);\ntarget = project_position(target_world, instanceTargetPositions64Low);\nfloat antiMeridianX = 0.0;\nif (arc.useShortestPath) {\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nantiMeridianX = -(project.coordinateOrigin.x + 180.) / 360. * TILE_SIZE;\n}\nfloat thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x);\nif (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) {\nisValid = 0.0;\nindexDir = sign(segmentRatio - thresholdRatio);\nsegmentRatio = thresholdRatio;\n}\n}\nnextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;\nvec3 currPos = interpolateFlat(source, target, segmentRatio);\nvec3 nextPos = interpolateFlat(source, target, nextSegmentRatio);\nif (arc.useShortestPath) {\nif (nextPos.x < antiMeridianX) {\ncurrPos.x += TILE_SIZE;\nnextPos.x += TILE_SIZE;\n}\n}\ncurr = project_common_position_to_clipspace(vec4(currPos, 1.0));\nnext = project_common_position_to_clipspace(vec4(nextPos, 1.0));\ngeometry.position = vec4(currPos, 1.0);\n}\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceWidths * arc.widthScale, arc.widthUnits),\narc.widthMinPixels, arc.widthMaxPixels\n);\nvec3 offset = vec3(\ngetExtrusionOffset((next.xy - curr.xy) * indexDir, segmentSide, widthPixels),\n0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\nDECKGL_FILTER_GL_POSITION(curr, geometry);\ngl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);\nvec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio);\nvColor = vec4(color.rgb, color.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME arc-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 uv;\nin float isValid;\nout vec4 fragColor;\nvoid main(void) {\nif (isValid == 0.0) {\ndiscard;\n}\nfragColor = vColor;\ngeometry.uv = uv;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[$,H,cn]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:un},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:un},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{widthUnits:n,widthScale:i,widthMinPixels:o,widthMaxPixels:s,greatCircle:r,wrapLongitude:a,numSegments:l}=this.props,c={numSegments:l,widthUnits:t.UNIT[n],widthScale:i,widthMinPixels:o,widthMaxPixels:s,greatCircle:r,useShortestPath:a},u=this.state.model;u.shaderInputs.setProps({arc:c}),u.setVertexCount(2*l),u.draw(this.context.renderPass)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-strip",isInstanced:!0})}}fn.layerName="ArcLayer",fn.defaultProps=dn;const pn=new Uint32Array([0,2,1,0,3,2]),hn=new Float32Array([0,1,0,0,1,0,1,1]);function gn(t,e){if(!e)return function(t){const e=new Float64Array(12);for(let n=0;n<t.length;n++)e[3*n+0]=t[n][0],e[3*n+1]=t[n][1],e[3*n+2]=t[n][2]||0;return{vertexCount:6,positions:e,indices:pn,texCoords:hn}}(t);const n=Math.max(Math.abs(t[0][0]-t[3][0]),Math.abs(t[1][0]-t[2][0])),i=Math.max(Math.abs(t[1][1]-t[0][1]),Math.abs(t[2][1]-t[3][1])),o=Math.ceil(n/e)+1,s=Math.ceil(i/e)+1,r=(o-1)*(s-1)*6,a=new Uint32Array(r),l=new Float32Array(o*s*2),c=new Float64Array(o*s*3);let u=0,d=0;for(let f=0;f<o;f++){const e=f/(o-1);for(let n=0;n<s;n++){const i=n/(s-1),o=mn(t,e,i);c[3*u+0]=o[0],c[3*u+1]=o[1],c[3*u+2]=o[2]||0,l[2*u+0]=e,l[2*u+1]=1-i,f>0&&n>0&&(a[d++]=u-s,a[d++]=u-s-1,a[d++]=u-1,a[d++]=u-s,a[d++]=u-1,a[d++]=u),u++}}return{vertexCount:r,positions:c,indices:a,texCoords:l}}function mn(e,n,i){return t.lerp$1(t.lerp$1(e[0],e[1],i),t.lerp$1(e[3],e[2],i),n)}const vn="layout(std140) uniform bitmapUniforms {\n vec4 bounds;\n float coordinateConversion;\n float desaturate;\n vec3 tintColor;\n vec4 transparentColor;\n} bitmap;\n",yn={name:"bitmap",vs:vn,fs:vn,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}};class xn extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME bitmap-layer-vertex-shader\n\nin vec2 texCoords;\nin vec3 positions;\nin vec3 positions64Low;\n\nout vec2 vTexCoord;\nout vec2 vTexPos;\n\nconst vec3 pickingColor = vec3(1.0, 0.0, 0.0);\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = pickingColor;\n\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vTexCoord = texCoords;\n\n if (bitmap.coordinateConversion < -0.5) {\n vTexPos = geometry.position.xy + project.commonOrigin.xy;\n } else if (bitmap.coordinateConversion > 0.5) {\n vTexPos = geometry.worldPosition.xy;\n }\n\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME bitmap-layer-fragment-shader\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D bitmapTexture;\n\nin vec2 vTexCoord;\nin vec2 vTexPos;\n\nout vec4 fragColor;\n\n/* projection utils */\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / PI / 2.0;\n\n// from degrees to Web Mercator\nvec2 lnglat_to_mercator(vec2 lnglat) {\n float x = lnglat.x;\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nvec2 mercator_to_lnglat(vec2 xy) {\n xy /= WORLD_SCALE;\n return degrees(vec2(\n xy.x - PI,\n atan(exp(xy.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n/* End projection utils */\n\n// apply desaturation\nvec3 color_desaturate(vec3 color) {\n float luminance = (color.r + color.g + color.b) * 0.333333333;\n return mix(color, vec3(luminance), bitmap.desaturate);\n}\n\n// apply tint\nvec3 color_tint(vec3 color) {\n return color * bitmap.tintColor;\n}\n\n// blend with background color\nvec4 apply_opacity(vec3 color, float alpha) {\n if (bitmap.transparentColor.a == 0.0) {\n return vec4(color, alpha);\n }\n float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha);\n float highLightRatio = alpha / blendedAlpha;\n vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n}\n\nvec2 getUV(vec2 pos) {\n return vec2(\n (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]),\n (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3])\n );\n}\n\n\nvec3 packUVsIntoRGB(vec2 uv) {\n // Extract the top 8 bits. We want values to be truncated down so we can add a fraction\n vec2 uv8bit = floor(uv * 256.);\n\n // Calculate the normalized remainders of u and v parts that do not fit into 8 bits\n // Scale and clamp to 0-1 range\n vec2 uvFraction = fract(uv * 256.);\n vec2 uvFraction4bit = floor(uvFraction * 16.);\n\n // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates\n float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.;\n\n return vec3(uv8bit, fractions) / 255.;\n}\n\n\nvoid main(void) {\n vec2 uv = vTexCoord;\n if (bitmap.coordinateConversion < -0.5) {\n vec2 lnglat = mercator_to_lnglat(vTexPos);\n uv = getUV(lnglat);\n } else if (bitmap.coordinateConversion > 0.5) {\n vec2 commonPos = lnglat_to_mercator(vTexPos);\n uv = getUV(commonPos);\n }\n vec4 bitmapColor = texture(bitmapTexture, uv);\n\n fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity);\n\n geometry.uv = uv;\n DECKGL_FILTER_COLOR(fragColor, geometry);\n\n if (bool(picking.isActive) && !bool(picking.isAttribute)) {\n // Since instance information is not used, we can use picking color for pixel index\n fragColor.rgb = packUVsIntoRGB(uv);\n }\n}\n",modules:[$,H,yn]})}initializeState(){const t=this.getAttributeManager();t.remove(["instancePickingColors"]);const e=!0;t.add({indices:{size:1,isIndexed:!0,update:t=>t.value=this.state.mesh.indices,noAlloc:e},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:t=>t.value=this.state.mesh.positions,noAlloc:e},texCoords:{size:2,update:t=>t.value=this.state.mesh.texCoords,noAlloc:e}})}updateState({props:t,oldProps:e,changeFlags:n}){const i=this.getAttributeManager();if(n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll()),t.bounds!==e.bounds){const t=this.state.mesh,e=this._createMesh();this.state.model.setVertexCount(e.vertexCount);for(const n in e)t&&t[n]!==e[n]&&i.invalidate(n);this.setState({mesh:e,...this._getCoordinateUniforms()})}else t._imageCoordinateSystem!==e._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(t){const{image:e}=this.props,n=t.info;if(!n.color||!e)return n.bitmap=null,n;const{width:i,height:o}=e;n.index=0;const s=function(t){const[e,n,i]=t;return[(e+(15&i)/16)/256,(n+(240&i)/256)/256]}(n.color);return n.bitmap={size:{width:i,height:o},uv:s,pixel:[Math.floor(s[0]*i),Math.floor(s[1]*o)]},n}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(t){super._updateAutoHighlight({...t,color:this.encodePickingColor(0)})}_createMesh(){const{bounds:t}=this.props;let e=t;return _n(t)&&(e=[[t[0],t[1]],[t[0],t[3]],[t[2],t[3]],[t[2],t[1]]]),gn(e,this.context.viewport.resolution)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(t){const{shaderModuleProps:e}=t,{model:n,coordinateConversion:i,bounds:o,disablePicking:s}=this.state,{image:r,desaturate:a,transparentColor:l,tintColor:c}=this.props;if((!e.picking.isActive||!s)&&r&&n){const t={bitmapTexture:r,bounds:o,coordinateConversion:i,desaturate:a,tintColor:c.slice(0,3).map(t=>t/255),transparentColor:l.map(t=>t/255)};n.shaderInputs.setProps({bitmap:t}),n.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if("default"!==e){const{bounds:n}=this.props;if(!_n(n))throw new Error("_imageCoordinateSystem only supports rectangular bounds");const i=this.context.viewport.resolution?"lnglat":"cartesian";if(e="lnglat"===e?"lnglat":"cartesian","lnglat"===e&&"cartesian"===i)return{coordinateConversion:-1,bounds:n};if("cartesian"===e&&"lnglat"===i){const e=t.lngLatToWorld([n[0],n[1]]),i=t.lngLatToWorld([n[2],n[3]]);return{coordinateConversion:1,bounds:[e[0],e[1],i[0],i[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}}function _n(t){return Number.isFinite(t[0])}xn.layerName="BitmapLayer",xn.defaultProps={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}};const bn="layout(std140) uniform iconUniforms {\n float sizeScale;\n vec2 iconsTextureDim;\n float sizeBasis;\n float sizeMinPixels;\n float sizeMaxPixels;\n bool billboard;\n highp int sizeUnits;\n float alphaCutoff;\n} icon;\n",Pn={name:"icon",vs:bn,fs:bn,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}},Cn=()=>{},Ln={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},wn={x:0,y:0,width:0,height:0};function Sn(t,e,n,i){const o=Math.min(n/e.width,i/e.height),s=Math.floor(e.width*o),r=Math.floor(e.height*o);return 1===o?{image:e,width:s,height:r}:(t.canvas.height=r,t.canvas.width=s,t.clearRect(0,0,s,r),t.drawImage(e,0,0,e.width,e.height,0,0,s,r),{image:t.canvas,width:s,height:r})}function An(t){return t&&(t.id||t.url)}function On(t){const{device:e}=t;"webgl"===e.type?t.generateMipmapsWebGL():"webgpu"===e.type&&e.generateMipmapsWebGPU(t)}function Tn(t,e,n){for(let i=0;i<e.length;i++){const{icon:o,xOffset:s}=e[i];t[An(o)]={...o,x:s,y:n}}}class In{constructor(t,{onUpdate:e=Cn,onError:n=Cn}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=4,this._canvasWidth=1024,this._canvasHeight=0,this._canvas=null,this.device=t,this.onUpdate=e,this.onError=n}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(t){const e=this._autoPacking?An(t):t;return this._mapping[e]||wn}setProps({loadOptions:t,autoPacking:e,iconAtlas:n,iconMapping:i,textureParameters:o}){t&&(this._loadOptions=t),void 0!==e&&(this._autoPacking=e),i&&(this._mapping=i),n&&(this._texture?.delete(),this._texture=null,this._externalTexture=n),o&&(this._samplerParameters=o)}get isLoaded(){return 0===this._pendingCount}packIcons(t,e){if(!this._autoPacking||"undefined"==typeof document)return;const n=Object.values(function(t,e,n){if(!t||!e)return null;n=n||{};const i={},{iterable:o,objectInfo:s}=Kt(t);for(const r of o){s.index++;const t=e(r,s),o=An(t);if(!t)throw new Error("Icon is missing.");if(!t.url)throw new Error("Icon url is missing.");i[o]||n[o]&&t.url===n[o].url||(i[o]={...t,source:r,sourceIndex:s.index})}return i}(t,e,this._mapping)||{});if(n.length>0){const{mapping:t,xOffset:e,yOffset:i,rowHeight:o,canvasHeight:s}=function({icons:t,buffer:e,mapping:n={},xOffset:i=0,yOffset:o=0,rowHeight:s=0,canvasWidth:r}){let a=[];for(let c=0;c<t.length;c++){const l=t[c];if(!n[An(l)]){const{height:t,width:c}=l;i+c+e>r&&(Tn(n,a,o),i=0,o=s+o+e,s=0,a=[]),a.push({icon:l,xOffset:i}),i=i+c+e,s=Math.max(s,t)}}return a.length>0&&Tn(n,a,o),{mapping:n,rowHeight:s,xOffset:i,yOffset:o,canvasWidth:r,canvasHeight:(l=s+o+e,Math.pow(2,Math.ceil(Math.log2(l))))};var l}({icons:n,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=o,this._mapping=t,this._xOffset=e,this._yOffset=i,this._canvasHeight=s,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||Ln,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)})),this._texture.height!==this._canvasHeight&&(this._texture=function(t,e,n,i){const{width:o,height:s,device:r}=t,a=r.createTexture({format:"rgba8unorm",width:e,height:n,sampler:i,mipLevels:r.getMipLevelCount(e,n)}),l=r.createCommandEncoder();l.copyTextureToTexture({sourceTexture:t,destinationTexture:a,width:o,height:s});const c=l.finish();return r.submit(c),On(a),t.destroy(),a}(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||Ln)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(n)}}_loadIcons(e){const n=this._canvas.getContext("2d",{willReadFrequently:!0});for(const i of e)this._pendingCount++,t.load(i.url,this._loadOptions).then(t=>{const e=An(i),o=this._mapping[e],{x:s,y:r,width:a,height:l}=o,{image:c,width:u,height:d}=Sn(n,t,a,l),f=s+(a-u)/2,p=r+(l-d)/2;this._texture?.copyExternalImage({image:c,x:f,y:p,width:u,height:d}),o.x=f,o.y=p,o.width=u,o.height=d,this._texture&&On(this._texture),this.onUpdate(u!==a||d!==l)}).catch(t=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:t})}).finally(()=>{this._pendingCount--})}}const En=[0,0,0,255],Mn={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeBasis:"height",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:En},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}};class zn extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),\nicon.sizeMinPixels, icon.sizeMaxPixels\n);\nfloat iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y;\nfloat instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nif (icon.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / icon.iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME icon-layer-fragment-shader\nprecision highp float;\nuniform sampler2D iconsTexture;\nin float vColorMode;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nvec4 texColor = texture(iconsTexture, vTextureCoords);\nvec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);\nfloat a = texColor.a * layer.opacity * vColor.a;\nif (a < icon.alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color, a);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:'struct IconUniforms {\n sizeScale: f32,\n iconsTextureDim: vec2<f32>,\n sizeBasis: f32,\n sizeMinPixels: f32,\n sizeMaxPixels: f32,\n billboard: i32,\n sizeUnits: i32,\n alphaCutoff: f32\n};\n\n@group(0) @binding(auto) var<uniform> icon: IconUniforms;\n@group(0) @binding(auto) var iconsTexture : texture_2d<f32>;\n@group(0) @binding(auto) var iconsTextureSampler : sampler;\n\nfn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> {\n let angle_radian = angle_deg * PI / 180.0;\n let c = cos(angle_radian);\n let s = sin(angle_radian);\n let rotation = mat2x2<f32>(vec2<f32>(c, s), vec2<f32>(-s, c));\n return rotation * vertex;\n}\n\nstruct Attributes {\n @location(0) positions: vec2<f32>,\n\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceSizes: f32,\n @location(4) instanceAngles: f32,\n @location(5) instanceColors: vec4<f32>,\n @location(6) instancePickingColors: vec3<f32>,\n @location(7) instanceIconFrames: vec4<f32>,\n @location(8) instanceColorModes: f32,\n @location(9) instanceOffsets: vec2<f32>,\n @location(10) instancePixelOffset: vec2<f32>,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n\n @location(0) vColorMode: f32,\n @location(1) vColor: vec4<f32>,\n @location(2) vTextureCoords: vec2<f32>,\n @location(3) uv: vec2<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(inp: Attributes) -> Varyings {\n // write geometry fields used by filters + FS\n geometry.worldPosition = inp.instancePositions;\n geometry.uv = inp.positions;\n geometry.pickingColor = inp.instancePickingColors;\n\n var outp: Varyings;\n outp.uv = inp.positions;\n\n let iconSize = inp.instanceIconFrames.zw;\n\n // convert size in meters to pixels, then clamp\n let sizePixels = clamp(\n project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits),\n icon.sizeMinPixels, icon.sizeMaxPixels\n );\n\n // scale icon height to match instanceSize\n let iconConstraint = select(iconSize.y, iconSize.x, icon.sizeBasis == 0.0);\n let instanceScale = select(sizePixels / iconConstraint, 0.0, iconConstraint == 0.0);\n\n // scale and rotate vertex in "pixel" units; then add per-instance pixel offset\n var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets;\n pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale;\n pixelOffset = pixelOffset + inp.instancePixelOffset;\n pixelOffset.y = pixelOffset.y * -1.0;\n\n if (icon.billboard != 0) {\n var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0)); // TODO, &geometry.position);\n // DECKGL_FILTER_GL_POSITION(pos, geometry);\n\n var offset = vec3<f32>(pixelOffset, 0.0);\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipOffset = project_pixel_size_to_clipspace(offset.xy);\n pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w);\n outp.position = pos;\n } else {\n var offset_common = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);\n // DECKGL_FILTER_SIZE(offset_common, geometry);\n var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offset_common); // TODO, &geometry.position);\n // DECKGL_FILTER_GL_POSITION(pos, geometry);\n outp.position = pos;\n }\n\n let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5;\n outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim;\n\n outp.vColor = inp.instanceColors;\n // DECKGL_FILTER_COLOR(outp.vColor, geometry);\n\n outp.vColorMode = inp.instanceColorModes;\n outp.pickingColor = inp.instancePickingColors;\n\n return outp;\n}\n\n@fragment\nfn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {\n // expose to deck.gl filter hooks\n geometry.uv = inp.uv;\n\n let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords);\n\n // if colorMode == 0, use pixel color from the texture\n // if colorMode == 1 (or picking), use texture as transparency mask\n let rgb = mix(texColor.rgb, inp.vColor.rgb, inp.vColorMode);\n let a = texColor.a * layer.opacity * inp.vColor.a;\n\n if (a < icon.alphaCutoff) {\n discard;\n }\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inp.pickingColor)) {\n discard;\n }\n return vec4<f32>(inp.pickingColor, 1.0);\n }\n\n var fragColor = deckgl_premultiplied_alpha(vec4<f32>(rgb, a));\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return fragColor;\n}\n',modules:[$,W,H,Pn]})}initializeState(){this.state={iconManager:new In(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceIconDefs:{size:7,accessor:"getIcon",transform:this.getInstanceIconDef,shaderAttributes:{instanceOffsets:{size:2,elementOffset:0},instanceIconFrames:{size:4,elementOffset:2},instanceColorModes:{size:1,elementOffset:6}}},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:En},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(t){super.updateState(t);const{props:e,oldProps:n,changeFlags:i}=t,o=this.getAttributeManager(),{iconAtlas:s,iconMapping:r,data:a,getIcon:l,textureParameters:c}=e,{iconManager:u}=this.state;if("string"==typeof s)return;const d=s||this.internalState.isAsyncPropLoading("iconAtlas");u.setProps({loadOptions:e.loadOptions,autoPacking:!d,iconAtlas:s,iconMapping:d?r:null,textureParameters:c}),d?n.iconMapping!==e.iconMapping&&o.invalidate("getIcon"):(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getIcon))&&u.packIcons(a,l),i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),o.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(t){super.finalizeState(t),this.state.iconManager.finalize()}draw({uniforms:e}){const{sizeScale:n,sizeBasis:i,sizeMinPixels:o,sizeMaxPixels:s,sizeUnits:r,billboard:a,alphaCutoff:l}=this.props,{iconManager:c}=this.state,u=c.getTexture();if(u){const e=this.state.model,c={iconsTexture:u,iconsTextureDim:[u.width,u.height],sizeUnits:t.UNIT[r],sizeScale:n,sizeBasis:"height"===i?1:0,sizeMinPixels:o,sizeMaxPixels:s,billboard:a,alphaCutoff:l};e.shaderInputs.setProps({icon:c}),e.draw(this.context.renderPass)}}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([-1,-1,1,-1,-1,1,1,1])}}}),isInstanced:!0})}_onUpdate(t){t?(this.getAttributeManager()?.invalidate("getIcon"),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){const n=this.getCurrentLayer()?.props.onIconError;n?n(e):t.defaultLogger.error(e.error.message)()}getInstanceIconDef(t){const{x:e,y:n,width:i,height:o,mask:s,anchorX:r=i/2,anchorY:a=o/2}=this.state.iconManager.getIconMapping(t);return[i/2-r,o/2-a,e,n,i,o,s?1:0]}}zn.defaultProps=Mn,zn.layerName="IconLayer";const Rn="layout(std140) uniform pointCloudUniforms {\n float radiusPixels;\n highp int sizeUnits;\n} pointCloud;\n",Fn={name:"pointCloud",source:"",vs:Rn,fs:Rn,uniformTypes:{radiusPixels:"f32",sizeUnits:"i32"}},Bn=[0,0,0,255],kn=[0,0,1],Nn={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:kn},getColor:{type:"accessor",value:Bn},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};class Dn extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceNormals;\nin vec4 instanceColors;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec3 instancePickingColors;\nout vec4 vColor;\nout vec2 unitPosition;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.normal = project_normal(instanceNormals);\nunitPosition = positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\nvec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\nvec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, instanceColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 unitPosition;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition.xy;\nfloat distToCenter = length(unitPosition);\nif (distToCenter > 1.0) {\ndiscard;\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"struct PointCloudUniforms {\n radiusPixels: f32,\n sizeUnits: i32,\n};\n\n@group(0) @binding(0)\nvar<uniform> pointCloudUniforms: PointCloudUniforms;\n\nstruct ConstantAttributes {\n instanceNormals: vec3<f32>,\n instanceColors: vec4<f32>,\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instancePickingColors: vec3<f32>\n};\n\nconst constants = ConstantAttributes(\n vec3<f32>(1.0, 0.0, 0.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec3<f32>(0.0),\n vec3<f32>(0.0),\n vec3<f32>(0.0)\n);\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @builtin(vertex_index) vertexIndex : u32,\n @location(0) positions: vec3<f32>,\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceNormals: vec3<f32>,\n @location(4) instanceColors: vec4<f32>,\n @location(5) instancePickingColors: vec3<f32>\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) unitPosition: vec2<f32>,\n @location(2) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n geometry.worldPosition = attributes.instancePositions;\n\n let centerResult = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = centerResult.commonPosition;\n geometry.normal = project_normal(attributes.instanceNormals);\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = attributes.instancePickingColors;\n\n // Find the center of the point and add the current vertex\n let offset = vec3<f32>(\n attributes.positions.xy *\n project_unit_size_to_pixel(pointCloudUniforms.radiusPixels, pointCloudUniforms.sizeUnits),\n 0.0\n );\n // DECKGL_FILTER_SIZE(offset, geometry);\n\n varyings.position = centerResult.clipPosition;\n // DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position.x += clipPixels.x;\n varyings.position.y += clipPixels.y;\n\n // Apply lighting\n let lightColor = lighting_getLightColor2(attributes.instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vColor = vec4(lightColor, attributes.instanceColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(vColor, geometry);\n varyings.pickingColor = attributes.instancePickingColors;\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n // var geometry: Geometry;\n // geometry.uv = unitPosition.xy;\n\n let distToCenter = length(varyings.unitPosition);\n if (distToCenter > 1.0) {\n discard;\n }\n\n var fragColor: vec4<f32>;\n\n fragColor = varyings.vColor;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(varyings.pickingColor)) {\n discard;\n }\n return vec4<f32>(varyings.pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n}\n",modules:[$,W,G,H,Fn]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:kn},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:Bn}})}updateState(t){const{changeFlags:e,props:n}=t;super.updateState(t),e.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),e.dataChanged&&function(t){const{header:e,attributes:n}=t;if(e&&n&&(t.length=e.vertexCount,n.POSITION&&(n.instancePositions=n.POSITION),n.NORMAL&&(n.instanceNormals=n.NORMAL),n.COLOR_0)){const{size:t,value:e}=n.COLOR_0;n.instanceColors={size:t,type:"unorm8",value:e}}}(n.data)}draw({uniforms:e}){const{pointSize:n,sizeUnits:i}=this.props,o=this.state.model,s={sizeUnits:t.UNIT[i],radiusPixels:n};o.shaderInputs.setProps({pointCloud:s}),o.draw(this.context.renderPass)}_getModel(){const t=[];for(let e=0;e<3;e++){const n=e/3*Math.PI*2;t.push(2*Math.cos(n),2*Math.sin(n),0)}return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-list",attributes:{positions:new Float32Array(t)}}),isInstanced:!0})}}Dn.layerName="PointCloudLayer",Dn.defaultProps=Nn;const Un="layout(std140) uniform scatterplotUniforms {\n float radiusScale;\n float radiusMinPixels;\n float radiusMaxPixels;\n float lineWidthScale;\n float lineWidthMinPixels;\n float lineWidthMaxPixels;\n float stroked;\n float filled;\n bool antialiasing;\n bool billboard;\n highp int radiusUnits;\n highp int lineWidthUnits;\n} scatterplot;\n",jn={name:"scatterplot",vs:Un,fs:Un,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}},Gn=[0,0,0,255],Vn={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:Gn},getLineColor:{type:"accessor",value:Gn},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class Wn extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-vertex-shader\nin vec3 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceRadius;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nin vec2 instancePixelOffset;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout vec2 unitPosition;\nout float innerUnitRadius;\nout float outerRadiusPixels;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nouterRadiusPixels = clamp(\nproject_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),\nscatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n);\nfloat lineWidthPixels = clamp(\nproject_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),\nscatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n);\nouterRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\nfloat edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;\nunitPosition = edgePadding * positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\ninnerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;\nif (scatterplot.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = edgePadding * positions * outerRadiusPixels;\noffset.xy += instancePixelOffset;\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);\noffset.xy += project_pixel_size(instancePixelOffset);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin vec2 unitPosition;\nin float innerUnitRadius;\nin float outerRadiusPixels;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition;\nfloat distToCenter = length(unitPosition) * outerRadiusPixels;\nfloat inCircle = scatterplot.antialiasing ?\nsmoothedge(distToCenter, outerRadiusPixels) :\nstep(distToCenter, outerRadiusPixels);\nif (inCircle == 0.0) {\ndiscard;\n}\nif (scatterplot.stroked > 0.5) {\nfloat isLine = scatterplot.antialiasing ?\nsmoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :\nstep(innerUnitRadius * outerRadiusPixels, distToCenter);\nif (scatterplot.filled > 0.5) {\nfragColor = mix(vFillColor, vLineColor, isLine);\n} else {\nif (isLine == 0.0) {\ndiscard;\n}\nfragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);\n}\n} else if (scatterplot.filled < 0.5) {\ndiscard;\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= inCircle;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"// Main shaders\n\nstruct ScatterplotUniforms {\n radiusScale: f32,\n radiusMinPixels: f32,\n radiusMaxPixels: f32,\n lineWidthScale: f32,\n lineWidthMinPixels: f32,\n lineWidthMaxPixels: f32,\n stroked: f32,\n filled: i32,\n antialiasing: i32,\n billboard: i32,\n radiusUnits: i32,\n lineWidthUnits: i32,\n};\n\nstruct ConstantAttributeUniforms {\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4<f32>,\n instanceLineColors: vec4<f32>,\n instancePickingColors: vec3<f32>,\n instancePixelOffset: vec2<f32>,\n\n instancePositionsConstant: i32,\n instancePositions64LowConstant: i32,\n instanceRadiusConstant: i32,\n instanceLineWidthsConstant: i32,\n instanceFillColorsConstant: i32,\n instanceLineColorsConstant: i32,\n instancePickingColorsConstant: i32,\n instancePixelOffsetConstant: i32\n};\n\n@group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms;\n\nstruct ConstantAttributes {\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4<f32>,\n instanceLineColors: vec4<f32>,\n instancePickingColors: vec3<f32>,\n instancePixelOffset: vec2<f32>\n};\n\nconst constants = ConstantAttributes(\n vec3<f32>(0.0),\n vec3<f32>(0.0),\n 0.0,\n 0.0,\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec3<f32>(0.0),\n vec2<f32>(0.0)\n);\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @builtin(vertex_index) vertexIndex : u32,\n @location(0) positions: vec3<f32>,\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceRadius: f32,\n @location(4) instanceLineWidths: f32,\n @location(5) instanceFillColors: vec4<f32>,\n @location(6) instanceLineColors: vec4<f32>,\n @location(7) instancePickingColors: vec3<f32>,\n @location(8) instancePixelOffset: vec2<f32>\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vFillColor: vec4<f32>,\n @location(1) vLineColor: vec4<f32>,\n @location(2) unitPosition: vec2<f32>,\n @location(3) innerUnitRadius: f32,\n @location(4) outerRadiusPixels: f32,\n @location(5) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n // Draw an inline geometry constant array clip space triangle to verify that rendering works.\n // var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));\n // if (attributes.instanceIndex == 0) {\n // varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0);\n // return varyings;\n // }\n\n geometry.worldPosition = attributes.instancePositions;\n\n // Multiply out radius and clamp to limits\n varyings.outerRadiusPixels = clamp(\n project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits),\n scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n );\n\n // Multiply out line width and clamp to limits\n let lineWidthPixels = clamp(\n project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits),\n scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n );\n\n // outer radius needs to offset by half stroke width\n varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\n // Expand geometry to accommodate edge smoothing\n let edgePadding = select(\n (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,\n 1.0,\n scatterplot.antialiasing != 0\n );\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = edgePadding * attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = attributes.instancePickingColors;\n\n varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;\n\n if (scatterplot.billboard != 0) {\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels;\n offset = vec3<f32>(offset.xy + attributes.instancePixelOffset, offset.z);\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position = vec4<f32>(varyings.position.x + clipPixels.x, varyings.position.y + clipPixels.y, varyings.position.z, varyings.position.w);\n } else {\n var offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels);\n offset = vec3<f32>(offset.xy + project_pixel_size_vec2(attributes.instancePixelOffset), offset.z);\n // DECKGL_FILTER_SIZE(offset, geometry);\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n }\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry);\n varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry);\n varyings.pickingColor = attributes.instancePickingColors;\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n // var geometry: Geometry;\n // geometry.uv = unitPosition;\n\n let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels;\n let inCircle = select(\n smoothedge(distToCenter, varyings.outerRadiusPixels),\n step(distToCenter, varyings.outerRadiusPixels),\n scatterplot.antialiasing != 0\n );\n\n if (inCircle == 0.0) {\n discard;\n }\n\n var fragColor: vec4<f32>;\n\n if (scatterplot.stroked != 0) {\n let isLine = select(\n smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n scatterplot.antialiasing != 0\n );\n\n if (scatterplot.filled != 0) {\n fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine);\n } else {\n if (isLine == 0.0) {\n discard;\n }\n fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine);\n }\n } else if (scatterplot.filled == 0) {\n discard;\n } else {\n fragColor = varyings.vFillColor;\n }\n\n fragColor.a *= inCircle;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(varyings.pickingColor)) {\n discard;\n }\n return vec4<f32>(varyings.pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n // return vec4<f32>(0, 0, 1, 1);\n}\n",modules:[$,W,H,jn]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:n,radiusScale:i,radiusMinPixels:o,radiusMaxPixels:s,stroked:r,filled:a,billboard:l,antialiasing:c,lineWidthUnits:u,lineWidthScale:d,lineWidthMinPixels:f,lineWidthMaxPixels:p}=this.props,h={stroked:r,filled:a,billboard:l,antialiasing:c,radiusUnits:t.UNIT[n],radiusScale:i,radiusMinPixels:o,radiusMaxPixels:s,lineWidthUnits:t.UNIT[u],lineWidthScale:d,lineWidthMinPixels:f,lineWidthMaxPixels:p},g=this.state.model;g.shaderInputs.setProps({scatterplot:h}),g.draw(this.context.renderPass)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0])}}}),isInstanced:!0})}}Wn.defaultProps=Vn,Wn.layerName="ScatterplotLayer";const $n=1,Hn=-1;function Yn(t,e,n={}){const i=function(t,e={}){return Math.sign(function(t,e={}){const{start:n=0,end:i=t.length,plane:o="xy"}=e,s=e.size||2;let r=0;const a=Kn[o[0]],l=Kn[o[1]];for(let c=n,u=i-s;c<i;c+=s)r+=(t[c+a]-t[u+a])*(t[c+l]+t[u+l]),u=c;return r/2}(t,e))}(t,n);return i!==e&&(function(t,e){const{start:n=0,end:i=t.length,size:o=2}=e,s=(i-n)/o,r=Math.floor(s/2);for(let a=0;a<r;++a){const e=n+a*o,i=n+(s-1-a)*o;for(let n=0;n<o;++n){const o=t[e+n];t[e+n]=t[i+n],t[i+n]=o}}}(t,n),!0)}const Kn={x:0,y:1,z:2};function qn(t,e){const n=e.length,i=t.length;if(i>0){let o=!0;for(let s=0;s<n;s++)if(t[i-n+s]!==e[s]){o=!1;break}if(o)return!1}for(let o=0;o<n;o++)t[i+o]=e[o];return!0}function Zn(t,e){const n=e.length;for(let i=0;i<n;i++)t[i]=e[i]}function Xn(t,e,n,i,o=[]){const s=i+e*n;for(let r=0;r<n;r++)o[r]=t[s+r];return o}function Jn(t,e,n,i,o=[]){let s,r;if(8&n)s=(i[3]-t[1])/(e[1]-t[1]),r=3;else if(4&n)s=(i[1]-t[1])/(e[1]-t[1]),r=1;else if(2&n)s=(i[2]-t[0])/(e[0]-t[0]),r=2;else{if(!(1&n))return null;s=(i[0]-t[0])/(e[0]-t[0]),r=0}for(let a=0;a<t.length;a++)o[a]=(1&r)===a?i[r]:s*(e[a]-t[a])+t[a];return o}function Qn(t,e){let n=0;return t[0]<e[0]?n|=1:t[0]>e[2]&&(n|=2),t[1]<e[1]?n|=4:t[1]>e[3]&&(n|=8),n}function ti(t,e){const{size:n=2,broken:i=!1,gridResolution:o=10,gridOffset:s=[0,0],startIndex:r=0,endIndex:a=t.length}=e||{},l=(a-r)/n;let c=[];const u=[c],d=Xn(t,0,n,r);let f,p;const h=ii(d,o,s,[]),g=[];qn(c,d);for(let m=1;m<l;m++){for(f=Xn(t,m,n,r,f),p=Qn(f,h);p;){Jn(d,f,p,h,g);const t=Qn(g,h);t&&(Jn(d,g,t,h,g),p=t),qn(c,g),Zn(d,g),oi(h,o,p),i&&c.length>n&&(c=[],u.push(c),qn(c,d)),p=Qn(f,h)}qn(c,f),Zn(d,f)}return i?u:u[0]}function ei(t,e=null,n){if(!t.length)return[];const{size:i=2,gridResolution:o=10,gridOffset:s=[0,0],edgeTypes:r=!1}=n||{},a=[],l=[{pos:t,types:r?new Array(t.length/i).fill(1):null,holes:e||[]}],c=[[],[]];let u=[];for(;l.length;){const{pos:t,types:e,holes:n}=l.shift();si(t,i,n[0]||t.length,c),u=ii(c[0],o,s,u);const d=Qn(c[1],u);if(d){let o=ni(t,e,i,0,n[0]||t.length,u,d);const s={pos:o[0].pos,types:o[0].types,holes:[]},a={pos:o[1].pos,types:o[1].types,holes:[]};l.push(s,a);for(let l=0;l<n.length;l++)o=ni(t,e,i,n[l],n[l+1]||t.length,u,d),o[0]&&(s.holes.push(s.pos.length),s.pos=ri(s.pos,o[0].pos),r&&(s.types=ri(s.types,o[0].types))),o[1]&&(a.holes.push(a.pos.length),a.pos=ri(a.pos,o[1].pos),r&&(a.types=ri(a.types,o[1].types)))}else{const i={positions:t};r&&(i.edgeTypes=e),n.length&&(i.holeIndices=n),a.push(i)}}return a}function ni(t,e,n,i,o,s,r){const a=(o-i)/n,l=[],c=[],u=[],d=[],f=[];let p,h,g;const m=Xn(t,a-1,n,i);let v=Math.sign(8&r?m[1]-s[3]:m[0]-s[2]),y=e&&e[a-1],x=0,_=0;for(let b=0;b<a;b++)p=Xn(t,b,n,i,p),h=Math.sign(8&r?p[1]-s[3]:p[0]-s[2]),g=e&&e[i/n+b],h&&v&&v!==h&&(Jn(m,p,r,s,f),qn(l,f)&&u.push(y),qn(c,f)&&d.push(y)),h<=0?(qn(l,p)&&u.push(g),x-=h):u.length&&(u[u.length-1]=0),h>=0?(qn(c,p)&&d.push(g),_+=h):d.length&&(d[d.length-1]=0),Zn(m,p),v=h,y=g;return[x?{pos:l,types:e&&u}:null,_?{pos:c,types:e&&d}:null]}function ii(t,e,n,i){const o=Math.floor((t[0]-n[0])/e)*e+n[0],s=Math.floor((t[1]-n[1])/e)*e+n[1];return i[0]=o,i[1]=s,i[2]=o+e,i[3]=s+e,i}function oi(t,e,n){8&n?(t[1]+=e,t[3]+=e):4&n?(t[1]-=e,t[3]-=e):2&n?(t[0]+=e,t[2]+=e):1&n&&(t[0]-=e,t[2]-=e)}function si(t,e,n,i){let o=1/0,s=-1/0,r=1/0,a=-1/0;for(let l=0;l<n;l+=e){const e=t[l],n=t[l+1];o=e<o?e:o,s=e>s?e:s,r=n<r?n:r,a=n>a?n:a}return i[0][0]=o,i[0][1]=r,i[1][0]=s,i[1][1]=a,i}function ri(t,e){for(let n=0;n<e.length;n++)t.push(e[n]);return t}function ai(t,e,n,i){let o=-1,s=-1;for(let r=n+1;r<i;r+=e){const e=Math.abs(t[r]);e>o&&(o=e,s=r-1)}return s}function li(t,e,n,i,o=85.051129){const s=t[n],r=t[i-e];if(Math.abs(s-r)>180){const i=Xn(t,0,e,n);i[0]+=360*Math.round((r-s)/360),qn(t,i),i[1]=Math.sign(i[1])*o,qn(t,i),i[0]=s,qn(t,i)}}function ci(t,e,n,i){let o,s=t[0];for(let r=n;r<i;r+=e){o=t[r];const e=o-s;(e>180||e<-180)&&(o-=360*Math.round(e/360)),t[r]=s=o}}function ui(t,e){let n;const i=t.length/e;for(let s=0;s<i&&(n=t[s*e],(n+180)%360==0);s++);const o=360*-Math.round(n/360);if(0!==o)for(let s=0;s<i;s++)t[s*e]+=o}class di extends Ut{constructor(e){const{indices:n,attributes:i}=function(e){const{radius:n,height:i=1,nradial:o=10}=e;let{vertices:s}=e;s&&(t.defaultLogger.assert(s.length>=o),s=s.flatMap(t=>[t[0],t[1]]),Yn(s,Hn));const r=i>0,a=o+1,l=r?3*a+1:o,c=2*Math.PI/o,u=new Uint16Array(r?3*o*2:0),d=new Float32Array(3*l),f=new Float32Array(3*l);let p=0;if(r){for(let t=0;t<a;t++){const e=t*c,r=t%o,a=Math.sin(e),l=Math.cos(e);for(let t=0;t<2;t++)d[p+0]=s?s[2*r]:l*n,d[p+1]=s?s[2*r+1]:a*n,d[p+2]=(.5-t)*i,f[p+0]=s?s[2*r]:l,f[p+1]=s?s[2*r+1]:a,p+=3}d[p+0]=d[p-3],d[p+1]=d[p-2],d[p+2]=d[p-1],p+=3}for(let t=r?0:1;t<a;t++){const e=Math.floor(t/2)*Math.sign(.5-t%2),r=e*c,a=(e+o)%o,l=Math.sin(r),u=Math.cos(r);d[p+0]=s?s[2*a]:u*n,d[p+1]=s?s[2*a+1]:l*n,d[p+2]=i/2,f[p+2]=1,p+=3}if(r){let t=0;for(let e=0;e<o;e++)u[t++]=2*e+0,u[t++]=2*e+2,u[t++]=2*e+0,u[t++]=2*e+1,u[t++]=2*e+1,u[t++]=2*e+3}return{indices:u,attributes:{POSITION:{size:3,value:d},NORMAL:{size:3,value:f}}}}(e);super({...e,indices:n,attributes:i})}}const fi="layout(std140) uniform columnUniforms {\n float radius;\n float angle;\n vec2 offset;\n bool extruded;\n bool stroked;\n bool isStroke;\n float coverage;\n float elevationScale;\n float edgeDistance;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int radiusUnits;\n highp int widthUnits;\n} column;\n",pi={name:"column",vs:fi,fs:fi,uniformTypes:{radius:"f32",angle:"f32",offset:"vec2<f32>",extruded:"f32",stroked:"f32",isStroke:"f32",coverage:"f32",elevationScale:"f32",edgeDistance:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",radiusUnits:"i32",widthUnits:"i32"}},hi=[0,0,0,255],gi={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:t=>t.position},getFillColor:{type:"accessor",value:hi},getLineColor:{type:"accessor",value:hi},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class mi extends on{getShaders(){const t={},{flatShading:e}=this.props;return e&&(t.FLAT_SHADING=1),super.getShaders({vs:"#version 300 es\n#define SHADER_NAME column-layer-vertex-shader\nin vec3 positions;\nin vec3 normals;\nin vec3 instancePositions;\nin float instanceElevations;\nin vec3 instancePositions64Low;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin float instanceStrokeWidths;\nin vec3 instancePickingColors;\nout vec4 vColor;\n#ifdef FLAT_SHADING\nout vec3 cameraPosition;\nout vec4 position_commonspace;\n#endif\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nvec4 color = column.isStroke ? instanceLineColors : instanceFillColors;\nmat2 rotationMatrix = mat2(cos(column.angle), sin(column.angle), -sin(column.angle), cos(column.angle));\nfloat elevation = 0.0;\nfloat strokeOffsetRatio = 1.0;\nif (column.extruded) {\nelevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale;\n} else if (column.stroked) {\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceStrokeWidths * column.widthScale, column.widthUnits),\ncolumn.widthMinPixels, column.widthMaxPixels) / 2.0;\nfloat halfOffset = project_pixel_size(widthPixels) / project_size(column.edgeDistance * column.coverage * column.radius);\nif (column.isStroke) {\nstrokeOffsetRatio -= sign(positions.z) * halfOffset;\n} else {\nstrokeOffsetRatio -= halfOffset;\n}\n}\nfloat shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);\nfloat dotRadius = column.radius * column.coverage * shouldRender;\ngeometry.pickingColor = instancePickingColors;\nvec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);\nvec3 centroidPosition64Low = instancePositions64Low;\nvec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + column.offset) * dotRadius;\nif (column.radiusUnits == UNIT_METERS) {\noffset = project_size(offset);\n} else if (column.radiusUnits == UNIT_PIXELS) {\noffset = project_pixel_size(offset);\n}\nvec3 pos = vec3(offset, 0.);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);\ngeometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (column.extruded && !column.isStroke) {\n#ifdef FLAT_SHADING\ncameraPosition = project.cameraPosition;\nposition_commonspace = geometry.position;\nvColor = vec4(color.rgb, color.a * layer.opacity);\n#else\nvec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, color.a * layer.opacity);\n#endif\n} else {\nvColor = vec4(color.rgb, color.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME column-layer-fragment-shader\nprecision highp float;\nout vec4 fragColor;\nin vec4 vColor;\n#ifdef FLAT_SHADING\nin vec3 cameraPosition;\nin vec4 position_commonspace;\n#endif\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\n#ifdef FLAT_SHADING\nif (column.extruded && !column.isStroke && !bool(picking.isActive)) {\nvec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\nfragColor.rgb = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal);\n}\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:t,modules:[$,e?V:G,H,pi]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:hi},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:hi},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(t){super.updateState(t);const{props:e,oldProps:n,changeFlags:i}=t,o=i.extensionsChanged||e.flatShading!==n.flatShading;o&&(this.state.models?.forEach(t=>t.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());const s=this.getNumInstances();this.state.fillModel.setInstanceCount(s),this.state.wireframeModel.setInstanceCount(s),(o||e.diskResolution!==n.diskResolution||e.vertices!==n.vertices||(e.extruded||e.stroked)!==(n.extruded||n.stroked))&&this._updateGeometry(e)}getGeometry(t,e,n){const i=new di({radius:1,height:n?2:0,vertices:e,nradial:t});let o=0;if(e)for(let s=0;s<t;s++){const n=e[s];o+=Math.sqrt(n[0]*n[0]+n[1]*n[1])/t}else o=1;return this.setState({edgeDistance:Math.cos(Math.PI/t)*o}),i}_getModels(){const t=this.getShaders(),e=this.getAttributeManager().getBufferLayouts(),n=new Nt(this.context.device,{...t,id:`${this.props.id}-fill`,bufferLayout:e,isInstanced:!0}),i=new Nt(this.context.device,{...t,id:`${this.props.id}-wireframe`,bufferLayout:e,isInstanced:!0});return{fillModel:n,wireframeModel:i,models:[i,n]}}_updateGeometry({diskResolution:t,vertices:e,extruded:n,stroked:i}){const o=this.getGeometry(t,e,n||i);this.setState({fillVertexCount:o.attributes.POSITION.value.length/3});const s=this.state.fillModel,r=this.state.wireframeModel,{POSITION:a,NORMAL:l}=o.attributes,c=new Ut({topology:"triangle-strip",attributes:{POSITION:a,NORMAL:l}});s.setGeometry(c),r.setGeometry(o),r.setTopology("line-list")}draw({uniforms:e}){const{lineWidthUnits:n,lineWidthScale:i,lineWidthMinPixels:o,lineWidthMaxPixels:s,radiusUnits:r,elevationScale:a,extruded:l,filled:c,stroked:u,wireframe:d,offset:f,coverage:p,radius:h,angle:g}=this.props,m=this.state.fillModel,v=this.state.wireframeModel,{fillVertexCount:y,edgeDistance:x}=this.state,_={radius:h,angle:g/180*Math.PI,offset:f,extruded:l,stroked:u,coverage:p,elevationScale:a,edgeDistance:x,radiusUnits:t.UNIT[r],widthUnits:t.UNIT[n],widthScale:i,widthMinPixels:o,widthMaxPixels:s};l&&d&&(v.shaderInputs.setProps({column:{..._,isStroke:!0}}),v.draw(this.context.renderPass)),c&&(m.setVertexCount(y),m.shaderInputs.setProps({column:{..._,isStroke:!1}}),m.draw(this.context.renderPass)),!l&&u&&(m.setVertexCount(2*y/3),m.shaderInputs.setProps({column:{..._,isStroke:!0}}),m.draw(this.context.renderPass))}}function vi(t,e,n,i){let o;if(Array.isArray(t[0])){const n=t.length*e;o=new Array(n);for(let i=0;i<t.length;i++)for(let n=0;n<e;n++)o[i*e+n]=t[i][n]||0}else o=t;return n?ti(o,{size:e,gridResolution:n}):i?function(t,e){const{size:n=2,startIndex:i=0,endIndex:o=t.length,normalize:s=!0}=e||{},r=t.slice(i,o);ci(r,n,0,o-i);const a=ti(r,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(s)for(const l of a)ui(l,n);return a}(o,{size:e}):o}mi.layerName="ColumnLayer",mi.defaultProps=gi;class yi extends an{constructor(t){super({...t,attributes:{positions:{size:3,padding:18,initialize:!0,type:t.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(t){return this.attributes[t]}getGeometryFromBuffer(t){return this.normalize?super.getGeometryFromBuffer(t):null}normalizeGeometry(t){return this.normalize?vi(t,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):t}getGeometrySize(t){if(xi(t)){let e=0;for(const n of t)e+=this.getGeometrySize(n);return e}const e=this.getPathLength(t);return e<2?0:this.isClosed(t)?e<3?0:e+2:e}updateGeometryAttributes(t,e){if(0!==e.geometrySize)if(t&&xi(t))for(const n of t){const t=this.getGeometrySize(n);e.geometrySize=t,this.updateGeometryAttributes(n,e),e.vertexStart+=t}else this._updateSegmentTypes(t,e),this._updatePositions(t,e)}_updateSegmentTypes(t,e){const n=this.attributes.segmentTypes,i=!!t&&this.isClosed(t),{vertexStart:o,geometrySize:s}=e;n.fill(0,o,o+s),i?(n[o]=4,n[o+s-2]=4):(n[o]+=1,n[o+s-2]+=2),n[o+s-1]=4}_updatePositions(t,e){const{positions:n}=this.attributes;if(!n||!t)return;const{vertexStart:i,geometrySize:o}=e,s=new Array(3);for(let r=i,a=0;a<o;r++,a++)this.getPointOnPath(t,a,s),n[3*r]=s[0],n[3*r+1]=s[1],n[3*r+2]=s[2]}getPathLength(t){return t.length/this.positionSize}getPointOnPath(t,e,n=[]){const{positionSize:i}=this;e*i>=t.length&&(e+=1-t.length/i);const o=e*i;return n[0]=t[o],n[1]=t[o+1],n[2]=3===i&&t[o+2]||0,n}isClosed(t){if(!this.normalize)return Boolean(this.opts.loop);const{positionSize:e}=this,n=t.length-e;return t[0]===t[n]&&t[1]===t[n+1]&&(2===e||t[2]===t[n+2])}}function xi(t){return Array.isArray(t[0])}const _i="layout(std140) uniform pathUniforms {\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n float jointType;\n float capType;\n float miterLimit;\n bool billboard;\n highp int widthUnits;\n} path;\n",bi={name:"path",vs:_i,fs:_i,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}},Pi=[0,0,0,255],Ci={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:Pi},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},Li={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t};class wi extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME path-layer-vertex-shader\nin vec2 positions;\nin float instanceTypes;\nin vec3 instanceStartPositions;\nin vec3 instanceEndPositions;\nin vec3 instanceLeftPositions;\nin vec3 instanceRightPositions;\nin vec3 instanceLeftPositions64Low;\nin vec3 instanceStartPositions64Low;\nin vec3 instanceEndPositions64Low;\nin vec3 instanceRightPositions64Low;\nin float instanceStrokeWidths;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nuniform float opacity;\nout vec4 vColor;\nout vec2 vCornerOffset;\nout float vMiterLength;\nout vec2 vPathPosition;\nout float vPathLength;\nout float vJointType;\nconst float EPSILON = 0.001;\nconst vec3 ZERO_OFFSET = vec3(0.0);\nfloat flipIfTrue(bool flag) {\nreturn -(float(flag) * 2. - 1.);\n}\nvec3 getLineJoinOffset(\nvec3 prevPoint, vec3 currPoint, vec3 nextPoint,\nvec2 width\n) {\nbool isEnd = positions.x > 0.0;\nfloat sideOfPath = positions.y;\nfloat isJoint = float(sideOfPath == 0.0);\nvec3 deltaA3 = (currPoint - prevPoint);\nvec3 deltaB3 = (nextPoint - currPoint);\nmat3 rotationMatrix;\nbool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);\nif (needsRotation) {\ndeltaA3 = deltaA3 * rotationMatrix;\ndeltaB3 = deltaB3 * rotationMatrix;\n}\nvec2 deltaA = deltaA3.xy / width;\nvec2 deltaB = deltaB3.xy / width;\nfloat lenA = length(deltaA);\nfloat lenB = length(deltaB);\nvec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\nvec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\nvec2 perpA = vec2(-dirA.y, dirA.x);\nvec2 perpB = vec2(-dirB.y, dirB.x);\nvec2 tangent = dirA + dirB;\ntangent = length(tangent) > 0. ? normalize(tangent) : perpA;\nvec2 miterVec = vec2(-tangent.y, tangent.x);\nvec2 dir = isEnd ? dirA : dirB;\nvec2 perp = isEnd ? perpA : perpB;\nfloat L = isEnd ? lenA : lenB;\nfloat sinHalfA = abs(dot(miterVec, perp));\nfloat cosHalfA = abs(dot(dirA, miterVec));\nfloat turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\nfloat cornerPosition = sideOfPath * turnDirection;\nfloat miterSize = 1.0 / max(sinHalfA, EPSILON);\nmiterSize = mix(\nmin(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\nmiterSize,\nstep(0.0, cornerPosition)\n);\nvec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))\n* (sideOfPath + isJoint * turnDirection);\nbool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\nbool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\nbool isCap = isStartCap || isEndCap;\nif (isCap) {\noffsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);\nvJointType = path.capType;\n} else {\nvJointType = path.jointType;\n}\nvPathLength = L;\nvCornerOffset = offsetVec;\nvMiterLength = dot(vCornerOffset, miterVec * turnDirection);\nvMiterLength = isCap ? isJoint : vMiterLength;\nvec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\nvPathPosition = vec2(\ndot(offsetFromStartOfPath, perp),\ndot(offsetFromStartOfPath, dir)\n);\ngeometry.uv = vPathPosition;\nfloat isValid = step(instanceTypes, 3.5);\nvec3 offset = vec3(offsetVec * width * isValid, 0.0);\nif (needsRotation) {\noffset = rotationMatrix * offset;\n}\nreturn offset;\n}\nvoid clipLine(inout vec4 position, vec4 refPosition) {\nif (position.w < EPSILON) {\nfloat r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\nposition = refPosition + (position - refPosition) * r;\n}\n}\nvoid main() {\ngeometry.pickingColor = instancePickingColors;\nvColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\nfloat isEnd = positions.x;\nvec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);\nvec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);\nvec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\nvec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);\nvec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);\nvec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);\ngeometry.worldPosition = currPosition;\nvec2 widthPixels = vec2(clamp(\nproject_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),\npath.widthMinPixels, path.widthMaxPixels) / 2.0);\nvec3 width;\nif (path.billboard) {\nvec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);\nvec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\nvec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);\nclipLine(prevPositionScreen, currPositionScreen);\nclipLine(nextPositionScreen, currPositionScreen);\nclipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\nwidth = vec3(widthPixels, 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(\nprevPositionScreen.xyz / prevPositionScreen.w,\ncurrPositionScreen.xyz / currPositionScreen.w,\nnextPositionScreen.xyz / nextPositionScreen.w,\nproject_pixel_size_to_clipspace(width.xy)\n);\nDECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);\ngl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);\n} else {\nprevPosition = project_position(prevPosition, prevPosition64Low);\ncurrPosition = project_position(currPosition, currPosition64Low);\nnextPosition = project_position(nextPosition, nextPosition64Low);\nwidth = vec3(project_pixel_size(widthPixels), 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);\ngeometry.position = vec4(currPosition + offset, 1.0);\ngl_Position = project_common_position_to_clipspace(geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME path-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 vCornerOffset;\nin float vMiterLength;\nin vec2 vPathPosition;\nin float vPathLength;\nin float vJointType;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vPathPosition;\nif (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {\nif (vJointType > 0.5 && length(vCornerOffset) > 1.0) {\ndiscard;\n}\nif (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {\ndiscard;\n}\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[$,H,bi]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const t=!0;this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:Li,accessor:"getPath",update:this.calculatePositions,noAlloc:t,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:t},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:Li,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:Li,defaultValue:Pi},instancePickingColors:{size:4,type:"uint8",accessor:(t,{index:e,target:n})=>this.encodePickingColor(t&&t.__source?t.__source.index:e,n)}}),this.setState({pathTesselator:new yi({fp64:this.use64bitPositions()})})}updateState(t){super.updateState(t);const{props:e,changeFlags:n}=t,i=this.getAttributeManager();if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPath)){const{pathTesselator:t}=this.state,o=e.data.attributes||{};t.updateGeometry({data:e.data,geometryBuffer:o.getPath,buffers:o,normalize:!e._pathType,loop:"loop"===e._pathType,getGeometry:e.getPath,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:n.dataChanged}),this.setState({numInstances:t.instanceCount,startIndices:t.vertexStarts}),n.dataChanged||i.invalidateAll()}n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll())}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n}=e,i=this.props.data;return i[0]&&i[0].__source&&(e.object=i.find(t=>t.__source.index===n)),e}disablePickingIndex(t){const e=this.props.data;if(e[0]&&e[0].__source)for(let n=0;n<e.length;n++)e[n].__source.index===t&&this._disablePickingIndex(n);else super.disablePickingIndex(t)}draw({uniforms:e}){const{jointRounded:n,capRounded:i,billboard:o,miterLimit:s,widthUnits:r,widthScale:a,widthMinPixels:l,widthMaxPixels:c}=this.props,u=this.state.model,d={jointType:Number(n),capType:Number(i),billboard:o,widthUnits:t.UNIT[r],widthScale:a,miterLimit:s,widthMinPixels:l,widthMaxPixels:c};u.shaderInputs.setProps({path:d}),u.draw(this.context.renderPass)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-list",attributes:{indices:new Uint16Array([0,1,2,1,4,2,1,3,4,3,5,4]),positions:{value:new Float32Array([0,0,0,-1,0,1,1,-1,1,1,1,0]),size:2}}}),isInstanced:!0})}calculatePositions(t){const{pathTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("positions")}calculateSegmentTypes(t){const{pathTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("segmentTypes")}}wi.defaultProps=Ci,wi.layerName="PathLayer";var Si,Ai={exports:{}};var Oi=function(){if(Si)return Ai.exports;function t(t,n,o){o=o||2;var s,r,a,u,d,p,h,g=n&&n.length,m=g?n[0]*o:t.length,v=e(t,0,m,o,!0),y=[];if(!v||v.next===v.prev)return y;if(g&&(v=function(t,n,i,o){var s,r,a,u=[];for(s=0,r=n.length;s<r;s++)(a=e(t,n[s]*o,s<r-1?n[s+1]*o:t.length,o,!1))===a.next&&(a.steiner=!0),u.push(f(a));for(u.sort(l),s=0;s<u.length;s++)i=c(u[s],i);return i}(t,n,v,o)),t.length>80*o){s=a=t[0],r=u=t[1];for(var x=o;x<m;x+=o)(d=t[x])<s&&(s=d),(p=t[x+1])<r&&(r=p),d>a&&(a=d),p>u&&(u=p);h=0!==(h=Math.max(a-s,u-r))?32767/h:0}return i(v,y,o,s,r,h,0),y}function e(t,e,n,i,o){var s,r;if(o===w(t,e,n,i)>0)for(s=e;s<n;s+=i)r=P(s,t[s],t[s+1],r);else for(s=n-i;s>=e;s-=i)r=P(s,t[s],t[s+1],r);return r&&m(r,r.next)&&(C(r),r=r.next),r}function n(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!m(i,i.next)&&0!==g(i.prev,i,i.next))i=i.next;else{if(C(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function i(t,e,l,c,u,f,p){if(t){!p&&f&&function(t,e,n,i){var o=t;do{0===o.z&&(o.z=d(o.x,o.y,e,n,i)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,function(t){var e,n,i,o,s,r,a,l,c=1;do{for(n=t,t=null,s=null,r=0;n;){for(r++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ);e++);for(l=c;a>0||l>0&&i;)0!==a&&(0===l||!i||n.z<=i.z)?(o=n,n=n.nextZ,a--):(o=i,i=i.nextZ,l--),s?s.nextZ=o:t=o,o.prevZ=s,s=o;n=i}s.nextZ=null,c*=2}while(r>1)}(o)}(t,c,u,f);for(var h,g,m=t;t.prev!==t.next;)if(h=t.prev,g=t.next,f?s(t,c,u,f):o(t))e.push(h.i/l|0),e.push(t.i/l|0),e.push(g.i/l|0),C(t),t=g.next,m=g.next;else if((t=g)===m){p?1===p?i(t=r(n(t),e,l),e,l,c,u,f,2):2===p&&a(t,e,l,c,u,f):i(n(t),e,l,c,u,f,1);break}}}function o(t){var e=t.prev,n=t,i=t.next;if(g(e,n,i)>=0)return!1;for(var o=e.x,s=n.x,r=i.x,a=e.y,l=n.y,c=i.y,u=o<s?o<r?o:r:s<r?s:r,d=a<l?a<c?a:c:l<c?l:c,f=o>s?o>r?o:r:s>r?s:r,h=a>l?a>c?a:c:l>c?l:c,m=i.next;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=h&&p(o,a,s,l,r,c,m.x,m.y)&&g(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function s(t,e,n,i){var o=t.prev,s=t,r=t.next;if(g(o,s,r)>=0)return!1;for(var a=o.x,l=s.x,c=r.x,u=o.y,f=s.y,h=r.y,m=a<l?a<c?a:c:l<c?l:c,v=u<f?u<h?u:h:f<h?f:h,y=a>l?a>c?a:c:l>c?l:c,x=u>f?u>h?u:h:f>h?f:h,_=d(m,v,e,n,i),b=d(y,x,e,n,i),P=t.prevZ,C=t.nextZ;P&&P.z>=_&&C&&C.z<=b;){if(P.x>=m&&P.x<=y&&P.y>=v&&P.y<=x&&P!==o&&P!==r&&p(a,u,l,f,c,h,P.x,P.y)&&g(P.prev,P,P.next)>=0)return!1;if(P=P.prevZ,C.x>=m&&C.x<=y&&C.y>=v&&C.y<=x&&C!==o&&C!==r&&p(a,u,l,f,c,h,C.x,C.y)&&g(C.prev,C,C.next)>=0)return!1;C=C.nextZ}for(;P&&P.z>=_;){if(P.x>=m&&P.x<=y&&P.y>=v&&P.y<=x&&P!==o&&P!==r&&p(a,u,l,f,c,h,P.x,P.y)&&g(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;C&&C.z<=b;){if(C.x>=m&&C.x<=y&&C.y>=v&&C.y<=x&&C!==o&&C!==r&&p(a,u,l,f,c,h,C.x,C.y)&&g(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function r(t,e,i){var o=t;do{var s=o.prev,r=o.next.next;!m(s,r)&&v(s,o,o.next,r)&&_(s,r)&&_(r,s)&&(e.push(s.i/i|0),e.push(o.i/i|0),e.push(r.i/i|0),C(o),C(o.next),o=t=r),o=o.next}while(o!==t);return n(o)}function a(t,e,o,s,r,a){var l=t;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&h(l,c)){var u=b(l,c);return l=n(l,l.next),u=n(u,u.next),i(l,e,o,s,r,a,0),void i(u,e,o,s,r,a,0)}c=c.next}l=l.next}while(l!==t)}function l(t,e){return t.x-e.x}function c(t,e){var i=function(t,e){var n,i=e,o=t.x,s=t.y,r=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){var a=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=o&&a>r&&(r=a,n=i.x<i.next.x?i:i.next,a===o))return n}i=i.next}while(i!==e);if(!n)return null;var l,c=n,d=n.x,f=n.y,h=1/0;i=n;do{o>=i.x&&i.x>=d&&o!==i.x&&p(s<f?o:r,s,d,f,s<f?r:o,s,i.x,i.y)&&(l=Math.abs(s-i.y)/(o-i.x),_(i,t)&&(l<h||l===h&&(i.x>n.x||i.x===n.x&&u(n,i)))&&(n=i,h=l)),i=i.next}while(i!==c);return n}(t,e);if(!i)return e;var o=b(i,t);return n(o,o.next),n(i,i.next)}function u(t,e){return g(t.prev,t,e.prev)<0&&g(e.next,t,t.next)<0}function d(t,e,n,i,o){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function f(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function p(t,e,n,i,o,s,r,a){return(o-r)*(e-a)>=(t-r)*(s-a)&&(t-r)*(i-a)>=(n-r)*(e-a)&&(n-r)*(s-a)>=(o-r)*(i-a)}function h(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&v(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(_(t,e)&&_(e,t)&&function(t,e){var n=t,i=!1,o=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&o<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(g(t.prev,t,e.prev)||g(t,e.prev,e))||m(t,e)&&g(t.prev,t,t.next)>0&&g(e.prev,e,e.next)>0)}function g(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function v(t,e,n,i){var o=x(g(t,e,n)),s=x(g(t,e,i)),r=x(g(n,i,t)),a=x(g(n,i,e));return o!==s&&r!==a||(!(0!==o||!y(t,n,e))||(!(0!==s||!y(t,i,e))||(!(0!==r||!y(n,t,i))||!(0!==a||!y(n,e,i)))))}function y(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function x(t){return t>0?1:t<0?-1:0}function _(t,e){return g(t.prev,t,t.next)<0?g(t,e,t.next)>=0&&g(t,t.prev,e)>=0:g(t,e,t.prev)<0||g(t,t.next,e)<0}function b(t,e){var n=new L(t.i,t.x,t.y),i=new L(e.i,e.x,e.y),o=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=o,o.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function P(t,e,n,i){var o=new L(t,e,n);return i?(o.next=i.next,o.prev=i,i.next.prev=o,i.next=o):(o.prev=o,o.next=o),o}function C(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function L(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function w(t,e,n,i){for(var o=0,s=e,r=n-i;s<n;s+=i)o+=(t[r]-t[s])*(t[s+1]+t[r+1]),r=s;return o}return Si=1,Ai.exports=t,Ai.exports.default=t,t.deviation=function(t,e,n,i){var o=e&&e.length,s=o?e[0]*n:t.length,r=Math.abs(w(t,0,s,n));if(o)for(var a=0,l=e.length;a<l;a++){var c=e[a]*n,u=a<l-1?e[a+1]*n:t.length;r-=Math.abs(w(t,c,u,n))}var d=0;for(a=0;a<i.length;a+=3){var f=i[a]*n,p=i[a+1]*n,h=i[a+2]*n;d+=Math.abs((t[f]-t[h])*(t[p+1]-t[f+1])-(t[f]-t[p])*(t[h+1]-t[f+1]))}return 0===r&&0===d?0:Math.abs((d-r)/r)},t.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,o=0;o<t.length;o++){for(var s=0;s<t[o].length;s++)for(var r=0;r<e;r++)n.vertices.push(t[o][s][r]);o>0&&(i+=t[o-1].length,n.holes.push(i))}return n},Ai.exports}();const Ti=n.getDefaultExportFromCjs(Oi),Ii=$n,Ei=Hn,Mi={};function zi(t){return"positions"in t?t.positions:t}function Ri(t){return"holeIndices"in t?t.holeIndices:null}function Fi(t,e,n,i,o){let s=e;const r=n.length;for(let a=0;a<r;a++)for(let e=0;e<i;e++)t[s++]=n[a][e]||0;if(!function(t){const e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]&&e[2]===n[2]}(n))for(let a=0;a<i;a++)t[s++]=n[0][a]||0;return Mi.start=e,Mi.end=s,Mi.size=i,Yn(t,o,Mi),s}function Bi(t,e,n,i,o=0,s,r){const a=(s=s||n.length)-o;if(a<=0)return e;let l=e;for(let c=0;c<a;c++)t[l++]=n[o+c];if(!function(t,e,n,i){for(let o=0;o<e;o++)if(t[n+o]!==t[i-e+o])return!1;return!0}(n,i,o,s))for(let c=0;c<i;c++)t[l++]=n[o+c];return Mi.start=e,Mi.end=l,Mi.size=i,Yn(t,r,Mi),l}function ki(t,e){!function(t){if(t=t&&t.positions||t,!Array.isArray(t)&&!ArrayBuffer.isView(t))throw new Error("invalid polygon")}(t);const n=[],i=[];if("positions"in t){const{positions:o,holeIndices:s}=t;if(s){let t=0;for(let r=0;r<=s.length;r++)t=Bi(n,t,o,e,s[r-1],s[r],0===r?Ii:Ei),i.push(t);return i.pop(),{positions:n,holeIndices:i}}t=o}if(!function(t){return Array.isArray(t[0])}(t))return Bi(n,0,t,e,0,n.length,Ii),n;if(!function(t){return t.length>=1&&t[0].length>=2&&Number.isFinite(t[0][0])}(t)){let o=0;for(const[s,r]of t.entries())o=Fi(n,o,r,e,0===s?Ii:Ei),i.push(o);return i.pop(),{positions:n,holeIndices:i}}return Fi(n,0,t,e,Ii),n}function Ni(t,e,n){const i=t.length/3;let o=0;for(let s=0;s<i;s++){const r=(s+1)%i;o+=t[3*s+e]*t[3*r+n],o-=t[3*r+e]*t[3*s+n]}return Math.abs(o/2)}function Di(t,e,n,i){const o=t.length/3;for(let s=0;s<o;s++){const o=3*s,r=t[o+0],a=t[o+1],l=t[o+2];t[o+e]=r,t[o+n]=a,t[o+i]=l}}class Ui extends an{constructor(t){const{fp64:e,IndexType:n=Uint32Array}=t;super({...t,attributes:{positions:{size:3,type:e?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:n,size:1}}})}get(t){const{attributes:e}=this;return"indices"===t?e.indices&&e.indices.subarray(0,this.vertexCount):e[t]}updateGeometry(t){super.updateGeometry(t);const e=this.buffers.indices;if(e)this.vertexCount=(e.value||e).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(t){if(this.normalize){const e=ki(t,this.positionSize);return this.opts.resolution?ei(zi(e),Ri(e),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?function(t,e=null,n){const{size:i=2,normalize:o=!0,edgeTypes:s=!1}=n||{};e=e||[];const r=[],a=[];let l=0,c=0;for(let d=0;d<=e.length;d++){const o=e[d]||t.length,s=c,u=ai(t,i,l,o);for(let e=u;e<o;e++)r[c++]=t[e];for(let e=l;e<u;e++)r[c++]=t[e];ci(r,i,s,c),li(r,i,s,c,n?.maxLatitude),l=o,a[d]=c}a.pop();const u=ei(r,a,{size:i,gridResolution:360,gridOffset:[-180,-180],edgeTypes:s});if(o)for(const d of u)ui(d.positions,i);return u}(zi(e),Ri(e),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):e}return t}getGeometrySize(t){if(ji(t)){let e=0;for(const n of t)e+=this.getGeometrySize(n);return e}return zi(t).length/this.positionSize}getGeometryFromBuffer(t){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(t):null}updateGeometryAttributes(t,e){if(t&&ji(t))for(const n of t){const t=this.getGeometrySize(n);e.geometrySize=t,this.updateGeometryAttributes(n,e),e.vertexStart+=t,e.indexStart=this.indexStarts[e.geometryIndex+1]}else{const n=t;this._updateIndices(n,e),this._updatePositions(n,e),this._updateVertexValid(n,e)}}_updateIndices(t,{geometryIndex:e,vertexStart:n,indexStart:i}){const{attributes:o,indexStarts:s,typedArrayManager:r}=this;let a=o.indices;if(!a||!t)return;let l=i;const c=function(t,e,n,i){let o=Ri(t);o&&(o=o.map(t=>t/e));let s=zi(t);const r=i&&3===e;if(n){const t=s.length;s=s.slice();const i=[];for(let o=0;o<t;o+=e){i[0]=s[o],i[1]=s[o+1],r&&(i[2]=s[o+2]);const t=n(i);s[o]=t[0],s[o+1]=t[1],r&&(s[o+2]=t[2])}}if(r){const t=Ni(s,0,1),e=Ni(s,0,2),i=Ni(s,1,2);if(!t&&!e&&!i)return[];t>e&&t>i||(e>i?(n||(s=s.slice()),Di(s,0,2,1)):(n||(s=s.slice()),Di(s,2,0,1)))}return Ti(s,o,e)}(t,this.positionSize,this.opts.preproject,this.opts.full3d);a=r.allocate(a,i+c.length,{copy:!0});for(let u=0;u<c.length;u++)a[l++]=c[u]+n;s[e+1]=i+c.length,o.indices=a}_updatePositions(t,{vertexStart:e,geometrySize:n}){const{attributes:{positions:i},positionSize:o}=this;if(!i||!t)return;const s=zi(t);for(let r=e,a=0;a<n;r++,a++){const t=s[a*o],e=s[a*o+1],n=o>2?s[a*o+2]:0;i[3*r]=t,i[3*r+1]=e,i[3*r+2]=n}}_updateVertexValid(t,{vertexStart:e,geometrySize:n}){const{positionSize:i}=this,o=this.attributes.vertexValid,s=t&&Ri(t);if(t&&t.edgeTypes?o.set(t.edgeTypes,e):o.fill(1,e,e+n),s)for(let r=0;r<s.length;r++)o[e+s[r]/i-1]=0;o[e+n-1]=0}}function ji(t){return Array.isArray(t)&&t.length>0&&!Number.isFinite(t[0])}const Gi="layout(std140) uniform solidPolygonUniforms {\n bool extruded;\n bool isWireframe;\n float elevationScale;\n} solidPolygon;\n",Vi={name:"solidPolygon",vs:Gi,fs:Gi,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}},Wi="in vec4 fillColors;\nin vec4 lineColors;\nin vec3 pickingColors;\nout vec4 vColor;\nstruct PolygonProps {\nvec3 positions;\nvec3 positions64Low;\nvec3 normal;\nfloat elevations;\n};\nvec3 project_offset_normal(vec3 vector) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\nreturn normalize(vector * project.commonUnitsPerWorldUnit);\n}\nreturn project_normal(vector);\n}\nvoid calculatePosition(PolygonProps props) {\nvec3 pos = props.positions;\nvec3 pos64Low = props.positions64Low;\nvec3 normal = props.normal;\nvec4 colors = solidPolygon.isWireframe ? lineColors : fillColors;\ngeometry.worldPosition = props.positions;\ngeometry.pickingColor = pickingColors;\nif (solidPolygon.extruded) {\npos.z += props.elevations * solidPolygon.elevationScale;\n}\ngl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (solidPolygon.extruded) {\n#ifdef IS_SIDE_VERTEX\nnormal = project_offset_normal(normal);\n#else\nnormal = project_normal(normal);\n#endif\ngeometry.normal = normal;\nvec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, colors.a * layer.opacity);\n} else {\nvColor = vec4(colors.rgb, colors.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",$i=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader\nin vec3 vertexPositions;\nin vec3 vertexPositions64Low;\nin float elevations;\n${Wi}\nvoid main(void) {\nPolygonProps props;\nprops.positions = vertexPositions;\nprops.positions64Low = vertexPositions64Low;\nprops.elevations = elevations;\nprops.normal = vec3(0.0, 0.0, 1.0);\ncalculatePosition(props);\n}\n`,Hi=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader-side\n#define IS_SIDE_VERTEX\nin vec2 positions;\nin vec3 vertexPositions;\nin vec3 nextVertexPositions;\nin vec3 vertexPositions64Low;\nin vec3 nextVertexPositions64Low;\nin float elevations;\nin float instanceVertexValid;\n${Wi}\nvoid main(void) {\nif(instanceVertexValid < 0.5){\ngl_Position = vec4(0.);\nreturn;\n}\nPolygonProps props;\nvec3 pos;\nvec3 pos64Low;\nvec3 nextPos;\nvec3 nextPos64Low;\n#if RING_WINDING_ORDER_CW == 1\npos = vertexPositions;\npos64Low = vertexPositions64Low;\nnextPos = nextVertexPositions;\nnextPos64Low = nextVertexPositions64Low;\n#else\npos = nextVertexPositions;\npos64Low = nextVertexPositions64Low;\nnextPos = vertexPositions;\nnextPos64Low = vertexPositions64Low;\n#endif\nprops.positions = mix(pos, nextPos, positions.x);\nprops.positions64Low = mix(pos64Low, nextPos64Low, positions.x);\nprops.normal = vec3(\npos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),\nnextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),\n0.0);\nprops.elevations = elevations * positions.y;\ncalculatePosition(props);\n}\n`,Yi=[0,0,0,255],Ki={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:Yi},getLineColor:{type:"accessor",value:Yi},material:!0},qi={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t};class Zi extends on{getShaders(t){return super.getShaders({vs:"top"===t?$i:Hi,fs:"#version 300 es\n#define SHADER_NAME solid-polygon-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:{RING_WINDING_ORDER_CW:this.props._normalize||"CCW"!==this.props._windingOrder?1:0},modules:[$,G,H,Vi]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const{viewport:t}=this.context;let{coordinateSystem:e}=this.props;const{_full3d:n}=this.props;let i;t.isGeospatial&&"default"===e&&(e="lnglat"),"lnglat"===e&&(i=n?t.projectPosition.bind(t):t.projectFlat.bind(t)),this.setState({numInstances:0,polygonTesselator:new Ui({preproject:i,fp64:this.use64bitPositions(),IndexType:Uint32Array})});const o=this.getAttributeManager(),s=!0;o.remove(["instancePickingColors"]),o.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:qi,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:s},elevations:{size:1,stepMode:"dynamic",transition:qi,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:qi,accessor:"getFillColor",defaultValue:Yi},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:qi,accessor:"getLineColor",defaultValue:Yi},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(t,{index:e,target:n})=>this.encodePickingColor(t&&t.__source?t.__source.index:e,n)}})}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n}=e,i=this.props.data;return i[0]&&i[0].__source&&(e.object=i.find(t=>t.__source.index===n)),e}disablePickingIndex(t){const e=this.props.data;if(e[0]&&e[0].__source)for(let n=0;n<e.length;n++)e[n].__source.index===t&&this._disablePickingIndex(n);else super.disablePickingIndex(t)}draw({uniforms:t}){const{extruded:e,filled:n,wireframe:i,elevationScale:o}=this.props,{topModel:s,sideModel:r,wireframeModel:a,polygonTesselator:l}=this.state,c={extruded:Boolean(e),elevationScale:o,isWireframe:!1};a&&i&&(a.setInstanceCount(l.instanceCount-1),a.shaderInputs.setProps({solidPolygon:{...c,isWireframe:!0}}),a.draw(this.context.renderPass)),r&&n&&(r.setInstanceCount(l.instanceCount-1),r.shaderInputs.setProps({solidPolygon:c}),r.draw(this.context.renderPass)),s&&n&&(s.setVertexCount(l.vertexCount),s.shaderInputs.setProps({solidPolygon:c}),s.draw(this.context.renderPass))}updateState(t){super.updateState(t),this.updateGeometry(t);const{props:e,oldProps:n,changeFlags:i}=t,o=this.getAttributeManager();(i.extensionsChanged||e.filled!==n.filled||e.extruded!==n.extruded)&&(this.state.models?.forEach(t=>t.destroy()),this.setState(this._getModels()),o.invalidateAll())}updateGeometry({props:t,oldProps:e,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPolygon)){const{polygonTesselator:e}=this.state,i=t.data.attributes||{};e.updateGeometry({data:t.data,normalize:t._normalize,geometryBuffer:i.getPolygon,buffers:i,getGeometry:t.getPolygon,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:n.dataChanged,full3d:t._full3d}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),n.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){const{id:t,filled:e,extruded:n}=this.props;let i,o,s;if(e){const e=this.getShaders("top");e.defines.NON_INSTANCED_MODEL=1;const n=this.getAttributeManager().getBufferLayouts({isInstanced:!1});i=new Nt(this.context.device,{...e,id:`${t}-top`,topology:"triangle-list",bufferLayout:n,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(n){const e=this.getAttributeManager().getBufferLayouts({isInstanced:!0});o=new Nt(this.context.device,{...this.getShaders("side"),id:`${t}-side`,bufferLayout:e,geometry:new Ut({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),s=new Nt(this.context.device,{...this.getShaders("side"),id:`${t}-wireframe`,bufferLayout:e,geometry:new Ut({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[o,s,i].filter(Boolean),topModel:i,sideModel:o,wireframeModel:s}}calculateIndices(t){const{polygonTesselator:e}=this.state;t.startIndices=e.indexStarts,t.value=e.get("indices")}calculatePositions(t){const{polygonTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("positions")}calculateVertexValid(t){t.value=this.state.polygonTesselator.get("vertexValid")}}function Xi({data:t,getIndex:e,dataRange:n,replace:i}){const{startRow:o=0,endRow:s=1/0}=n,r=t.length;let a=r,l=r;for(let d=0;d<r;d++){const n=e(t[d]);if(a>d&&n>=o&&(a=d),n>=s){l=d;break}}let c=a;const u=l-a!==i.length?t.slice(l):void 0;for(let d=0;d<i.length;d++)t[c++]=i[d];if(u){for(let e=0;e<u.length;e++)t[c++]=u[e];t.length=c}return{startRow:a,endRow:a+i.length}}Zi.defaultProps=Ki,Zi.layerName="SolidPolygonLayer";const Ji=[0,0,0,255],Qi={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:t=>t.polygon},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:Ji},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0};class to extends rn{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&t.defaultLogger.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:t}){const e=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getPolygon);if(e&&Array.isArray(t.dataChanged)){const e=this.state.paths.slice(),n=t.dataChanged.map(t=>Xi({data:e,getIndex:t=>t.__source.index,dataRange:t,replace:this._getPaths(t)}));this.setState({paths:e,pathsDiff:n})}else e&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(t={}){const{data:e,getPolygon:n,positionFormat:i,_normalize:o}=this.props,s=[],r="XY"===i?2:3,{startRow:a,endRow:l}=t,{iterable:c,objectInfo:u}=Kt(e,a,l);for(const d of c){u.index++;let t=n(d,u);o&&(t=ki(t,r));const{holeIndices:e}=t,i=t.positions||t;if(e)for(let n=0;n<=e.length;n++){const t=i.slice(e[n-1]||0,e[n]||i.length);s.push(this.getSubLayerRow({path:t},d,u.index))}else s.push(this.getSubLayerRow({path:i},d,u.index))}return s}renderLayers(){const{data:t,_dataDiff:e,stroked:n,filled:i,extruded:o,wireframe:s,_normalize:r,_windingOrder:a,elevationScale:l,transitions:c,positionFormat:u}=this.props,{lineWidthUnits:d,lineWidthScale:f,lineWidthMinPixels:p,lineWidthMaxPixels:h,lineJointRounded:g,lineMiterLimit:m,lineDashJustified:v}=this.props,{getFillColor:y,getLineColor:x,getLineWidth:_,getLineDashArray:b,getElevation:P,getPolygon:C,updateTriggers:L,material:w}=this.props,{paths:S,pathsDiff:A}=this.state,O=this.getSubLayerClass("fill",Zi),T=this.getSubLayerClass("stroke",wi),I=this.shouldRenderSubLayer("fill",S)&&new O({_dataDiff:e,extruded:o,elevationScale:l,filled:i,wireframe:s,_normalize:r,_windingOrder:a,getElevation:P,getFillColor:y,getLineColor:o&&s?x:Ji,material:w,transitions:c},this.getSubLayerProps({id:"fill",updateTriggers:L&&{getPolygon:L.getPolygon,getElevation:L.getElevation,getFillColor:L.getFillColor,lineColors:o&&s,getLineColor:L.getLineColor}}),{data:t,positionFormat:u,getPolygon:C});return[!o&&I,!o&&n&&this.shouldRenderSubLayer("stroke",S)&&new T({_dataDiff:A&&(()=>A),widthUnits:d,widthScale:f,widthMinPixels:p,widthMaxPixels:h,jointRounded:g,miterLimit:m,dashJustified:v,_pathType:"loop",transitions:c&&{getWidth:c.getLineWidth,getColor:c.getLineColor,getPath:c.getPolygon},getColor:this.getSubLayerAccessor(x),getWidth:this.getSubLayerAccessor(_),getDashArray:this.getSubLayerAccessor(b)},this.getSubLayerProps({id:"stroke",updateTriggers:L&&{getWidth:L.getLineWidth,getColor:L.getLineColor,getDashArray:L.getLineDashArray}}),{data:S,positionFormat:u,getPath:t=>t.path}),o&&I]}}to.layerName="PolygonLayer",to.defaultProps=Qi;const eo="layout(std140) uniform sdfUniforms {\n float gamma;\n bool enabled;\n float buffer;\n float outlineBuffer;\n vec4 outlineColor;\n} sdf;\n",no={name:"sdf",vs:eo,fs:eo,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}},io={none:0,start:1,center:2,end:3},oo={name:"text",vs:`layout(std140) uniform textUniforms {\n highp vec2 cutoffPixels;\n highp ivec2 align;\n highp float fontSize;\n bool flipY;\n} text;\n\n#define ALIGN_MODE_START ${io.start}\n#define ALIGN_MODE_CENTER ${io.center}\n#define ALIGN_MODE_END ${io.end}\n`,getUniforms:({contentCutoffPixels:t=[0,0],contentAlignHorizontal:e="none",contentAlignVertical:n="none",fontSize:i,viewport:o})=>({cutoffPixels:t,align:[io[e],io[n]],fontSize:i,flipY:o?.flipY??!1}),uniformTypes:{cutoffPixels:"vec2<f32>",align:"vec2<i32>",fontSize:"f32",flipY:"f32"}},so=.75;class ro extends zn{getShaders(){const t=super.getShaders();return{...t,modules:[...t.modules,oo,no],vs:"#version 300 es\n#define SHADER_NAME multi-icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nin vec4 instanceClipRect;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nfloat getPixelOffsetFromAlignment(float anchor, float extent, float clipStart, float clipEnd, int mode) {\nif (clipEnd < clipStart) return 0.0;\nif (mode == ALIGN_MODE_START) {\nreturn max(- (anchor + clipStart), 0.0);\n}\nif (mode == ALIGN_MODE_CENTER) {\nfloat _min = max(0., anchor + clipStart);\nfloat _max = min(extent, anchor + clipEnd);\nreturn _min < _max ? (_min + _max) / 2.0 - anchor : 0.0;\n}\nif (mode == ALIGN_MODE_END) {\nreturn min(extent - (anchor + clipEnd), 0.);\n}\nreturn 0.0;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),\nicon.sizeMinPixels, icon.sizeMaxPixels\n);\nfloat instanceScale = sizePixels / text.fontSize;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nvec2 anchorPosScreen;\nif (icon.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nanchorPosScreen = gl_Position.xy / gl_Position.w;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nif (text.flipY) {\noffset_common.y *= -1.;\n}\nDECKGL_FILTER_SIZE(offset_common, geometry);\nvec4 anchorPos = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0));\nanchorPosScreen = anchorPos.xy / anchorPos.w;\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nanchorPosScreen = vec2(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 * project.viewportSize / project.devicePixelRatio;\nvec2 xy = project_size_to_pixel(instanceClipRect.xy);\nvec2 wh = project_size_to_pixel(instanceClipRect.zw);\nif (text.flipY) {\nxy.y = -xy.y - wh.y;\n}\nif (text.align.x > 0 || text.align.y > 0) {\nvec2 viewportPixels = project.viewportSize / project.devicePixelRatio;\nvec2 scrollPixels = vec2(\ngetPixelOffsetFromAlignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x),\n-getPixelOffsetFromAlignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y)\n);\npixelOffset += scrollPixels;\ngl_Position.xy += project_pixel_size_to_clipspace(scrollPixels);\n}\nif (instanceClipRect.z >= 0.) {\nif (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) {\ngl_Position = vec4(0.0);\n}\nelse if (text.cutoffPixels.x > 0.) {\nfloat vpWidth = project.viewportSize.x / project.devicePixelRatio;\nfloat l = max(anchorPosScreen.x + xy.x, 0.0);\nfloat r = min(anchorPosScreen.x + xy.x + wh.x, vpWidth);\nif (r - l < text.cutoffPixels.x) {\ngl_Position = vec4(0.0);\n}\n}\n}\nif (instanceClipRect.w >= 0.) {\nif (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) {\ngl_Position = vec4(0.0);\n}\nelse if (text.cutoffPixels.y > 0.) {\nfloat vpHeight = project.viewportSize.y / project.devicePixelRatio;\nfloat t = max(anchorPosScreen.y - xy.y - wh.y, 0.0);\nfloat b = min(anchorPosScreen.y - xy.y, vpHeight);\nif (b - t < text.cutoffPixels.y) {\ngl_Position = vec4(0.0);\n}\n}\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / icon.iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME multi-icon-layer-fragment-shader\nprecision highp float;\nuniform sampler2D iconsTexture;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nif (!bool(picking.isActive)) {\nfloat alpha = texture(iconsTexture, vTextureCoords).a;\nvec4 color = vColor;\nif (sdf.enabled) {\nfloat distance = alpha;\nalpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);\nif (sdf.outlineBuffer > 0.0) {\nfloat inFill = alpha;\nfloat inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);\ncolor = mix(sdf.outlineColor, vColor, inFill);\nalpha = inBorder;\n}\n}\nfloat a = alpha * color.a;\nif (a < icon.alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color.rgb, a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){super.initializeState();const t=this.getAttributeManager();t.attributes.instanceIconDefs.settings.update=this.calculateInstanceIconDefs,t.addInstanced({instancePickingColors:{type:"uint8",size:4,accessor:(t,{index:e,target:n})=>this.encodePickingColor(e,n)},instanceClipRect:{size:4,accessor:"getContentBox",defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);const{props:n,oldProps:i,changeFlags:o}=e,{outlineColor:s}=n;if(o.updateTriggersChanged&&(o.updateTriggersChanged.getIcon||o.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate("instanceIconDefs"),s!==i.outlineColor){const t=[s[0]/255,s[1]/255,s[2]/255,(s[3]??255)/255];this.setState({outlineColor:t})}!n.sdf&&n.outlineWidth&&t.defaultLogger.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(t){const{sdf:e,smoothing:n,fontSize:i,outlineWidth:o,contentCutoffPixels:s,contentAlignHorizontal:r,contentAlignVertical:a}=this.props,{outlineColor:l}=this.state,c=o?Math.max(n,so*(1-o)):-1,u=this.state.model,d={buffer:so,outlineBuffer:c,gamma:n,enabled:Boolean(e),outlineColor:l},f={contentCutoffPixels:s,contentAlignHorizontal:r,contentAlignVertical:a,fontSize:i,viewport:this.context.viewport};if(u.shaderInputs.setProps({sdf:d,text:f}),super.draw(t),e&&o){const{iconManager:t}=this.state;t.getTexture()&&(u.shaderInputs.setProps({sdf:{...d,outlineBuffer:so}}),u.draw(this.context.renderPass))}}calculateInstanceIconDefs(t,{startRow:e,endRow:n}){const{data:i,getIcon:o,getIconOffsets:s}=this.props;let r=t.getVertexOffset(e);const a=t.value,{iterable:l,objectInfo:c}=Kt(i,e,n);for(const u of l){c.index++;const e=o(u,c),n=s(u,c);if(e){let i=0;for(const o of Array.from(e)){const e=super.getInstanceIconDef(o);e[0]=n[2*i],e[1]+=n[2*i+1],e[6]=1,a.set(e,r),r+=t.size,i++}}}}}ro.defaultProps={getIconOffsets:{type:"accessor",value:t=>t.offsets},getContentBox:{type:"accessor",value:[0,0,-1,-1]},fontSize:1,alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none"},ro.layerName="MultiIconLayer";const ao=1e20;class lo{constructor({fontSize:t=24,buffer:e=3,radius:n=8,cutoff:i=.25,fontFamily:o="sans-serif",fontWeight:s="normal",fontStyle:r="normal",lang:a=null}={}){this.buffer=e,this.cutoff=i,this.radius=n,this.lang=a;const l=this.size=t+4*e,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${r} ${s} ${t}px ${o}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:i,actualBoundingBoxLeft:o,actualBoundingBoxRight:s}=this.ctx.measureText(t),r=Math.ceil(n),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-o))),l=Math.min(this.size-this.buffer,r+Math.ceil(i)),c=a+2*this.buffer,u=l+2*this.buffer,d=Math.max(c*u,0),f=new Uint8ClampedArray(d),p={data:f,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:r,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:h,buffer:g,gridInner:m,gridOuter:v}=this;this.lang&&(h.lang=this.lang),h.clearRect(g,g,a,l),h.fillText(t,g,g+r);const y=h.getImageData(g,g,a,l);v.fill(ao,0,d),m.fill(0,0,d);for(let x=0;x<l;x++)for(let t=0;t<a;t++){const e=y.data[4*(x*a+t)+3]/255;if(0===e)continue;const n=(x+g)*c+t+g;if(1===e)v[n]=0,m[n]=ao;else{const t=.5-e;v[n]=t>0?t*t:0,m[n]=t<0?t*t:0}}co(v,0,0,c,u,c,this.f,this.v,this.z),co(m,g,g,a,l,c,this.f,this.v,this.z);for(let x=0;x<d;x++){const t=Math.sqrt(v[x])-Math.sqrt(m[x]);f[x]=Math.round(255-255*(t/this.radius+this.cutoff))}return p}}function co(t,e,n,i,o,s,r,a,l){for(let c=e;c<e+i;c++)uo(t,n*s+c,s,o,r,a,l);for(let c=n;c<n+o;c++)uo(t,c*s+e,1,i,r,a,l)}function uo(t,e,n,i,o,s,r){s[0]=0,r[0]=-ao,r[1]=ao,o[0]=t[e];for(let a=1,l=0,c=0;a<i;a++){o[a]=t[e+a*n];const i=a*a;do{const t=s[l];c=(o[a]-o[t]+i-t*t)/(a-t)/2}while(c<=r[l]&&--l>-1);l++,s[l]=a,r[l]=c,r[l+1]=ao}for(let a=0,l=0;a<i;a++){for(;r[l+1]<a;)l++;const i=s[l],c=a-i;t[e+a*n]=o[i]+c*c}}const fo=[];function po(t,e,n,i){let o=0;for(let s=e;s<n;s++){const e=t[s];o+=i[e]?.advance||0}return o}function ho(t,e,n,i,o,s){let r=e,a=0;for(let l=e;l<n;l++){const e=po(t,l,l+1,o);a+e>i&&(r<l&&s.push(l),r=l,a=0),a+=e}return a}function go(t,e,n,i,o=0,s){void 0===s&&(s=t.length);const r=[];return"break-all"===e?ho(t,o,s,n,i,r):function(t,e,n,i,o,s){let r=e,a=e,l=e,c=0;for(let u=e;u<n;u++)if(" "===t[u]?l=u+1:" "!==t[u+1]&&u+1!==n||(l=u+1),l>a){let e=po(t,a,l,o);c+e>i&&(r<a&&(s.push(a),r=a,c=0),e>i&&(e=ho(t,a,l,i,o,s),r=s[s.length-1])),a=l,c+=e}}(t,o,s,n,i,r),r}function mo(e,n,i,o,s,r){let a=0,l=0;for(let t=n;t<i;t++){const n=o[e[t]];n&&(l=Math.max(l,n.height))}for(let c=n;c<i;c++){const n=e[c],i=o[n];i?(s[c]=a+i.anchorX,a+=i.advance):(t.defaultLogger.warn(`Missing character: ${n} (${n.codePointAt(0)})`)(),s[c]=a,a+=32)}r[0]=a,r[1]=l}class vo{constructor(t=5){this._cache={},this._order=[],this.limit=t}get(t){const e=this._cache[t];return e&&(this._deleteOrder(t),this._appendOrder(t)),e}set(t,e){this._cache[t]?(this.delete(t),this._cache[t]=e,this._appendOrder(t)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[t]=e,this._appendOrder(t))}delete(t){this._cache[t]&&(delete this._cache[t],this._deleteOrder(t))}_deleteOrder(t){const e=this._order.indexOf(t);e>=0&&this._order.splice(e,1)}_appendOrder(t){this._order.push(t)}}const yo={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:function(){const t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1};let xo=new vo(3);function _o(t,e,n,i){t.font=`${i} ${n}px ${e}`,t.fillStyle="#000",t.textBaseline="alphabetic",t.textAlign="left"}class bo{constructor(){this.props={...yo}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}setProps(t={}){Object.assign(this.props,t),t._getFontRenderer&&(this._getFontRenderer=t._getFontRenderer),this._key=this._getKey();const e=function(t,e){let n;n="string"==typeof e?new Set(Array.from(e)):new Set(e);const i=xo.get(t);if(!i)return n;for(const o in i.mapping)n.has(o)&&n.delete(o);return n}(this._key,this.props.characterSet),n=xo.get(this._key);if(n&&0===e.size)return void(this._atlas!==n&&(this._atlas=n));const i=this._generateFontAtlas(e,n);this._atlas=i,xo.set(this._key,i)}_generateFontAtlas(t,e){const{fontFamily:n,fontWeight:i,fontSize:o,buffer:s,sdf:r,radius:a,cutoff:l}=this.props;let c=e&&e.data;c||(c=document.createElement("canvas"),c.width=1024);const u=c.getContext("2d",{willReadFrequently:!0});_o(u,n,o,i);const d=t=>function(t,e,n){if(void 0===n){const n=t.measureText("A");return n.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(n.fontBoundingBoxAscent),descent:Math.ceil(n.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:.9*e,descent:.3*e}}const i=t.measureText(n);return i.actualBoundingBoxAscent?{advance:i.width,width:Math.ceil(i.actualBoundingBoxRight-i.actualBoundingBoxLeft),ascent:Math.ceil(i.actualBoundingBoxAscent),descent:Math.ceil(i.actualBoundingBoxDescent)}:{advance:i.width,width:i.width,ascent:.9*e,descent:.3*e}}(u,o,t);let f;this._getFontRenderer?f=this._getFontRenderer(this.props):r&&(f={measure:d,draw:Po(this.props)});const{mapping:p,canvasHeight:h,xOffset:g,yOffsetMin:m,yOffsetMax:v}=function({characterSet:t,measureText:e,buffer:n,maxCanvasWidth:i,mapping:o={},xOffset:s=0,yOffsetMin:r=0,yOffsetMax:a=0}){let l=s,c=r,u=a;for(const f of t)if(!o[f]){const{advance:t,width:s,ascent:r,descent:a}=e(f),d=r+a;l+s+2*n>i&&(l=0,c=u),o[f]={x:l+n,y:c+n,width:s,height:d,advance:t,anchorX:s/2,anchorY:r},l+=s+2*n,u=Math.max(u,c+d+2*n)}return{mapping:o,xOffset:l,yOffsetMin:c,yOffsetMax:u,canvasHeight:(d=u,Math.pow(2,Math.ceil(Math.log2(d))))};var d}({measureText:t=>f?f.measure(t):d(t),buffer:s,characterSet:t,maxCanvasWidth:1024,...e&&{mapping:e.mapping,xOffset:e.xOffset,yOffsetMin:e.yOffsetMin,yOffsetMax:e.yOffsetMax}});if(c.height!==h){const t=c.height>0?u.getImageData(0,0,c.width,c.height):null;c.height=h,t&&u.putImageData(t,0,0)}if(_o(u,n,o,i),f)for(const x of t){const t=p[x],{data:e,left:n=0,top:i=0}=f.draw(x),o=t.x-n,s=t.y-i,r=Math.max(0,Math.round(o)),a=Math.max(0,Math.round(s)),l=Math.min(e.width,c.width-r),d=Math.min(e.height,c.height-a);u.putImageData(e,r,a,0,0,l,d),t.x+=r-o,t.y+=a-s}else for(const x of t){const t=p[x];u.fillText(x,t.x,t.y+t.anchorY)}const y=f?f.measure():d();return{baselineOffset:(y.ascent-y.descent)/2,xOffset:g,yOffsetMin:m,yOffsetMax:v,mapping:p,data:c,width:c.width,height:c.height}}_getKey(){const{fontFamily:t,fontWeight:e,fontSize:n,buffer:i,sdf:o,radius:s,cutoff:r}=this.props;return o?`${t} ${e} ${n} ${i} ${s} ${r}`:`${t} ${e} ${n} ${i}`}}function Po({fontSize:t,buffer:e,radius:n,cutoff:i,fontFamily:o,fontWeight:s}){const r=new lo({fontSize:t,buffer:e,radius:n,cutoff:i,fontFamily:o,fontWeight:`${s}`});return t=>{const{data:n,width:i,height:o}=r.draw(t),s=new ImageData(i,o);return function(t,e){for(let n=0;n<t.length;n++)e.data[4*n+3]=t[n]}(n,s),{data:s,left:e,top:e}}}const Co="layout(std140) uniform textBackgroundUniforms {\n bool billboard;\n float sizeScale;\n float sizeMinPixels;\n float sizeMaxPixels;\n vec4 borderRadius;\n vec4 padding;\n highp int sizeUnits;\n bool stroked;\n} textBackground;\n",Lo={name:"textBackground",vs:Co,fs:Co,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}},wo={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,fontSize:1,borderRadius:{type:"object",value:0},padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getClipRect:{type:"accessor",value:[0,0,-1,-1]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}};class So extends on{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME text-background-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceRects;\nin vec4 instanceClipRect;\nin float instanceSizes;\nin float instanceAngles;\nin vec2 instancePixelOffsets;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout float vLineWidth;\nout vec2 uv;\nout vec2 dimensions;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = radians(angle);\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvLineWidth = instanceLineWidths;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits),\ntextBackground.sizeMinPixels, textBackground.sizeMaxPixels\n);\nfloat instanceScale = sizePixels / text.fontSize;\ndimensions = instanceRects.zw * instanceScale + textBackground.padding.xy + textBackground.padding.zw;\nvec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * instanceScale + mix(-textBackground.padding.xy, textBackground.padding.zw, positions);\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles);\npixelOffset += instancePixelOffsets;\npixelOffset.y *= -1.0;\nvec2 xy = project_size_to_pixel(instanceClipRect.xy);\nvec2 wh = project_size_to_pixel(instanceClipRect.zw);\nif (text.flipY) {\nxy.y = -xy.y - wh.y;\n}\nif (instanceClipRect.z >= 0.0) {\ndimensions.x = wh.x;\npixelOffset.x = xy.x + uv.x * wh.x + mix(-textBackground.padding.x, textBackground.padding.z, uv.x);\n}\nif (instanceClipRect.w >= 0.0) {\ndimensions.y = wh.y;\npixelOffset.y = xy.y + uv.y * wh.y + mix(-textBackground.padding.y, textBackground.padding.w, uv.y);\n}\nif (textBackground.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nif (text.flipY) {\noffset_common.y *= -1.;\n}\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME text-background-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin float vLineWidth;\nin vec2 uv;\nin vec2 dimensions;\nout vec4 fragColor;\nfloat round_rect(vec2 p, vec2 size, vec4 radii) {\nvec2 pixelPositionCB = (p - 0.5) * size;\nvec2 sizeCB = size * 0.5;\nfloat maxBorderRadius = min(size.x, size.y) * 0.5;\nvec4 borderRadius = vec4(min(radii, maxBorderRadius));\nborderRadius.xy =\n(pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw;\nborderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y;\nvec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x;\nreturn -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x);\n}\nfloat rect(vec2 p, vec2 size) {\nvec2 pixelPosition = p * size;\nreturn min(min(pixelPosition.x, size.x - pixelPosition.x),\nmin(pixelPosition.y, size.y - pixelPosition.y));\n}\nvec4 get_stroked_fragColor(float dist) {\nfloat isBorder = smoothedge(dist, vLineWidth);\nreturn mix(vFillColor, vLineColor, isBorder);\n}\nvoid main(void) {\ngeometry.uv = uv;\nif (textBackground.borderRadius != vec4(0.0)) {\nfloat distToEdge = round_rect(uv, dimensions, textBackground.borderRadius);\nfloat shapeAlpha = smoothedge(-distToEdge, 0.0);\nif (shapeAlpha == 0.0) {\ndiscard;\n}\nif (textBackground.stroked) {\nfragColor = get_stroked_fragColor(distToEdge);\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= shapeAlpha;\n} else {\nif (textBackground.stroked) {\nfloat distToEdge = rect(uv, dimensions);\nfragColor = get_stroked_fragColor(distToEdge);\n} else {\nfragColor = vFillColor;\n}\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[$,H,Lo,oo]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instanceClipRect:{size:4,accessor:"getClipRect",defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(t){super.updateState(t);const{changeFlags:e}=t;e.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{billboard:n,sizeScale:i,sizeUnits:o,sizeMinPixels:s,sizeMaxPixels:r,getLineWidth:a,fontSize:l}=this.props;let{padding:c,borderRadius:u}=this.props;c.length<4&&(c=[c[0],c[1],c[0],c[1]]),Array.isArray(u)||(u=[u,u,u,u]);const d=this.state.model,f={billboard:n,stroked:Boolean(a),borderRadius:u,padding:c,sizeUnits:t.UNIT[o],sizeScale:i,sizeMinPixels:s,sizeMaxPixels:r},p={fontSize:l,viewport:this.context.viewport};d.shaderInputs.setProps({textBackground:f,text:p}),d.draw(this.context.renderPass)}_getModel(){return new Nt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ut({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array([0,0,1,0,0,1,1,1])}}}),isInstanced:!0})}}So.defaultProps=wo,So.layerName="TextBackgroundLayer";const Ao={start:1,middle:0,end:-1},Oo={top:1,center:0,bottom:-1},To=[0,0,0,255],Io={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:To},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:yo.characterSet},fontFamily:yo.fontFamily,fontWeight:yo.fontWeight,lineHeight:1,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:To},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none",getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:To},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},getContentBox:{type:"accessor",value:[0,0,-1,-1]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}};class Eo extends rn{constructor(){super(...arguments),this.getBoundingRect=(t,e)=>{const{size:[n,i]}=this.transformParagraph(t,e),{getTextAnchor:o,getAlignmentBaseline:s}=this.props;return[(Ao["function"==typeof o?o(t,e):o]-1)*n/2,(Oo["function"==typeof s?s(t,e):s]-1)*i/2,n,i]},this.getIconOffsets=(t,e)=>{const{getTextAnchor:n,getAlignmentBaseline:i}=this.props,{x:o,y:s,rowWidth:r,size:[,a]}=this.transformParagraph(t,e),l=Ao["function"==typeof n?n(t,e):n],c=Oo["function"==typeof i?i(t,e):i],u=o.length,d=new Array(2*u);let f=0;for(let p=0;p<u;p++)d[f++]=(l-1)*r[p]/2+o[p],d[f++]=(c-1)*a/2+s[p];return d}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new bo},this.props.maxWidth>0&&t.defaultLogger.once(1,"v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(t){const{props:e,oldProps:n,changeFlags:i}=t;(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getText))&&this._updateText();(this._updateFontAtlas()||e.lineHeight!==n.lineHeight||e.wordBreak!==n.wordBreak||e.maxWidth!==n.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:t}){return t.object=t.index>=0?this.props.data[t.index]:null,t}_updateFontAtlas(){const{fontSettings:t,fontFamily:e,fontWeight:n,_getFontRenderer:i}=this.props,{fontAtlasManager:o,characterSet:s}=this.state,r={...t,characterSet:s,fontFamily:e,fontWeight:n,_getFontRenderer:i};if(!o.mapping)return o.setProps(r),!0;for(const a in r)if(r[a]!==o.props[a])return o.setProps(r),!0;return!1}_updateText(){const{data:t,characterSet:e}=this.props,n=t.attributes?.getText;let i,{getText:o}=this.props,s=t.startIndices;const r="auto"===e&&new Set;if(n&&s){const{texts:e,characterCount:a}=function({value:t,length:e,stride:n,offset:i,startIndices:o,characterSet:s}){const r=t.BYTES_PER_ELEMENT,a=n?n/r:1,l=i?i/r:0,c=o[e]||Math.ceil((t.length-l)/a),u=s&&new Set,d=new Array(e);let f=t;if(a>1||l>0){f=new(0,t.constructor)(c);for(let e=0;e<c;e++)f[e]=t[e*a+l]}for(let p=0;p<e;p++){const t=o[p],e=o[p+1]||c,n=f.subarray(t,e);d[p]=String.fromCodePoint.apply(null,n),u&&n.forEach(u.add,u)}if(u)for(const p of u)s.add(String.fromCodePoint(p));return{texts:d,characterCount:c}}({...ArrayBuffer.isView(n)?{value:n}:n,length:t.length,startIndices:s,characterSet:r});i=a,o=(t,{index:n})=>e[n]}else{const{iterable:e,objectInfo:n}=Kt(t);s=[0],i=0;for(const t of e){n.index++;const e=Array.from(o(t,n)||"");r&&e.forEach(r.add,r),i+=e.length,s.push(i)}}this.setState({getText:o,startIndices:s,numInstances:i,characterSet:r||e})}transformParagraph(t,e){const{fontAtlasManager:n}=this.state,i=n.mapping,{baselineOffset:o}=n.atlas,{fontSize:s}=n.props,r=this.state.getText,{wordBreak:a,lineHeight:l,maxWidth:c}=this.props;return function(t,e,n,i,o,s){const r=Array.from(t),a=r.length,l=new Array(a),c=new Array(a),u=new Array(a),d=("break-word"===i||"break-all"===i)&&isFinite(o)&&o>0,f=[0,0],p=[0,0];let h=0,g=e+n/2,m=0,v=0;for(let y=0;y<=a;y++){const t=r[y];if("\n"!==t&&y!==a||(v=y),v>m){const t=d?go(r,i,o,s,m,v):fo;for(let e=0;e<=t.length;e++){const i=0===e?m:t[e-1],o=e<t.length?t[e]:v;mo(r,i,o,s,l,p);for(let t=i;t<o;t++)c[t]=g,u[t]=p[0];h++,g+=n,f[0]=Math.max(f[0],p[0])}m=v}"\n"===t&&(l[m]=0,c[m]=0,u[m]=0,m++)}return f[1]=h*n,{x:l,y:c,rowWidth:u,size:f}}(r(t,e)||"",o,l*s,a,c*s,i)}renderLayers(){const{startIndices:t,numInstances:e,getText:n,fontAtlasManager:{atlas:i,mapping:o},styleVersion:s}=this.state,{data:r,_dataDiff:a,getPosition:l,getColor:c,getSize:u,getAngle:d,getPixelOffset:f,getBackgroundColor:p,getBorderColor:h,getBorderWidth:g,getContentBox:m,backgroundBorderRadius:v,backgroundPadding:y,background:x,billboard:_,fontSettings:b,outlineWidth:P,outlineColor:C,sizeScale:L,sizeUnits:w,sizeMinPixels:S,sizeMaxPixels:A,contentCutoffPixels:O,contentAlignHorizontal:T,contentAlignVertical:I,transitions:E,updateTriggers:M}=this.props,z=this.getSubLayerClass("characters",ro),R=this.getSubLayerClass("background",So),{fontSize:F}=this.state.fontAtlasManager.props;return[x&&new R({getFillColor:p,getLineColor:h,getLineWidth:g,borderRadius:v,padding:y,getPosition:l,getSize:u,getAngle:d,getPixelOffset:f,getClipRect:m,billboard:_,sizeScale:L,sizeUnits:w,sizeMinPixels:S,sizeMaxPixels:A,fontSize:F,transitions:E&&{getPosition:E.getPosition,getAngle:E.getAngle,getSize:E.getSize,getFillColor:E.getBackgroundColor,getLineColor:E.getBorderColor,getLineWidth:E.getBorderWidth,getPixelOffset:E.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:M.getPosition,getAngle:M.getAngle,getSize:M.getSize,getFillColor:M.getBackgroundColor,getLineColor:M.getBorderColor,getLineWidth:M.getBorderWidth,getPixelOffset:M.getPixelOffset,getBoundingRect:{getText:M.getText,getTextAnchor:M.getTextAnchor,getAlignmentBaseline:M.getAlignmentBaseline,styleVersion:s}}}),{data:r.attributes&&r.attributes.background?{length:r.length,attributes:r.attributes.background}:r,_dataDiff:a,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new z({sdf:b.sdf,smoothing:Number.isFinite(b.smoothing)?b.smoothing:yo.smoothing,outlineWidth:P/(b.radius||yo.radius),outlineColor:C,iconAtlas:i,iconMapping:o,getPosition:l,getColor:c,getSize:u,getAngle:d,getPixelOffset:f,getContentBox:m,billboard:_,sizeScale:L,sizeUnits:w,sizeMinPixels:S,sizeMaxPixels:A,fontSize:F,contentCutoffPixels:O,contentAlignHorizontal:T,contentAlignVertical:I,transitions:E&&{getPosition:E.getPosition,getAngle:E.getAngle,getColor:E.getColor,getSize:E.getSize,getPixelOffset:E.getPixelOffset,getContentBox:E.getContentBox}},this.getSubLayerProps({id:"characters",updateTriggers:{all:M.getText,getPosition:M.getPosition,getAngle:M.getAngle,getColor:M.getColor,getSize:M.getSize,getPixelOffset:M.getPixelOffset,getContentBox:M.getContentBox,getIconOffsets:{getTextAnchor:M.getTextAnchor,getAlignmentBaseline:M.getAlignmentBaseline,styleVersion:s}}}),{data:r,_dataDiff:a,startIndices:t,numInstances:e,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(e){!function(e){t.defaultLogger.assert(Number.isFinite(e)&&e>=3,"Invalid cache limit"),xo=new vo(e)}(e)}}Eo.defaultProps=Io,Eo.layerName="TextLayer";const Mo={circle:{type:Wn,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:zn,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:Eo,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},zo={type:wi,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},Ro={type:Zi,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Fo({type:t,props:e}){const n={};for(const i in e)n[i]=t.defaultProps[e[i]];return n}function Bo(t,e){const{transitions:n,updateTriggers:i}=t.props,o={updateTriggers:{},transitions:n&&{getPosition:n.geometry}};for(const s in e){const r=e[s];let a=t.props[s];s.startsWith("get")&&(a=t.getSubLayerAccessor(a),o.updateTriggers[r]=i[s],n&&(o.transitions[r]=n[s])),o[r]=a}return o}function ko(e,n,i={}){const o={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:s=0,endRow:r=e.length}=i;for(let a=s;a<r;a++){const i=e[a],{geometry:s}=i;if(s)if("GeometryCollection"===s.type){t.defaultLogger.assert(Array.isArray(s.geometries),"GeoJSON does not have geometries array");const{geometries:e}=s;for(let t=0;t<e.length;t++){No(e[t],o,n,i,a)}}else No(s,o,n,i,a)}return o}function No(e,n,i,o,s){const{type:r,coordinates:a}=e,{pointFeatures:l,lineFeatures:c,polygonFeatures:u,polygonOutlineFeatures:d}=n;if(function(e,n){let i=Do[e];t.defaultLogger.assert(i,`Unknown GeoJSON type ${e}`);for(;n&&--i>0;)n=n[0];return n&&Number.isFinite(n[0])}(r,a))switch(r){case"Point":l.push(i({geometry:e},o,s));break;case"MultiPoint":a.forEach(t=>{l.push(i({geometry:{type:"Point",coordinates:t}},o,s))});break;case"LineString":c.push(i({geometry:e},o,s));break;case"MultiLineString":a.forEach(t=>{c.push(i({geometry:{type:"LineString",coordinates:t}},o,s))});break;case"Polygon":u.push(i({geometry:e},o,s)),a.forEach(t=>{d.push(i({geometry:{type:"LineString",coordinates:t}},o,s))});break;case"MultiPolygon":a.forEach(t=>{u.push(i({geometry:{type:"Polygon",coordinates:t}},o,s)),t.forEach(t=>{d.push(i({geometry:{type:"LineString",coordinates:t}},o,s))})})}else t.defaultLogger.warn(`${r} coordinates are malformed`)()}const Do={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function Uo(t){return t.geometry.coordinates}function jo(t,e){const n={points:{},lines:{},polygons:{},polygonsOutline:{}},{points:i,lines:o,polygons:s}=t,r=function(t,e){const n={points:null,lines:null,polygons:null};for(const i in n){const o=t[i].globalFeatureIds.value;n[i]=new Uint8ClampedArray(4*o.length);const s=[];for(let t=0;t<o.length;t++)e(o[t],s),n[i][4*t+0]=s[0],n[i][4*t+1]=s[1],n[i][4*t+2]=s[2],n[i][4*t+3]=255}return n}(t,e);n.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:4,value:r.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},n.lines.data={length:o.pathIndices.value.length-1,startIndices:o.pathIndices.value,attributes:{...o.attributes,getPath:o.positions,instancePickingColors:{size:4,value:r.lines}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},n.lines._pathType="open";const a=s.positions.value.length/s.positions.size,l=Array(a).fill(1);for(const c of s.primitivePolygonIndices.value)l[c-1]=0;return n.polygons.data={length:s.polygonIndices.value.length-1,startIndices:s.polygonIndices.value,attributes:{...s.attributes,getPolygon:s.positions,instanceVertexValid:{size:1,value:new Uint16Array(l)},pickingColors:{size:4,value:r.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},n.polygons._normalize=!1,s.triangles&&(n.polygons.data.attributes.indices=s.triangles.value),n.polygonsOutline.data={length:s.primitivePolygonIndices.value.length-1,startIndices:s.primitivePolygonIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:4,value:r.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},n.polygonsOutline._pathType="open",n}const Go=["points","linestrings","polygons"],Vo={...Fo(Mo.circle),...Fo(Mo.icon),...Fo(Mo.text),...Fo(zo),...Fo(Ro),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};class Wo extends rn{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:t,changeFlags:e}){if(!e.dataChanged)return;const{data:n}=this.props,i=n&&"points"in n&&"polygons"in n&&"lines"in n;this.setState({binary:i}),i?this._updateStateBinary({props:t,changeFlags:e}):this._updateStateJSON({props:t,changeFlags:e})}_updateStateBinary({props:t,changeFlags:e}){const n=jo(t.data,this.encodePickingColor);this.setState({layerProps:n})}_updateStateJSON({props:e,changeFlags:n}){const i=function(e){if(Array.isArray(e))return e;switch(t.defaultLogger.assert(e.type,"GeoJSON does not have type"),e.type){case"Feature":return[e];case"FeatureCollection":return t.defaultLogger.assert(Array.isArray(e.features),"GeoJSON does not have features array"),e.features;default:return[{geometry:e}]}}(e.data),o=this.getSubLayerRow.bind(this);let s={};const r={};if(Array.isArray(n.dataChanged)){const t=this.state.features;for(const e in t)s[e]=t[e].slice(),r[e]=[];for(const e of n.dataChanged){const n=ko(i,o,e);for(const i in t)r[i].push(Xi({data:s[i],getIndex:t=>t.__source.index,dataRange:e,replace:n[i]}))}}else s=ko(i,o);const a=function(t,e){const n={points:{},lines:{},polygons:{},polygonsOutline:{}},{pointFeatures:i,lineFeatures:o,polygonFeatures:s,polygonOutlineFeatures:r}=t;return n.points.data=i,n.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),n.points.getPosition=Uo,n.lines.data=o,n.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),n.lines.getPath=Uo,n.polygons.data=s,n.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),n.polygons.getPolygon=Uo,n.polygonsOutline.data=r,n.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),n.polygonsOutline.getPath=Uo,n}(s,r);this.setState({features:s,featuresDiff:r,layerProps:a})}getPickingInfo(t){const e=super.getPickingInfo(t),{index:n,sourceLayer:i}=e;return e.featureType=Go.find(t=>i.id.startsWith(`${this.id}-${t}-`)),n>=0&&i.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(e.index=this.props.data.points.globalFeatureIds.value[n]),e}_updateAutoHighlight(t){const e=`${this.id}-points-`,n="points"===t.featureType;for(const i of this.getSubLayers())i.id.startsWith(e)===n&&i.updateAutoHighlight(t)}_renderPolygonLayer(){const{extruded:t,wireframe:e}=this.props,{layerProps:n}=this.state,i="polygons-fill",o=this.shouldRenderSubLayer(i,n.polygons?.data)&&this.getSubLayerClass(i,Ro.type);if(o){const s=Bo(this,Ro.props),r=t&&e;return r||delete s.getLineColor,s.updateTriggers.lineColors=r,new o(s,this.getSubLayerProps({id:i,updateTriggers:s.updateTriggers}),n.polygons)}return null}_renderLineLayers(){const{extruded:t,stroked:e}=this.props,{layerProps:n}=this.state,i="polygons-stroke",o="linestrings",s=!t&&e&&this.shouldRenderSubLayer(i,n.polygonsOutline?.data)&&this.getSubLayerClass(i,zo.type),r=this.shouldRenderSubLayer(o,n.lines?.data)&&this.getSubLayerClass(o,zo.type);if(s||r){const t=Bo(this,zo.props);return[s&&new s(t,this.getSubLayerProps({id:i,updateTriggers:t.updateTriggers}),n.polygonsOutline),r&&new r(t,this.getSubLayerProps({id:o,updateTriggers:t.updateTriggers}),n.lines)]}return null}_renderPointLayers(){const{pointType:t}=this.props,{layerProps:e,binary:n}=this.state;let{highlightedObjectIndex:i}=this.props;!n&&Number.isFinite(i)&&(i=e.points.data.findIndex(t=>t.__source.index===i));const o=new Set(t.split("+")),s=[];for(const r of o){const t=`points-${r}`,o=Mo[r],a=o&&this.shouldRenderSubLayer(t,e.points?.data)&&this.getSubLayerClass(t,o.type);if(a){const l=Bo(this,o.props);let c=e.points;if("text"===r&&n){const{instancePickingColors:t,...e}=c.data.attributes;c={...c,data:{...c.data,attributes:e}}}s.push(new a(l,this.getSubLayerProps({id:t,updateTriggers:l.updateTriggers,highlightedObjectIndex:i}),c))}}return s}renderLayers(){const{extruded:t}=this.props,e=this._renderPolygonLayer();return[!t&&e,this._renderLineLayers(),this._renderPointLayers(),t&&e]}getSubLayerAccessor(t){const{binary:e}=this.state;return e&&"function"==typeof t?(e,n)=>{const{data:i,index:o}=n,s=function(t,e){if(!t)return null;const n="startIndices"in t?t.startIndices[e]:e,i=t.featureIds.value[n];return-1!==n?function(t,e,n){const i={properties:{...t.properties[e]}};for(const o in t.numericProps)i.properties[o]=t.numericProps[o].value[n];return i}(t,i,n):null}(i,o);return t(s,n)}:super.getSubLayerAccessor(t)}}Wo.layerName="GeoJsonLayer",Wo.defaultProps=Vo,exports.ArcLayer=fn,exports.BitmapLayer=xn,exports.ColumnLayer=mi,exports.CompositeLayer=rn,exports.DynamicTexture=Mt,exports.GeoJsonLayer=Wo,exports.Geometry=Ut,exports.IconLayer=zn,exports.Layer=on,exports.Model=Nt,exports.MultiIconLayer=ro,exports.PathLayer=wi,exports.PointCloudLayer=Dn,exports.PolygonLayer=to,exports.ScatterplotLayer=Wn,exports.ShaderInputs=dt,exports.SolidPolygonLayer=Zi,exports.TextBackgroundLayer=So,exports.TextLayer=Eo,exports.UniformStore=T,exports.color=W,exports.createIterable=Kt,exports.lighting=M,exports.normalizeByteColor3=a,exports.phongMaterial=V,exports.picking=H,exports.project32=$,exports.shaderModuleHasUniforms=lt,exports.uid=X;
|
|
2
|
+
//# sourceMappingURL=geojson-layer-wtQbiowp.cjs.map
|