@deck.gl/geo-layers 9.4.0-alpha.2 → 9.4.0-beta.1
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/dist.dev.js +6375 -5029
- package/dist/geo-cell-layer/GeoCellLayer.d.ts.map +1 -1
- package/dist/geo-cell-layer/GeoCellLayer.js +2 -1
- package/dist/geo-cell-layer/GeoCellLayer.js.map +1 -1
- package/dist/index.cjs +21181 -1889
- package/dist/index.cjs.map +3 -4
- package/dist/mesh-layer/mesh-layer-uniforms.d.ts +1 -0
- package/dist/mesh-layer/mesh-layer-uniforms.d.ts.map +1 -1
- package/dist/mesh-layer/mesh-layer-uniforms.js +8 -0
- package/dist/mesh-layer/mesh-layer-uniforms.js.map +1 -1
- package/dist/mesh-layer/mesh-layer.d.ts.map +1 -1
- package/dist/mesh-layer/mesh-layer.js +15 -6
- package/dist/mesh-layer/mesh-layer.js.map +1 -1
- package/dist/mesh-layer/mesh-layer.wgsl.d.ts +3 -0
- package/dist/mesh-layer/mesh-layer.wgsl.d.ts.map +1 -0
- package/dist/mesh-layer/mesh-layer.wgsl.js +130 -0
- package/dist/mesh-layer/mesh-layer.wgsl.js.map +1 -0
- package/dist/mesh-layer/mesh-pbr-material.d.ts +252 -0
- package/dist/mesh-layer/mesh-pbr-material.d.ts.map +1 -0
- package/dist/mesh-layer/mesh-pbr-material.js +27 -0
- package/dist/mesh-layer/mesh-pbr-material.js.map +1 -0
- package/dist/trips-layer/trips-layer-uniforms.d.ts +1 -0
- package/dist/trips-layer/trips-layer-uniforms.d.ts.map +1 -1
- package/dist/trips-layer/trips-layer-uniforms.js +14 -3
- package/dist/trips-layer/trips-layer-uniforms.js.map +1 -1
- package/dist/trips-layer/trips-layer.d.ts +6 -1
- package/dist/trips-layer/trips-layer.d.ts.map +1 -1
- package/dist/trips-layer/trips-layer.js +57 -24
- package/dist/trips-layer/trips-layer.js.map +1 -1
- package/dist/trips-layer/trips-layer.wgsl.d.ts +11 -0
- package/dist/trips-layer/trips-layer.wgsl.d.ts.map +1 -0
- package/dist/trips-layer/trips-layer.wgsl.js +48 -0
- package/dist/trips-layer/trips-layer.wgsl.js.map +1 -0
- package/dist.min.js +1415 -149
- package/dist.webgl-only/a5-layer/a5-layer.js +30 -0
- package/dist.webgl-only/a5-layer/a5-layer.js.map +1 -0
- package/dist.webgl-only/geo-cell-layer/GeoCellLayer.js +57 -0
- package/dist.webgl-only/geo-cell-layer/GeoCellLayer.js.map +1 -0
- package/dist.webgl-only/geohash-layer/geohash-layer.js +24 -0
- package/dist.webgl-only/geohash-layer/geohash-layer.js.map +1 -0
- package/dist.webgl-only/geohash-layer/geohash-utils.js +54 -0
- package/dist.webgl-only/geohash-layer/geohash-utils.js.map +1 -0
- package/dist.webgl-only/great-circle-layer/great-circle-layer.js +17 -0
- package/dist.webgl-only/great-circle-layer/great-circle-layer.js.map +1 -0
- package/dist.webgl-only/h3-layers/h3-cluster-layer.js +52 -0
- package/dist.webgl-only/h3-layers/h3-cluster-layer.js.map +1 -0
- package/dist.webgl-only/h3-layers/h3-hexagon-layer.js +209 -0
- package/dist.webgl-only/h3-layers/h3-hexagon-layer.js.map +1 -0
- package/dist.webgl-only/h3-layers/h3-utils.js +60 -0
- package/dist.webgl-only/h3-layers/h3-utils.js.map +1 -0
- package/dist.webgl-only/index.cjs +22542 -0
- package/dist.webgl-only/index.cjs.map +6 -0
- package/dist.webgl-only/index.js +22 -0
- package/dist.webgl-only/index.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-fragment.glsl.js +34 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-fragment.glsl.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-uniforms.js +19 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-vertex.glsl.js +64 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer.js +149 -0
- package/dist.webgl-only/mesh-layer/mesh-layer.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer.wgsl.js +5 -0
- package/dist.webgl-only/mesh-layer/mesh-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-pbr-material.js +27 -0
- package/dist.webgl-only/mesh-layer/mesh-pbr-material.js.map +1 -0
- package/dist.webgl-only/mvt-layer/coordinate-transform.js +45 -0
- package/dist.webgl-only/mvt-layer/coordinate-transform.js.map +1 -0
- package/dist.webgl-only/mvt-layer/find-index-binary.js +100 -0
- package/dist.webgl-only/mvt-layer/find-index-binary.js.map +1 -0
- package/dist.webgl-only/mvt-layer/mvt-layer.js +315 -0
- package/dist.webgl-only/mvt-layer/mvt-layer.js.map +1 -0
- package/dist.webgl-only/quadkey-layer/quadkey-layer.js +27 -0
- package/dist.webgl-only/quadkey-layer/quadkey-layer.js.map +1 -0
- package/dist.webgl-only/quadkey-layer/quadkey-utils.js +30 -0
- package/dist.webgl-only/quadkey-layer/quadkey-utils.js.map +1 -0
- package/dist.webgl-only/s2-layer/s2-geometry.js +127 -0
- package/dist.webgl-only/s2-layer/s2-geometry.js.map +1 -0
- package/dist.webgl-only/s2-layer/s2-layer.js +24 -0
- package/dist.webgl-only/s2-layer/s2-layer.js.map +1 -0
- package/dist.webgl-only/s2-layer/s2-utils.js +91 -0
- package/dist.webgl-only/s2-layer/s2-utils.js.map +1 -0
- package/dist.webgl-only/terrain-layer/terrain-layer.js +260 -0
- package/dist.webgl-only/terrain-layer/terrain-layer.js.map +1 -0
- package/dist.webgl-only/tile-3d-layer/tile-3d-layer.js +343 -0
- package/dist.webgl-only/tile-3d-layer/tile-3d-layer.js.map +1 -0
- package/dist.webgl-only/tile-layer/tile-layer.js +233 -0
- package/dist.webgl-only/tile-layer/tile-layer.js.map +1 -0
- package/dist.webgl-only/tileset-2d/index.js +7 -0
- package/dist.webgl-only/tileset-2d/index.js.map +1 -0
- package/dist.webgl-only/tileset-2d/memoize.js +45 -0
- package/dist.webgl-only/tileset-2d/memoize.js.map +1 -0
- package/dist.webgl-only/tileset-2d/tile-2d-header.js +141 -0
- package/dist.webgl-only/tileset-2d/tile-2d-header.js.map +1 -0
- package/dist.webgl-only/tileset-2d/tile-2d-traversal.js +208 -0
- package/dist.webgl-only/tileset-2d/tile-2d-traversal.js.map +1 -0
- package/dist.webgl-only/tileset-2d/tileset-2d.js +557 -0
- package/dist.webgl-only/tileset-2d/tileset-2d.js.map +1 -0
- package/dist.webgl-only/tileset-2d/types.js +5 -0
- package/dist.webgl-only/tileset-2d/types.js.map +1 -0
- package/dist.webgl-only/tileset-2d/utils.js +246 -0
- package/dist.webgl-only/tileset-2d/utils.js.map +1 -0
- package/dist.webgl-only/trips-layer/trips-layer-uniforms.js +23 -0
- package/dist.webgl-only/trips-layer/trips-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/trips-layer/trips-layer.js +97 -0
- package/dist.webgl-only/trips-layer/trips-layer.js.map +1 -0
- package/dist.webgl-only/trips-layer/trips-layer.wgsl.js +3 -0
- package/dist.webgl-only/trips-layer/trips-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/wms-layer/utils.js +17 -0
- package/dist.webgl-only/wms-layer/utils.js.map +1 -0
- package/dist.webgl-only/wms-layer/wms-layer.js +198 -0
- package/dist.webgl-only/wms-layer/wms-layer.js.map +1 -0
- package/package.json +11 -6
- package/src/geo-cell-layer/GeoCellLayer.ts +2 -0
- package/src/mesh-layer/mesh-layer-uniforms.ts +9 -0
- package/src/mesh-layer/mesh-layer.ts +15 -6
- package/src/mesh-layer/mesh-layer.wgsl.ts +130 -0
- package/src/mesh-layer/mesh-pbr-material.ts +39 -0
- package/src/trips-layer/trips-layer-uniforms.ts +15 -3
- package/src/trips-layer/trips-layer.ts +84 -38
- package/src/trips-layer/trips-layer.wgsl.ts +63 -0
package/dist.min.js
CHANGED
|
@@ -4,26 +4,53 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['deck'] = factory();
|
|
6
6
|
else root['deck'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var z1=Object.create;var En=Object.defineProperty;var k1=Object.getOwnPropertyDescriptor;var j1=Object.getOwnPropertyNames;var q1=Object.getPrototypeOf,J1=Object.prototype.hasOwnProperty;var W1=(t,e,r)=>e in t?En(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Of=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var We=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),be=(t,e)=>{for(var r in e)En(t,r,{get:e[r],enumerable:!0})},jo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j1(e))!J1.call(t,o)&&o!==r&&En(t,o,{get:()=>e[o],enumerable:!(n=k1(e,o))||n.enumerable});return t},Ct=(t,e,r)=>(jo(t,e,"default"),r&&jo(r,e,"default")),D=(t,e,r)=>(r=t!=null?z1(q1(t)):{},jo(e||!t||!t.__esModule?En(r,"default",{value:t,enumerable:!0}):r,t)),X1=t=>jo(En({},"__esModule",{value:!0}),t);var Xt=(t,e,r)=>(W1(t,typeof e!="symbol"?e+"":e,r),r);var Xe=We((Dv,Uf)=>{Uf.exports=globalThis.deck});var ot=We((Vv,Gf)=>{Gf.exports=globalThis.deck});var ls=We((iw,oh)=>{oh.exports=globalThis.h3||{}});var rr=We((jL,op)=>{op.exports=globalThis.loaders});var Nc=We((cd,oo)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof Of=="function"&&typeof oo=="object"&&oo&&oo.exports?oo.exports=e():(t.dcodeIO=t.dcodeIO||{}).Long=e()})(cd,function(){"use strict";function t(T,A,B){this.low=T|0,this.high=A|0,this.unsigned=!!B}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function e(T){return(T&&T.__isLong__)===!0}t.isLong=e;var r={},n={};function o(T,A){var B,L,F;return A?(T>>>=0,(F=0<=T&&T<256)&&(L=n[T],L)?L:(B=i(T,(T|0)<0?-1:0,!0),F&&(n[T]=B),B)):(T|=0,(F=-128<=T&&T<128)&&(L=r[T],L)?L:(B=i(T,T<0?-1:0,!1),F&&(r[T]=B),B))}t.fromInt=o;function s(T,A){if(isNaN(T)||!isFinite(T))return A?x:g;if(A){if(T<0)return x;if(T>=p)return _}else{if(T<=-d)return R;if(T+1>=d)return C}return T<0?s(-T,A).neg():i(T%h|0,T/h|0,A)}t.fromNumber=s;function i(T,A,B){return new t(T,A,B)}t.fromBits=i;var a=Math.pow;function c(T,A,B){if(T.length===0)throw Error("empty string");if(T==="NaN"||T==="Infinity"||T==="+Infinity"||T==="-Infinity")return g;if(typeof A=="number"?(B=A,A=!1):A=!!A,B=B||10,B<2||36<B)throw RangeError("radix");var L;if((L=T.indexOf("-"))>0)throw Error("interior hyphen");if(L===0)return c(T.substring(1),A,B).neg();for(var F=s(a(B,8)),w=g,U=0;U<T.length;U+=8){var W=Math.min(8,T.length-U),z=parseInt(T.substring(U,U+W),B);if(W<8){var re=s(a(B,W));w=w.mul(re).add(s(z))}else w=w.mul(F),w=w.add(s(z))}return w.unsigned=A,w}t.fromString=c;function l(T){return T instanceof t?T:typeof T=="number"?s(T):typeof T=="string"?c(T):i(T.low,T.high,T.unsigned)}t.fromValue=l;var f=1<<16,u=1<<24,h=f*f,p=h*h,d=p/2,m=o(u),g=o(0);t.ZERO=g;var x=o(0,!0);t.UZERO=x;var b=o(1);t.ONE=b;var M=o(1,!0);t.UONE=M;var E=o(-1);t.NEG_ONE=E;var C=i(-1,2147483647,!1);t.MAX_VALUE=C;var _=i(-1,-1,!0);t.MAX_UNSIGNED_VALUE=_;var R=i(0,-2147483648,!1);t.MIN_VALUE=R;var S=t.prototype;return S.toInt=function(){return this.unsigned?this.low>>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},S.toString=function(A){if(A=A||10,A<2||36<A)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(R)){var B=s(A),L=this.div(B),F=L.mul(B).sub(this);return L.toString(A)+F.toInt().toString(A)}else return"-"+this.neg().toString(A);for(var w=s(a(A,6),this.unsigned),U=this,W="";;){var z=U.div(w),re=U.sub(z.mul(w)).toInt()>>>0,K=re.toString(A);if(U=z,U.isZero())return K+W;for(;K.length<6;)K="0"+K;W=""+K+W}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(R)?64:this.neg().getNumBitsAbs();for(var A=this.high!=0?this.high:this.low,B=31;B>0&&!(A&1<<B);B--);return this.high!=0?B+33:B+1},S.isZero=function(){return this.high===0&&this.low===0},S.isNegative=function(){return!this.unsigned&&this.high<0},S.isPositive=function(){return this.unsigned||this.high>=0},S.isOdd=function(){return(this.low&1)===1},S.isEven=function(){return(this.low&1)===0},S.equals=function(A){return e(A)||(A=l(A)),this.unsigned!==A.unsigned&&this.high>>>31===1&&A.high>>>31===1?!1:this.high===A.high&&this.low===A.low},S.eq=S.equals,S.notEquals=function(A){return!this.eq(A)},S.neq=S.notEquals,S.lessThan=function(A){return this.comp(A)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(A){return this.comp(A)<=0},S.lte=S.lessThanOrEqual,S.greaterThan=function(A){return this.comp(A)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(A){return this.comp(A)>=0},S.gte=S.greaterThanOrEqual,S.compare=function(A){if(e(A)||(A=l(A)),this.eq(A))return 0;var B=this.isNegative(),L=A.isNegative();return B&&!L?-1:!B&&L?1:this.unsigned?A.high>>>0>this.high>>>0||A.high===this.high&&A.low>>>0>this.low>>>0?-1:1:this.sub(A).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(R)?R:this.not().add(b)},S.neg=S.negate,S.add=function(A){e(A)||(A=l(A));var B=this.high>>>16,L=this.high&65535,F=this.low>>>16,w=this.low&65535,U=A.high>>>16,W=A.high&65535,z=A.low>>>16,re=A.low&65535,K=0,Y=0,ee=0,Ie=0;return Ie+=w+re,ee+=Ie>>>16,Ie&=65535,ee+=F+z,Y+=ee>>>16,ee&=65535,Y+=L+W,K+=Y>>>16,Y&=65535,K+=B+U,K&=65535,i(ee<<16|Ie,K<<16|Y,this.unsigned)},S.subtract=function(A){return e(A)||(A=l(A)),this.add(A.neg())},S.sub=S.subtract,S.multiply=function(A){if(this.isZero()||(e(A)||(A=l(A)),A.isZero()))return g;if(this.eq(R))return A.isOdd()?R:g;if(A.eq(R))return this.isOdd()?R:g;if(this.isNegative())return A.isNegative()?this.neg().mul(A.neg()):this.neg().mul(A).neg();if(A.isNegative())return this.mul(A.neg()).neg();if(this.lt(m)&&A.lt(m))return s(this.toNumber()*A.toNumber(),this.unsigned);var B=this.high>>>16,L=this.high&65535,F=this.low>>>16,w=this.low&65535,U=A.high>>>16,W=A.high&65535,z=A.low>>>16,re=A.low&65535,K=0,Y=0,ee=0,Ie=0;return Ie+=w*re,ee+=Ie>>>16,Ie&=65535,ee+=F*re,Y+=ee>>>16,ee&=65535,ee+=w*z,Y+=ee>>>16,ee&=65535,Y+=L*re,K+=Y>>>16,Y&=65535,Y+=F*z,K+=Y>>>16,Y&=65535,Y+=w*W,K+=Y>>>16,Y&=65535,K+=B*re+L*z+F*W+w*U,K&=65535,i(ee<<16|Ie,K<<16|Y,this.unsigned)},S.mul=S.multiply,S.divide=function(A){if(e(A)||(A=l(A)),A.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?x:g;var B,L,F;if(this.unsigned){if(A.unsigned||(A=A.toUnsigned()),A.gt(this))return x;if(A.gt(this.shru(1)))return M;F=x}else{if(this.eq(R)){if(A.eq(b)||A.eq(E))return R;if(A.eq(R))return b;var w=this.shr(1);return B=w.div(A).shl(1),B.eq(g)?A.isNegative()?b:E:(L=this.sub(A.mul(B)),F=B.add(L.div(A)),F)}else if(A.eq(R))return this.unsigned?x:g;if(this.isNegative())return A.isNegative()?this.neg().div(A.neg()):this.neg().div(A).neg();if(A.isNegative())return this.div(A.neg()).neg();F=g}for(L=this;L.gte(A);){B=Math.max(1,Math.floor(L.toNumber()/A.toNumber()));for(var U=Math.ceil(Math.log(B)/Math.LN2),W=U<=48?1:a(2,U-48),z=s(B),re=z.mul(A);re.isNegative()||re.gt(L);)B-=W,z=s(B,this.unsigned),re=z.mul(A);z.isZero()&&(z=b),F=F.add(z),L=L.sub(re)}return F},S.div=S.divide,S.modulo=function(A){return e(A)||(A=l(A)),this.sub(this.div(A).mul(A))},S.mod=S.modulo,S.not=function(){return i(~this.low,~this.high,this.unsigned)},S.and=function(A){return e(A)||(A=l(A)),i(this.low&A.low,this.high&A.high,this.unsigned)},S.or=function(A){return e(A)||(A=l(A)),i(this.low|A.low,this.high|A.high,this.unsigned)},S.xor=function(A){return e(A)||(A=l(A)),i(this.low^A.low,this.high^A.high,this.unsigned)},S.shiftLeft=function(A){return e(A)&&(A=A.toInt()),(A&=63)===0?this:A<32?i(this.low<<A,this.high<<A|this.low>>>32-A,this.unsigned):i(0,this.low<<A-32,this.unsigned)},S.shl=S.shiftLeft,S.shiftRight=function(A){return e(A)&&(A=A.toInt()),(A&=63)===0?this:A<32?i(this.low>>>A|this.high<<32-A,this.high>>A,this.unsigned):i(this.high>>A-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(A){if(e(A)&&(A=A.toInt()),A&=63,A===0)return this;var B=this.high;if(A<32){var L=this.low;return i(L>>>A|B<<32-A,B>>>A,this.unsigned)}else return A===32?i(B,0,this.unsigned):i(B>>>A-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},S.toBytes=function(T){return T?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var T=this.high,A=this.low;return[A&255,A>>>8&255,A>>>16&255,A>>>24&255,T&255,T>>>8&255,T>>>16&255,T>>>24&255]},S.toBytesBE=function(){var T=this.high,A=this.low;return[T>>>24&255,T>>>16&255,T>>>8&255,T&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255]},t})});var Wc=We((JG,Yd)=>{Yd.exports=globalThis.luma});var Zs=We((WG,Kd)=>{Kd.exports=globalThis.deck});var $c=We((_V,lm)=>{lm.exports=globalThis.luma});var o1=We((g5,n1)=>{n1.exports=globalThis.deck});var d1=We(Sf=>{Sf.read=function(t,e,r,n,o){var s,i,a=o*8-n-1,c=(1<<a)-1,l=c>>1,f=-7,u=r?o-1:0,h=r?-1:1,p=t[e+u];for(u+=h,s=p&(1<<-f)-1,p>>=-f,f+=a;f>0;s=s*256+t[e+u],u+=h,f-=8);for(i=s&(1<<-f)-1,s>>=-f,f+=n;f>0;i=i*256+t[e+u],u+=h,f-=8);if(s===0)s=1-l;else{if(s===c)return i?NaN:(p?-1:1)*(1/0);i=i+Math.pow(2,n),s=s-l}return(p?-1:1)*i*Math.pow(2,s-n)};Sf.write=function(t,e,r,n,o,s){var i,a,c,l=s*8-o-1,f=(1<<l)-1,u=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=f):(i=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-i))<1&&(i--,c*=2),i+u>=1?e+=h/c:e+=h*Math.pow(2,1-u),e*c>=2&&(i++,c/=2),i+u>=f?(a=0,i=f):i+u>=1?(a=(e*c-1)*Math.pow(2,o),i=i+u):(a=e*Math.pow(2,u-1)*Math.pow(2,o),i=0));o>=8;t[r+p]=a&255,p+=d,a/=256,o-=8);for(i=i<<o|a,l+=o;l>0;t[r+p]=i&255,p+=d,i/=256,l-=8);t[r+p-d]|=m*128}});var b1=We((sj,y1)=>{"use strict";y1.exports=J;var Zi=d1();function J(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}J.Varint=0;J.Fixed64=1;J.Bytes=2;J.Fixed32=5;var _f=(1<<16)*(1<<16),m1=1/_f,WR=12,x1=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");J.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),o=n>>3,s=this.pos;this.type=n&7,t(o,e,this),this.pos===s&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=$i(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=A1(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=$i(this.buf,this.pos)+$i(this.buf,this.pos+4)*_f;return this.pos+=8,t},readSFixed64:function(){var t=$i(this.buf,this.pos)+A1(this.buf,this.pos+4)*_f;return this.pos+=8,t},readFloat:function(){var t=Zi.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Zi.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,n;return n=e[this.pos++],r=n&127,n<128||(n=e[this.pos++],r|=(n&127)<<7,n<128)||(n=e[this.pos++],r|=(n&127)<<14,n<128)||(n=e[this.pos++],r|=(n&127)<<21,n<128)?r:(n=e[this.pos],r|=(n&15)<<28,XR(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=WR&&x1?cv(this.buf,e,t):av(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==J.Bytes)return t.push(this.readVarint(e));var r=_t(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==J.Bytes)return t.push(this.readSVarint());var e=_t(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==J.Bytes)return t.push(this.readBoolean());var e=_t(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==J.Bytes)return t.push(this.readFloat());var e=_t(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==J.Bytes)return t.push(this.readDouble());var e=_t(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==J.Bytes)return t.push(this.readFixed32());var e=_t(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==J.Bytes)return t.push(this.readSFixed32());var e=_t(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==J.Bytes)return t.push(this.readFixed64());var e=_t(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==J.Bytes)return t.push(this.readSFixed64());var e=_t(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===J.Varint)for(;this.buf[this.pos++]>127;);else if(e===J.Bytes)this.pos=this.readVarint()+this.pos;else if(e===J.Fixed32)this.pos+=4;else if(e===J.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Mn(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Mn(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Mn(this.buf,t&-1,this.pos),Mn(this.buf,Math.floor(t*m1),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Mn(this.buf,t&-1,this.pos),Mn(this.buf,Math.floor(t*m1),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){YR(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=lv(this.buf,t,this.pos);var r=this.pos-e;r>=128&&g1(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Zi.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Zi.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var n=this.pos-r;n>=128&&g1(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,J.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ZR,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,$R,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,rv,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,ev,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,tv,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,nv,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,ov,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,sv,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,iv,e)},writeBytesField:function(t,e){this.writeTag(t,J.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,J.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,J.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,J.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,J.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,J.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,J.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,J.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,J.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,J.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};function XR(t,e,r){var n=r.buf,o,s;if(s=n[r.pos++],o=(s&112)>>4,s<128||(s=n[r.pos++],o|=(s&127)<<3,s<128)||(s=n[r.pos++],o|=(s&127)<<10,s<128)||(s=n[r.pos++],o|=(s&127)<<17,s<128)||(s=n[r.pos++],o|=(s&127)<<24,s<128)||(s=n[r.pos++],o|=(s&1)<<31,s<128))return Tn(t,o,e);throw new Error("Expected varint not more than 10 bytes")}function _t(t){return t.type===J.Bytes?t.readVarint()+t.pos:t.pos+1}function Tn(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function YR(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(r=~(-t%4294967296),n=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,n=n+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),KR(r,n,e),QR(n,e)}function KR(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function QR(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function g1(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(n);for(var o=r.pos-1;o>=t;o--)r.buf[o+n]=r.buf[o]}function ZR(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function $R(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function ev(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function tv(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function rv(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function nv(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function ov(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function sv(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function iv(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function $i(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function Mn(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function A1(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function av(t,e,r){for(var n="",o=e;o<r;){var s=t[o],i=null,a=s>239?4:s>223?3:s>191?2:1;if(o+a>r)break;var c,l,f;a===1?s<128&&(i=s):a===2?(c=t[o+1],(c&192)===128&&(i=(s&31)<<6|c&63,i<=127&&(i=null))):a===3?(c=t[o+1],l=t[o+2],(c&192)===128&&(l&192)===128&&(i=(s&15)<<12|(c&63)<<6|l&63,(i<=2047||i>=55296&&i<=57343)&&(i=null))):a===4&&(c=t[o+1],l=t[o+2],f=t[o+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(i=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,(i<=65535||i>=1114112)&&(i=null))),i===null?(i=65533,a=1):i>65535&&(i-=65536,n+=String.fromCharCode(i>>>10&1023|55296),i=56320|i&1023),n+=String.fromCharCode(i),o+=a}return n}function cv(t,e,r){return x1.decode(t.subarray(e,r))}function lv(t,e,r){for(var n=0,o,s;n<e.length;n++){if(o=e.charCodeAt(n),o>55295&&o<57344)if(s)if(o<56320){t[r++]=239,t[r++]=191,t[r++]=189,s=o;continue}else o=s-55296<<10|o-56320|65536,s=null;else{o>56319||n+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):s=o;continue}else s&&(t[r++]=239,t[r++]=191,t[r++]=189,s=null);o<128?t[r++]=o:(o<2048?t[r++]=o>>6|192:(o<65536?t[r++]=o>>12|224:(t[r++]=o>>18|240,t[r++]=o>>12&63|128),t[r++]=o>>6&63|128),t[r++]=o&63|128)}return r}});var ko={};be(ko,{A5Layer:()=>np,GeohashLayer:()=>H1,GreatCircleLayer:()=>ad,H3ClusterLayer:()=>Xd,H3HexagonLayer:()=>Qs,MVTLayer:()=>U1,QuadkeyLayer:()=>Td,S2Layer:()=>yd,TerrainLayer:()=>r1,Tile3DLayer:()=>W0,TileLayer:()=>mr,TripsLayer:()=>qd,_GeoCellLayer:()=>De,_Tile2DHeader:()=>pr,_Tileset2D:()=>dr,_WMSLayer:()=>Qr,_getURLFromTemplate:()=>ut});var nt={},Df=D(Xe(),1);Ct(nt,D(Xe(),1));if(!Df.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");Ct(ko,nt);var Vf=D(ot(),1),na=D(Xe(),1),Y1={...na.PolygonLayer.defaultProps},Sn=class extends Vf.CompositeLayer{indexToBounds(){return null}renderLayers(){let{elevationScale:e,extruded:r,wireframe:n,filled:o,stroked:s,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:h,getElevation:p,getFillColor:d,getLineColor:m,getLineWidth:g}=this.props,{updateTriggers:x,material:b,transitions:M}=this.props,E=this.getSubLayerClass("cell",na.PolygonLayer),{updateTriggers:C,..._}=this.indexToBounds()||{};return new E({filled:o,wireframe:n,extruded:r,elevationScale:e,stroked:s,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:h,material:b,transitions:M,getElevation:p,getFillColor:d,getLineColor:m,getLineWidth:g},this.getSubLayerProps({id:"cell",updateTriggers:x&&{...C,getElevation:x.getElevation,getFillColor:x.getFillColor,getLineColor:x.getLineColor,getLineWidth:x.getLineWidth}}),_)}};Sn.layerName="GeoCellLayer";Sn.defaultProps=Y1;var De=Sn;var K1=Object.defineProperty,In=(t,e)=>{for(var r in e)K1(t,r,{get:e[r],enumerable:!0})},Ae={};In(Ae,{ARRAY_TYPE:()=>oe,EPSILON:()=>ge,RANDOM:()=>Yt,equals:()=>eA,setMatrixArrayType:()=>Q1,toRadian:()=>$1});var ge=1e-6,oe=typeof Float32Array<"u"?Float32Array:Array,Yt=Math.random;function Q1(t){oe=t}var Z1=Math.PI/180;function $1(t){return t*Z1}function eA(t,e){return Math.abs(t-e)<=ge*Math.max(1,Math.abs(t),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Kt={};In(Kt,{LDU:()=>AA,add:()=>xA,adjoint:()=>lA,clone:()=>rA,copy:()=>nA,create:()=>tA,determinant:()=>fA,equals:()=>bA,exactEquals:()=>yA,frob:()=>gA,fromRotation:()=>pA,fromScaling:()=>dA,fromValues:()=>sA,identity:()=>oA,invert:()=>cA,mul:()=>EA,multiply:()=>cu,multiplyScalar:()=>TA,multiplyScalarAndAdd:()=>MA,rotate:()=>uA,scale:()=>hA,set:()=>iA,str:()=>mA,sub:()=>SA,subtract:()=>lu,transpose:()=>aA});function tA(){var t=new oe(4);return oe!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function rA(t){var e=new oe(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function nA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function oA(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function sA(t,e,r,n){var o=new oe(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=n,o}function iA(t,e,r,n,o){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t}function aA(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t}function cA(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*s-o*n;return i?(i=1/i,t[0]=s*i,t[1]=-n*i,t[2]=-o*i,t[3]=r*i,t):null}function lA(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t}function fA(t){return t[0]*t[3]-t[2]*t[1]}function cu(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*a+s*c,t[1]=o*a+i*c,t[2]=n*l+s*f,t[3]=o*l+i*f,t}function uA(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*a,t[1]=o*c+i*a,t[2]=n*-a+s*c,t[3]=o*-a+i*c,t}function hA(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1];return t[0]=n*a,t[1]=o*a,t[2]=s*c,t[3]=i*c,t}function pA(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t}function dA(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t}function mA(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function gA(t){return Math.hypot(t[0],t[1],t[2],t[3])}function AA(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]}function xA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function lu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function yA(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function bA(t,e){var r=t[0],n=t[1],o=t[2],s=t[3],i=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-i)<=ge*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=ge*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-c)<=ge*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(s-l)<=ge*Math.max(1,Math.abs(s),Math.abs(l))}function TA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function MA(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}var EA=cu,SA=lu;function _A(){var t=new oe(9);return oe!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}var aa={};In(aa,{add:()=>Dx,calculateW:()=>Bx,clone:()=>Px,conjugate:()=>wx,copy:()=>Ox,create:()=>la,dot:()=>_u,equals:()=>jx,exactEquals:()=>kx,exp:()=>Tu,fromEuler:()=>Lx,fromMat3:()=>Eu,fromValues:()=>Nx,getAngle:()=>Ex,getAxisAngle:()=>Mx,identity:()=>Tx,invert:()=>vx,len:()=>Hx,length:()=>Cu,lerp:()=>Vx,ln:()=>Mu,mul:()=>Gx,multiply:()=>bu,normalize:()=>ya,pow:()=>Ix,random:()=>Rx,rotateX:()=>Sx,rotateY:()=>_x,rotateZ:()=>Cx,rotationTo:()=>qx,scale:()=>Su,set:()=>Ux,setAxes:()=>Wx,setAxisAngle:()=>yu,slerp:()=>es,sqlerp:()=>Jx,sqrLen:()=>zx,squaredLength:()=>Bu,str:()=>Fx});var v={};In(v,{add:()=>RA,angle:()=>YA,bezier:()=>HA,ceil:()=>vA,clone:()=>CA,copy:()=>BA,create:()=>Aa,cross:()=>$o,dist:()=>nx,distance:()=>du,div:()=>rx,divide:()=>pu,dot:()=>xa,equals:()=>$A,exactEquals:()=>ZA,floor:()=>wA,forEach:()=>ix,fromValues:()=>ca,hermite:()=>VA,inverse:()=>DA,len:()=>xu,length:()=>fu,lerp:()=>GA,max:()=>FA,min:()=>LA,mul:()=>tx,multiply:()=>hu,negate:()=>UA,normalize:()=>Au,random:()=>zA,rotateX:()=>JA,rotateY:()=>WA,rotateZ:()=>XA,round:()=>PA,scale:()=>NA,scaleAndAdd:()=>OA,set:()=>IA,sqrDist:()=>ox,sqrLen:()=>sx,squaredDistance:()=>mu,squaredLength:()=>gu,str:()=>QA,sub:()=>ex,subtract:()=>uu,transformMat3:()=>jA,transformMat4:()=>kA,transformQuat:()=>qA,zero:()=>KA});function Aa(){var t=new oe(3);return oe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function CA(t){var e=new oe(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function fu(t){var e=t[0],r=t[1],n=t[2];return Math.hypot(e,r,n)}function ca(t,e,r){var n=new oe(3);return n[0]=t,n[1]=e,n[2]=r,n}function BA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function IA(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function RA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function uu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function hu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function pu(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function vA(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function wA(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function LA(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function FA(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function PA(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function NA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function OA(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function du(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return Math.hypot(r,n,o)}function mu(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return r*r+n*n+o*o}function gu(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function UA(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function DA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Au(t,e){var r=e[0],n=e[1],o=e[2],s=r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function xa(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function $o(t,e,r){var n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2];return t[0]=o*c-s*a,t[1]=s*i-n*c,t[2]=n*a-o*i,t}function GA(t,e,r,n){var o=e[0],s=e[1],i=e[2];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t}function VA(t,e,r,n,o,s){var i=s*s,a=i*(2*s-3)+1,c=i*(s-2)+s,l=i*(s-1),f=i*(3-2*s);return t[0]=e[0]*a+r[0]*c+n[0]*l+o[0]*f,t[1]=e[1]*a+r[1]*c+n[1]*l+o[1]*f,t[2]=e[2]*a+r[2]*c+n[2]*l+o[2]*f,t}function HA(t,e,r,n,o,s){var i=1-s,a=i*i,c=s*s,l=a*i,f=3*s*a,u=3*c*i,h=c*s;return t[0]=e[0]*l+r[0]*f+n[0]*u+o[0]*h,t[1]=e[1]*l+r[1]*f+n[1]*u+o[1]*h,t[2]=e[2]*l+r[2]*f+n[2]*u+o[2]*h,t}function zA(t,e){e=e||1;var r=Yt()*2*Math.PI,n=Yt()*2-1,o=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=n*e,t}function kA(t,e,r){var n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*o+r[8]*s+r[12])/i,t[1]=(r[1]*n+r[5]*o+r[9]*s+r[13])/i,t[2]=(r[2]*n+r[6]*o+r[10]*s+r[14])/i,t}function jA(t,e,r){var n=e[0],o=e[1],s=e[2];return t[0]=n*r[0]+o*r[3]+s*r[6],t[1]=n*r[1]+o*r[4]+s*r[7],t[2]=n*r[2]+o*r[5]+s*r[8],t}function qA(t,e,r){var n=r[0],o=r[1],s=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=o*l-s*c,u=s*a-n*l,h=n*c-o*a,p=o*h-s*u,d=s*f-n*h,m=n*u-o*f,g=i*2;return f*=g,u*=g,h*=g,p*=2,d*=2,m*=2,t[0]=a+f+p,t[1]=c+u+d,t[2]=l+h+m,t}function JA(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),s[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function WA(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),s[1]=o[1],s[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function XA(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),s[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function YA(t,e){var r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2],c=Math.sqrt(r*r+n*n+o*o),l=Math.sqrt(s*s+i*i+a*a),f=c*l,u=f&&xa(t,e)/f;return Math.acos(Math.min(Math.max(u,-1),1))}function KA(t){return t[0]=0,t[1]=0,t[2]=0,t}function QA(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function ZA(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function $A(t,e){var r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2];return Math.abs(r-s)<=ge*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=ge*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(o-a)<=ge*Math.max(1,Math.abs(o),Math.abs(a))}var ex=uu,tx=hu,rx=pu,nx=du,ox=mu,xu=fu,sx=gu,ix=function(){var t=Aa();return function(e,r,n,o,s,i){var a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();function ax(){var t=new oe(4);return oe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function cx(t){var e=new oe(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function lx(t,e,r,n){var o=new oe(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=n,o}function fx(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function ux(t,e,r,n,o){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t}function hx(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function px(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function dx(t){var e=t[0],r=t[1],n=t[2],o=t[3];return Math.hypot(e,r,n,o)}function mx(t){var e=t[0],r=t[1],n=t[2],o=t[3];return e*e+r*r+n*n+o*o}function gx(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=o*i,t[3]=s*i,t}function Ax(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function xx(t,e,r,n){var o=e[0],s=e[1],i=e[2],a=e[3];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function yx(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function bx(t,e){var r=t[0],n=t[1],o=t[2],s=t[3],i=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-i)<=ge*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=ge*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-c)<=ge*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(s-l)<=ge*Math.max(1,Math.abs(s),Math.abs(l))}var zv=function(){var t=ax();return function(e,r,n,o,s,i){var a,c;for(r||(r=4),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();function la(){var t=new oe(4);return oe!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Tx(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function yu(t,e,r){r=r*.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function Mx(t,e){var r=Math.acos(e[3])*2,n=Math.sin(r/2);return n>ge?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r}function Ex(t,e){var r=_u(t,e);return Math.acos(2*r*r-1)}function bu(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+o*l-s*c,t[1]=o*f+i*c+s*a-n*l,t[2]=s*f+i*l+n*c-o*a,t[3]=i*f-n*a-o*c-s*l,t}function Sx(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=o*c+s*a,t[2]=s*c-o*a,t[3]=i*c-n*a,t}function _x(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-s*a,t[1]=o*c+i*a,t[2]=s*c+n*a,t[3]=i*c-o*a,t}function Cx(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*a,t[1]=o*c-n*a,t[2]=s*c+i*a,t[3]=i*c-s*a,t}function Bx(t,e){var r=e[0],n=e[1],o=e[2];return t[0]=r,t[1]=n,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-o*o)),t}function Tu(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=Math.sqrt(r*r+n*n+o*o),a=Math.exp(s),c=i>0?a*Math.sin(i)/i:0;return t[0]=r*c,t[1]=n*c,t[2]=o*c,t[3]=a*Math.cos(i),t}function Mu(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=Math.sqrt(r*r+n*n+o*o),a=i>0?Math.atan2(i,s)/i:0;return t[0]=r*a,t[1]=n*a,t[2]=o*a,t[3]=.5*Math.log(r*r+n*n+o*o+s*s),t}function Ix(t,e,r){return Mu(t,e),Su(t,t,r),Tu(t,t),t}function es(t,e,r,n){var o=e[0],s=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],h,p,d,m,g;return p=o*c+s*l+i*f+a*u,p<0&&(p=-p,c=-c,l=-l,f=-f,u=-u),1-p>ge?(h=Math.acos(p),d=Math.sin(h),m=Math.sin((1-n)*h)/d,g=Math.sin(n*h)/d):(m=1-n,g=n),t[0]=m*o+g*c,t[1]=m*s+g*l,t[2]=m*i+g*f,t[3]=m*a+g*u,t}function Rx(t){var e=Yt(),r=Yt(),n=Yt(),o=Math.sqrt(1-e),s=Math.sqrt(e);return t[0]=o*Math.sin(2*Math.PI*r),t[1]=o*Math.cos(2*Math.PI*r),t[2]=s*Math.sin(2*Math.PI*n),t[3]=s*Math.cos(2*Math.PI*n),t}function vx(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-o*a,t[3]=s*a,t}function wx(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function Eu(t,e){var r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var o=0;e[4]>e[0]&&(o=1),e[8]>e[o*3+o]&&(o=2);var s=(o+1)%3,i=(o+2)%3;n=Math.sqrt(e[o*3+o]-e[s*3+s]-e[i*3+i]+1),t[o]=.5*n,n=.5/n,t[3]=(e[s*3+i]-e[i*3+s])*n,t[s]=(e[s*3+o]+e[o*3+s])*n,t[i]=(e[i*3+o]+e[o*3+i])*n}return t}function Lx(t,e,r,n){var o=.5*Math.PI/180;e*=o,r*=o,n*=o;var s=Math.sin(e),i=Math.cos(e),a=Math.sin(r),c=Math.cos(r),l=Math.sin(n),f=Math.cos(n);return t[0]=s*c*f-i*a*l,t[1]=i*a*f+s*c*l,t[2]=i*c*l-s*a*f,t[3]=i*c*f+s*a*l,t}function Fx(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var Px=cx,Nx=lx,Ox=fx,Ux=ux,Dx=hx,Gx=bu,Su=px,_u=Ax,Vx=xx,Cu=dx,Hx=Cu,Bu=mx,zx=Bu,ya=gx,kx=yx,jx=bx,qx=function(){var t=Aa(),e=ca(1,0,0),r=ca(0,1,0);return function(n,o,s){var i=xa(o,s);return i<-.999999?($o(t,e,o),xu(t)<1e-6&&$o(t,r,o),Au(t,t),yu(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):($o(t,o,s),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,ya(n,n))}}(),Jx=function(){var t=la(),e=la();return function(r,n,o,s,i,a){return es(t,n,i,a),es(e,o,s,a),es(r,t,e,2*a*(1-a)),r}}(),Wx=function(){var t=_A();return function(e,r,n,o){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],ya(e,Eu(e,t))}}(),P={};In(P,{add:()=>Zx,angle:()=>xy,ceil:()=>$x,clone:()=>Xx,copy:()=>Kx,create:()=>Iu,cross:()=>fy,dist:()=>By,distance:()=>Lu,div:()=>Cy,divide:()=>wu,dot:()=>ly,equals:()=>My,exactEquals:()=>Ty,floor:()=>ey,forEach:()=>vy,fromValues:()=>Yx,inverse:()=>ay,len:()=>Ey,length:()=>Pu,lerp:()=>uy,max:()=>ry,min:()=>ty,mul:()=>_y,multiply:()=>vu,negate:()=>iy,normalize:()=>cy,random:()=>hy,rotate:()=>Ay,round:()=>ny,scale:()=>oy,scaleAndAdd:()=>sy,set:()=>Qx,sqrDist:()=>Iy,sqrLen:()=>Ry,squaredDistance:()=>Fu,squaredLength:()=>Nu,str:()=>by,sub:()=>Sy,subtract:()=>Ru,transformMat2:()=>py,transformMat2d:()=>dy,transformMat3:()=>my,transformMat4:()=>gy,zero:()=>yy});function Iu(){var t=new oe(2);return oe!=Float32Array&&(t[0]=0,t[1]=0),t}function Xx(t){var e=new oe(2);return e[0]=t[0],e[1]=t[1],e}function Yx(t,e){var r=new oe(2);return r[0]=t,r[1]=e,r}function Kx(t,e){return t[0]=e[0],t[1]=e[1],t}function Qx(t,e,r){return t[0]=e,t[1]=r,t}function Zx(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function Ru(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function vu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function wu(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function $x(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function ey(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function ty(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function ry(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function ny(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function oy(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function sy(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t}function Lu(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.hypot(r,n)}function Fu(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function Pu(t){var e=t[0],r=t[1];return Math.hypot(e,r)}function Nu(t){var e=t[0],r=t[1];return e*e+r*r}function iy(t,e){return t[0]=-e[0],t[1]=-e[1],t}function ay(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function cy(t,e){var r=e[0],n=e[1],o=r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t}function ly(t,e){return t[0]*e[0]+t[1]*e[1]}function fy(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t}function uy(t,e,r,n){var o=e[0],s=e[1];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t}function hy(t,e){e=e||1;var r=Yt()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function py(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t}function dy(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o+r[4],t[1]=r[1]*n+r[3]*o+r[5],t}function my(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[3]*o+r[6],t[1]=r[1]*n+r[4]*o+r[7],t}function gy(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}function Ay(t,e,r,n){var o=e[0]-r[0],s=e[1]-r[1],i=Math.sin(n),a=Math.cos(n);return t[0]=o*a-s*i+r[0],t[1]=o*i+s*a+r[1],t}function xy(t,e){var r=t[0],n=t[1],o=e[0],s=e[1],i=Math.sqrt(r*r+n*n)*Math.sqrt(o*o+s*s),a=i&&(r*o+n*s)/i;return Math.acos(Math.min(Math.max(a,-1),1))}function yy(t){return t[0]=0,t[1]=0,t}function by(t){return"vec2("+t[0]+", "+t[1]+")"}function Ty(t,e){return t[0]===e[0]&&t[1]===e[1]}function My(t,e){var r=t[0],n=t[1],o=e[0],s=e[1];return Math.abs(r-o)<=ge*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-s)<=ge*Math.max(1,Math.abs(n),Math.abs(s))}var Ey=Pu,Sy=Ru,_y=vu,Cy=wu,By=Lu,Iy=Fu,Ry=Nu,vy=function(){var t=Iu();return function(e,r,n,o,s,i){var a,c;for(r||(r=2),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}}(),ss=(1+Math.sqrt(5))/2,kv=2*Math.PI,ts=2*Math.PI/5,st=Math.PI/5,Hf=Math.PI/10,wy=2*Math.atan(ss),fa=Math.PI-wy,jv=-.5*Math.PI+Math.acos(-1/Math.sqrt(3-ss)),is=(Math.sqrt(5)-1)/2,Ly=3-Math.sqrt(5),Fy=Math.sqrt(3-ss),qv=Math.sqrt(3)*Fy/ss,rs=63710072e-1,Jv=4*Math.PI*rs*rs;Ae.setMatrixArrayType(Float64Array);var ba=class ua{constructor(e){this.vertices=e,this.isWindingCorrect()||this.vertices.reverse()}getArea(){let e=0,r=this.vertices.length;for(let n=0;n<r;n++){let o=(n+1)%r;e+=(this.vertices[o][0]-this.vertices[n][0])*(this.vertices[o][1]+this.vertices[n][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(let r of this.vertices)P.scale(r,r,e);return this}rotate180(){for(let e of this.vertices)P.negate(e,e);return this}reflectY(){for(let e of this.vertices)e[1]=-e[1];return this.vertices.reverse(),this}translate(e){for(let r of this.vertices)P.add(r,r,e);return this}transform(e){for(let r of this.vertices)P.transformMat2(r,r,e);return this}transform2d(e){for(let r of this.vertices)P.transformMat2d(r,r,e);return this}clone(){return new ua(this.vertices.map(r=>P.clone(r)))}getCenter(){let e=this.vertices.length;return this.vertices.reduce((n,o)=>[n[0]+o[0]/e,n[1]+o[1]/e],[0,0])}containsPoint(e){if(!this.isWindingCorrect())throw new Error("Pentagon is not counter-clockwise");let r=this.vertices.length,n=1;for(let o=0;o<r;o++){let s=this.vertices[o],i=this.vertices[(o+1)%r],a=s[0]-i[0],c=s[1]-i[1],l=e[0]-s[0],f=e[1]-s[1],u=a*f-c*l;if(u<0){let h=Math.sqrt(l*l+f*f);n=Math.min(n,u/h)}}return n}splitEdges(e){if(e<=1)return this;let r=[],n=this.vertices.length;for(let o=0;o<n;o++){let s=this.vertices[o],i=this.vertices[(o+1)%n];r.push(P.clone(s));for(let a=1;a<e;a++){let c=a/e,l=P.create();P.lerp(l,s,i,c),r.push(l)}}return new ua(r)}};Ae.setMatrixArrayType(Float64Array);var Ou=[0,0],Uu=[0,1],Qt=[.7885966681787006,1.6149108024237764],Du=[1.6171013659387945,1.054928690397459],Gu=[Math.cos(Hf),Math.sin(Hf)],Py=2*P.length(Qt)*Math.cos(st),Ny=st-Math.atan2(Qt[1],Qt[0]),Oy=2*is/Py;[Ou,Uu,Qt,Du,Gu].forEach(t=>{P.scale(t,t,Oy),P.rotate(t,t,[0,0],Ny)});var Uy=new ba([Ou,Uu,Qt,Du,Gu]),Vu=Math.atan2(Qt[1],Qt[0])-st,Dy=[0,0],ns=is/Math.cos(st),zf=Vu+st,os=[ns*Math.cos(zf),ns*Math.sin(zf)],kf=Vu-st,Bn=[ns*Math.cos(kf),ns*Math.sin(kf)],Hu=new ba([Dy,os,Bn]),zu=Kt.fromValues(os[0],os[1],Bn[0],Bn[1]),Wv=Kt.invert(Kt.create(),zu),Gy=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2559257686421274e-24,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),Vy=new Float64Array([.0022392089963541657,28831978048607556e-22,508622073997266e-23,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]),Hy=class{applyCoefficients(t,e){let r=Math.sin(t),n=Math.cos(t),o=2*(n-r)*(n+r),s,i;return s=o*e[5]+e[4],i=o*s+e[3],s=o*i-s+e[2],i=o*s-i+e[1],s=o*i-s+e[0],t+2*r*n*s}forward(t){return this.applyCoefficients(t,Gy)}inverse(t){return this.applyCoefficients(t,Vy)}};Ae.setMatrixArrayType(Float64Array);var ku=new Hy;function jf(t){return t*(Math.PI/180)}function qf(t){return t*(180/Math.PI)}function Jf(t){let e=P.length(t),r=Math.atan2(t[1],t[0]);return[e,r]}function zy([t,e]){let r=t*Math.cos(e),n=t*Math.sin(e);return[r,n]}function ky(t,[e,r,n]){let o=[e[0]-n[0],e[1]-n[1]],s=[n[0]-r[0],n[1]-r[1]],i=[t[0]-n[0],t[1]-n[1]],a=s[0]*o[1]-s[1]*o[0],c=(s[0]*i[1]-s[1]*i[0])/a,l=(o[0]*i[1]-o[1]*i[0])/a,f=1-(c+l);return[c,l,f]}function jy(t,[e,r,n]){return[t[0]*e[0]+t[1]*r[0]+t[2]*n[0],t[0]*e[1]+t[1]*r[1]+t[2]*n[1]]}function ha(t){let e=Math.atan2(t[1],t[0]),r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),n=Math.acos(t[2]/r);return[e,n]}function Pr([t,e]){let r=Math.sin(e),n=r*Math.cos(t),o=r*Math.sin(t),s=Math.cos(e);return[n,o,s]}var ju=93;function qy([t,e]){let r=jf(t+ju),n=jf(e),o=ku.forward(n),s=Math.PI/2-o;return[r,s]}function qu([t,e]){let r=qf(t)-ju,n=Math.PI/2-e,o=ku.inverse(n),s=qf(o);return[r,s]}function Jy(t){let e=t.map(s=>Pr(qy(s))),r=v.create();for(let s of e)v.add(r,r,s);v.normalize(r,r);let[n,o]=qu(ha(r));return(o>89.99||o<-89.99)&&(n=t[0][0]),n=((n+180)%360+360)%360-180,t.map(s=>{let[i,a]=s;for(;i-n>180;)i=i-360;for(;i-n<-180;)i=i+360;return[i,a]})}Ae.setMatrixArrayType(Float64Array);var as=Math.sqrt(5),cs=Math.sqrt(.2),Ju=Math.sqrt((1-cs)/2),Wu=Math.sqrt((1+cs)/2),qo=.5,Wf=Math.sqrt((2.5-as)/10),Xf=Math.sqrt((2.5+as)/10),Yf=Math.sqrt((1+cs)/8),Kf=Math.sqrt((1-cs)/8),Qf=Math.sqrt((3-as)/8),Zf=Math.sqrt((3+as)/8),Wy=[[0,0],[Ju,0],[Wf,qo],[-Yf,Qf],[-Yf,-Qf],[Wf,-qo],[-Wu,0],[-Kf,-Zf],[Xf,-qo],[Xf,qo],[-Kf,Zf],[0,0]],Xy=Wy.map(([t,e])=>[-e,t]),Jo=Xy.map((t,e)=>e===0?[0,0,0,1]:e===11?[0,-1,0,0]:[...t,0,e<6?Wu:Ju]);Ae.setMatrixArrayType(Float64Array);var Xu=["vu","uw","vw","vw","vw"],_n=["wu","uw","vw","vu","uw"],oa=["wu","uv","wv","wu","uw"],Wo=["vu","uv","wv","wu","uw"],Yy=[Xu,Wo,oa,_n,oa,Wo,oa,_n,_n,_n,Wo,Wo],Ky=[4,2,3,2,0,4,3,2,2,0,3,0],$f=[0,1,2,4,3,5,7,8,6,11,10,9],Ye=[];function Qy(){Xo([0,0],0,Jo[0]);for(let t=0;t<5;t++){let e=t*ts,r=e+st;Xo([e,fa],st,Jo[t+1]),Xo([r,Math.PI-fa],st,Jo[(t+3)%5+6])}Xo([0,Math.PI],0,Jo[11])}var wr=0;function Xo(t,e,r){if(wr>11)throw new Error(`Too many origins: ${wr}`);let n=aa.create();aa.conjugate(n,r);let o={id:wr,axis:t,quat:r,inverseQuat:n,angle:e,orientation:Yy[wr],firstQuintant:Ky[wr]};Ye.push(o),wr++}Qy();Ye.sort((t,e)=>$f.indexOf(t.id)-$f.indexOf(e.id));Ye.forEach((t,e)=>t.id=e);function Zy(t,e){let r=e.orientation,n=r===Xu||r===_n?-1:1,o=(t-e.firstQuintant+5)%5,s=r[o];return{quintant:(e.firstQuintant+n*o+5)%5,orientation:s}}var $y=class{forward([t,e]){return[Math.tan(e),t]}inverse([t,e]){return[e,Math.atan(t)]}},Lr=v.create(),Cn=v.create(),eu=v.create(),tu=v.create();function sa(t,e){v.lerp(Lr,t,e,.5),v.normalize(Lr,Lr),v.cross(Lr,t,Lr);let r=v.length(Lr);if(r<1e-8){let n=v.subtract(v.create(),t,e);return .5*v.length(n)}return r}function eb(t,e,r){return v.cross(Cn,e,r),v.dot(t,Cn)}function tb(t,e,r,n,o){v.cross(Cn,n,o);let s=v.dot(e,Cn),i=v.dot(r,Cn);return v.scale(eu,e,i),v.scale(tu,r,s),v.sub(t,tu,eu)}function pa(t,e,r,n){let o=v.angle(e,r);if(o<1e-12)return v.lerp(t,e,r,n);let s=Math.sin((1-n)*o)/Math.sin(o),i=Math.sin(n*o)/Math.sin(o),a=v.scale(v.create(),e,s),c=v.scale(v.create(),r,i);return v.add(t,a,c)}Ae.setMatrixArrayType(Float64Array);var Yo=v.create(),Ko=v.create(),Qo=v.create(),Fr=v.create(),rb=class{constructor(t){this._area=null,this.vertices=t,Object.freeze(this.vertices)}getBoundary(t=1,e=!0){let r=[],n=this.vertices.length;for(let o=0;o<n*t;o++){let s=o/t;r.push(this.slerp(s))}return e&&r.push(r[0]),r}slerp(t){let e=this.vertices.length,r=t%1,n=Math.floor(t%e),o=(n+1)%e;return pa(v.create(),this.vertices[n],this.vertices[o],r)}getTransformedVertices(t){let e=this.vertices.length,r=Math.floor(t%e),n=(r+1)%e,o=(r+e-1)%e,s=v.clone(this.vertices[r]),i=v.clone(this.vertices[n]),a=v.clone(this.vertices[o]);return v.sub(i,i,s),v.sub(a,a,s),[s,i,a]}containsPoint(t){let e=this.vertices.length,r=1/0;for(let n=0;n<e;n++){let[o,s,i]=this.getTransformedVertices(n),a=v.sub(v.create(),t,o);v.normalize(a,a),v.normalize(s,s),v.normalize(i,i);let c=v.cross(v.create(),s,a),l=v.cross(v.create(),a,i),f=v.dot(o,c),u=v.dot(o,l);r=Math.min(r,f,u)}return r}getTriangleArea(t,e,r){v.lerp(Yo,e,r,.5),v.lerp(Ko,r,t,.5),v.lerp(Qo,t,e,.5),v.normalize(Yo,Yo),v.normalize(Ko,Ko),v.normalize(Qo,Qo);let n=eb(Yo,Ko,Qo),o=Math.max(-1,Math.min(1,n));return Math.abs(o)<1e-8?2*o:Math.asin(o)*2}getArea(){return this._area===null&&(this._area=this._getArea()),this._area}_getArea(){if(this.vertices.length<3)return 0;if(this.vertices.length===3)return this._area=this.getTriangleArea(this.vertices[0],this.vertices[1],this.vertices[2]),this._area;v.set(Fr,0,0,0);for(let e of this.vertices)v.add(Fr,Fr,e);v.normalize(Fr,Fr);let t=0;for(let e=0;e<this.vertices.length;e++){let r=this.vertices[e],n=this.vertices[(e+1)%this.vertices.length],o=this.getTriangleArea(Fr,r,n);isNaN(o)||(t+=o)}return this._area=t,this._area}isWindingCorrect(){if(!(this.getArea()>0))debugger}};Ae.setMatrixArrayType(Float64Array);var Zo=class extends rb{constructor(t){if(t.length!==3)throw new Error("SphericalTriangleShape requires exactly 3 vertices");super(t)}};Ae.setMatrixArrayType(Float64Array);var nb=class{forward(t,e,r){let[n,o,s]=e,i=new Zo([n,o,s]),a=v.subtract(v.create(),t,n);v.normalize(a,a);let c=tb(v.create(),n,a,o,s);v.normalize(c,c);let l=sa(n,t)/sa(n,c),f=i.getArea(),u=l/f,h=[1-l,u*new Zo([n,c,s]).getArea(),u*new Zo([n,o,c]).getArea()];return jy(h,r)}inverse(t,e,r){let[n,o,s]=r,i=new Zo([n,o,s]),a=ky(t,e),c=1-1e-14;if(a[0]>c)return n;if(a[1]>c)return o;if(a[2]>c)return s;let l=v.create();v.cross(l,o,s);let f=i.getArea(),u=1-a[0],p=a[2]/u*f,d=Math.sin(p),m=Math.sin(p/2),g=2*m*m,x=v.dot(n,o),b=v.dot(o,s),M=v.dot(s,n),E=v.length(l),C=v.dot(n,l),_=d*C+g*(x*b-M),R=g*E*(1+x),S=2/Math.acos(b)*Math.atan2(R,_),T=pa(v.create(),o,s,S),A=sa(n,T),B=this.safeAcos(u*A)/this.safeAcos(A);return pa([0,0,0],n,T,B)}safeAcos(t){return t<.001?2*t+t*t*t/3:Math.acos(1-2*t*t)}},Fe=-1,Se=1;Ae.setMatrixArrayType(Float64Array);var ob=([t,e])=>P.fromValues(t-e,e);Ae.setMatrixArrayType(Float64Array);var da=P.fromValues(1,0),ma=P.fromValues(0,1),ru=P.negate(P.create(),da),nu=P.negate(P.create(),ma),ia=P.fromValues(0,0),sb=(t,[e,r])=>{let n=ia,o=ia;switch(e===Se&&r===Se?(n=da,o=ma):e===Fe&&r===Se?(n=nu,o=ru):e===Se&&r===Fe?(n=ma,o=da):e===Fe&&r===Fe&&(n=ru,o=nu),t){case 0:return ia;case 1:return n;case 2:return P.add(P.create(),o,n);case 3:return P.scaleAndAdd(P.create(),o,n,2);default:throw new Error(`Invalid Quaternary value: ${t}`)}},ou=t=>[[Se,Se],[Se,Fe],[Se,Se],[Fe,Se]][t];function Yu(t){return Array.from({length:t.length},(e,r)=>t.indexOf(r))}var Ku=[0,1,3,4,5,6,7,2],Qu=[0,1,2,7,3,4,5,6],Xv=Yu(Ku),Yv=Yu(Qu),ib=(t,e,r,n,o)=>{if(e<=0)return;let s=t[e]||0,i=t[e-1],a=r[0]+r[1],c=!0,l=!0;if(n!==(a===0)?(c=s===1||s===2,l=s===1):(c=s<2,l=s===0),!c)return;let f=l?i:i+4,u=o[f];t[e-1]=u%4,t[e]=(s+4+Math.floor(u/4)-Math.floor(f/4))%4};Ae.setMatrixArrayType(Float64Array);var su=P.fromValues(-1,1),Zu=!0,ab=(t,e,r,n=Zu)=>{let o=BigInt(t),s=r==="vu"||r==="wu"||r==="vw",i=r==="wv"||r==="vw",a=r==="wu"||r==="uw";s&&(o=(1n<<BigInt(2*e))-o-1n);let c=cb(o,e,i,a,n);if(a){let{offset:[l,f],flips:[u,h]}=c;c.offset=[f,l],u===Fe&&P.add(c.offset,c.offset,su),h===Fe&&P.subtract(c.offset,c.offset,su)}if(i){let{offset:[l,f],flips:u}=c,h=(1<<e)-(l+f);u[0]=-u[0],c.offset[1]=h,c.flips=u}return c},cb=(t,e,r,n,o=Zu)=>{let s=P.create(),i=[Se,Se],a=BigInt(t),c=[];for(;a>0n||c.length<e;)c.push(Number(a%4n)),a=a>>2n;let l=n?Qu:Ku;for(let u=c.length-1;u>=0;u--)o&&ib(c,u,i,r,l),P.multiply(i,i,ou(c[u]));i[0]=Se,i[1]=Se;for(let u=c.length-1;u>=0;u--){P.scale(s,s,2);let h=sb(c[u],i);P.add(s,s,h),P.multiply(i,i,ou(c[u]))}return{q:c[0]||0,offset:ob(s),flips:i}};var Bt=.1,Kv=[[Bt*Math.cos(45*Math.PI/180),Bt*Math.sin(45*Math.PI/180)],[Bt*Math.cos(113*Math.PI/180),Bt*Math.sin(113*Math.PI/180)],[Bt*Math.cos(293*Math.PI/180),Bt*Math.sin(293*Math.PI/180)],[Bt*Math.cos(225*Math.PI/180),Bt*Math.sin(225*Math.PI/180)]];Ae.setMatrixArrayType(Float64Array);var lb=!1,fb=P.clone(Bn),ub=P.negate(P.create(),Bn),Ta=[0,1,2,3,4].map(t=>{let e=Kt.create();return Kt.fromRotation(e,ts*t),e}),iu=P.create();function hb(t,e,r){let n=(lb?Hu:Uy).clone();P.transformMat2(iu,r.offset,zu),r.flips[0]===Se&&r.flips[1]===Fe&&n.rotate180();let{q:o}=r,s=r.flips[0]+r.flips[1];return((s===-2||s===2)&&o>1||s===0&&(o===0||o===3))&&n.reflectY(),r.flips[0]===Fe&&r.flips[1]===Fe?n.rotate180():r.flips[0]===Fe?n.translate(ub):r.flips[1]===Fe&&n.translate(fb),n.translate(iu),n.scale(1/2**t),n.transform(Ta[e]),n}function $u(t){let e=Hu.clone();return e.transform(Ta[t]),e}function pb(){let t=[];for(let e of Ta)t.push(P.transformMat2(P.create(),os,e));return t.reverse(),new ba(t)}Ae.setMatrixArrayType(Float64Array);var db=class{constructor(){if(this.vertices=[],this.invocations=0,this.addFaceCenters(),this.addVertices(),this.addMidpoints(),this.vertices.length!==62)throw new Error("Failed to construct CRS: vertices length is not 62");Object.freeze(this.vertices)}getVertex(t){this.invocations++,this.invocations===1e4&&console.warn("Too many CRS invocations, results should be cached");for(let e of this.vertices)if(v.distance(t,e)<1e-5)return e;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){Ye.forEach(t=>this.add(Pr(t.axis)))}addVertices(){let t=Math.atan(Ly);for(let e of Ye)for(let r=0;r<5;r++){let n=(2*r+1)*Math.PI/5,o=Pr([n+e.angle,t]);v.transformQuat(o,o,e.quat),this.add(o)}}addMidpoints(){let t=Math.atan(is);for(let e of Ye)for(let r=0;r<5;r++){let n=2*r*Math.PI/5,o=Pr([n+e.angle,t]);v.transformQuat(o,o,e.quat),this.add(o)}}add(t){let e=v.normalize(v.create(),t);return this.vertices.find(n=>v.distance(e,n)<1e-5)?!1:(this.vertices.push(e),!0)}};Ae.setMatrixArrayType(Float64Array);var mb=new db,gb=class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.polyhedral=new nb,this.gnomonic=new $y}forward(t,e){let r=Ye[e],n=Pr(t),o=v.create();v.transformQuat(o,n,r.inverseQuat);let s=ha(o),i=this.gnomonic.forward(s);i[1]=i[1]-r.angle;let a=this.getFaceTriangleIndex(i),c=this.shouldReflect(i),l=this.getFaceTriangle(a,c,!1),f=this.getSphericalTriangle(a,e,c);return this.polyhedral.forward(n,f,l)}inverse(t,e){let r=Jf(t),n=this.getFaceTriangleIndex(r),o=this.shouldReflect(r),s=this.getFaceTriangle(n,o,!1),i=this.getSphericalTriangle(n,e,o),a=this.polyhedral.inverse(t,s,i);return ha(a)}shouldReflect(t){let[e,r]=t;return zy([e,this.normalizeGamma(r)])[0]>is}getFaceTriangleIndex([t,e]){return(Math.floor(e/st)+10)%10}getFaceTriangle(t,e=!1,r=!1){let n=t;return e&&(n+=r?20:10),this.faceTriangles[n]?this.faceTriangles[n]:(this.faceTriangles[n]=e?this._getReflectedFaceTriangle(t,r):this._getFaceTriangle(t),Object.freeze(this.faceTriangles[n]),this.faceTriangles[n])}_getFaceTriangle(t){let e=Math.floor((t+1)/2)%5,[r,n,o]=$u(e).getVertices(),s=P.create();return P.lerp(s,n,o,.5),t%2===0?[r,s,n]:[r,o,s]}_getReflectedFaceTriangle(t,e=!1){let[r,n,o]=this._getFaceTriangle(t).map(a=>P.clone(a)),s=t%2===0;P.negate(r,r);let i=s?n:o;return P.scaleAndAdd(r,r,i,e?1+1/Math.cos(fa):2),[r,o,n]}getSphericalTriangle(t,e,r=!1){let n=10*e+t;return r&&(n+=120),this.sphericalTriangles[n]?this.sphericalTriangles[n]:(this.sphericalTriangles[n]=this._getSphericalTriangle(t,e,r),Object.freeze(this.sphericalTriangles[n]),this.sphericalTriangles[n])}_getSphericalTriangle(t,e,r=!1){let n=Ye[e];return this.getFaceTriangle(t,r,!0).map(i=>{let[a,c]=Jf(i),l=[a,c+n.angle],f=Pr(this.gnomonic.inverse(l));return v.transformQuat(f,f,n.quat),mb.getVertex(f)})}normalizeGamma(t){let e=t/ts,r=Math.round(e);return(e-r)*ts}},Nr=2,ga=30,au=58n,Ab=0n;function xb(t){if(t===0n)return-1;if(t&1n||(t&0b111n)===0b100n||(t&0b11111n)===0b10000n)return ga;let e=ga-1,r=t>>1n;if(r===0n)return-1;let n=Number(r&0xFFFFFFFFn),o;for(n===0?(r>>=32n,e-=16,o=Number(r)):o=n,o&65535||(o>>=16,e-=8),e>=6&&!(o&255)&&(o>>=8,e-=4),e>=4&&!(o&15)&&(o>>=4,e-=2);e>-1&&!(o&1);)e-=1,o=o>>(e<Nr?1:2);return e}function yb(t){let e=xb(t);if(e===-1)return{origin:Ye[0],segment:0,S:0n,resolution:e};let r=au,n=0;if(e===ga){let u=t&1n?1n:t&0b100n?3n:5n;r=au+u,n=u===1n?0:u===3n?32:40}let o=Number(t>>r)+n,s,i;if(e===0)s=Ye[o],i=0;else{let u=Math.floor(o/5);s=Ye[u],i=(o+s.firstQuintant)%5}if(!s)throw new Error(`Could not parse origin: ${o}`);if(e<Nr)return{origin:s,segment:i,S:0n,resolution:e};let a=e-Nr+1,c=BigInt(2*a),l=(1n<<r)-1n,f=(t&l)>>r-c;return{origin:s,segment:i,S:f,resolution:e}}Ae.setMatrixArrayType(Float64Array);var Qv=Kt.create(),bb=new gb;function Tb({S:t,segment:e,origin:r,resolution:n}){let{quintant:o,orientation:s}=Zy(e,r);if(n===Nr-1)return $u(o);if(n===Nr-2)return pb();let i=n-Nr+1,a=ab(t,i,s);return hb(i,o,a)}function eh(t,{closedRing:e=!0,segments:r="auto"}={closedRing:!0,segments:"auto"}){if(t===Ab)return[];let{S:n,segment:o,origin:s,resolution:i}=yb(t);r==="auto"&&(r=Math.max(1,Math.pow(2,6-i)));let u=Tb({S:n,segment:o,origin:s,resolution:i}).splitEdges(r).getVertices().map(p=>bb.inverse(p,s.id)).map(p=>qu(p)),h=Jy(u);return e&&h.push(h[0]),h.reverse(),h}function th(t){return BigInt(`0x${t}`)}var rh=2;var Mb=rh*rs/Math.sqrt(15),nh=new Array(31);nh[0]=rh*rs/Math.sqrt(3);for(let t=1;t<=30;t++)nh[t]=Mb/(1<<t-1);Ae.setMatrixArrayType(Float64Array);var On=D(ls(),1);var Eb=1/Math.PI*180,Sb=1/180*Math.PI,_b={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{..._b}};var Q=globalThis.mathgl.config;function Ma(t,{precision:e=Q.precision}={}){return t=Cb(t),`${parseFloat(t.toPrecision(e))}`}function Pe(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ea(t){return sh(t)}function Sa(t){return Ne(t)}function sh(t,e){return _a(t,r=>r*Sb,e)}function Ne(t,e){return _a(t,r=>r*Eb,e)}function fs(t,e,r){return _a(t,n=>Math.max(e,Math.min(r,n)))}function It(t,e,r){return Pe(t)?t.map((n,o)=>It(n,e[o],r)):r*e+(1-r)*t}function _e(t,e,r){let n=Q.EPSILON;r&&(Q.EPSILON=r);try{if(t===e)return!0;if(Pe(t)&&Pe(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!_e(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=Q.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{Q.EPSILON=n}}function Cb(t){return Math.round(t/Q.EPSILON)*Q.EPSILON}function Bb(t){return t.clone?t.clone():new Array(t.length)}function _a(t,e,r){if(Pe(t)){let n=t;r=r||Bb(n);for(let o=0;o<r.length&&o<n.length;++o){let s=typeof t=="number"?t:t[o];r[o]=e(s,o,r)}return r}return e(t)}var Rt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Pe(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Q)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Ma(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!_e(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let s=e[o],i=typeof r=="number"?r:r[o];this[o]=s+n*(i-s)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(Q.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function Ib(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function V(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function vt(t,e,r=""){if(Q.debug&&!Ib(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function he(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var wt=class extends Rt{get x(){return this[0]}set x(e){this[0]=V(e)}get y(){return this[1]}set y(e){this[1]=V(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let n=0;n<this.ELEMENTS;++n){let o=this[n]-e[n];r+=o*o}return V(r)}dot(e){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*e[n];return V(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return he(e>=0&&e<this.ELEMENTS,"index is out of range"),V(this[e])}setComponent(e,r){return he(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var te=typeof Float32Array<"u"?Float32Array:Array,Rn=Math.random;function Or(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var Aw=Math.PI/180;function Rb(){let t=new te(2);return te!=Float32Array&&(t[0]=0,t[1]=0),t}function ih(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t}function ah(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o+r[4],t[1]=r[1]*n+r[3]*o+r[5],t}function us(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[3]*o+r[6],t[1]=r[1]*n+r[4]*o+r[7],t}function hs(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var xw=function(){let t=Rb();return function(e,r,n,o,s,i){let a,c;for(r||(r=2),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}}();function ps(t,e,r){let n=e[0],o=e[1],s=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/s,t[1]=(r[1]*n+r[5]*o)/s,t}function ds(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s||1;return t[0]=(r[0]*n+r[4]*o+r[8]*s)/i,t[1]=(r[1]*n+r[5]*o+r[9]*s)/i,t[2]=(r[2]*n+r[6]*o+r[10]*s)/i,t}function ch(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t[2]=e[2],t}function lh(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t[2]=e[2],t[3]=e[3],t}function ms(t,e,r){let n=e[0],o=e[1],s=e[2];return t[0]=r[0]*n+r[3]*o+r[6]*s,t[1]=r[1]*n+r[4]*o+r[7]*s,t[2]=r[2]*n+r[5]*o+r[8]*s,t[3]=e[3],t}var Zt=class extends wt{constructor(e=0,r=0){super(2),Pe(e)&&arguments.length===1?this.copy(e):(Q.debug&&(V(e),V(r)),this[0]=e,this[1]=r)}set(e,r){return this[0]=e,this[1]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return Q.debug&&(V(e.x),V(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return hs(this,this,e),this.check()}transformAsVector(e){return ps(this,this,e),this.check()}transformByMatrix3(e){return us(this,this,e),this.check()}transformByMatrix2x3(e){return ah(this,this,e),this.check()}transformByMatrix2(e){return ih(this,this,e),this.check()}};var tr={};be(tr,{add:()=>Fb,angle:()=>va,bezier:()=>Jb,ceil:()=>Pb,clone:()=>vb,copy:()=>wb,create:()=>gs,cross:()=>$t,dist:()=>tT,distance:()=>dh,div:()=>eT,divide:()=>ph,dot:()=>vn,equals:()=>Qb,exactEquals:()=>Kb,floor:()=>Nb,forEach:()=>oT,fromValues:()=>As,hermite:()=>qb,inverse:()=>zb,len:()=>wa,length:()=>fh,lerp:()=>kb,max:()=>Ub,min:()=>Ob,mul:()=>$b,multiply:()=>hh,negate:()=>Hb,normalize:()=>Ca,random:()=>Wb,rotateX:()=>Ba,rotateY:()=>Ia,rotateZ:()=>Ra,round:()=>Db,scale:()=>Gb,scaleAndAdd:()=>Vb,set:()=>Lb,slerp:()=>jb,sqrDist:()=>rT,sqrLen:()=>nT,squaredDistance:()=>mh,squaredLength:()=>gh,str:()=>Yb,sub:()=>Zb,subtract:()=>uh,transformMat3:()=>wn,transformMat4:()=>er,transformQuat:()=>Ln,zero:()=>Xb});function gs(){let t=new te(3);return te!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function vb(t){let e=new te(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function fh(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function As(t,e,r){let n=new te(3);return n[0]=t,n[1]=e,n[2]=r,n}function wb(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Lb(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function Fb(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function uh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function hh(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function ph(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function Pb(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function Nb(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function Ob(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function Ub(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function Db(t,e){return t[0]=Or(e[0]),t[1]=Or(e[1]),t[2]=Or(e[2]),t}function Gb(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function Vb(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function dh(t,e){let r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(r*r+n*n+o*o)}function mh(t,e){let r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return r*r+n*n+o*o}function gh(t){let e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function Hb(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function zb(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Ca(t,e){let r=e[0],n=e[1],o=e[2],s=r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function vn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function $t(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2];return t[0]=o*c-s*a,t[1]=s*i-n*c,t[2]=n*a-o*i,t}function kb(t,e,r,n){let o=e[0],s=e[1],i=e[2];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t}function jb(t,e,r,n){let o=Math.acos(Math.min(Math.max(vn(e,r),-1),1)),s=Math.sin(o),i=Math.sin((1-n)*o)/s,a=Math.sin(n*o)/s;return t[0]=i*e[0]+a*r[0],t[1]=i*e[1]+a*r[1],t[2]=i*e[2]+a*r[2],t}function qb(t,e,r,n,o,s){let i=s*s,a=i*(2*s-3)+1,c=i*(s-2)+s,l=i*(s-1),f=i*(3-2*s);return t[0]=e[0]*a+r[0]*c+n[0]*l+o[0]*f,t[1]=e[1]*a+r[1]*c+n[1]*l+o[1]*f,t[2]=e[2]*a+r[2]*c+n[2]*l+o[2]*f,t}function Jb(t,e,r,n,o,s){let i=1-s,a=i*i,c=s*s,l=a*i,f=3*s*a,u=3*c*i,h=c*s;return t[0]=e[0]*l+r[0]*f+n[0]*u+o[0]*h,t[1]=e[1]*l+r[1]*f+n[1]*u+o[1]*h,t[2]=e[2]*l+r[2]*f+n[2]*u+o[2]*h,t}function Wb(t,e){e=e===void 0?1:e;let r=Rn()*2*Math.PI,n=Rn()*2-1,o=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=n*e,t}function er(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*o+r[8]*s+r[12])/i,t[1]=(r[1]*n+r[5]*o+r[9]*s+r[13])/i,t[2]=(r[2]*n+r[6]*o+r[10]*s+r[14])/i,t}function wn(t,e,r){let n=e[0],o=e[1],s=e[2];return t[0]=n*r[0]+o*r[3]+s*r[6],t[1]=n*r[1]+o*r[4]+s*r[7],t[2]=n*r[2]+o*r[5]+s*r[8],t}function Ln(t,e,r){let n=r[0],o=r[1],s=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=o*l-s*c,u=s*a-n*l,h=n*c-o*a,p=o*h-s*u,d=s*f-n*h,m=n*u-o*f,g=i*2;return f*=g,u*=g,h*=g,p*=2,d*=2,m*=2,t[0]=a+f+p,t[1]=c+u+d,t[2]=l+h+m,t}function Ba(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),s[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Ia(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),s[1]=o[1],s[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Ra(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),s[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function va(t,e){let r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2],c=Math.sqrt((r*r+n*n+o*o)*(s*s+i*i+a*a)),l=c&&vn(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function Xb(t){return t[0]=0,t[1]=0,t[2]=0,t}function Yb(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function Kb(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function Qb(t,e){let r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))}var Zb=uh,$b=hh,eT=ph,tT=dh,rT=mh,wa=fh,nT=gh,oT=function(){let t=gs();return function(e,r,n,o,s,i){let a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var La=[0,0,0],xs,y=class extends wt{static get ZERO(){return xs||(xs=new y(0,0,0),Object.freeze(xs)),xs}constructor(e=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Pe(e)?this.copy(e):(Q.debug&&(V(e),V(r),V(n)),this[0]=e,this[1]=r,this[2]=n)}set(e,r,n){return this[0]=e,this[1]=r,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Q.debug&&(V(e.x),V(e.y),V(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=V(e)}angle(e){return va(this,e)}cross(e){return $t(this,this,e),this.check()}rotateX({radians:e,origin:r=La}){return Ba(this,this,r,e),this.check()}rotateY({radians:e,origin:r=La}){return Ia(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=La}){return Ra(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return er(this,this,e),this.check()}transformAsVector(e){return ds(this,this,e),this.check()}transformByMatrix3(e){return wn(this,this,e),this.check()}transformByMatrix2(e){return ch(this,this,e),this.check()}transformByQuaternion(e){return Ln(this,this,e),this.check()}};var ys,Dr=class extends wt{static get ZERO(){return ys||(ys=new Dr(0,0,0,0),Object.freeze(ys)),ys}constructor(e=0,r=0,n=0,o=0){super(-0,-0,-0,-0),Pe(e)&&arguments.length===1?this.copy(e):(Q.debug&&(V(e),V(r),V(n),V(o)),this[0]=e,this[1]=r,this[2]=n,this[3]=o)}set(e,r,n,o){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return Q.debug&&(V(e.x),V(e.y),V(e.z),V(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=V(e)}get w(){return this[3]}set w(e){this[3]=V(e)}transform(e){return er(this,this,e),this.check()}transformByMatrix3(e){return ms(this,this,e),this.check()}transformByMatrix2(e){return lh(this,this,e),this.check()}transformByQuaternion(e){return Ln(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};var Gr=class extends Rt{toString(){let e="[";if(Q.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=V(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function Ah(){let t=new te(9);return te!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function xh(t,e){if(t===e){let r=e[1],n=e[2],o=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=o}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function yh(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=f*i-a*l,h=-f*s+a*c,p=l*s-i*c,d=r*u+n*h+o*p;return d?(d=1/d,t[0]=u*d,t[1]=(-f*n+o*l)*d,t[2]=(a*n-o*i)*d,t[3]=h*d,t[4]=(f*r-o*c)*d,t[5]=(-a*r+o*s)*d,t[6]=p*d,t[7]=(-l*r+n*c)*d,t[8]=(i*r-n*s)*d,t):null}function bh(t){let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],c=t[7],l=t[8];return e*(l*s-i*c)+r*(-l*o+i*a)+n*(c*o-s*a)}function Fa(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=r[0],p=r[1],d=r[2],m=r[3],g=r[4],x=r[5],b=r[6],M=r[7],E=r[8];return t[0]=h*n+p*i+d*l,t[1]=h*o+p*a+d*f,t[2]=h*s+p*c+d*u,t[3]=m*n+g*i+x*l,t[4]=m*o+g*a+x*f,t[5]=m*s+g*c+x*u,t[6]=b*n+M*i+E*l,t[7]=b*o+M*a+E*f,t[8]=b*s+M*c+E*u,t}function Th(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=r[0],p=r[1];return t[0]=n,t[1]=o,t[2]=s,t[3]=i,t[4]=a,t[5]=c,t[6]=h*n+p*i+l,t[7]=h*o+p*a+f,t[8]=h*s+p*c+u,t}function Mh(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=Math.sin(r),p=Math.cos(r);return t[0]=p*n+h*i,t[1]=p*o+h*a,t[2]=p*s+h*c,t[3]=p*i-h*n,t[4]=p*a-h*o,t[5]=p*c-h*s,t[6]=l,t[7]=f,t[8]=u,t}function Pa(t,e,r){let n=r[0],o=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=o*e[3],t[4]=o*e[4],t[5]=o*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function Eh(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r+r,a=n+n,c=o+o,l=r*i,f=n*i,u=n*a,h=o*i,p=o*a,d=o*c,m=s*i,g=s*a,x=s*c;return t[0]=1-u-d,t[3]=f-x,t[6]=h+g,t[1]=f+x,t[4]=1-l-d,t[7]=p-m,t[2]=h-g,t[5]=p+m,t[8]=1-l-u,t}var Na;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(Na||(Na={}));var iT=Object.freeze([1,0,0,0,1,0,0,0,1]),k=class extends Gr{static get IDENTITY(){return cT()}static get ZERO(){return aT()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Na}constructor(e,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):r.length>0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(iT)}fromObject(e){return this.check()}fromQuaternion(e){return Eh(this,e),this.check()}set(e,r,n,o,s,i,a,c,l){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=s,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,n,o,s,i,a,c,l){return this[0]=e,this[1]=o,this[2]=a,this[3]=r,this[4]=s,this[5]=c,this[6]=n,this[7]=i,this[8]=l,this.check()}determinant(){return bh(this)}transpose(){return xh(this,this),this.check()}invert(){return yh(this,this),this.check()}multiplyLeft(e){return Fa(this,e,this),this.check()}multiplyRight(e){return Fa(this,this,e),this.check()}rotate(e){return Mh(this,this,e),this.check()}scale(e){return Array.isArray(e)?Pa(this,this,e):Pa(this,this,[e,e]),this.check()}translate(e){return Th(this,this,e),this.check()}transform(e,r){let n;switch(e.length){case 2:n=us(r||[-0,-0],e,this);break;case 3:n=wn(r||[-0,-0,-0],e,this);break;case 4:n=ms(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return vt(n,e.length),n}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},bs,Ts=null;function aT(){return bs||(bs=new k([0,0,0,0,0,0,0,0,0]),Object.freeze(bs)),bs}function cT(){return Ts||(Ts=new k,Object.freeze(Ts)),Ts}var Pn={};be(Pn,{add:()=>FT,adjoint:()=>dT,clone:()=>fT,copy:()=>uT,create:()=>lT,decompose:()=>ST,determinant:()=>Da,equals:()=>UT,exactEquals:()=>OT,frob:()=>LT,fromQuat:()=>qa,fromQuat2:()=>TT,fromRotation:()=>AT,fromRotationTranslation:()=>_h,fromRotationTranslationScale:()=>_T,fromRotationTranslationScaleOrigin:()=>CT,fromScaling:()=>gT,fromTranslation:()=>mT,fromValues:()=>hT,fromXRotation:()=>xT,fromYRotation:()=>yT,fromZRotation:()=>bT,frustum:()=>Ja,getRotation:()=>ET,getScaling:()=>Ch,getTranslation:()=>MT,identity:()=>Sh,invert:()=>Ua,lookAt:()=>Ya,mul:()=>DT,multiply:()=>Fn,multiplyScalar:()=>PT,multiplyScalarAndAdd:()=>NT,ortho:()=>Xa,orthoNO:()=>Ih,orthoZO:()=>RT,perspective:()=>Wa,perspectiveFromFieldOfView:()=>IT,perspectiveNO:()=>Bh,perspectiveZO:()=>BT,rotate:()=>Ha,rotateX:()=>za,rotateY:()=>ka,rotateZ:()=>ja,scale:()=>Va,set:()=>pT,str:()=>wT,sub:()=>GT,subtract:()=>Rh,targetTo:()=>vT,translate:()=>Ga,transpose:()=>Oa});function lT(){let t=new te(16);return te!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function fT(t){let e=new te(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function uT(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function hT(t,e,r,n,o,s,i,a,c,l,f,u,h,p,d,m){let g=new te(16);return g[0]=t,g[1]=e,g[2]=r,g[3]=n,g[4]=o,g[5]=s,g[6]=i,g[7]=a,g[8]=c,g[9]=l,g[10]=f,g[11]=u,g[12]=h,g[13]=p,g[14]=d,g[15]=m,g}function pT(t,e,r,n,o,s,i,a,c,l,f,u,h,p,d,m,g){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t[4]=s,t[5]=i,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=u,t[11]=h,t[12]=p,t[13]=d,t[14]=m,t[15]=g,t}function Sh(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Oa(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],s=e[6],i=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=s,t[11]=e[14],t[12]=o,t[13]=i,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ua(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],p=e[11],d=e[12],m=e[13],g=e[14],x=e[15],b=r*a-n*i,M=r*c-o*i,E=r*l-s*i,C=n*c-o*a,_=n*l-s*a,R=o*l-s*c,S=f*m-u*d,T=f*g-h*d,A=f*x-p*d,B=u*g-h*m,L=u*x-p*m,F=h*x-p*g,w=b*F-M*L+E*B+C*A-_*T+R*S;return w?(w=1/w,t[0]=(a*F-c*L+l*B)*w,t[1]=(o*L-n*F-s*B)*w,t[2]=(m*R-g*_+x*C)*w,t[3]=(h*_-u*R-p*C)*w,t[4]=(c*A-i*F-l*T)*w,t[5]=(r*F-o*A+s*T)*w,t[6]=(g*E-d*R-x*M)*w,t[7]=(f*R-h*E+p*M)*w,t[8]=(i*L-a*A+l*S)*w,t[9]=(n*A-r*L-s*S)*w,t[10]=(d*_-m*E+x*b)*w,t[11]=(u*E-f*_-p*b)*w,t[12]=(a*T-i*B-c*S)*w,t[13]=(r*B-n*T+o*S)*w,t[14]=(m*M-d*C-g*b)*w,t[15]=(f*C-u*M+h*b)*w,t):null}function dT(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],p=e[11],d=e[12],m=e[13],g=e[14],x=e[15],b=r*a-n*i,M=r*c-o*i,E=r*l-s*i,C=n*c-o*a,_=n*l-s*a,R=o*l-s*c,S=f*m-u*d,T=f*g-h*d,A=f*x-p*d,B=u*g-h*m,L=u*x-p*m,F=h*x-p*g;return t[0]=a*F-c*L+l*B,t[1]=o*L-n*F-s*B,t[2]=m*R-g*_+x*C,t[3]=h*_-u*R-p*C,t[4]=c*A-i*F-l*T,t[5]=r*F-o*A+s*T,t[6]=g*E-d*R-x*M,t[7]=f*R-h*E+p*M,t[8]=i*L-a*A+l*S,t[9]=n*A-r*L-s*S,t[10]=d*_-m*E+x*b,t[11]=u*E-f*_-p*b,t[12]=a*T-i*B-c*S,t[13]=r*B-n*T+o*S,t[14]=m*M-d*C-g*b,t[15]=f*C-u*M+h*b,t}function Da(t){let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],c=t[7],l=t[8],f=t[9],u=t[10],h=t[11],p=t[12],d=t[13],m=t[14],g=t[15],x=e*i-r*s,b=e*a-n*s,M=r*a-n*i,E=l*d-f*p,C=l*m-u*p,_=f*m-u*d,R=e*_-r*C+n*E,S=s*_-i*C+a*E,T=l*M-f*b+u*x,A=p*M-d*b+m*x;return c*R-o*S+g*T-h*A}function Fn(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=e[9],p=e[10],d=e[11],m=e[12],g=e[13],x=e[14],b=e[15],M=r[0],E=r[1],C=r[2],_=r[3];return t[0]=M*n+E*a+C*u+_*m,t[1]=M*o+E*c+C*h+_*g,t[2]=M*s+E*l+C*p+_*x,t[3]=M*i+E*f+C*d+_*b,M=r[4],E=r[5],C=r[6],_=r[7],t[4]=M*n+E*a+C*u+_*m,t[5]=M*o+E*c+C*h+_*g,t[6]=M*s+E*l+C*p+_*x,t[7]=M*i+E*f+C*d+_*b,M=r[8],E=r[9],C=r[10],_=r[11],t[8]=M*n+E*a+C*u+_*m,t[9]=M*o+E*c+C*h+_*g,t[10]=M*s+E*l+C*p+_*x,t[11]=M*i+E*f+C*d+_*b,M=r[12],E=r[13],C=r[14],_=r[15],t[12]=M*n+E*a+C*u+_*m,t[13]=M*o+E*c+C*h+_*g,t[14]=M*s+E*l+C*p+_*x,t[15]=M*i+E*f+C*d+_*b,t}function Ga(t,e,r){let n=r[0],o=r[1],s=r[2],i,a,c,l,f,u,h,p,d,m,g,x;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*s+e[12],t[13]=e[1]*n+e[5]*o+e[9]*s+e[13],t[14]=e[2]*n+e[6]*o+e[10]*s+e[14],t[15]=e[3]*n+e[7]*o+e[11]*s+e[15]):(i=e[0],a=e[1],c=e[2],l=e[3],f=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],g=e[10],x=e[11],t[0]=i,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=u,t[6]=h,t[7]=p,t[8]=d,t[9]=m,t[10]=g,t[11]=x,t[12]=i*n+f*o+d*s+e[12],t[13]=a*n+u*o+m*s+e[13],t[14]=c*n+h*o+g*s+e[14],t[15]=l*n+p*o+x*s+e[15]),t}function Va(t,e,r){let n=r[0],o=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ha(t,e,r,n){let o=n[0],s=n[1],i=n[2],a=Math.sqrt(o*o+s*s+i*i),c,l,f,u,h,p,d,m,g,x,b,M,E,C,_,R,S,T,A,B,L,F,w,U;return a<1e-6?null:(a=1/a,o*=a,s*=a,i*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,u=e[0],h=e[1],p=e[2],d=e[3],m=e[4],g=e[5],x=e[6],b=e[7],M=e[8],E=e[9],C=e[10],_=e[11],R=o*o*f+c,S=s*o*f+i*l,T=i*o*f-s*l,A=o*s*f-i*l,B=s*s*f+c,L=i*s*f+o*l,F=o*i*f+s*l,w=s*i*f-o*l,U=i*i*f+c,t[0]=u*R+m*S+M*T,t[1]=h*R+g*S+E*T,t[2]=p*R+x*S+C*T,t[3]=d*R+b*S+_*T,t[4]=u*A+m*B+M*L,t[5]=h*A+g*B+E*L,t[6]=p*A+x*B+C*L,t[7]=d*A+b*B+_*L,t[8]=u*F+m*w+M*U,t[9]=h*F+g*w+E*U,t[10]=p*F+x*w+C*U,t[11]=d*F+b*w+_*U,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function za(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[4],i=e[5],a=e[6],c=e[7],l=e[8],f=e[9],u=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*o+l*n,t[5]=i*o+f*n,t[6]=a*o+u*n,t[7]=c*o+h*n,t[8]=l*o-s*n,t[9]=f*o-i*n,t[10]=u*o-a*n,t[11]=h*o-c*n,t}function ka(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[0],i=e[1],a=e[2],c=e[3],l=e[8],f=e[9],u=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o-l*n,t[1]=i*o-f*n,t[2]=a*o-u*n,t[3]=c*o-h*n,t[8]=s*n+l*o,t[9]=i*n+f*o,t[10]=a*n+u*o,t[11]=c*n+h*o,t}function ja(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[0],i=e[1],a=e[2],c=e[3],l=e[4],f=e[5],u=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o+l*n,t[1]=i*o+f*n,t[2]=a*o+u*n,t[3]=c*o+h*n,t[4]=l*o-s*n,t[5]=f*o-i*n,t[6]=u*o-a*n,t[7]=h*o-c*n,t}function mT(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function gT(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function AT(t,e,r){let n=r[0],o=r[1],s=r[2],i=Math.sqrt(n*n+o*o+s*s),a,c,l;return i<1e-6?null:(i=1/i,n*=i,o*=i,s*=i,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=n*n*l+a,t[1]=o*n*l+s*c,t[2]=s*n*l-o*c,t[3]=0,t[4]=n*o*l-s*c,t[5]=o*o*l+a,t[6]=s*o*l+n*c,t[7]=0,t[8]=n*s*l+o*c,t[9]=o*s*l-n*c,t[10]=s*s*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function xT(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function yT(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function bT(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function _h(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=n+n,c=o+o,l=s+s,f=n*a,u=n*c,h=n*l,p=o*c,d=o*l,m=s*l,g=i*a,x=i*c,b=i*l;return t[0]=1-(p+m),t[1]=u+b,t[2]=h-x,t[3]=0,t[4]=u-b,t[5]=1-(f+m),t[6]=d+g,t[7]=0,t[8]=h+x,t[9]=d-g,t[10]=1-(f+p),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function TT(t,e){let r=new te(3),n=-e[0],o=-e[1],s=-e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=n*n+o*o+s*s+i*i;return u>0?(r[0]=(a*i+f*n+c*s-l*o)*2/u,r[1]=(c*i+f*o+l*n-a*s)*2/u,r[2]=(l*i+f*s+a*o-c*n)*2/u):(r[0]=(a*i+f*n+c*s-l*o)*2,r[1]=(c*i+f*o+l*n-a*s)*2,r[2]=(l*i+f*s+a*o-c*n)*2),_h(t,e,r),t}function MT(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Ch(t,e){let r=e[0],n=e[1],o=e[2],s=e[4],i=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+n*n+o*o),t[1]=Math.sqrt(s*s+i*i+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function ET(t,e){let r=new te(3);Ch(r,e);let n=1/r[0],o=1/r[1],s=1/r[2],i=e[0]*n,a=e[1]*o,c=e[2]*s,l=e[4]*n,f=e[5]*o,u=e[6]*s,h=e[8]*n,p=e[9]*o,d=e[10]*s,m=i+f+d,g=0;return m>0?(g=Math.sqrt(m+1)*2,t[3]=.25*g,t[0]=(u-p)/g,t[1]=(h-c)/g,t[2]=(a-l)/g):i>f&&i>d?(g=Math.sqrt(1+i-f-d)*2,t[3]=(u-p)/g,t[0]=.25*g,t[1]=(a+l)/g,t[2]=(h+c)/g):f>d?(g=Math.sqrt(1+f-i-d)*2,t[3]=(h-c)/g,t[0]=(a+l)/g,t[1]=.25*g,t[2]=(u+p)/g):(g=Math.sqrt(1+d-i-f)*2,t[3]=(a-l)/g,t[0]=(h+c)/g,t[1]=(u+p)/g,t[2]=.25*g),t}function ST(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];let o=n[0],s=n[1],i=n[2],a=n[4],c=n[5],l=n[6],f=n[8],u=n[9],h=n[10];r[0]=Math.sqrt(o*o+s*s+i*i),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+u*u+h*h);let p=1/r[0],d=1/r[1],m=1/r[2],g=o*p,x=s*d,b=i*m,M=a*p,E=c*d,C=l*m,_=f*p,R=u*d,S=h*m,T=g+E+S,A=0;return T>0?(A=Math.sqrt(T+1)*2,t[3]=.25*A,t[0]=(C-R)/A,t[1]=(_-b)/A,t[2]=(x-M)/A):g>E&&g>S?(A=Math.sqrt(1+g-E-S)*2,t[3]=(C-R)/A,t[0]=.25*A,t[1]=(x+M)/A,t[2]=(_+b)/A):E>S?(A=Math.sqrt(1+E-g-S)*2,t[3]=(_-b)/A,t[0]=(x+M)/A,t[1]=.25*A,t[2]=(C+R)/A):(A=Math.sqrt(1+S-g-E)*2,t[3]=(x-M)/A,t[0]=(_+b)/A,t[1]=(C+R)/A,t[2]=.25*A),t}function _T(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3],c=o+o,l=s+s,f=i+i,u=o*c,h=o*l,p=o*f,d=s*l,m=s*f,g=i*f,x=a*c,b=a*l,M=a*f,E=n[0],C=n[1],_=n[2];return t[0]=(1-(d+g))*E,t[1]=(h+M)*E,t[2]=(p-b)*E,t[3]=0,t[4]=(h-M)*C,t[5]=(1-(u+g))*C,t[6]=(m+x)*C,t[7]=0,t[8]=(p+b)*_,t[9]=(m-x)*_,t[10]=(1-(u+d))*_,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function CT(t,e,r,n,o){let s=e[0],i=e[1],a=e[2],c=e[3],l=s+s,f=i+i,u=a+a,h=s*l,p=s*f,d=s*u,m=i*f,g=i*u,x=a*u,b=c*l,M=c*f,E=c*u,C=n[0],_=n[1],R=n[2],S=o[0],T=o[1],A=o[2],B=(1-(m+x))*C,L=(p+E)*C,F=(d-M)*C,w=(p-E)*_,U=(1-(h+x))*_,W=(g+b)*_,z=(d+M)*R,re=(g-b)*R,K=(1-(h+m))*R;return t[0]=B,t[1]=L,t[2]=F,t[3]=0,t[4]=w,t[5]=U,t[6]=W,t[7]=0,t[8]=z,t[9]=re,t[10]=K,t[11]=0,t[12]=r[0]+S-(B*S+w*T+z*A),t[13]=r[1]+T-(L*S+U*T+re*A),t[14]=r[2]+A-(F*S+W*T+K*A),t[15]=1,t}function qa(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r+r,a=n+n,c=o+o,l=r*i,f=n*i,u=n*a,h=o*i,p=o*a,d=o*c,m=s*i,g=s*a,x=s*c;return t[0]=1-u-d,t[1]=f+x,t[2]=h-g,t[3]=0,t[4]=f-x,t[5]=1-l-d,t[6]=p+m,t[7]=0,t[8]=h+g,t[9]=p-m,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ja(t,e,r,n,o,s,i){let a=1/(r-e),c=1/(o-n),l=1/(s-i);return t[0]=s*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+n)*c,t[10]=(i+s)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=i*s*2*l,t[15]=0,t}function Bh(t,e,r,n,o){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let i=1/(n-o);t[10]=(o+n)*i,t[14]=2*o*n*i}else t[10]=-1,t[14]=-2*n;return t}var Wa=Bh;function BT(t,e,r,n,o){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let i=1/(n-o);t[10]=o*i,t[14]=o*n*i}else t[10]=-1,t[14]=-n;return t}function IT(t,e,r,n){let o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),i=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(i+a),l=2/(o+s);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((i-a)*c*.5),t[9]=(o-s)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function Ih(t,e,r,n,o,s,i){let a=1/(e-r),c=1/(n-o),l=1/(s-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=(i+s)*l,t[15]=1,t}var Xa=Ih;function RT(t,e,r,n,o,s,i){let a=1/(e-r),c=1/(n-o),l=1/(s-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=s*l,t[15]=1,t}function Ya(t,e,r,n){let o,s,i,a,c,l,f,u,h,p,d=e[0],m=e[1],g=e[2],x=n[0],b=n[1],M=n[2],E=r[0],C=r[1],_=r[2];return Math.abs(d-E)<1e-6&&Math.abs(m-C)<1e-6&&Math.abs(g-_)<1e-6?Sh(t):(u=d-E,h=m-C,p=g-_,o=1/Math.sqrt(u*u+h*h+p*p),u*=o,h*=o,p*=o,s=b*p-M*h,i=M*u-x*p,a=x*h-b*u,o=Math.sqrt(s*s+i*i+a*a),o?(o=1/o,s*=o,i*=o,a*=o):(s=0,i=0,a=0),c=h*a-p*i,l=p*s-u*a,f=u*i-h*s,o=Math.sqrt(c*c+l*l+f*f),o?(o=1/o,c*=o,l*=o,f*=o):(c=0,l=0,f=0),t[0]=s,t[1]=c,t[2]=u,t[3]=0,t[4]=i,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=f,t[10]=p,t[11]=0,t[12]=-(s*d+i*m+a*g),t[13]=-(c*d+l*m+f*g),t[14]=-(u*d+h*m+p*g),t[15]=1,t)}function vT(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=n[0],c=n[1],l=n[2],f=o-r[0],u=s-r[1],h=i-r[2],p=f*f+u*u+h*h;p>0&&(p=1/Math.sqrt(p),f*=p,u*=p,h*=p);let d=c*h-l*u,m=l*f-a*h,g=a*u-c*f;return p=d*d+m*m+g*g,p>0&&(p=1/Math.sqrt(p),d*=p,m*=p,g*=p),t[0]=d,t[1]=m,t[2]=g,t[3]=0,t[4]=u*g-h*m,t[5]=h*d-f*g,t[6]=f*m-u*d,t[7]=0,t[8]=f,t[9]=u,t[10]=h,t[11]=0,t[12]=o,t[13]=s,t[14]=i,t[15]=1,t}function wT(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function LT(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function FT(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function Rh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function PT(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function NT(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function OT(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function UT(t,e){let r=t[0],n=t[1],o=t[2],s=t[3],i=t[4],a=t[5],c=t[6],l=t[7],f=t[8],u=t[9],h=t[10],p=t[11],d=t[12],m=t[13],g=t[14],x=t[15],b=e[0],M=e[1],E=e[2],C=e[3],_=e[4],R=e[5],S=e[6],T=e[7],A=e[8],B=e[9],L=e[10],F=e[11],w=e[12],U=e[13],W=e[14],z=e[15];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(n-M)<=1e-6*Math.max(1,Math.abs(n),Math.abs(M))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(s-C)<=1e-6*Math.max(1,Math.abs(s),Math.abs(C))&&Math.abs(i-_)<=1e-6*Math.max(1,Math.abs(i),Math.abs(_))&&Math.abs(a-R)<=1e-6*Math.max(1,Math.abs(a),Math.abs(R))&&Math.abs(c-S)<=1e-6*Math.max(1,Math.abs(c),Math.abs(S))&&Math.abs(l-T)<=1e-6*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(f-A)<=1e-6*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(u-B)<=1e-6*Math.max(1,Math.abs(u),Math.abs(B))&&Math.abs(h-L)<=1e-6*Math.max(1,Math.abs(h),Math.abs(L))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(d-w)<=1e-6*Math.max(1,Math.abs(d),Math.abs(w))&&Math.abs(m-U)<=1e-6*Math.max(1,Math.abs(m),Math.abs(U))&&Math.abs(g-W)<=1e-6*Math.max(1,Math.abs(g),Math.abs(W))&&Math.abs(x-z)<=1e-6*Math.max(1,Math.abs(x),Math.abs(z))}var DT=Fn,GT=Rh;function VT(){let t=new te(4);return te!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function vh(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function wh(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function Lh(t){let e=t[0],r=t[1],n=t[2],o=t[3];return Math.sqrt(e*e+r*r+n*n+o*o)}function Fh(t){let e=t[0],r=t[1],n=t[2],o=t[3];return e*e+r*r+n*n+o*o}function Ph(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=o*i,t[3]=s*i,t}function Nh(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Oh(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function Uh(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*s+r[12]*i,t[1]=r[1]*n+r[5]*o+r[9]*s+r[13]*i,t[2]=r[2]*n+r[6]*o+r[10]*s+r[14]*i,t[3]=r[3]*n+r[7]*o+r[11]*s+r[15]*i,t}function Dh(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2],l=r[3],f=l*n+a*s-c*o,u=l*o+c*n-i*s,h=l*s+i*o-a*n,p=-i*n-a*o-c*s;return t[0]=f*l+p*-i+u*-c-h*-a,t[1]=u*l+p*-a+h*-i-f*-c,t[2]=h*l+p*-c+f*-a-u*-i,t[3]=e[3],t}var Kw=function(){let t=VT();return function(e,r,n,o,s,i){let a,c;for(r||(r=4),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var Za;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Za||(Za={}));var zT=45*Math.PI/180,kT=1,Ka=.1,Qa=500,jT=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),N=class extends Gr{static get IDENTITY(){return JT()}static get ZERO(){return qT()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Za}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,o,s,i,a,c,l,f,u,h,p,d,m,g){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=s,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=u,this[11]=h,this[12]=p,this[13]=d,this[14]=m,this[15]=g,this.check()}setRowMajor(e,r,n,o,s,i,a,c,l,f,u,h,p,d,m,g){return this[0]=e,this[1]=s,this[2]=l,this[3]=p,this[4]=r,this[5]=i,this[6]=f,this[7]=d,this[8]=n,this[9]=a,this[10]=u,this[11]=m,this[12]=o,this[13]=c,this[14]=h,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(jT)}fromObject(e){return this.check()}fromQuaternion(e){return qa(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:s,near:i=Ka,far:a=Qa}=e;return a===1/0?WT(this,r,n,o,s,i):Ja(this,r,n,o,s,i,a),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return Ya(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:s,near:i=Ka,far:a=Qa}=e;return Xa(this,r,n,o,s,i,a),this.check()}orthographic(e){let{fovy:r=zT,aspect:n=kT,focalDistance:o=1,near:s=Ka,far:i=Qa}=e;Gh(r);let a=r/2,c=o*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:i})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:s=500}=e;return Gh(r),Wa(this,r,n,o,s),this.check()}determinant(){return Da(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],s=1/n[1],i=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*s,e[2]=this[2]*i,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*s,e[6]=this[6]*i,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*s,e[10]=this[10]*i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],s=1/n[1],i=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*s,e[2]=this[2]*i,e[3]=this[4]*o,e[4]=this[5]*s,e[5]=this[6]*i,e[6]=this[8]*o,e[7]=this[9]*s,e[8]=this[10]*i,e}transpose(){return Oa(this,this),this.check()}invert(){return Ua(this,this),this.check()}multiplyLeft(e){return Fn(this,e,this),this.check()}multiplyRight(e){return Fn(this,this,e),this.check()}rotateX(e){return za(this,this,e),this.check()}rotateY(e){return ka(this,this,e),this.check()}rotateZ(e){return ja(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return Ha(this,this,e,r),this.check()}scale(e){return Va(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ga(this,this,e),this.check()}transform(e,r){return e.length===4?(r=Uh(r||[-0,-0,-0,-0],e,this),vt(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=hs(r||[-0,-0],e,this);break;case 3:o=er(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return vt(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=ps(r||[-0,-0],e,this);break;case 3:n=ds(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return vt(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},Ms,Es;function qT(){return Ms||(Ms=new N([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ms)),Ms}function JT(){return Es||(Es=new N,Object.freeze(Es)),Es}function Gh(t){if(t>Math.PI*2)throw Error("expected radians")}function WT(t,e,r,n,o,s){let i=2*s/(r-e),a=2*s/(o-n),c=(r+e)/(r-e),l=(o+n)/(o-n),f=-1,u=-1,h=-2*s;return t[0]=i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=u,t[12]=0,t[13]=0,t[14]=h,t[15]=0,t}function Vh(){let t=new te(4);return te!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Hh(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function $a(t,e,r){r=r*.5;let n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function ec(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+o*l-s*c,t[1]=o*f+i*c+s*a-n*l,t[2]=s*f+i*l+n*c-o*a,t[3]=i*f-n*a-o*c-s*l,t}function zh(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=o*c+s*a,t[2]=s*c-o*a,t[3]=i*c-n*a,t}function kh(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-s*a,t[1]=o*c+i*a,t[2]=s*c+n*a,t[3]=i*c-o*a,t}function jh(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*a,t[1]=o*c-n*a,t[2]=s*c+i*a,t[3]=i*c-s*a,t}function qh(t,e){let r=e[0],n=e[1],o=e[2];return t[0]=r,t[1]=n,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-o*o)),t}function Nn(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],h,p,d,m,g;return h=o*c+s*l+i*f+a*u,h<0&&(h=-h,c=-c,l=-l,f=-f,u=-u),1-h>1e-6?(p=Math.acos(h),g=Math.sin(p),d=Math.sin((1-n)*p)/g,m=Math.sin(n*p)/g):(d=1-n,m=n),t[0]=d*o+m*c,t[1]=d*s+m*l,t[2]=d*i+m*f,t[3]=d*a+m*u,t}function Jh(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-o*a,t[3]=s*a,t}function Wh(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function tc(t,e){let r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let o=0;e[4]>e[0]&&(o=1),e[8]>e[o*3+o]&&(o=2);let s=(o+1)%3,i=(o+2)%3;n=Math.sqrt(e[o*3+o]-e[s*3+s]-e[i*3+i]+1),t[o]=.5*n,n=.5/n,t[3]=(e[s*3+i]-e[i*3+s])*n,t[s]=(e[s*3+o]+e[o*3+s])*n,t[i]=(e[i*3+o]+e[o*3+i])*n}return t}var Xh=vh;var Yh=wh,Kh=Nh,Qh=Oh,Zh=Lh;var $h=Fh;var ep=Ph;var tp=function(){let t=gs(),e=As(1,0,0),r=As(0,1,0);return function(n,o,s){let i=vn(o,s);return i<-.999999?($t(t,e,o),wa(t)<1e-6&&$t(t,r,o),Ca(t,t),$a(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):($t(t,o,s),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,ep(n,n))}}(),fL=function(){let t=Vh(),e=Vh();return function(r,n,o,s,i,a){return Nn(t,n,i,a),Nn(e,o,s,a),Nn(r,t,e,2*a*(1-a)),r}}(),uL=function(){let t=Ah();return function(e,r,n,o){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],ep(e,tc(e,t))}}();var XT=[0,0,0,1],it=class extends Rt{constructor(e=0,r=0,n=0,o=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,n,o)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,n,o){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return tc(this,e),this.check()}fromAxisRotation(e,r){return $a(this,e,r),this.check()}identity(){return Hh(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=V(e)}get y(){return this[1]}set y(e){this[1]=V(e)}get z(){return this[2]}set z(e){this[2]=V(e)}get w(){return this[3]}set w(e){this[3]=V(e)}len(){return Zh(this)}lengthSquared(){return $h(this)}dot(e){return Kh(this,e)}rotationTo(e,r){return tp(this,e,r),this.check()}add(e){return Xh(this,this,e),this.check()}calculateW(){return qh(this,this),this.check()}conjugate(){return Wh(this,this),this.check()}invert(){return Jh(this,this),this.check()}lerp(e,r,n){return n===void 0?this.lerp(this,e,r):(Qh(this,e,r,n),this.check())}multiplyRight(e){return ec(this,this,e),this.check()}multiplyLeft(e){return ec(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return zh(this,this,e),this.check()}rotateY(e){return kh(this,this,e),this.check()}rotateZ(e){return jh(this,this,e),this.check()}scale(e){return Yh(this,this,e),this.check()}slerp(e,r,n){let o,s,i;switch(arguments.length){case 1:({start:o=XT,target:s,ratio:i}=e);break;case 2:o=this,s=e,i=r;break;default:o=e,s=r,i=n}return Nn(this,o,s,i),this.check()}transformVector4(e,r=new Dr){return Dh(r,e,this),vt(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var Ge={};be(Ge,{EPSILON1:()=>YT,EPSILON10:()=>oM,EPSILON11:()=>sM,EPSILON12:()=>iM,EPSILON13:()=>aM,EPSILON14:()=>cM,EPSILON15:()=>lM,EPSILON16:()=>fM,EPSILON17:()=>uM,EPSILON18:()=>hM,EPSILON19:()=>pM,EPSILON2:()=>KT,EPSILON20:()=>dM,EPSILON3:()=>QT,EPSILON4:()=>ZT,EPSILON5:()=>$T,EPSILON6:()=>eM,EPSILON7:()=>tM,EPSILON8:()=>rM,EPSILON9:()=>nM,PI_OVER_FOUR:()=>gM,PI_OVER_SIX:()=>AM,PI_OVER_TWO:()=>mM,TWO_PI:()=>xM});var YT=.1,KT=.01,QT=.001,ZT=1e-4,$T=1e-5,eM=1e-6,tM=1e-7,rM=1e-8,nM=1e-9,oM=1e-10,sM=1e-11,iM=1e-12,aM=1e-13,cM=1e-14,lM=1e-15,fM=1e-16,uM=1e-17,hM=1e-18,pM=1e-19,dM=1e-20,mM=Math.PI/2,gM=Math.PI/4,AM=Math.PI/6,xM=Math.PI*2;function Ss(t,e){e=e===void 0?t[0][0]:e;for(let r of t){let n=r[0]-e;n>180?r[0]-=360:n<-180&&(r[0]+=360)}}function yM(t,e,r){let[n,o]=(0,On.cellToLatLng)(t),s=e.length;Ss(e,o);let i=e[0]===e[s-1]?s-1:s;for(let a=0;a<i;a++)e[a][0]=It(o,e[a][0],r),e[a][1]=It(n,e[a][1],r)}function rp(t,e,r){let n=t(e,r),[o,s]=(0,On.cellToLatLng)(n);return[s,o]}function rc(t,e=1){let r=(0,On.cellToBoundary)(t,!0);return e!==1?yM(t,r,e):Ss(r),r}function _s(t){let e=new Float64Array(t.length*2),r=0;for(let n of t)e[r++]=n[0],e[r++]=n[1];return e}var bM={getPentagon:{type:"accessor",value:t=>t.pentagon}},Un=class extends De{indexToBounds(){let{data:e,getPentagon:r}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(n,o)=>{let s=r(n,o),i=eh(typeof s=="string"?th(s):s,{closedRing:!0,segments:"auto"});return _s(i)}}}};Un.layerName="A5Layer";Un.defaultProps=bM;var np=Un;var hr=D(ot(),1),od=D(Xe(),1),sd=D(rr(),1);function TM(t){return typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t}function Cs(t){if(Array.isArray(t))return t.map(e=>Cs(e));if(t&&typeof t=="object"){let e={};for(let[r,n]of Object.entries(t))e[TM(r)]=Cs(n);return e}return t}var sp=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",MM=sp+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",EM="["+sp+"]["+MM+"]*",SM=new RegExp("^"+EM+"$");function Bs(t,e){let r=[],n=e.exec(t);for(;n;){let o=[];o.startIndex=e.lastIndex-n[0].length;let s=n.length;for(let i=0;i<s;i++)o.push(n[i]);r.push(o),n=e.exec(t)}return r}var Vr=function(t){let e=SM.exec(t);return!(e===null||typeof e>"u")};function ip(t){return typeof t<"u"}var Dn=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Is=["__proto__","constructor","prototype"];var _M={allowBooleanAttributes:!1,unpairedTags:[]};function up(t,e){e=Object.assign({},_M,e);let r=[],n=!1,o=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=cp(t,s),s.err)return s}else if(t[s]==="<"){let i=s;if(s++,t[s]==="!"){s=lp(t,s);continue}else{let a=!1;t[s]==="/"&&(a=!0,s++);let c="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
|
|
8
|
-
`&&t[s]!=="\r";s++)c+=t[s];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),s--),!
|
|
9
|
-
`||t==="\r"}function cp(t,e){let r=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){let n=t.substr(r,e-r);if(e>5&&n==="xml")return se("InvalidXml","XML declaration allowed only at the start of the document.",Ce(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function lp(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let r=1;for(e+=8;e<t.length;e++)if(t[e]==="<")r++;else if(t[e]===">"&&(r--,r===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}var CM='"',BM="'";function IM(t,e){let r="",n="",o=!1;for(;e<t.length;e++){if(t[e]===CM||t[e]===BM)n===""?n=t[e]:n!==t[e]||(n="");else if(t[e]===">"&&n===""){o=!0;break}r+=t[e]}return n!==""?!1:{value:r,index:e,tagClosed:o}}var RM=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function fp(t,e){let r=Bs(t,RM),n={};for(let o=0;o<r.length;o++){if(r[o][1].length===0)return se("InvalidAttr","Attribute '"+r[o][2]+"' has no space in starting.",Gn(r[o]));if(r[o][3]!==void 0&&r[o][4]===void 0)return se("InvalidAttr","Attribute '"+r[o][2]+"' is without value.",Gn(r[o]));if(r[o][3]===void 0&&!e.allowBooleanAttributes)return se("InvalidAttr","boolean attribute '"+r[o][2]+"' is not allowed.",Gn(r[o]));let s=r[o][2];if(!LM(s))return se("InvalidAttr","Attribute '"+s+"' is an invalid name.",Gn(r[o]));if(!Object.prototype.hasOwnProperty.call(n,s))n[s]=1;else return se("InvalidAttr","Attribute '"+s+"' is repeated.",Gn(r[o]))}return!0}function vM(t,e){let r=/\d/;for(t[e]==="x"&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(r))break}return-1}function wM(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,vM(t,e);let r=0;for(;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(t[e]===";")break;return-1}return e}function se(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function LM(t){return Vr(t)}function FM(t){return Vr(t)}function Ce(t,e){let r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function Gn(t){return t.startIndex+t[1].length}var hp=t=>Dn.includes(t)?"__"+t:t,PM={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:hp};function NM(t,e){if(typeof t!="string")return;let r=t.toLowerCase();if(Dn.some(n=>r===n.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Is.some(n=>r===n.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function pp(t){return typeof t=="boolean"?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof t=="object"&&t!==null?{enabled:t.enabled!==!1,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:pp(!0)}var dp=function(t){let e=Object.assign({},PM,t),r=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(let{value:n,name:o}of r)n&&NM(n,o);return e.onDangerousProperty===null&&(e.onDangerousProperty=hp),e.processEntities=pp(e.processEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(n=>typeof n=="string"&&n.startsWith("*.")?".."+n.substring(2):n)),e};var Rs;typeof Symbol!="function"?Rs="@@xmlMetadata":Rs=Symbol("XML Node Metadata");var Re=class{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,r){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:r})}addChild(e,r){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,[":@"]:e[":@"]}):this.child.push({[e.tagname]:e.child}),r!==void 0&&(this.child[this.child.length-1][Rs]={startIndex:r})}static getMetaDataSymbol(){return Rs}};var Hn=class{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,r){let n=Object.create(null),o=0;if(e[r+3]==="O"&&e[r+4]==="C"&&e[r+5]==="T"&&e[r+6]==="Y"&&e[r+7]==="P"&&e[r+8]==="E"){r=r+9;let s=1,i=!1,a=!1,c="";for(;r<e.length;r++)if(e[r]==="<"&&!a){if(i&&nr(e,"!ENTITY",r)){r+=7;let l,f;if([l,f,r]=this.readEntityExp(e,r+1,this.suppressValidationErr),f.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&o>=this.options.maxEntityCount)throw new Error(`Entity count (${o+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);let u=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n[l]={regx:RegExp(`&${u};`,"g"),val:f},o++}}else if(i&&nr(e,"!ELEMENT",r)){r+=8;let{index:l}=this.readElementExp(e,r+1);r=l}else if(i&&nr(e,"!ATTLIST",r))r+=8;else if(i&&nr(e,"!NOTATION",r)){r+=9;let{index:l}=this.readNotationExp(e,r+1,this.suppressValidationErr);r=l}else if(nr(e,"!--",r))a=!0;else throw new Error("Invalid DOCTYPE");s++,c=""}else if(e[r]===">"){if(a?e[r-1]==="-"&&e[r-2]==="-"&&(a=!1,s--):s--,s===0)break}else e[r]==="["?i=!0:c+=e[r];if(s!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:r}}readEntityExp(e,r){r=ve(e,r);let n=r;for(;r<e.length&&!/\s/.test(e[r])&&e[r]!=='"'&&e[r]!=="'";)r++;let o=e.substring(n,r);if(Vn(o),r=ve(e,r),!this.suppressValidationErr){if(e.substring(r,r+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[r]==="%")throw new Error("Parameter entities are not supported")}let s="";if([r,s]=this.readIdentifierVal(e,r,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${o}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return r--,[o,s,r]}readNotationExp(e,r){r=ve(e,r);let n=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let o=e.substring(n,r);!this.suppressValidationErr&&Vn(o),r=ve(e,r);let s=e.substring(r,r+6).toUpperCase();if(!this.suppressValidationErr&&s!=="SYSTEM"&&s!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);r+=s.length,r=ve(e,r);let i=null,a=null;if(s==="PUBLIC")[r,i]=this.readIdentifierVal(e,r,"publicIdentifier"),r=ve(e,r),(e[r]==='"'||e[r]==="'")&&([r,a]=this.readIdentifierVal(e,r,"systemIdentifier"));else if(s==="SYSTEM"&&([r,a]=this.readIdentifierVal(e,r,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:o,publicIdentifier:i,systemIdentifier:a,index:--r}}readIdentifierVal(e,r,n){let o="",s=e[r];if(s!=='"'&&s!=="'")throw new Error(`Expected quoted string, found "${s}"`);r++;let i=r;for(;r<e.length&&e[r]!==s;)r++;if(o=e.substring(i,r),e[r]!==s)throw new Error(`Unterminated ${n} value`);return r++,[r,o]}readElementExp(e,r){r=ve(e,r);let n=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let o=e.substring(n,r);if(!this.suppressValidationErr&&!Vr(o))throw new Error(`Invalid element name: "${o}"`);r=ve(e,r);let s="";if(e[r]==="E"&&nr(e,"MPTY",r))r+=4;else if(e[r]==="A"&&nr(e,"NY",r))r+=2;else if(e[r]==="("){r++;let i=r;for(;r<e.length&&e[r]!==")";)r++;if(s=e.substring(i,r),e[r]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[r]}"`);return{elementName:o,contentModel:s.trim(),index:r}}readAttlistExp(e,r){r=ve(e,r);let n=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let o=e.substring(n,r);for(Vn(o),r=ve(e,r),n=r;r<e.length&&!/\s/.test(e[r]);)r++;let s=e.substring(n,r);if(!Vn(s))throw new Error(`Invalid attribute name: "${s}"`);r=ve(e,r);let i="";if(e.substring(r,r+8).toUpperCase()==="NOTATION"){if(i="NOTATION",r+=8,r=ve(e,r),e[r]!=="(")throw new Error(`Expected '(', found "${e[r]}"`);r++;let c=[];for(;r<e.length&&e[r]!==")";){let l=r;for(;r<e.length&&e[r]!=="|"&&e[r]!==")";)r++;let f=e.substring(l,r);if(f=f.trim(),!Vn(f))throw new Error(`Invalid notation name: "${f}"`);c.push(f),e[r]==="|"&&(r++,r=ve(e,r))}if(e[r]!==")")throw new Error("Unterminated list of notations");r++,i+=" ("+c.join("|")+")"}else{let c=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;i+=e.substring(c,r);let l=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!l.includes(i.toUpperCase()))throw new Error(`Invalid attribute type: "${i}"`)}r=ve(e,r);let a="";return e.substring(r,r+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",r+=8):e.substring(r,r+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",r+=7):[r,a]=this.readIdentifierVal(e,r,"ATTLIST"),{elementName:o,attributeName:s,attributeType:i,defaultValue:a,index:r}}},ve=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function nr(t,e,r){for(let n=0;n<e.length;n++)if(e[n]!==t[r+n+1])return!1;return!0}function Vn(t){if(Vr(t))return t;throw new Error(`Invalid entity name ${t}`)}var OM=/^[-+]?0x[a-fA-F0-9]+$/,UM=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,DM={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function nc(t,e={}){if(e=Object.assign({},DM,e),!t||typeof t!="string")return t;let r=t.trim();if(r.length===0)return t;if(e.skipLike!==void 0&&e.skipLike.test(r))return t;if(r==="0")return 0;if(e.hex&&OM.test(r))return zM(r,16);if(isFinite(r)){if(r.includes("e")||r.includes("E"))return VM(t,r,e);{let n=UM.exec(r);if(n){let o=n[1]||"",s=n[2],i=HM(n[3]),a=o?t[s.length+1]===".":t[s.length]===".";if(!e.leadingZeros&&(s.length>1||s.length===1&&!a))return t;{let c=Number(r),l=String(c);if(c===0)return c;if(l.search(/[eE]/)!==-1)return e.eNotation?c:t;if(r.indexOf(".")!==-1)return l==="0"||l===i||l===`${o}${i}`?c:t;let f=s?i:r;return s?f===l||o+f===l?c:t:f===l||f===o+l?c:t}}else return t}}else return kM(t,Number(r),e)}var GM=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function VM(t,e,r){if(!r.eNotation)return t;let n=e.match(GM);if(n){let o=n[1]||"",s=n[3].indexOf("e")===-1?"E":"e",i=n[2],a=o?t[i.length+1]===s:t[i.length]===s;return i.length>1&&a?t:i.length===1&&(n[3].startsWith(`.${s}`)||n[3][0]===s)?Number(e):i.length>0?r.leadingZeros&&!a?(e=(n[1]||"")+n[3],Number(e)):t:Number(e)}else return t}function HM(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substring(0,t.length-1))),t}function zM(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function kM(t,e,r){let n=e===1/0;switch(r.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return n?"Infinity":"-Infinity";case"original":default:return t}}function oc(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(let r of t)if(typeof r=="string"&&e===r||r instanceof RegExp&&r.test(e))return!0}:()=>!1}var or=class{constructor(e,r={},n){this.pattern=e,this.separator=r.separator||".",this.segments=this._parse(e),this.data=n,this._hasDeepWildcard=this.segments.some(o=>o.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(o=>o.attrName!==void 0),this._hasPositionSelector=this.segments.some(o=>o.position!==void 0)}_parse(e){let r=[],n=0,o="";for(;n<e.length;)e[n]===this.separator?n+1<e.length&&e[n+1]===this.separator?(o.trim()&&(r.push(this._parseSegment(o.trim())),o=""),r.push({type:"deep-wildcard"}),n+=2):(o.trim()&&r.push(this._parseSegment(o.trim())),o="",n++):(o+=e[n],n++);return o.trim()&&r.push(this._parseSegment(o.trim())),r}_parseSegment(e){let r={type:"tag"},n=null,o=e,s=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(s&&(o=s[1]+s[3],s[2])){let f=s[2].slice(1,-1);f&&(n=f)}let i,a=o;if(o.includes("::")){let f=o.indexOf("::");if(i=o.substring(0,f).trim(),a=o.substring(f+2).trim(),!i)throw new Error(`Invalid namespace in pattern: ${e}`)}let c,l=null;if(a.includes(":")){let f=a.lastIndexOf(":"),u=a.substring(0,f).trim(),h=a.substring(f+1).trim();["first","last","odd","even"].includes(h)||/^nth\(\d+\)$/.test(h)?(c=u,l=h):c=a}else c=a;if(!c)throw new Error(`Invalid segment pattern: ${e}`);if(r.tag=c,i&&(r.namespace=i),n)if(n.includes("=")){let f=n.indexOf("=");r.attrName=n.substring(0,f).trim(),r.attrValue=n.substring(f+1).trim()}else r.attrName=n.trim();if(l){let f=l.match(/^nth\((\d+)\)$/);f?(r.position="nth",r.positionValue=parseInt(f[1],10)):r.position=l}return r}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}};var Hr=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard())return this._deepWildcards.push(e),this;let r=e.length,o=e.segments[e.segments.length-1]?.tag;if(!o||o==="*")this._wildcardByDepth.has(r)||this._wildcardByDepth.set(r,[]),this._wildcardByDepth.get(r).push(e);else{let s=`${r}:${o}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(e)}return this}addAll(e){for(let r of e)this.add(r);return this}has(e){return this._patterns.has(e.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(e){return this.findMatch(e)!==null}findMatch(e){let r=e.getDepth(),n=e.getCurrentTag(),o=`${r}:${n}`,s=this._byDepthAndTag.get(o);if(s){for(let a=0;a<s.length;a++)if(e.matches(s[a]))return s[a]}let i=this._wildcardByDepth.get(r);if(i){for(let a=0;a<i.length;a++)if(e.matches(i[a]))return i[a]}for(let a=0;a<this._deepWildcards.length;a++)if(e.matches(this._deepWildcards[a]))return this._deepWildcards[a];return null}};var jM=new Set(["push","pop","reset","updateCurrent","restore"]),zr=class{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null}push(e,r=null,n=null){if(this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path.length>0){let f=this.path[this.path.length-1];f.values=void 0}let o=this.path.length;this.siblingStacks[o]||(this.siblingStacks[o]=new Map);let s=this.siblingStacks[o],i=n?`${n}:${e}`:e,a=s.get(i)||0,c=0;for(let f of s.values())c+=f;s.set(i,a+1);let l={tag:e,position:c,counter:a};n!=null&&(l.namespace=n),r!=null&&(l.values=r),this.path.push(l)}pop(){if(this.path.length===0)return;this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null;let e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){let r=this.path[this.path.length-1];e!=null&&(r.values=e,this._frozenPathCache=null)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){return this.path.length===0?void 0:this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let r=this.path[this.path.length-1];return r.values!==void 0&&e in r.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,r=!0){let n=e||this.separator;if(n===this.separator&&r===!0){if(this._pathStringCache!==null&&this._pathStringCache!==void 0)return this._pathStringCache;let s=this.path.map(i=>r&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(n);return this._pathStringCache=s,s}return this.path.map(s=>r&&s.namespace?`${s.namespace}:${s.tag}`:s.tag).join(n)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=[],this.siblingStacks=[]}matches(e){let r=e.segments;return r.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(r):this._matchSimple(r)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let r=0;r<e.length;r++){let n=e[r],o=this.path[r],s=r===this.path.length-1;if(!this._matchSegment(n,o,s))return!1}return!0}_matchWithDeepWildcard(e){let r=this.path.length-1,n=e.length-1;for(;n>=0&&r>=0;){let o=e[n];if(o.type==="deep-wildcard"){if(n--,n<0)return!0;let s=e[n],i=!1;for(let a=r;a>=0;a--){let c=a===this.path.length-1;if(this._matchSegment(s,this.path[a],c)){r=a-1,n--,i=!0;break}}if(!i)return!1}else{let s=r===this.path.length-1;if(!this._matchSegment(o,this.path[r],s))return!1;r--,n--}}return n<0}_matchSegment(e,r,n){if(e.tag!=="*"&&e.tag!==r.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==r.namespace)return!1;if(e.attrName!==void 0){if(!n||!r.values||!(e.attrName in r.values))return!1;if(e.attrValue!==void 0){let o=r.values[e.attrName];if(String(o)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!n)return!1;let o=r.counter??0;if(e.position==="first"&&o!==0)return!1;if(e.position==="odd"&&o%2!==1)return!1;if(e.position==="even"&&o%2!==0)return!1;if(e.position==="nth"&&o!==e.positionValue)return!1}return!0}matchesAny(e){return e.matchesAny(this)}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=e.path.map(r=>({...r})),this.siblingStacks=e.siblingStacks.map(r=>new Map(r))}readOnly(){let e=this;return new Proxy(e,{get(r,n,o){if(jM.has(n))return()=>{throw new TypeError(`Cannot call '${n}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};if(n==="path")return r._frozenPathCache===null&&(r._frozenPathCache=Object.freeze(r.path.map(i=>Object.freeze({...i})))),r._frozenPathCache;if(n==="siblingStacks")return r._frozenSiblingsCache===null&&(r._frozenSiblingsCache=Object.freeze(r.siblingStacks.map(i=>Object.freeze(new Map(i))))),r._frozenSiblingsCache;let s=Reflect.get(r,n,o);return typeof s=="function"?s.bind(r):s},set(r,n){throw new TypeError(`Cannot set property '${String(n)}' on a read-only Matcher.`)},deleteProperty(r,n){throw new TypeError(`Cannot delete property '${String(n)}' from a read-only Matcher.`)}})}};function qM(t,e){if(!t)return{};let r=e.attributesGroupName?t[e.attributesGroupName]:t;if(!r)return{};let n={};for(let o in r)if(o.startsWith(e.attributeNamePrefix)){let s=o.substring(e.attributeNamePrefix.length);n[s]=r[o]}else n[o]=r[o];return n}function JM(t){if(!t||typeof t!="string")return;let e=t.indexOf(":");if(e!==-1&&e>0){let r=t.substring(0,e);if(r!=="xmlns")return r}}var zn=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,o)=>mp(o,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,o)=>mp(o,16,"&#x")}},this.addExternalEntities=WM,this.parseXml=ZM,this.parseTextData=XM,this.resolveNameSpace=YM,this.buildAttributesMap=QM,this.isItStopNode=rE,this.replaceEntitiesValue=eE,this.readStopNodeData=sE,this.saveTextToParentTag=tE,this.addChild=$M,this.ignoreAttributesFn=oc(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new zr,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new Hr;let r=this.options.stopNodes;if(r&&r.length>0){for(let n=0;n<r.length;n++){let o=r[n];typeof o=="string"?this.stopNodeExpressionsSet.add(new or(o)):o instanceof or&&this.stopNodeExpressionsSet.add(o)}this.stopNodeExpressionsSet.seal()}}};function WM(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let n=e[r],o=n.replace(/[.\-+*:]/g,"\\.");this.lastEntities[n]={regex:new RegExp("&"+o+";","g"),val:t[n]}}}function XM(t,e,r,n,o,s,i){let a=this.options;if(t!==void 0&&(a.trimValues&&!n&&(t=t.trim()),t.length>0)){i||(t=this.replaceEntitiesValue(t,e,r));let c=a.jPath?r.toString():r,l=a.tagValueProcessor(e,t,c,o,s);return l==null?t:typeof l!=typeof t||l!==t?l:a.trimValues||t.trim()===t?ac(t,a.parseTagValue,a.numberParseOptions):t}}function YM(t){if(this.options.removeNSPrefix){let e=t.split(":"),r=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=r+e[1])}return t}var KM=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function QM(t,e,r){let n=this.options;if(n.ignoreAttributes!==!0&&typeof t=="string"){let o=Bs(t,KM),s=o.length,i={},a=new Array(s),c=!1,l={};for(let h=0;h<s;h++){let p=this.resolveNameSpace(o[h][1]),d=o[h][4];if(p.length&&d!==void 0){let m=d;n.trimValues&&(m=m.trim()),m=this.replaceEntitiesValue(m,r,this.readonlyMatcher),a[h]=m,l[p]=m,c=!0}}c&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(l);let f=n.jPath?e.toString():this.readonlyMatcher,u=!1;for(let h=0;h<s;h++){let p=this.resolveNameSpace(o[h][1]);if(this.ignoreAttributesFn(p,f))continue;let d=n.attributeNamePrefix+p;if(p.length)if(n.transformAttributeName&&(d=n.transformAttributeName(d)),d=gp(d,n),o[h][4]!==void 0){let m=a[h],g=n.attributeValueProcessor(p,m,f);g==null?i[d]=m:typeof g!=typeof m||g!==m?i[d]=g:i[d]=ac(m,n.parseAttributeValue,n.numberParseOptions),u=!0}else n.allowBooleanAttributes&&(i[d]=!0,u=!0)}if(!u)return;if(n.attributesGroupName){let h={};return h[n.attributesGroupName]=i,h}return i}}var ZM=function(t){t=t.replace(/\r\n?/g,`
|
|
10
|
-
`);let e=new Re("!xml"),r=e,n="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.docTypeEntitiesKeys=[],this.lastEntitiesKeys=Object.keys(this.lastEntities),this.htmlEntitiesKeys=this.options.htmlEntities?Object.keys(this.htmlEntities):[];let o=this.options,s=new Hn(o.processEntities),i=t.length;for(let a=0;a<i;a++)if(t[a]==="<"){let l=t.charCodeAt(a+1);if(l===47){let f=kr(t,">",a,"Closing Tag is not closed."),u=t.substring(a+2,f).trim();if(o.removeNSPrefix){let p=u.indexOf(":");p!==-1&&(u=u.substr(p+1))}u=sc(o.transformTagName,u,"",o).tagName,r&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher));let h=this.matcher.getCurrentTag();if(u&&o.unpairedTagsSet.has(u))throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);h&&o.unpairedTagsSet.has(h)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=this.tagsNodeStack.pop(),n="",a=f}else if(l===63){let f=ic(t,a,!1,"?>");if(!f)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,this.readonlyMatcher),!(o.ignoreDeclaration&&f.tagName==="?xml"||o.ignorePiTags)){let u=new Re(f.tagName);u.add(o.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(u[":@"]=this.buildAttributesMap(f.tagExp,this.matcher,f.tagName)),this.addChild(r,u,this.readonlyMatcher,a)}a=f.closeIndex+1}else if(l===33&&t.charCodeAt(a+2)===45&&t.charCodeAt(a+3)===45){let f=kr(t,"-->",a+4,"Comment is not closed.");if(o.commentPropName){let u=t.substring(a+4,f-2);n=this.saveTextToParentTag(n,r,this.readonlyMatcher),r.add(o.commentPropName,[{[o.textNodeName]:u}])}a=f}else if(l===33&&t.charCodeAt(a+2)===68){let f=s.readDocType(t,a);this.docTypeEntities=f.entities,this.docTypeEntitiesKeys=Object.keys(this.docTypeEntities)||[],a=f.i}else if(l===33&&t.charCodeAt(a+2)===91){let f=kr(t,"]]>",a,"CDATA is not closed.")-2,u=t.substring(a+9,f);n=this.saveTextToParentTag(n,r,this.readonlyMatcher);let h=this.parseTextData(u,r.tagname,this.readonlyMatcher,!0,!1,!0,!0);h==null&&(h=""),o.cdataPropName?r.add(o.cdataPropName,[{[o.textNodeName]:u}]):r.add(o.textNodeName,h),a=f+2}else{let f=ic(t,a,o.removeNSPrefix);if(!f){let _=t.substring(Math.max(0,a-50),Math.min(i,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${_}"`)}let u=f.tagName,h=f.rawTagName,p=f.tagExp,d=f.attrExpPresent,m=f.closeIndex;if({tagName:u,tagExp:p}=sc(o.transformTagName,u,p,o),o.strictReservedNames&&(u===o.commentPropName||u===o.cdataPropName||u===o.textNodeName||u===o.attributesGroupName))throw new Error(`Invalid tag name: ${u}`);r&&n&&r.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher,!1));let g=r;g&&o.unpairedTagsSet.has(g.tagname)&&(r=this.tagsNodeStack.pop(),this.matcher.pop());let x=!1;p.length>0&&p.lastIndexOf("/")===p.length-1&&(x=!0,u[u.length-1]==="/"?(u=u.substr(0,u.length-1),p=u):p=p.substr(0,p.length-1),d=u!==p);let b=null,M={},E;E=JM(h),u!==e.tagname&&this.matcher.push(u,{},E),u!==p&&d&&(b=this.buildAttributesMap(p,this.matcher,u),b&&(M=qM(b,o))),u!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let C=a;if(this.isCurrentNodeStopNode){let _="";if(x)a=f.closeIndex;else if(o.unpairedTagsSet.has(u))a=f.closeIndex;else{let S=this.readStopNodeData(t,h,m+1);if(!S)throw new Error(`Unexpected end of ${h}`);a=S.i,_=S.tagContent}let R=new Re(u);b&&(R[":@"]=b),R.add(o.textNodeName,_),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,R,this.readonlyMatcher,C)}else{if(x){({tagName:u,tagExp:p}=sc(o.transformTagName,u,p,o));let _=new Re(u);b&&(_[":@"]=b),this.addChild(r,_,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(o.unpairedTagsSet.has(u)){let _=new Re(u);b&&(_[":@"]=b),this.addChild(r,_,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=f.closeIndex;continue}else{let _=new Re(u);if(this.tagsNodeStack.length>o.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),b&&(_[":@"]=b),this.addChild(r,_,this.readonlyMatcher,C),r=_}n="",a=m}}}else n+=t[a];return e.child};function $M(t,e,r,n){this.options.captureMetaData||(n=void 0);let o=this.options.jPath?r.toString():r,s=this.options.updateTag(e.tagname,o,e[":@"]);s===!1||(typeof s=="string"&&(e.tagname=s),t.addChild(e,n))}function eE(t,e,r){let n=this.options.processEntities;if(!n||!n.enabled)return t;if(n.allowedTags){let o=this.options.jPath?r.toString():r;if(!(Array.isArray(n.allowedTags)?n.allowedTags.includes(e):n.allowedTags(e,o)))return t}if(n.tagFilter){let o=this.options.jPath?r.toString():r;if(!n.tagFilter(e,o))return t}for(let o of this.docTypeEntitiesKeys){let s=this.docTypeEntities[o],i=t.match(s.regx);if(i){if(this.entityExpansionCount+=i.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n.maxTotalExpansions}`);let a=t.length;if(t=t.replace(s.regx,s.val),n.maxExpandedLength&&(this.currentExpandedLength+=t.length-a,this.currentExpandedLength>n.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(let o of this.lastEntitiesKeys){let s=this.lastEntities[o],i=t.match(s.regex);if(i&&(this.entityExpansionCount+=i.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n.maxTotalExpansions}`);t=t.replace(s.regex,s.val)}if(t.indexOf("&")===-1)return t;for(let o of this.htmlEntitiesKeys){let s=this.htmlEntities[o],i=t.match(s.regex);if(i&&(this.entityExpansionCount+=i.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n.maxTotalExpansions}`);t=t.replace(s.regex,s.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t}function tE(t,e,r,n){return t&&(n===void 0&&(n=e.child.length===0),t=this.parseTextData(t,e.tagname,r,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,n),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function rE(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function nE(t,e,r=">"){let n=0,o=[],s=t.length,i=r.charCodeAt(0),a=r.length>1?r.charCodeAt(1):-1;for(let c=e;c<s;c++){let l=t.charCodeAt(c);if(n)l===n&&(n=0);else if(l===34||l===39)n=l;else if(l===i)if(a!==-1){if(t.charCodeAt(c+1)===a)return{data:String.fromCharCode(...o),index:c}}else return{data:String.fromCharCode(...o),index:c};else if(l===9){o.push(32);continue}o.push(l)}}function kr(t,e,r,n){let o=t.indexOf(e,r);if(o===-1)throw new Error(n);return o+e.length-1}function oE(t,e,r,n){let o=t.indexOf(e,r);if(o===-1)throw new Error(n);return o}function ic(t,e,r,n=">"){let o=nE(t,e+1,n);if(!o)return;let s=o.data,i=o.index,a=s.search(/\s/),c=s,l=!0;a!==-1&&(c=s.substring(0,a),s=s.substring(a+1).trimStart());let f=c;if(r){let u=c.indexOf(":");u!==-1&&(c=c.substr(u+1),l=c!==o.data.substr(u+1))}return{tagName:c,tagExp:s,closeIndex:i,attrExpPresent:l,rawTagName:f}}function sE(t,e,r){let n=r,o=1,s=t.length;for(;r<s;r++)if(t[r]==="<"){let i=t.charCodeAt(r+1);if(i===47){let a=oE(t,">",r,`${e} is not closed`);if(t.substring(r+2,a).trim()===e&&(o--,o===0))return{tagContent:t.substring(n,r),i:a};r=a}else if(i===63)r=kr(t,"?>",r+1,"StopNode is not closed.");else if(i===33&&t.charCodeAt(r+2)===45&&t.charCodeAt(r+3)===45)r=kr(t,"-->",r+3,"StopNode is not closed.");else if(i===33&&t.charCodeAt(r+2)===91)r=kr(t,"]]>",r,"StopNode is not closed.")-2;else{let a=ic(t,r,">");a&&((a&&a.tagName)===e&&a.tagExp[a.tagExp.length-1]!=="/"&&o++,r=a.closeIndex)}}}function ac(t,e,r){if(e&&typeof t=="string"){let n=t.trim();return n==="true"?!0:n==="false"?!1:nc(t,r)}else return ip(t)?t:""}function mp(t,e,r){let n=Number.parseInt(t,e);return n>=0&&n<=1114111?String.fromCodePoint(n):r+t+";"}function sc(t,e,r,n){if(t){let o=t(e);r===e&&(r=o),e=o}return e=gp(e,n),{tagName:e,tagExp:r}}function gp(t,e){if(Is.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return Dn.includes(t)?e.onDangerousProperty(t):t}var cc=Re.getMetaDataSymbol();function iE(t,e){if(!t||typeof t!="object")return{};if(!e)return t;let r={};for(let n in t)if(n.startsWith(e)){let o=n.substring(e.length);r[o]=t[n]}else r[n]=t[n];return r}function lc(t,e,r,n){return Ap(t,e,r,n)}function Ap(t,e,r,n){let o,s={};for(let i=0;i<t.length;i++){let a=t[i],c=aE(a);if(c!==void 0&&c!==e.textNodeName){let l=iE(a[":@"]||{},e.attributeNamePrefix);r.push(c,l)}if(c===e.textNodeName)o===void 0?o=a[c]:o+=""+a[c];else{if(c===void 0)continue;if(a[c]){let l=Ap(a[c],e,r,n),f=lE(l,e);if(a[":@"]?cE(l,a[":@"],n,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),a[cc]!==void 0&&typeof l=="object"&&l!==null&&(l[cc]=a[cc]),s[c]!==void 0&&Object.prototype.hasOwnProperty.call(s,c))Array.isArray(s[c])||(s[c]=[s[c]]),s[c].push(l);else{let u=e.jPath?n.toString():n;e.isArray(c,u,f)?s[c]=[l]:s[c]=l}c!==void 0&&c!==e.textNodeName&&r.pop()}}}return typeof o=="string"?o.length>0&&(s[e.textNodeName]=o):o!==void 0&&(s[e.textNodeName]=o),s}function aE(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let n=e[r];if(n!==":@")return n}}function cE(t,e,r,n){if(e){let o=Object.keys(e),s=o.length;for(let i=0;i<s;i++){let a=o[i],c=a.startsWith(n.attributeNamePrefix)?a.substring(n.attributeNamePrefix.length):a,l=n.jPath?r.toString()+"."+c:r;n.isArray(a,l,!0,!0)?t[a]=[e[a]]:t[a]=e[a]}}}function lE(t,e){let{textNodeName:r}=e,n=Object.keys(t).length;return!!(n===0||n===1&&(t[r]||typeof t[r]=="boolean"||t[r]===0))}var jr=class{constructor(e){this.externalEntities={},this.options=dp(e)}parse(e,r){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let s=up(e,r);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let n=new zn(this.options);n.addExternalEntities(this.externalEntities);let o=n.parseXml(e);return this.options.preserveOrder||o===void 0?o:lc(o,this.options,n.matcher,n.readonlyMatcher)}addEntity(e,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=r}static getMetaDataSymbol(){return Re.getMetaDataSymbol()}};function fc(t,e){if(e?._parser&&e._parser!=="fast-xml-parser")throw new Error(e?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:e?.removeNSPrefix,textNodeName:e?.textNodeName,isArray:(o,s,i,a)=>Boolean(e?.arrayPaths?.some(l=>s===l)),...e?._fastXML},n=fE(t,r);return e?.uncapitalizeKeys?Cs(n):n}function fE(t,e){return new jr({ignoreAttributes:!1,attributeNamePrefix:"",...e}).parse(t)}var uE="4.4.3",Ke={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:uE,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:hE,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(t,e)=>fc(new TextDecoder().decode(t),{...Ke.options.xml,...e?.xml}),parseTextSync:(t,e)=>fc(t,{...Ke.options.xml,...e?.xml})};function hE(t){return t.startsWith("<?xml")}async function Oe(t,e,r,n){return n._parse(t,e,r,n)}function H(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var at={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},pE=at.self||at.window||at.global||{},dE=at.window||at.self||at.global||{},mE=at.global||at.self||at.window||{},gE=at.document||{};var kn=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var xp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),AE=xp&&parseFloat(xp[1])||0;var vs=globalThis,xE=globalThis.document||{},ws=globalThis.process||{},yE=globalThis.console,NF=globalThis.navigator||{};function yp(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}function sr(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||yp()}var uc="4.1.1";function qr(t,e){if(!t)throw new Error(e||"Assertion failed")}function hc(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return qr(Number.isFinite(e)&&e>=0),e}function bp(t){let{logLevel:e,message:r}=t;t.logLevel=hc(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let o=typeof t.message;return qr(o==="string"||o==="object"),Object.assign(t,{args:n},t.opts)}var ir=()=>{},Ls=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...n){return this._log("log",e,r,n)}info(e,r,...n){return this._log("info",e,r,n)}once(e,r,...n){return this._log("once",e,r,n,{once:!0})}_log(e,r,n,o,s={}){let i=bp({logLevel:r,message:n,args:this._buildArgs(r,n,o),opts:s});return this._createLogFunction(e,i,s)}_buildArgs(e,r,n){return[e,r,...n]}_createLogFunction(e,r,n){if(!this._shouldLog(r.logLevel))return ir;let o=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&o!==void 0){if(this._onceCache.has(o))return ir;this._onceCache.add(o)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=hc(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function TE(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Fs=class{constructor(e,r,n="sessionStorage"){this.storage=TE(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function Tp(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function Mp(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Ps;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ps||(Ps={}));var ME=10;function Ep(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ps[t]||Ps.WHITE)}function Sp(t,e,r){return!sr&&typeof t=="string"&&(e&&(t=`\x1B[${Ep(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Ep(r)+ME}m${t}\x1B[49m`)),t}function _p(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),o=t;for(let s of n){let i=o[s];typeof i=="function"&&(e.find(a=>s===a)||(o[s]=i.bind(t)))}}function Jr(){let t;if(sr()&&vs.performance)t=vs?.performance?.now?.();else if("hrtime"in ws){let e=ws?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Wr={debug:sr()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},pc={enabled:!0,level:0},mt=class extends Ls{constructor({id:e}={id:""}){super({level:0}),this.VERSION=uc,this._startTs=Jr(),this._deltaTs=Jr(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Fs(`__probe-${this.id}__`,{[this.id]:pc}),this.timeStamp(`${this.id} started`),_p(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Jr()-this._startTs).toPrecision(10))}getDelta(){return Number((Jr()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:Wr.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:Wr.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...n){return this._log("log",e,r,n,{method:Wr.log,time:!0,once:!0})}log(e,r,...n){return this._log("log",e,r,n,{method:Wr.debug})}info(e,r,...n){return this._log("info",e,r,n,{method:console.info})}once(e,r,...n){return this._log("once",e,r,n,{method:Wr.debug||Wr.info,once:!0})}table(e,r,n){return r?this._log("table",e,r,n&&[n]||[],{method:console.table||ir,tag:SE(r)}):ir}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||ir})}group(e,r,n={collapsed:!1}){let o=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:o})}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||ir})}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let n=r.method;qr(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Jr();let o=EE(this.id,r.message,r);return n.bind(console,o,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(pc),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...pc};this._storage.setConfiguration({[this.id]:{...r,...e}})}};mt.VERSION=uc;function EE(t,e,r){if(typeof e=="string"){let n=r.time?Mp(Tp(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=Sp(e,r.color,r.background)}return e}function SE(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var dc=new mt({id:"@probe.gl/log"});var mc="4.4.3",_E=mc[0]>="0"&&mc[0]<="9"?`v${mc}`:"";function CE(){let t=new mt({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=_E,globalThis.probe||={},globalThis.probe.loaders=t,t}var gc=CE();var Cp=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer;function jn(t,e){return Bp(t||{},e)}function Bp(t,e,r=0){if(r>3)return e;let n={...t};for(let[o,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?n[o]=Bp(n[o]||{},e[o],r+1):n[o]=e[o];return n}function Ac(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function xc(t){return globalThis.loaders?.modules?.[t]||null}function BE(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.3"),globalThis._loadersgl_.version}var Ip=BE();function Rp(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var ct={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},TP=ct.self||ct.window||ct.global||{},MP=ct.window||ct.self||ct.global||{},EP=ct.global||ct.self||ct.window||{},SP=ct.document||{};var gt=typeof process!="object"||String(process)!=="[object process]"||process.browser,qn=typeof importScripts=="function",_P=typeof window<"u"&&typeof window.orientation<"u",vp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),CP=vp&&parseFloat(vp[1])||0;var yc={};function Jn(t={}){let e=t.useLocalLibraries??t.core?.useLocalLibraries,r=t.CDN??t.core?.CDN,n=t.modules;return{...e!==void 0?{useLocalLibraries:e}:{},...r!==void 0?{CDN:r}:{},...n!==void 0?{modules:n}:{}}}async function Ve(t,e=null,r={},n=null){return e&&(t=wp(t,e,r,n)),yc[t]=yc[t]||IE(t),await yc[t]}function wp(t,e,r={},n=null){if(r?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!r.useLocalLibraries&&t.startsWith("http"))return t;n=n||t;let o=r.modules||{};return o[n]?o[n]:gt?r.CDN?(Rp(r.CDN.startsWith("http")),`${r.CDN}/${e}@${Ip}/dist/libs/${n}`):qn?`../src/libs/${n}`:`modules/${e}/src/libs/${n}`:`modules/${e}/dist/libs/${n}`}async function IE(t){if(t.endsWith("wasm"))return await vE(t);if(!gt){let{requireFromFile:r}=globalThis.loaders||{};try{let n=await r?.(t);return n||!t.includes("/dist/libs/")?n:await r?.(t.replace("/dist/libs/","/src/libs/"))}catch(n){if(t.includes("/dist/libs/"))try{return await r?.(t.replace("/dist/libs/","/src/libs/"))}catch{}return console.error(n),null}}if(qn)return importScripts(t);let e=await wE(t);return RE(e,t)}function RE(t,e){if(!gt){let{requireFromString:n}=globalThis.loaders||{};return n?.(t,e)}if(qn)return eval.call(globalThis,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function vE(t){let{readFileAsArrayBuffer:e}=globalThis.loaders||{};if(gt||!e||t.startsWith("http"))return await(await fetch(t)).arrayBuffer();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${t}`)}}async function wE(t){let{readFileAsText:e}=globalThis.loaders||{};if(gt||!e||t.startsWith("http"))return await(await fetch(t)).text();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${t}`)}}function Fp(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?Lp(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?Lp(t,0,e):""}function Lp(t,e,r){if(t.byteLength<=e+r)return"";let n=new DataView(t),o="";for(let s=0;s<r;s++)o+=String.fromCharCode(n.getUint8(e+s));return o}function bc(t){try{return JSON.parse(t)}catch{throw new Error(`Failed to parse JSON from data starting with "${Fp(t)}"`)}}function Wn(...t){let e=t,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let n=e.reduce((i,a)=>i+a.length,0),o=new r(n),s=0;for(let i of e)o.set(i,s),s+=i.length;return o}function ar(t,e,r){let n=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(n).buffer}function Lt(t,e){return H(t>=0),H(e>0),t+(e-1)&~(e-1)}function Tc(t,e,r){let n;if(t instanceof ArrayBuffer)n=new Uint8Array(t);else{let o=t.byteOffset,s=t.byteLength;n=new Uint8Array(t.buffer||t.arrayBuffer,o,s)}return e.set(n,r),r+Lt(n.byteLength,4)}function Xn(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var cr=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Xn(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Xn()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Ft=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,o=this.stats[r];return o||(e instanceof cr?o=e:o=new cr(r,n),this.stats[r]=o),o}};var LE="Queued Requests",FE="Active Requests",PE="Cancelled Requests",NE="Queued Requests Ever",OE="Active Requests Ever",UE={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Pt=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...UE,...e},this.stats=new Ft({id:this.props.id}),this.stats.get(LE),this.stats.get(FE),this.stats.get(PE),this.stats.get(NE),this.stats.get(OE)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},o=new Promise(s=>(n.resolve=s,n));return this.requestQueue.push(n),this.requestMap.set(e,o),this._issueNewRequests(),o}_issueRequest(e){let{handle:r,resolve:n}=e,o=!1,s=()=>{o||(o=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:s}):Promise.resolve({done:s})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var DE="",Pp={};function Np(t){for(let e in Pp)if(t.startsWith(e)){let r=Pp[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${DE}${t}`),t}function Nt(t){if(t instanceof ArrayBuffer)return t;if(Cp(t))return Yn(t);let{buffer:e,byteOffset:r,byteLength:n}=t;return e instanceof ArrayBuffer&&r===0&&n===e.byteLength?e:Yn(e,r,n)}function Yn(t,e=0,r=t.byteLength-e){let n=new Uint8Array(t,e,r),o=new Uint8Array(n.length);return o.set(n),o.buffer}var Ot={};be(Ot,{dirname:()=>VE,filename:()=>GE,join:()=>HE,resolve:()=>zE});function Op(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function GE(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function VE(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function HE(...t){let e="/";return t=t.map((r,n)=>(n&&(r=r.replace(new RegExp(`^${e}`),"")),n!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function zE(...t){let e=[];for(let s=0;s<t.length;s++)e[s]=t[s];let r="",n=!1,o;for(let s=e.length-1;s>=-1&&!n;s--){let i;s>=0?i=e[s]:(o===void 0&&(o=Op()),i=o),i.length!==0&&(r=`${i}/${r}`,n=i.charCodeAt(0)===Kn)}return r=kE(r,!n),n?`/${r}`:r.length>0?r:"."}var Kn=47,Mc=46;function kE(t,e){let r="",n=-1,o=0,s,i=!1;for(let a=0;a<=t.length;++a){if(a<t.length)s=t.charCodeAt(a);else{if(s===Kn)break;s=Kn}if(s===Kn){if(!(n===a-1||o===1))if(n!==a-1&&o===2){if(r.length<2||!i||r.charCodeAt(r.length-1)!==Mc||r.charCodeAt(r.length-2)!==Mc){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Kn;--l);if(l!==c){r=l===-1?"":r.slice(0,l),n=a,o=0,i=!1;continue}}else if(r.length===2||r.length===1){r="",n=a,o=0,i=!1;continue}}e&&(r.length>0?r+="/..":r="..",i=!0)}else{let c=t.slice(n+1,a);r.length>0?r+=`/${c}`:r=c,i=!1}n=a,o=0}else s===Mc&&o!==-1?++o:o=-1}return r}var Ec=class{optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(e,r,n){n?this.options=jn({...n,core:Ec.defaultOptions},r):this.options={...r},this.data=e,this.url=typeof e=="string"?Np(e):"",this.loadOptions=qE(this.options.core?.loadOptions),this.fetch=jE(this.loadOptions)}setProps(e){this.options=Object.assign(this.options,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}},Xr=Ec;Xt(Xr,"defaultOptions",{core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}});function jE(t){let e=t?.core?.fetch;if(e&&typeof e=="function")return(n,o)=>e(n,o);let r=t?.fetch;return r&&typeof r!="function"?n=>fetch(n,r):n=>fetch(n)}function qE(t){let e={...t};t?.core&&(e.core={...t.core});let r=typeof e.baseUri=="string"?e.baseUri:void 0,n=typeof e.baseUrl=="string"?e.baseUrl:void 0;return(r!==void 0||n!==void 0)&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=n??r),delete e.baseUri,delete e.baseUrl),e}var Ut=class{};Xt(Ut,"type","template"),Xt(Ut,"testURL",e=>!1);function Up(t,e){let r=Ke.parseTextSync?.(t,e),n=r?.ServiceExceptionReport?.ServiceException||r?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof n=="string"?n:n.value||n.code||"Unknown error"}var JE="4.4.3",Qn={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:JE,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:WE,options:{wms:{throwOnError:!1}},parse:async(t,e)=>Sc(new TextDecoder().decode(t),e),parseSync:(t,e)=>Sc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>Sc(t,e)};function WE(t){return t.startsWith("<?xml")}function Sc(t,e){let r={...Qn.options.wms,...e?.wms},n=Up(t,r),o=r.minimalErrors?n:`WMS Service error: ${n}`;if(r.throwOnError)throw new Error(o);return o}function lr(t){return Array.isArray(t)?t:t?[t]:[]}function Zn(t){let e=lr(t);return e.length>0&&e.every(r=>typeof r=="string")?e:[]}function $n(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseFloat(t);default:return}}function Ns(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseInt(t,10);default:return}}function fr(t){switch(t){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function _c(t,e){let r=Ke.parseTextSync?.(t,e),n=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,o=XE(n);if(e?.inheritedLayerProps)for(let s of o.layers)Gp(s,null);return e?.includeRawJSON&&(o.json=n),e?.includeXMLText&&(o.xml=t),o}function XE(t){let e={version:String(t.version||""),name:String(t.Service?.Name||"unnamed"),title:t.Service?.Title?String(t.Service?.Title):void 0,abstract:t.Service?.Abstract?String(t.Service?.Abstract):void 0,keywords:Zn(t.Service?.KeywordList?.Keyword),fees:t.Service?.Fees?JSON.stringify(t.Service?.Fees):void 0,accessConstraints:t.Service?.AccessConstraints?JSON.stringify(t.Service?.AccessConstraints):void 0,layerLimit:Ns(t.Service?.LayerLimit),maxWidth:Ns(t.Service?.maxWidth),maxHeight:Ns(t.Service?.maxHeight),layers:[],requests:YE(t.Capability?.Request),exceptions:KE(t.Exception)},r=lr(t.Capability?.Layer);for(let n of r)e.layers.push(Dp(n));for(let[n,o]of Object.entries(e))o===void 0&&delete e[n];return e}function YE(t){let e={};for(let[r,n]of Object.entries(t||{})){let o=Zn(n?.Format);e[r]={mimeTypes:o}}return e}function KE(t){if(lr(t?.Format).length>0)return{mimeTypes:Zn(t)}}function Dp(t){let e={title:String(t?.Title||""),name:t?.Name&&String(t?.Name),abstract:t?.Name&&String(t?.Abstract),keywords:Zn(t.KeywordList?.Keyword)},r=t?.CRS||t?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(e.crs=r);let n=t?.EX_GeographicBoundingBox&&QE(t?.EX_GeographicBoundingBox);n&&(e.geographicBoundingBox=n),n=t?.LatLonBoundingBox&&ZE(t?.LatLonBoundingBox),n&&(e.geographicBoundingBox=n);let o=t?.BoundingBox&&$E(t?.BoundingBox);o&&o.length>0&&(e.boundingBoxes=o);let i=lr(t?.Dimension).map(l=>tS(l));i.length&&(e.dimensions=i),t?.opaque&&(e.opaque=fr(t?.opaque)),t?.cascaded&&(e.cascaded=fr(t?.cascaded)),t?.queryable&&(e.queryable=fr(t?.queryable));let a=lr(t?.Layer),c=[];for(let l of a)c.push(Dp(l));c.length>0&&(e.layers=c);for(let[l,f]of Object.entries(e))f===void 0&&delete e[l];return e}function QE(t){let{westBoundLongitude:e,northBoundLatitude:r,eastBoundLongitude:n,southBoundLatitude:o}=t;return[[e,o],[n,r]]}function ZE(t){let{minx:e,miny:r,maxx:n,maxy:o}=t;return[[e,r],[n,o]]}function $E(t){return lr(t).map(r=>eS(r))}function eS(t){let{CRS:e,SRS:r,minx:n,miny:o,maxx:s,maxy:i,resx:a,resy:c}=t,l={crs:e||r,boundingBox:[[$n(n),$n(o)],[$n(s),$n(i)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function tS(t){let{name:e,units:r,value:n}=t,o={name:e,units:r,extent:n};return t.unitSymbol&&(o.unitSymbol=t.unitSymbol),t.default&&(o.defaultValue=t.default),t.multipleValues&&(o.multipleValues=fr(t.multipleValues)),t.nearestValue&&(o.nearestValue=fr(t.nearestValue)),t.current&&(o.current=fr(t.current)),o}function Gp(t,e){e?.geographicBoundingBox&&!t.geographicBoundingBox&&(t.geographicBoundingBox=[...e.geographicBoundingBox]),e?.crs&&!t.crs&&(t.crs=[...e.crs]),e?.boundingBoxes&&!t.boundingBoxes&&(t.boundingBoxes=[...e.boundingBoxes]),e?.dimensions&&!t.dimensions&&(t.dimensions=[...e.dimensions]);for(let r of t.layers||[])Gp(r,t)}var rS="4.4.3",Yr={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:rS,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:nS,options:{wms:{}},parse:async(t,e)=>_c(new TextDecoder().decode(t),e?.wms),parseTextSync:(t,e)=>_c(t,e?.wms)};function nS(t){return t.startsWith("<?xml")}function Cc(t,e){let n=(Ke.parseTextSync?.(t,e)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(n)?n:[n]).map(s=>oS(s))}}function oS(t){return{attributes:t||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var Vp={...Yr,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(t,e)=>Cc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>Cc(t,e)};function Bc(t,e){return Ke.parseTextSync?.(t,e)}var Hp={...Yr,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(t,e)=>Bc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>Bc(t,e)};var zp="4.4.3";var sS=globalThis.loaders?.parseImageNode,Ic=typeof Image<"u",Rc=typeof ImageBitmap<"u",iS=Boolean(sS),vc=kn?!0:iS;function kp(t){switch(t){case"auto":return Rc||Ic||vc;case"imagebitmap":return Rc;case"image":return Ic;case"data":return vc;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function jp(){if(Rc)return"imagebitmap";if(Ic)return"image";if(vc)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function qp(t){let e=aS(t);if(!e)throw new Error("Not an image");return e}function eo(t){switch(qp(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function aS(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var cS=/^data:image\/svg\+xml/,lS=/\.svg((\?|#).*)?$/;function Os(t){return t&&(cS.test(t)||lS.test(t))}function Jp(t,e){if(Os(e)){let n=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return wc(t,e)}function wc(t,e){if(Os(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function Us(t,e,r){let n=Jp(t,r),o=self.URL||self.webkitURL,s=typeof n!="string"&&o.createObjectURL(n);try{return await fS(s||n,e)}finally{s&&o.revokeObjectURL(s)}}async function fS(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,o)=>{try{r.onload=()=>n(r),r.onerror=s=>{let i=s instanceof Error?s.message:"error";o(new Error(i))}}catch(s){o(s)}})}var Wp=!0;async function Xp(t,e,r){let n;Os(r)?n=await Us(t,e,r):n=wc(t,r);let o=e&&e.imagebitmap;return await uS(n,o)}async function uS(t,e=null){if((hS(e)||!Wp)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),Wp=!1}return await createImageBitmap(t)}function hS(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Yp(t){return!gS(t,"ftyp",4)||!(t[8]&96)?null:pS(t)}function pS(t){switch(dS(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function dS(t,e,r){return String.fromCharCode(...t.slice(e,r))}function mS(t){return[...t].map(e=>e.charCodeAt(0))}function gS(t,e,r=0){let n=mS(e);for(let o=0;o<n.length;++o)if(n[o]!==t[o+r])return!1;return!0}var lt=!1,to=!0;function ur(t){let e=ro(t);return xS(e)||TS(e)||yS(e)||bS(e)||AS(e)}function AS(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=Yp(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function xS(t){let e=ro(t);return e.byteLength>=24&&e.getUint32(0,lt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,lt),height:e.getUint32(20,lt)}:null}function yS(t){let e=ro(t);return e.byteLength>=10&&e.getUint32(0,lt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,to),height:e.getUint16(8,to)}:null}function bS(t){let e=ro(t);return e.byteLength>=14&&e.getUint16(0,lt)===16973&&e.getUint32(2,to)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,to),height:e.getUint32(22,to)}:null}function TS(t){let e=ro(t);if(!(e.byteLength>=3&&e.getUint16(0,lt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:o}=MS(),s=2;for(;s+9<e.byteLength;){let i=e.getUint16(s,lt);if(o.has(i))return{mimeType:"image/jpeg",height:e.getUint16(s+5,lt),width:e.getUint16(s+7,lt)};if(!n.has(i))return null;s+=2,s+=e.getUint16(s,lt)}return null}function MS(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function ro(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function Kp(t,e){let{mimeType:r}=ur(t)||{},n=globalThis.loaders?.parseImageNode;return H(n),await n(t,r)}async function Qp(t,e,r){e=e||{};let o=(e.image||{}).type||"auto",{url:s}=r||{},i=ES(o),a;switch(i){case"imagebitmap":a=await Xp(t,e,s);break;case"image":a=await Us(t,e,s);break;case"data":a=await Kp(t,e);break;default:H(!1)}return o==="data"&&(a=eo(a)),a}function ES(t){switch(t){case"auto":case"data":return jp();default:return kp(t),t}}var SS=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],_S=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],CS={image:{type:"auto",decode:!0}},Kr={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:zp,mimeTypes:_S,extensions:SS,parse:Qp,tests:[t=>Boolean(ur(new DataView(t)))],options:CS};var Lc={};function Fc(t){if(Lc[t]===void 0){let e=kn?IS(t):BS(t);Lc[t]=e}return Lc[t]}function BS(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&r.includes(t)}function IS(t){switch(t){case"image/avif":case"image/webp":return RS(t);default:return!0}}function RS(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}var Gs={name:"Web Map Service (OGC WMS)",id:"wms",module:"wms",version:"0.0.0",extensions:[],mimeTypes:[],type:"wms",fromUrl:!0,fromBlob:!1,defaultOptions:{wms:{}},testURL:t=>t.toLowerCase().includes("wms"),createDataSource:(t,e)=>new Ds(t,e)},Ds=class extends Xr{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,r){super(e,r,Gs.defaultOptions),this.substituteCRS84=r.wms?.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...r.wmsParameters,...r.wms?.wmsParameters},this.vendorParameters=r.wms?.vendorParameters||r.vendorParameters||{}}async getMetadata(){let e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){let{boundingBox:r,bbox:n,...o}=e,s={bbox:r?[...r[0],...r[1]]:n,...o};return await this.getMap(s)}normalizeMetadata(e){return e}async getCapabilities(e,r){let n=this.getCapabilitiesURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);let i=await Yr.parse(s,this.loadOptions);return this.capabilities=i,i}async getMap(e,r){let n=this.getMapURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);try{return await Kr.parse(s,this.loadOptions)}catch{throw this._parseError(s)}}async getFeatureInfo(e,r){let n=this.getFeatureInfoURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),await Vp.parse(s,this.loadOptions)}async getFeatureInfoText(e,r){let n=this.getFeatureInfoURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),new TextDecoder().decode(s)}async describeLayer(e,r){let n=this.describeLayerURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),await Hp.parse(s,this.loadOptions)}async getLegendGraphic(e,r){let n=this.getLegendGraphicURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);try{return await Kr.parse(s,this.loadOptions)}catch{throw this._parseError(s)}}getCapabilitiesURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",n,r)}getMapURL(e,r){e=this._getWMS130Parameters(e);let n={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetMap",n,r)}getFeatureInfoURL(e,r){e=this._getWMS130Parameters(e);let{boundingBox:n,bbox:o}=e;e.bbox=n?[...n[0],...n[1]]:o;let s={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",s,r)}describeLayerURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",n,r)}getLegendGraphicURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",n,r)}_parseWMSUrl(e){let[r,n]=e.split("?"),o=n.split("&"),s={};for(let i of o){let[a,c]=i.split("=");s[a]=c}return{url:r,parameters:s}}_getWMSUrl(e,r,n){let o=this.url,s=!0,i={service:"WMS",version:r.version,request:e,...r,...this.vendorParameters,...n},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(i))(!a.includes(c)||l)&&(o+=s?"?":"&",s=!1,o+=this._getURLParameter(c,l,r));return encodeURI(o)}_getWMS130Parameters(e){let r={...e};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(e,r,n){switch(e){case"crs":n.version!=="1.3.0"?e="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":n.version==="1.3.0"&&(e="crs");break;case"bbox":let o=this._flipBoundingBox(r,n);o&&(r=o);break;case"x":n.version==="1.3.0"&&(e="i");break;case"y":n.version==="1.3.0"&&(e="j");break;default:}return e=e.toUpperCase(),Array.isArray(r)?`${e}=${r.join(",")}`:`${e}=${r?String(r):""}`}_flipBoundingBox(e,r){if(!Array.isArray(e)||e.length!==4)return null;let n=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),o=e;return n?[o[1],o[0],o[3],o[2]]:o}async _fetchArrayBuffer(e){let r=await this.fetch(e),n=await r.arrayBuffer();return this._checkResponse(r,n),n}_checkResponse(e,r){let n=e.headers["content-type"];if(!e.ok||Qn.mimeTypes.includes(n)){let o=jn(this.loadOptions,{wms:{throwOnError:!0}}),s=Qn.parseSync?.(r,o);throw new Error(s)}}_parseError(e){let r=Qn.parseSync?.(e,this.options.core?.loadOptions);return new Error(r)}};function Vs(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Qe=Math.PI,td=Qe/4,Zp=Qe/180,$p=180/Qe,Hs=512;function At(t){let[e,r]=t;Vs(Number.isFinite(e)),Vs(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let n=e*Zp,o=r*Zp,s=Hs*(n+Qe)/(2*Qe),i=Hs*(Qe+Math.log(Math.tan(td+o*.5)))/(2*Qe);return[s,i]}function xt(t){let[e,r]=t,n=e/Hs*(2*Qe)-Qe,o=2*(Math.atan(Math.exp(r/Hs*(2*Qe)-Qe))-td);return[n*$p,o*$p]}var lU=Math.PI/180;var nd=6378137*Math.PI;function Pc(t){let e=At(t);return e[0]=(e[0]/256-1)*nd,e[1]=(e[1]/256-1)*nd,e}var qS={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(t,e)=>console.error(e,t)}},Qr=class extends hr.CompositeLayer{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:r,oldProps:n}){let{viewport:o}=this.context;e.dataChanged||r.serviceType!==n.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(o,"image source changed"),0)):(0,hr._deepEqual)(r.layers,n.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(o,"viewport changed")):this.debounce(()=>this.loadImage(o,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:e,image:r,lastRequestParameters:n}=this.state;return r&&new od.BitmapLayer({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:n.srs==="EPSG:4326"?hr.COORDINATE_SYSTEM.LNGLAT:hr.COORDINATE_SYSTEM.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,r){let{lastRequestParameters:n}=this.state;return n?await this.state.imageSource.getFeatureInfoText?.({...n,query_layers:n.layers,x:e,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(e){if(e.data instanceof Ut)return e.data;if(typeof e.data=="string")return(0,sd.createDataSource)(e.data,[Gs],{core:{type:e.serviceType,loadOptions:e.loadOptions}});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:e}=this.state;try{this.state.loadCounter++;let r=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(e,r){let{layers:n,serviceType:o}=this.props;if(o==="wms"&&n.length===0)return;let s=e.getBounds(),{width:i,height:a}=e,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=e.resolution?"EPSG:4326":"EPSG:3857");let f={width:i,height:a,boundingBox:[[s[0],s[1]],[s[2],s[3]]],layers:n,crs:l};if(l==="EPSG:3857"){let u=Pc([s[0],s[1]]),h=Pc([s[2],s[3]]);f.boundingBox=[u,h]}try{this.state.loadCounter++,this.props.onImageLoadStart(c);let u=await this.state.imageSource.getImage(f);this.state.lastRequestId<c&&(this.getCurrentLayer()?.props.onImageLoad(c),this.setState({image:u,bounds:s,lastRequestParameters:f,lastRequestId:c}))}catch(u){this.raiseError(u,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(c,u)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,r=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),r)}};Qr.layerName="WMSLayer";Qr.defaultProps=qS;var id=D(Xe(),1),JS={getHeight:{type:"accessor",value:0},greatCircle:!0},no=class extends id.ArcLayer{};no.layerName="GreatCircleLayer";no.defaultProps=JS;var ad=no;var zs=D(Nc(),1),WS=3,XS=30,YS=2*XS+1,ld=180/Math.PI;function ud(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function fd(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function hd(t){return[fd(t[0]),fd(t[1])]}function pd(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function dd([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*ld,n*ld]}function md(t){let e=zs.default.fromString(t,!0,10).toString(2);for(;e.length<WS+YS;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),o=e.substring(3,r),s=o.length/2,i=zs.default.fromString(n,!0,2).toString(10),a=zs.default.fromString(o,!0,2).toString(4);for(;a.length<s;)a="0"+a;return`${i}/${a}`}function KS(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let o=e[0];e[0]=e[1],e[1]=o}}function gd(t){let e=t.split("/"),r=parseInt(e[0],10),n=e[1],o=n.length,s=[0,0],i;for(let a=o-1;a>=0;a--){i=o-a;let c=n[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,i-1);KS(u,s,l,f),s[0]+=u*l,s[1]+=u*f}if(r%2===1){let a=s[0];s[0]=s[1],s[1]=a}return{face:r,ij:s,level:i}}var Ad=D(Nc(),1);function QS(t){let e=t.padEnd(16,"0");return Ad.default.fromString(e,16)}var ZS=100;function $S({face:t,ij:e,level:r}){let n=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(ZS*Math.pow(2,-r))),s=new Float64Array(4*o*2+2),i=0,a=0;for(let c=0;c<4;c++){let l=n[c].slice(0),f=n[c+1],u=(f[0]-l[0])/o,h=(f[1]-l[1])/o;for(let p=0;p<o;p++){l[0]+=u,l[1]+=h;let d=ud(e,r,l),m=hd(d),g=pd(t,m),x=dd(g);Math.abs(x[1])>89.999&&(x[0]=a);let b=x[0]-a;x[0]+=b>180?-360:b<-180?360:0,s[i++]=x[0],s[i++]=x[1],a=x[0]}}return s[i++]=s[0],s[i++]=s[1],s}function e_(t){if(typeof t=="string"){if(t.indexOf("/")>0)return t;t=QS(t)}return md(t.toString())}function xd(t){let e=e_(t),r=gd(e);return $S(r)}var t_={getS2Token:{type:"accessor",value:t=>t.token}},so=class extends De{indexToBounds(){let{data:e,getS2Token:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,o)=>xd(r(n,o))}}};so.layerName="S2Layer";so.defaultProps=t_;var yd=so;var Oc=512;function r_(t,e){let r=0,n=0,o=1<<t.length,s=o/Oc;for(let i=0;i<t.length;i++){o>>=1;let a=parseInt(t[i]);a%2&&(r|=o),a>1&&(n|=o)}return[[r/s,Oc-n/s],[(r+e)/s,Oc-(n+e)/s]]}function bd(t,e=1){let[r,n]=r_(t,e),[o,s]=xt(r),[i,a]=xt(n);return[i,s,i,a,o,a,o,s,i,s]}var n_={getQuadkey:{type:"accessor",value:t=>t.quadkey}},io=class extends De{indexToBounds(){let{data:e,extruded:r,getQuadkey:n}=this.props,o=r?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(s,i)=>bd(n(s,i),o),updateTriggers:{getPolygon:o}}}};io.layerName="QuadkeyLayer";io.defaultProps=n_;var Td=io;var Ys=D(ot(),1),Hd=D(Xe(),1);var pr=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,getRequestPriority:r,requestScheduler:n,onLoad:o,onError:s}){let{index:i,id:a,bbox:c,userData:l,zoom:f}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:h}=this._abortController,p=await n.scheduleRequest(this,r);if(!p){this._isCancelled=!0;return}if(this._isCancelled){p.done();return}let d=null,m;try{d=await e({index:i,id:a,bbox:c,userData:l,zoom:f,signal:h})}catch(g){m=g||!0}finally{p.done()}if(u===this._loaderId){if(this._loader=void 0,this.content=d,this._isCancelled&&!d){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,m?s(m,this):o(this)}}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var lo=D(ot(),1);var ie={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var Md=new y,o_=new y,Dt=class{constructor(e=[0,0,0],r=[0,0,0],n){n=n||Md.copy(e).add(r).scale(.5),this.center=new y(n),this.halfDiagonal=new y(r).subtract(this.center),this.minimum=new y(e),this.maximum=new y(r)}clone(){return new Dt(this.minimum,this.maximum,this.center)}equals(e){return this===e||Boolean(e)&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){let{halfDiagonal:r}=this,n=o_.from(e.normal),o=r.x*Math.abs(n.x)+r.y*Math.abs(n.y)+r.z*Math.abs(n.z),s=this.center.dot(n)+e.distance;return s-o>0?ie.INSIDE:s+o<0?ie.OUTSIDE:ie.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=Md.from(e).subtract(this.center),{halfDiagonal:n}=this,o=0,s;return s=Math.abs(r.x)-n.x,s>0&&(o+=s*s),s=Math.abs(r.y)-n.y,s>0&&(o+=s*s),s=Math.abs(r.z)-n.z,s>0&&(o+=s*s),o}};var ao=new y,Ed=new y,He=class{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new y,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=ao.from(r),this.center=new y().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new He(this.center,this.radius)}union(e){let r=this.center,n=this.radius,o=e.center,s=e.radius,i=ao.copy(o).subtract(r),a=i.magnitude();if(n>=a+s)return this.clone();if(s>=a+n)return e.clone();let c=(n+a+s)*.5;return Ed.copy(i).scale((-n+c)/a).add(r),this.center.copy(Ed),this.radius=c,this}expand(e){let n=ao.from(e).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(e){this.center.transform(e);let r=Pn.getScaling(ao,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let n=ao.from(e).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(e){let r=this.center,n=this.radius,s=e.normal.dot(r)+e.distance;return s<-n?ie.OUTSIDE:s<n?ie.INTERSECTING:ie.INSIDE}};var s_=new y,i_=new y,ks=new y,js=new y,qs=new y,a_=new y,c_=new y,yt={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},Ze=class{constructor(e=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new y().from(e),this.halfAxes=new k(r)}get halfSize(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new y(e).len(),new y(r).len(),new y(n).len()]}get quaternion(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),o=new y(e).normalize(),s=new y(r).normalize(),i=new y(n).normalize();return new it().fromMatrix3(new k([...o,...s,...i]))}fromCenterHalfSizeQuaternion(e,r,n){let o=new it(n),s=new k().fromQuaternion(o);return s[0]=s[0]*r[0],s[1]=s[1]*r[0],s[2]=s[2]*r[0],s[3]=s[3]*r[1],s[4]=s[4]*r[1],s[5]=s[5]*r[1],s[6]=s[6]*r[2],s[7]=s[7]*r[2],s[8]=s[8]*r[2],this.center=new y().from(e),this.halfAxes=s,this}clone(){return new Ze(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new He){let r=this.halfAxes,n=r.getColumn(0,ks),o=r.getColumn(1,js),s=r.getColumn(2,qs),i=s_.copy(n).add(o).add(s);return e.center.copy(this.center),e.radius=i.magnitude(),e}intersectPlane(e){let r=this.center,n=e.normal,o=this.halfAxes,s=n.x,i=n.y,a=n.z,c=Math.abs(s*o[yt.COLUMN0ROW0]+i*o[yt.COLUMN0ROW1]+a*o[yt.COLUMN0ROW2])+Math.abs(s*o[yt.COLUMN1ROW0]+i*o[yt.COLUMN1ROW1]+a*o[yt.COLUMN1ROW2])+Math.abs(s*o[yt.COLUMN2ROW0]+i*o[yt.COLUMN2ROW1]+a*o[yt.COLUMN2ROW2]),l=n.dot(r)+e.distance;return l<=-c?ie.OUTSIDE:l>=c?ie.INSIDE:ie.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=i_.from(e).subtract(this.center),n=this.halfAxes,o=n.getColumn(0,ks),s=n.getColumn(1,js),i=n.getColumn(2,qs),a=o.magnitude(),c=s.magnitude(),l=i.magnitude();o.normalize(),s.normalize(),i.normalize();let f=0,u;return u=Math.abs(r.dot(o))-a,u>0&&(f+=u*u),u=Math.abs(r.dot(s))-c,u>0&&(f+=u*u),u=Math.abs(r.dot(i))-l,u>0&&(f+=u*u),f}computePlaneDistances(e,r,n=[-0,-0]){let o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=this.center,a=this.halfAxes,c=a.getColumn(0,ks),l=a.getColumn(1,js),f=a.getColumn(2,qs),u=a_.copy(c).add(l).add(f).add(i),h=c_.copy(u).subtract(e),p=r.dot(h);return o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).add(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).subtract(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).subtract(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).add(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).add(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).subtract(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).subtract(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),n[0]=o,n[1]=s,n}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,ks);r.transformAsPoint(e);let n=this.halfAxes.getColumn(1,js);n.transformAsPoint(e);let o=this.halfAxes.getColumn(2,qs);return o.transformAsPoint(e),this.halfAxes=new k([...r,...n,...o]),this}getTransform(){throw new Error("not implemented")}};var Sd=new y,_d=new y,pe=class{constructor(e=[0,0,1],r=0){this.normal=new y,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return he(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=Sd.from(e),this.normal.from(r).normalize();let n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,r,n,o){return this.normal.set(e,r,n),he(_e(this.normal.len(),1)),this.distance=o,this}clone(){return new pe(this.normal,this.distance)}equals(e){return _e(this.distance,e.distance)&&_e(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=_d.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,r)}projectPointOntoPlane(e,r=[0,0,0]){let n=Sd.from(e),o=this.getPointDistance(n),s=_d.copy(this.normal).scale(o);return n.subtract(s).to(r)}};var Cd=[new y([1,0,0]),new y([0,1,0]),new y([0,0,1])],Bd=new y,l_=new y,ce=class{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*Cd.length;let r=e.center,n=e.radius,o=0;for(let s of Cd){let i=this.planes[o],a=this.planes[o+1];i||(i=this.planes[o]=new pe),a||(a=this.planes[o+1]=new pe);let c=Bd.copy(s).scale(-n).add(r);i.fromPointNormal(c,s);let l=Bd.copy(s).scale(n).add(r),f=l_.copy(s).negate();a.fromPointNormal(l,f),o+=2}return this}computeVisibility(e){let r=ie.INSIDE;for(let n of this.planes)switch(e.intersectPlane(n)){case ie.OUTSIDE:return ie.OUTSIDE;case ie.INTERSECTING:r=ie.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(he(Number.isFinite(r),"parentPlaneMask is required."),r===ce.MASK_OUTSIDE||r===ce.MASK_INSIDE)return r;let n=ce.MASK_INSIDE,o=this.planes;for(let s=0;s<this.planes.length;++s){let i=s<31?1<<s:0;if(s<31&&!(r&i))continue;let a=o[s],c=e.intersectPlane(a);if(c===ie.OUTSIDE)return ce.MASK_OUTSIDE;c===ie.INTERSECTING&&(n|=i)}return n}};ce.MASK_OUTSIDE=4294967295;ce.MASK_INSIDE=0;ce.MASK_INDETERMINATE=2147483647;var _D=new y,CD=new y,BD=new y,ID=new y,RD=new y;var ND=new y,OD=new y,UD=new y,DD=new y,GD=new y,VD=new y,HD=new y,zD=new y,kD=new y,jD=new y,qD=new y,JD=new y;var ft=new k,u_=new k,h_=new k,Js=new k,Id=new k;function Gc(t,e={}){let r=Ge.EPSILON20,n=10,o=0,s=0,i=u_,a=h_;i.identity(),a.copy(t);let c=r*p_(a);for(;s<n&&d_(a)>c;)m_(a,Js),Id.copy(Js).transpose(),a.multiplyRight(Js),a.multiplyLeft(Id),i.multiplyRight(Js),++o>2&&(++s,o=0);return e.unitary=i.toTarget(e.unitary),e.diagonal=a.toTarget(e.diagonal),e}function p_(t){let e=0;for(let r=0;r<9;++r){let n=t[r];e+=n*n}return Math.sqrt(e)}var Uc=[1,0,0],Dc=[2,2,1];function d_(t){let e=0;for(let r=0;r<3;++r){let n=t[ft.getElementIndex(Dc[r],Uc[r])];e+=2*n*n}return Math.sqrt(e)}function m_(t,e){let r=Ge.EPSILON15,n=0,o=1;for(let l=0;l<3;++l){let f=Math.abs(t[ft.getElementIndex(Dc[l],Uc[l])]);f>n&&(o=l,n=f)}let s=Uc[o],i=Dc[o],a=1,c=0;if(Math.abs(t[ft.getElementIndex(i,s)])>r){let l=t[ft.getElementIndex(i,i)],f=t[ft.getElementIndex(s,s)],u=t[ft.getElementIndex(i,s)],h=(l-f)/2/u,p;h<0?p=-1/(-h+Math.sqrt(1+h*h)):p=1/(h+Math.sqrt(1+h*h)),a=1/Math.sqrt(1+p*p),c=p*a}return k.IDENTITY.to(e),e[ft.getElementIndex(s,s)]=e[ft.getElementIndex(i,i)]=a,e[ft.getElementIndex(i,s)]=c,e[ft.getElementIndex(s,i)]=-c,e}var Gt=new y,g_=new y,A_=new y,x_=new y,y_=new y,b_=new k,T_={diagonal:new k,unitary:new k};function co(t,e=new Ze){if(!t||t.length===0)return e.halfAxes=new k([0,0,0,0,0,0,0,0,0]),e.center=new y,e;let r=t.length,n=new y(0,0,0);for(let T of t)n.add(T);let o=1/r;n.multiplyByScalar(o);let s=0,i=0,a=0,c=0,l=0,f=0;for(let T of t){let A=Gt.copy(T).subtract(n);s+=A.x*A.x,i+=A.x*A.y,a+=A.x*A.z,c+=A.y*A.y,l+=A.y*A.z,f+=A.z*A.z}s*=o,i*=o,a*=o,c*=o,l*=o,f*=o;let u=b_;u[0]=s,u[1]=i,u[2]=a,u[3]=i,u[4]=c,u[5]=l,u[6]=a,u[7]=l,u[8]=f;let{unitary:h}=Gc(u,T_),p=e.halfAxes.copy(h),d=p.getColumn(0,A_),m=p.getColumn(1,x_),g=p.getColumn(2,y_),x=-Number.MAX_VALUE,b=-Number.MAX_VALUE,M=-Number.MAX_VALUE,E=Number.MAX_VALUE,C=Number.MAX_VALUE,_=Number.MAX_VALUE;for(let T of t)Gt.copy(T),x=Math.max(Gt.dot(d),x),b=Math.max(Gt.dot(m),b),M=Math.max(Gt.dot(g),M),E=Math.min(Gt.dot(d),E),C=Math.min(Gt.dot(m),C),_=Math.min(Gt.dot(g),_);d=d.multiplyByScalar(.5*(E+x)),m=m.multiplyByScalar(.5*(C+b)),g=g.multiplyByScalar(.5*(_+M)),e.center.copy(d).add(m).add(g);let R=g_.set(x-E,b-C,M-_).multiplyByScalar(.5),S=new k([R[0],0,0,0,R[1],0,0,0,R[2]]);return e.halfAxes.multiplyRight(S),e}var Zr=512,Rd=3,vd=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],wd=vd.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),M_=wd.concat([[.25,.5],[.75,.5]]),Vt=class{constructor(e,r,n){this.x=e,this.y=r,this.z=n}get children(){if(!this._children){let e=this.x*2,r=this.y*2,n=this.z+1;this._children=[new Vt(e,r,n),new Vt(e,r+1,n),new Vt(e+1,r,n),new Vt(e+1,r+1,n)]}return this._children}update(e){let{viewport:r,cullingVolume:n,elevationBounds:o,minZ:s,maxZ:i,bounds:a,offset:c,project:l}=e,f=this.getBoundingVolume(o,c,l);if(a&&!this.insideBounds(a)||n.computeVisibility(f)<0||l&&this.beyondHorizon(r.cameraPosition,l,o[1]))return!1;if(!this.childVisible){let{z:h}=this;if(h<i&&h>=s){let p=f.distanceTo(r.cameraPosition)*r.scale/r.height;h+=Math.floor(Math.log2(p))}if(h>=i)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let h of this.children)h.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(let r of this._children)r.getSelected(e);return e}beyondHorizon(e,r,n){let o=e[0],s=e[1],i=e[2],a=Math.sqrt(o*o+s*s+i*i),c=Math.atan2(o,-s)*180/Math.PI,l=Math.asin(i/a)*180/Math.PI,[f,u]=$r(this.x,this.y,this.z),[h,p]=$r(this.x+1,this.y+1,this.z),d=(f+h)/2,m=d+((c-d+540)%360-180),g=Math.max(f,Math.min(m,h)),x=Math.max(p,Math.min(l,u)),b=r([g,x,n]),M=b[0]*o+b[1]*s+b[2]*i,E=b[0]*b[0]+b[1]*b[1]+b[2]*b[2];return M<=E}insideBounds([e,r,n,o]){let s=Math.pow(2,this.z),i=Zr/s;return this.x*i<n&&this.y*i<o&&(this.x+1)*i>e&&(this.y+1)*i>r}getBoundingVolume(e,r,n){if(n){let c=this.z<1?M_:this.z<2?wd:vd,l=[];for(let f of c){let u=$r(this.x+f[0],this.y+f[1],this.z);u[2]=e[0],l.push(n(u)),e[0]!==e[1]&&(u[2]=e[1],l.push(n(u)))}return co(l)}let o=Math.pow(2,this.z),s=Zr/o,i=this.x*s+r*Zr,a=Zr-(this.y+1)*s;return new Dt([i,a,e[0]],[i+s,a+s,e[1]])}};function Ld(t,e,r,n){let o=t instanceof lo._GlobeViewport?t.projectPosition:null,s=Object.values(t.getFrustumPlanes()).map(({normal:p,distance:d})=>new pe(p.clone().negate(),d)),i=new ce(s),a=t.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,f=t instanceof lo.WebMercatorViewport&&t.pitch<=60?e:0;if(n){let[p,d,m,g]=n,x=At([p,g]),b=At([m,d]);n=[x[0],Zr-x[1],b[0],Zr-b[1]]}let u=new Vt(0,0,0),h={viewport:t,project:o,cullingVolume:i,elevationBounds:[c,l],minZ:f,maxZ:e,bounds:n,offset:0};if(u.update(h),t instanceof lo.WebMercatorViewport&&t.subViewports&&t.subViewports.length>1){for(h.offset=-1;u.update(h)&&!(--h.offset<-Rd););for(h.offset=1;u.update(h)&&!(++h.offset>Rd););}return u.getSelected()}var bt=512,E_=[-1/0,-1/0,1/0,1/0],Ht={type:"object",value:null,validate:(t,e)=>e.optional&&t===null||typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string"),equal:(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;let r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}};function Ws(t,e){let r=[e.transformAsPoint([t[0],t[1]]),e.transformAsPoint([t[2],t[1]]),e.transformAsPoint([t[0],t[3]]),e.transformAsPoint([t[2],t[3]])];return[Math.min(...r.map(o=>o[0])),Math.min(...r.map(o=>o[1])),Math.max(...r.map(o=>o[0])),Math.max(...r.map(o=>o[1]))]}function S_(t){return Math.abs(t.split("").reduce((e,r)=>(e<<5)-e+r.charCodeAt(0)|0,0))}function ut(t,e){if(!t||!t.length)return null;let{index:r,id:n}=e;if(Array.isArray(t)){let s=S_(n)%t.length;t=t[s]}let o=t;for(let s of Object.keys(r)){let i=new RegExp(`{${s}}`,"g");o=o.replace(i,String(r[s]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(o=o.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),o}function __(t,e,r){let n;if(e&&e.length===2){let[o,s]=e,i=t.getBounds({z:o}),a=t.getBounds({z:s});n=[Math.min(i[0],a[0]),Math.min(i[1],a[1]),Math.max(i[2],a[2]),Math.max(i[3],a[3])]}else n=t.getBounds();return t.isGeospatial?[Math.max(n[0],r[0]),Math.max(n[1],r[1]),Math.min(n[2],r[2]),Math.min(n[3],r[3])]:[Math.max(Math.min(n[0],r[2]),r[0]),Math.max(Math.min(n[1],r[3]),r[1]),Math.min(Math.max(n[2],r[0]),r[2]),Math.min(Math.max(n[3],r[1]),r[3])]}function Pd({viewport:t,z:e,cullRect:r}){return(t.subViewports||[t]).map(o=>Vc(o,e||0,r))}function Vc(t,e,r){if(!Array.isArray(e)){let s=r.x-t.x,i=r.y-t.y,{width:a,height:c}=r,l={targetZ:e},f=t.unproject([s,i],l),u=t.unproject([s+a,i],l),h=t.unproject([s,i+c],l),p=t.unproject([s+a,i+c],l);return[Math.min(f[0],u[0],h[0],p[0]),Math.min(f[1],u[1],h[1],p[1]),Math.max(f[0],u[0],h[0],p[0]),Math.max(f[1],u[1],h[1],p[1])]}let n=Vc(t,e[0],r),o=Vc(t,e[1],r);return[Math.min(n[0],o[0]),Math.min(n[1],o[1]),Math.max(n[2],o[2]),Math.max(n[3],o[3])]}function C_(t,e,r){return r?Ws(t,r).map(o=>o*e/bt):t.map(n=>n*e/bt)}function Hc(t,e){return Math.pow(2,t)*bt/e}function $r(t,e,r){let n=Hc(r,bt),o=t/n*360-180,s=Math.PI-2*Math.PI*e/n,i=180/Math.PI*Math.atan(.5*(Math.exp(s)-Math.exp(-s)));return[o,i]}function Fd(t,e,r,n){let o=Hc(r,n);return[t/o*bt,e/o*bt]}function zc(t,e,r,n,o=bt){if(t.isGeospatial){let[l,f]=$r(e,r,n),[u,h]=$r(e+1,r+1,n);return{west:l,north:f,east:u,south:h}}let[s,i]=Fd(e,r,n,o),[a,c]=Fd(e+1,r+1,n,o);return{left:s,top:i,right:a,bottom:c}}function B_(t,e,r,n,o){let s=__(t,null,n),i=Hc(e,r),[a,c,l,f]=C_(s,i,o),u=[];for(let h=Math.floor(a);h<l;h++)for(let p=Math.floor(c);p<f;p++)u.push({x:h,y:p,z:e});return u}function kc({viewport:t,maxZoom:e,minZoom:r,zRange:n,extent:o,tileSize:s=bt,modelMatrix:i,modelMatrixInverse:a,zoomOffset:c=0,visibleMinZoom:l,visibleMaxZoom:f}){let u=t.isGeospatial?Math.round(t.zoom+Math.log2(bt/s)+c):Math.ceil(t.zoom+c);if(typeof r=="number"&&Number.isFinite(r)&&u<r){if(!o)return[];u=r}if(typeof e=="number"&&Number.isFinite(e)&&u>e&&(u=e),l!=null&&t.zoom<l)return[];if(f!=null&&t.zoom>f)return[];let h=o;return i&&a&&o&&!t.isGeospatial&&(h=Ws(o,i)),t.isGeospatial?Ld(t,u,n,o):B_(t,u,s,h||E_,a)}function jc(t){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(t)}function qc(t){return Number.isFinite(t.west)&&Number.isFinite(t.north)&&Number.isFinite(t.east)&&Number.isFinite(t.south)}function Nd(t){let e={},r;return n=>{for(let o in n)if(!I_(n[o],e[o])){r=t(n),e=n;break}return r}}function I_(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}return!1}var Od=1,Xs=2,R_="never",v_="no-overlap",fo="best-available",w_=5,Dd=0,Gd=1e8,Ud=Gd-Dd-1,L_={[fo]:P_,[v_]:N_,[R_]:()=>{}},F_={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}},dr=class{constructor(e){this._getCullBounds=Nd(Pd),this.opts={...F_,...e},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize!==null&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new Pt({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new N,this._modelMatrixInverse=new N}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom)),this._viewport=null}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let e of this._cache.keys()){let r=this._cache.get(e);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(e):r.setNeedsReload()}}update(e,{zRange:r,modelMatrix:n}={zRange:null,modelMatrix:null}){let o=n?new N(n):new N,s=!o.equals(this._modelMatrix);if(!this._viewport||!e.equals(this._viewport)||!_e(this._zRange,r)||s){s&&(this._modelMatrixInverse=o.clone().invert(),this._modelMatrix=o),this._viewport=e,this._zRange=r;let a=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(c=>this._getTile(c,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));let i=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),i&&this._frameNumber++,this._frameNumber}isTileVisible(e,r,n){if(!e.isVisible)return!1;if(r&&this._viewport){let o=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:s}=e;for(let[i,a,c,l]of o){let f;if("west"in s)f=s.west<c&&s.east>i&&s.south<l&&s.north>a;else{if(n&&!N.IDENTITY.equals(n)){let[p,d,m,g]=Ws([s.left,s.top,s.right,s.bottom],n);s={left:p,top:d,right:m,bottom:g}}let u=Math.min(s.top,s.bottom),h=Math.max(s.top,s.bottom);f=s.left<c&&s.right>i&&u<l&&h>a}if(f)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:r,minZoom:n,zRange:o,modelMatrix:s,modelMatrixInverse:i}){let{tileSize:a,extent:c,zoomOffset:l,visibleMinZoom:f,visibleMaxZoom:u}=this.opts;return kc({viewport:e,maxZoom:r,minZoom:n,zRange:o,tileSize:a,extent:c,modelMatrix:s,modelMatrixInverse:i,zoomOffset:l,visibleMinZoom:f,visibleMaxZoom:u})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){let{tileSize:r}=this.opts;return{bbox:zc(this._viewport,e.x,e.y,e.z,r)}}getParentIndex(e){let r=Math.floor(e.x/2),n=Math.floor(e.y/2),o=e.z-1;return{x:r,y:n,z:o}}updateTileStates(){let e=this.opts.refinementStrategy||fo,r=new Array(this._cache.size),n=0;for(let o of this._cache.values())r[n++]=o.isVisible,o.isSelected=!1,o.isVisible=!1;for(let o of this._selectedTiles)o.isSelected=!0,o.isVisible=!0;(typeof e=="function"?e:L_[e])(Array.from(this._cache.values())),n=0;for(let o of this._cache.values())if(r[n++]!==o.isVisible)return!0;return!1}_getRequestPriority(e){if(!e.isSelected&&!e.isVisible)return-1;let r=this._getTileDistancePriority(e);return e.isSelected?Dd+r:Gd+r}_getTileDistancePriority(e){let{width:r,height:n}=this._viewport||{};if(!this._viewport||!r||!n)return 0;try{let o=this._getTileScreenCorners(e.bbox),s=[r/2,n/2];if(o.length===4){if(this._isPointInPolygon(s,o))return 0;let i=o.reduce((a,c,l)=>{let f=o[(l+1)%o.length];return Math.min(a,this._getPointToSegmentDistanceSquared(s,c,f))},Number.MAX_SAFE_INTEGER);return Math.min(i,Ud)}}catch{}return Ud}_getTileScreenCorners(e){return("west"in e?[[e.west,e.south],[e.east,e.south],[e.east,e.north],[e.west,e.north]]:[[e.left,e.top],[e.right,e.top],[e.right,e.bottom],[e.left,e.bottom]]).map(n=>this._viewport.project(n)).filter(([n,o])=>Number.isFinite(n)&&Number.isFinite(o))}_isPointInPolygon(e,r){let n=!1,[o,s]=e;for(let i=0,a=r.length-1;i<r.length;a=i++){let[c,l]=r[i],[f,u]=r[a];l>s!=u>s&&o<(f-c)*(s-l)/(u-l)+c&&(n=!n)}return n}_getPointToSegmentDistanceSquared(e,r,n){let[o,s]=e,[i,a]=r,[c,l]=n,f=c-i,u=l-a,h=f*f+u*u,p=h?Math.max(0,Math.min(1,((o-i)*f+(s-a)*u)/h)):0,d=i+p*f,m=a+p*u,g=o-d,x=s-m;return g*g+x*x}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=[],n=0;for(let o of this._cache.values())o.isLoading&&(n++,!o.isSelected&&!o.isVisible&&r.push(o));for(;e>0&&n>e&&r.length>0;)r.shift().abort(),n--}_rebuildTree(){let{_cache:e}=this;for(let r of e.values())r.parent=null,r.children&&(r.children.length=0);for(let r of e.values()){let n=this._getNearestAncestor(r);r.parent=n,n?.children&&n.children.push(r)}}_resizeCache(){let{_cache:e,opts:r}=this,n=r.maxCacheSize??(r.maxCacheByteSize!==null?1/0:w_*this.selectedTiles.length),o=r.maxCacheByteSize??1/0;if(e.size>n||this._cacheByteSize>o){for(let[i,a]of e)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize!==null?a.byteLength:0,e.delete(i),this.opts.onTileUnload?.(a)),e.size<=n&&this._cacheByteSize<=o)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((i,a)=>i.zoom-a.zoom),this._dirty=!1)}_getTile(e,r){let n=this.getTileId(e),o=this._cache.get(n),s=!1;return!o&&r?(o=new pr(e),Object.assign(o,this.getTileMetadata(o.index)),Object.assign(o,{id:n,zoom:this.getTileZoom(o.index)}),s=!0,this._cache.set(n,o),this._dirty=!0):o&&o.needsReload&&(s=!0),o&&s&&o.loadData({getData:this.opts.getTileData,getRequestPriority:this._getRequestPriority.bind(this),requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),o}_getNearestAncestor(e){let{_minZoom:r=0}=this,n=e.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let o=this._getTile(n);if(o)return o}return null}};function P_(t){for(let e of t)e.state=0;for(let e of t)e.isSelected&&!Vd(e)&&Jc(e);for(let e of t)e.isVisible=Boolean(e.state&Xs)}function N_(t){for(let r of t)r.state=0;for(let r of t)r.isSelected&&Vd(r);let e=Array.from(t).sort((r,n)=>r.zoom-n.zoom);for(let r of e)if(r.isVisible=Boolean(r.state&Xs),r.children&&(r.isVisible||r.state&Od))for(let n of r.children)n.state=Od;else r.isSelected&&Jc(r)}function Vd(t){let e=t;for(;e;){if(e.isLoaded||e.content)return e.state|=Xs,!0;e=e.parent}return!1}function Jc(t){for(let e of t.children)e.isLoaded||e.content?e.state|=Xs:Jc(e)}var O_={TilesetClass:dr,data:{type:"data",value:[]},dataComparator:Ht.equal,renderSubLayers:{type:"function",value:t=>new Hd.GeoJsonLayer(t)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:t=>console.error(t)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:fo,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null},uo=class extends Ys.CompositeLayer{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&(!e.content||!e.layers||e.layers.every(r=>r.isLoaded))))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:r}=this.state,n=e.propsOrDataChanged||e.updateTriggersChanged,o=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);r?n&&(r.setOptions(this._getTilesetOptions()),o?r.reloadAll():r.tiles.forEach(s=>{s.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:e,maxCacheSize:r,maxCacheByteSize:n,refinementStrategy:o,extent:s,maxZoom:i,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:f,visibleMinZoom:u,visibleMaxZoom:h}=this.props;return{maxCacheSize:r,maxCacheByteSize:n,maxZoom:i,minZoom:a,tileSize:e,refinementStrategy:o,extent:s,maxRequests:c,debounceTime:l,zoomOffset:f,visibleMinZoom:u,visibleMaxZoom:h,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let e=this.state.tileset,{zRange:r,modelMatrix:n}=this.props,o=e.update(this.context.viewport,{zRange:r,modelMatrix:n}),{isLoaded:s}=e,i=this.state.isLoaded!==s,a=this.state.frameNumber!==o;s&&(i||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:o}),this.state.isLoaded=s}_onViewportLoad(){let{tileset:e}=this.state,{onViewportLoad:r}=this.props;r&&r(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,r){this.props.onTileError(e),r.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){let{data:r,getTileData:n,fetch:o}=this.props,{signal:s}=e;return e.url=typeof r=="string"||Array.isArray(r)?ut(r,e):null,n?n(e):o&&e.url?o(e.url,{propName:"data",layer:this,signal:s}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){let r=e.sourceLayer,n=r.props.tile,o=e.info;return o.picked&&(o.tile=n),o.sourceTile=n,o.sourceTileSubLayer=r,o}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){let{visibleMinZoom:e,visibleMaxZoom:r,minZoom:n,extent:o}=this.props,s=this.context.viewport.zoom;if(e!=null&&s<e||r!=null&&s>r||n!=null&&!o&&s<n){for(let a of this.state.tileset.tiles)a.layers=null;return[]}return this.state.tileset.tiles.map(a=>{let c=this.getSubLayerPropsByTile(a);if(!(!a.isLoaded&&!a.content))if(a.layers)c&&a.layers[0]&&Object.keys(c).some(l=>a.layers[0].props[l]!==c[l])&&(a.layers=a.layers.map(l=>l.clone(c)));else{let l=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:a.id,updateTriggers:this.props.updateTriggers}),data:a.content,_offset:0,tile:a});a.layers=(0,Ys._flatten)(l,Boolean).map(f=>f.clone({tile:a,...c}))}return a.layers})}filterSubLayer({layer:e,cullRect:r}){let{tile:n}=e.props,{modelMatrix:o}=this.props;return this.state.tileset.isTileVisible(n,r,o?new N(o):null)}};uo.defaultProps=O_;uo.layerName="TileLayer";var mr=uo;var jd=D(Xe(),1);var zd=`layout(std140) uniform tripsUniforms {
|
|
7
|
+
"use strict";var __exports__=(()=>{var X1=Object.create;var Go=Object.defineProperty;var K1=Object.getOwnPropertyDescriptor;var Y1=Object.getOwnPropertyNames;var Q1=Object.getPrototypeOf,Z1=Object.prototype.hasOwnProperty;var Pf=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var je=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Ae=(t,e)=>{for(var r in e)Go(t,r,{get:e[r],enumerable:!0})},Vo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Y1(e))!Z1.call(t,o)&&o!==r&&Go(t,o,{get:()=>e[o],enumerable:!(n=K1(e,o))||n.enumerable});return t},Ct=(t,e,r)=>(Vo(t,e,"default"),r&&Vo(r,e,"default")),U=(t,e,r)=>(r=t!=null?X1(Q1(t)):{},Vo(e||!t||!t.__esModule?Go(r,"default",{value:t,enumerable:!0}):r,t)),$1=t=>Vo(Go({},"__esModule",{value:!0}),t);var Je=je((QR,Nf)=>{Nf.exports=globalThis.deck});var We=je(($R,Uf)=>{Uf.exports=globalThis.deck});var ss=je((xw,rh)=>{rh.exports=globalThis.h3||{}});var Yt=je((tF,op)=>{op.exports=globalThis.loaders});var Pc=je((cd,$n)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof Pf=="function"&&typeof $n=="object"&&$n&&$n.exports?$n.exports=e():(t.dcodeIO=t.dcodeIO||{}).Long=e()})(cd,function(){"use strict";function t(y,A,I){this.low=y|0,this.high=A|0,this.unsigned=!!I}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function e(y){return(y&&y.__isLong__)===!0}t.isLong=e;var r={},n={};function o(y,A){var I,L,F;return A?(y>>>=0,(F=0<=y&&y<256)&&(L=n[y],L)?L:(I=i(y,(y|0)<0?-1:0,!0),F&&(n[y]=I),I)):(y|=0,(F=-128<=y&&y<128)&&(L=r[y],L)?L:(I=i(y,y<0?-1:0,!1),F&&(r[y]=I),I))}t.fromInt=o;function s(y,A){if(isNaN(y)||!isFinite(y))return A?b:g;if(A){if(y<0)return b;if(y>=p)return E}else{if(y<=-d)return B;if(y+1>=d)return C}return y<0?s(-y,A).neg():i(y%h|0,y/h|0,A)}t.fromNumber=s;function i(y,A,I){return new t(y,A,I)}t.fromBits=i;var a=Math.pow;function c(y,A,I){if(y.length===0)throw Error("empty string");if(y==="NaN"||y==="Infinity"||y==="+Infinity"||y==="-Infinity")return g;if(typeof A=="number"?(I=A,A=!1):A=!!A,I=I||10,I<2||36<I)throw RangeError("radix");var L;if((L=y.indexOf("-"))>0)throw Error("interior hyphen");if(L===0)return c(y.substring(1),A,I).neg();for(var F=s(a(I,8)),w=g,D=0;D<y.length;D+=8){var W=Math.min(8,y.length-D),k=parseInt(y.substring(D,D+W),I);if(W<8){var ne=s(a(I,W));w=w.mul(ne).add(s(k))}else w=w.mul(F),w=w.add(s(k))}return w.unsigned=A,w}t.fromString=c;function l(y){return y instanceof t?y:typeof y=="number"?s(y):typeof y=="string"?c(y):i(y.low,y.high,y.unsigned)}t.fromValue=l;var f=65536,u=1<<24,h=f*f,p=h*h,d=p/2,m=o(u),g=o(0);t.ZERO=g;var b=o(0,!0);t.UZERO=b;var T=o(1);t.ONE=T;var S=o(1,!0);t.UONE=S;var M=o(-1);t.NEG_ONE=M;var C=i(-1,2147483647,!1);t.MAX_VALUE=C;var E=i(-1,-1,!0);t.MAX_UNSIGNED_VALUE=E;var B=i(0,-2147483648,!1);t.MIN_VALUE=B;var _=t.prototype;return _.toInt=function(){return this.unsigned?this.low>>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},_.toString=function(A){if(A=A||10,A<2||36<A)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(B)){var I=s(A),L=this.div(I),F=L.mul(I).sub(this);return L.toString(A)+F.toInt().toString(A)}else return"-"+this.neg().toString(A);for(var w=s(a(A,6),this.unsigned),D=this,W="";;){var k=D.div(w),ne=D.sub(k.mul(w)).toInt()>>>0,Q=ne.toString(A);if(D=k,D.isZero())return Q+W;for(;Q.length<6;)Q="0"+Q;W=""+Q+W}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(B)?64:this.neg().getNumBitsAbs();for(var A=this.high!=0?this.high:this.low,I=31;I>0&&(A&1<<I)==0;I--);return this.high!=0?I+33:I+1},_.isZero=function(){return this.high===0&&this.low===0},_.isNegative=function(){return!this.unsigned&&this.high<0},_.isPositive=function(){return this.unsigned||this.high>=0},_.isOdd=function(){return(this.low&1)===1},_.isEven=function(){return(this.low&1)===0},_.equals=function(A){return e(A)||(A=l(A)),this.unsigned!==A.unsigned&&this.high>>>31===1&&A.high>>>31===1?!1:this.high===A.high&&this.low===A.low},_.eq=_.equals,_.notEquals=function(A){return!this.eq(A)},_.neq=_.notEquals,_.lessThan=function(A){return this.comp(A)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(A){return this.comp(A)<=0},_.lte=_.lessThanOrEqual,_.greaterThan=function(A){return this.comp(A)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(A){return this.comp(A)>=0},_.gte=_.greaterThanOrEqual,_.compare=function(A){if(e(A)||(A=l(A)),this.eq(A))return 0;var I=this.isNegative(),L=A.isNegative();return I&&!L?-1:!I&&L?1:this.unsigned?A.high>>>0>this.high>>>0||A.high===this.high&&A.low>>>0>this.low>>>0?-1:1:this.sub(A).isNegative()?-1:1},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(B)?B:this.not().add(T)},_.neg=_.negate,_.add=function(A){e(A)||(A=l(A));var I=this.high>>>16,L=this.high&65535,F=this.low>>>16,w=this.low&65535,D=A.high>>>16,W=A.high&65535,k=A.low>>>16,ne=A.low&65535,Q=0,K=0,te=0,Ie=0;return Ie+=w+ne,te+=Ie>>>16,Ie&=65535,te+=F+k,K+=te>>>16,te&=65535,K+=L+W,Q+=K>>>16,K&=65535,Q+=I+D,Q&=65535,i(te<<16|Ie,Q<<16|K,this.unsigned)},_.subtract=function(A){return e(A)||(A=l(A)),this.add(A.neg())},_.sub=_.subtract,_.multiply=function(A){if(this.isZero()||(e(A)||(A=l(A)),A.isZero()))return g;if(this.eq(B))return A.isOdd()?B:g;if(A.eq(B))return this.isOdd()?B:g;if(this.isNegative())return A.isNegative()?this.neg().mul(A.neg()):this.neg().mul(A).neg();if(A.isNegative())return this.mul(A.neg()).neg();if(this.lt(m)&&A.lt(m))return s(this.toNumber()*A.toNumber(),this.unsigned);var I=this.high>>>16,L=this.high&65535,F=this.low>>>16,w=this.low&65535,D=A.high>>>16,W=A.high&65535,k=A.low>>>16,ne=A.low&65535,Q=0,K=0,te=0,Ie=0;return Ie+=w*ne,te+=Ie>>>16,Ie&=65535,te+=F*ne,K+=te>>>16,te&=65535,te+=w*k,K+=te>>>16,te&=65535,K+=L*ne,Q+=K>>>16,K&=65535,K+=F*k,Q+=K>>>16,K&=65535,K+=w*W,Q+=K>>>16,K&=65535,Q+=I*ne+L*k+F*W+w*D,Q&=65535,i(te<<16|Ie,Q<<16|K,this.unsigned)},_.mul=_.multiply,_.divide=function(A){if(e(A)||(A=l(A)),A.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?b:g;var I,L,F;if(this.unsigned){if(A.unsigned||(A=A.toUnsigned()),A.gt(this))return b;if(A.gt(this.shru(1)))return S;F=b}else{if(this.eq(B)){if(A.eq(T)||A.eq(M))return B;if(A.eq(B))return T;var w=this.shr(1);return I=w.div(A).shl(1),I.eq(g)?A.isNegative()?T:M:(L=this.sub(A.mul(I)),F=I.add(L.div(A)),F)}else if(A.eq(B))return this.unsigned?b:g;if(this.isNegative())return A.isNegative()?this.neg().div(A.neg()):this.neg().div(A).neg();if(A.isNegative())return this.div(A.neg()).neg();F=g}for(L=this;L.gte(A);){I=Math.max(1,Math.floor(L.toNumber()/A.toNumber()));for(var D=Math.ceil(Math.log(I)/Math.LN2),W=D<=48?1:a(2,D-48),k=s(I),ne=k.mul(A);ne.isNegative()||ne.gt(L);)I-=W,k=s(I,this.unsigned),ne=k.mul(A);k.isZero()&&(k=T),F=F.add(k),L=L.sub(ne)}return F},_.div=_.divide,_.modulo=function(A){return e(A)||(A=l(A)),this.sub(this.div(A).mul(A))},_.mod=_.modulo,_.not=function(){return i(~this.low,~this.high,this.unsigned)},_.and=function(A){return e(A)||(A=l(A)),i(this.low&A.low,this.high&A.high,this.unsigned)},_.or=function(A){return e(A)||(A=l(A)),i(this.low|A.low,this.high|A.high,this.unsigned)},_.xor=function(A){return e(A)||(A=l(A)),i(this.low^A.low,this.high^A.high,this.unsigned)},_.shiftLeft=function(A){return e(A)&&(A=A.toInt()),(A&=63)===0?this:A<32?i(this.low<<A,this.high<<A|this.low>>>32-A,this.unsigned):i(0,this.low<<A-32,this.unsigned)},_.shl=_.shiftLeft,_.shiftRight=function(A){return e(A)&&(A=A.toInt()),(A&=63)===0?this:A<32?i(this.low>>>A|this.high<<32-A,this.high>>A,this.unsigned):i(this.high>>A-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(A){if(e(A)&&(A=A.toInt()),A&=63,A===0)return this;var I=this.high;if(A<32){var L=this.low;return i(L>>>A|I<<32-A,I>>>A,this.unsigned)}else return A===32?i(I,0,this.unsigned):i(I>>>A-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},_.toBytes=function(y){return y?this.toBytesLE():this.toBytesBE()},_.toBytesLE=function(){var y=this.high,A=this.low;return[A&255,A>>>8&255,A>>>16&255,A>>>24&255,y&255,y>>>8&255,y>>>16&255,y>>>24&255]},_.toBytesBE=function(){var y=this.high,A=this.low;return[y>>>24&255,y>>>16&255,y>>>8&255,y&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255]},t})});var Wc=je((nG,Zd)=>{Zd.exports=globalThis.luma});var Ys=je((oG,$d)=>{$d.exports=globalThis.deck});var Xc=je((sG,em)=>{em.exports=globalThis.luma});var f1=je((w5,l1)=>{l1.exports=globalThis.deck});var T1=je(Sf=>{Sf.read=function(t,e,r,n,o){var s,i,a=o*8-n-1,c=(1<<a)-1,l=c>>1,f=-7,u=r?o-1:0,h=r?-1:1,p=t[e+u];for(u+=h,s=p&(1<<-f)-1,p>>=-f,f+=a;f>0;s=s*256+t[e+u],u+=h,f-=8);for(i=s&(1<<-f)-1,s>>=-f,f+=n;f>0;i=i*256+t[e+u],u+=h,f-=8);if(s===0)s=1-l;else{if(s===c)return i?NaN:(p?-1:1)*(1/0);i=i+Math.pow(2,n),s=s-l}return(p?-1:1)*i*Math.pow(2,s-n)};Sf.write=function(t,e,r,n,o,s){var i,a,c,l=s*8-o-1,f=(1<<l)-1,u=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=f):(i=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-i))<1&&(i--,c*=2),i+u>=1?e+=h/c:e+=h*Math.pow(2,1-u),e*c>=2&&(i++,c/=2),i+u>=f?(a=0,i=f):i+u>=1?(a=(e*c-1)*Math.pow(2,o),i=i+u):(a=e*Math.pow(2,u-1)*Math.pow(2,o),i=0));o>=8;t[r+p]=a&255,p+=d,a/=256,o-=8);for(i=i<<o|a,l+=o;l>0;t[r+p]=i&255,p+=d,i/=256,l-=8);t[r+p-d]|=m*128}});var C1=je((Tq,E1)=>{"use strict";E1.exports=J;var Zi=T1();function J(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}J.Varint=0;J.Fixed64=1;J.Bytes=2;J.Fixed32=5;var Mf=65536*65536,y1=1/Mf,iR=12,_1=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");J.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),o=n>>3,s=this.pos;this.type=n&7,t(o,e,this),this.pos===s&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=$i(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=M1(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=$i(this.buf,this.pos)+$i(this.buf,this.pos+4)*Mf;return this.pos+=8,t},readSFixed64:function(){var t=$i(this.buf,this.pos)+M1(this.buf,this.pos+4)*Mf;return this.pos+=8,t},readFloat:function(){var t=Zi.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Zi.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,n;return n=e[this.pos++],r=n&127,n<128||(n=e[this.pos++],r|=(n&127)<<7,n<128)||(n=e[this.pos++],r|=(n&127)<<14,n<128)||(n=e[this.pos++],r|=(n&127)<<21,n<128)?r:(n=e[this.pos],r|=(n&15)<<28,aR(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=iR&&_1?yR(this.buf,e,t):TR(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==J.Bytes)return t.push(this.readVarint(e));var r=Et(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==J.Bytes)return t.push(this.readSVarint());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==J.Bytes)return t.push(this.readBoolean());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==J.Bytes)return t.push(this.readFloat());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==J.Bytes)return t.push(this.readDouble());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==J.Bytes)return t.push(this.readFixed32());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==J.Bytes)return t.push(this.readSFixed32());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==J.Bytes)return t.push(this.readFixed64());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==J.Bytes)return t.push(this.readSFixed64());var e=Et(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===J.Varint)for(;this.buf[this.pos++]>127;);else if(e===J.Bytes)this.pos=this.readVarint()+this.pos;else if(e===J.Fixed32)this.pos+=4;else if(e===J.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),An(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),An(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),An(this.buf,t&-1,this.pos),An(this.buf,Math.floor(t*y1),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),An(this.buf,t&-1,this.pos),An(this.buf,Math.floor(t*y1),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){cR(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=SR(this.buf,t,this.pos);var r=this.pos-e;r>=128&&S1(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Zi.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Zi.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var n=this.pos-r;n>=128&&S1(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,J.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,uR,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,hR,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,mR,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,pR,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,dR,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,gR,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,AR,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,bR,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,xR,e)},writeBytesField:function(t,e){this.writeTag(t,J.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,J.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,J.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,J.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,J.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,J.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,J.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,J.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,J.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,J.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};function aR(t,e,r){var n=r.buf,o,s;if(s=n[r.pos++],o=(s&112)>>4,s<128||(s=n[r.pos++],o|=(s&127)<<3,s<128)||(s=n[r.pos++],o|=(s&127)<<10,s<128)||(s=n[r.pos++],o|=(s&127)<<17,s<128)||(s=n[r.pos++],o|=(s&127)<<24,s<128)||(s=n[r.pos++],o|=(s&1)<<31,s<128))return gn(t,o,e);throw new Error("Expected varint not more than 10 bytes")}function Et(t){return t.type===J.Bytes?t.readVarint()+t.pos:t.pos+1}function gn(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function cR(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(r=~(-t%4294967296),n=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,n=n+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),lR(r,n,e),fR(n,e)}function lR(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function fR(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function S1(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(n);for(var o=r.pos-1;o>=t;o--)r.buf[o+n]=r.buf[o]}function uR(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function hR(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function pR(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function dR(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function mR(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function gR(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function AR(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function bR(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function xR(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function $i(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function An(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function M1(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function TR(t,e,r){for(var n="",o=e;o<r;){var s=t[o],i=null,a=s>239?4:s>223?3:s>191?2:1;if(o+a>r)break;var c,l,f;a===1?s<128&&(i=s):a===2?(c=t[o+1],(c&192)===128&&(i=(s&31)<<6|c&63,i<=127&&(i=null))):a===3?(c=t[o+1],l=t[o+2],(c&192)===128&&(l&192)===128&&(i=(s&15)<<12|(c&63)<<6|l&63,(i<=2047||i>=55296&&i<=57343)&&(i=null))):a===4&&(c=t[o+1],l=t[o+2],f=t[o+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(i=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,(i<=65535||i>=1114112)&&(i=null))),i===null?(i=65533,a=1):i>65535&&(i-=65536,n+=String.fromCharCode(i>>>10&1023|55296),i=56320|i&1023),n+=String.fromCharCode(i),o+=a}return n}function yR(t,e,r){return _1.decode(t.subarray(e,r))}function SR(t,e,r){for(var n=0,o,s;n<e.length;n++){if(o=e.charCodeAt(n),o>55295&&o<57344)if(s)if(o<56320){t[r++]=239,t[r++]=191,t[r++]=189,s=o;continue}else o=s-55296<<10|o-56320|65536,s=null;else{o>56319||n+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):s=o;continue}else s&&(t[r++]=239,t[r++]=191,t[r++]=189,s=null);o<128?t[r++]=o:(o<2048?t[r++]=o>>6|192:(o<65536?t[r++]=o>>12|224:(t[r++]=o>>18|240,t[r++]=o>>12&63|128),t[r++]=o>>6&63|128),t[r++]=o&63|128)}return r}});var Do={};Ae(Do,{A5Layer:()=>np,GeohashLayer:()=>W1,GreatCircleLayer:()=>ad,H3ClusterLayer:()=>Qd,H3HexagonLayer:()=>Ks,MVTLayer:()=>z1,QuadkeyLayer:()=>yd,S2Layer:()=>xd,TerrainLayer:()=>c1,Tile3DLayer:()=>$0,TileLayer:()=>lr,TripsLayer:()=>Xd,_GeoCellLayer:()=>De,_Tile2DHeader:()=>ar,_Tileset2D:()=>cr,_WMSLayer:()=>qr,_getURLFromTemplate:()=>ft});var rt={},Of=U(Je(),1);Ct(rt,U(Je(),1));if(!Of.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");Ct(Do,rt);var Df=U(We(),1),na=U(Je(),1),eA={...na.PolygonLayer.defaultProps},xn=class extends Df.CompositeLayer{indexToBounds(){return null}renderLayers(){let{elevationScale:e,extruded:r,wireframe:n,filled:o,stroked:s,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineAntialiasing:f,lineJointRounded:u,lineMiterLimit:h,lineDashJustified:p,getElevation:d,getFillColor:m,getLineColor:g,getLineWidth:b}=this.props,{updateTriggers:T,material:S,transitions:M}=this.props,C=this.getSubLayerClass("cell",na.PolygonLayer),{updateTriggers:E,...B}=this.indexToBounds()||{};return new C({filled:o,wireframe:n,extruded:r,elevationScale:e,stroked:s,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineAntialiasing:f,lineJointRounded:u,lineMiterLimit:h,lineDashJustified:p,material:S,transitions:M,getElevation:d,getFillColor:m,getLineColor:g,getLineWidth:b},this.getSubLayerProps({id:"cell",updateTriggers:T&&{...E,getElevation:T.getElevation,getFillColor:T.getFillColor,getLineColor:T.getLineColor,getLineWidth:T.getLineWidth}}),B)}};xn.layerName="GeoCellLayer";xn.defaultProps=eA;var De=xn;var tA=Object.defineProperty,Mn=(t,e)=>{for(var r in e)tA(t,r,{get:e[r],enumerable:!0})},ge={};Mn(ge,{ARRAY_TYPE:()=>se,EPSILON:()=>me,RANDOM:()=>qt,equals:()=>sA,setMatrixArrayType:()=>rA,toRadian:()=>oA});var me=1e-6,se=typeof Float32Array<"u"?Float32Array:Array,qt=Math.random;function rA(t){se=t}var nA=Math.PI/180;function oA(t){return t*nA}function sA(t,e){return Math.abs(t-e)<=me*Math.max(1,Math.abs(t),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var jt={};Mn(jt,{LDU:()=>SA,add:()=>MA,adjoint:()=>dA,clone:()=>aA,copy:()=>cA,create:()=>iA,determinant:()=>mA,equals:()=>EA,exactEquals:()=>_A,frob:()=>yA,fromRotation:()=>bA,fromScaling:()=>xA,fromValues:()=>fA,identity:()=>lA,invert:()=>pA,mul:()=>vA,multiply:()=>iu,multiplyScalar:()=>CA,multiplyScalarAndAdd:()=>IA,rotate:()=>gA,scale:()=>AA,set:()=>uA,str:()=>TA,sub:()=>BA,subtract:()=>au,transpose:()=>hA});function iA(){var t=new se(4);return se!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function aA(t){var e=new se(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function cA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function lA(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function fA(t,e,r,n){var o=new se(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=n,o}function uA(t,e,r,n,o){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t}function hA(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t}function pA(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*s-o*n;return i?(i=1/i,t[0]=s*i,t[1]=-n*i,t[2]=-o*i,t[3]=r*i,t):null}function dA(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t}function mA(t){return t[0]*t[3]-t[2]*t[1]}function iu(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*a+s*c,t[1]=o*a+i*c,t[2]=n*l+s*f,t[3]=o*l+i*f,t}function gA(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*a,t[1]=o*c+i*a,t[2]=n*-a+s*c,t[3]=o*-a+i*c,t}function AA(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1];return t[0]=n*a,t[1]=o*a,t[2]=s*c,t[3]=i*c,t}function bA(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t}function xA(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t}function TA(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function yA(t){return Math.hypot(t[0],t[1],t[2],t[3])}function SA(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]}function MA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function au(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function _A(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function EA(t,e){var r=t[0],n=t[1],o=t[2],s=t[3],i=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-i)<=me*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=me*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-c)<=me*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(s-l)<=me*Math.max(1,Math.abs(s),Math.abs(l))}function CA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function IA(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t}var vA=iu,BA=au;function RA(){var t=new se(9);return se!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}var aa={};Mn(aa,{add:()=>zb,calculateW:()=>Lb,clone:()=>Vb,conjugate:()=>Ob,copy:()=>Hb,create:()=>la,dot:()=>Mu,equals:()=>Kb,exactEquals:()=>Xb,exp:()=>xu,fromEuler:()=>Ub,fromMat3:()=>yu,fromValues:()=>Gb,getAngle:()=>vb,getAxisAngle:()=>Ib,identity:()=>Cb,invert:()=>Nb,len:()=>Jb,length:()=>_u,lerp:()=>jb,ln:()=>Tu,mul:()=>qb,multiply:()=>bu,normalize:()=>xa,pow:()=>Fb,random:()=>Pb,rotateX:()=>Bb,rotateY:()=>Rb,rotateZ:()=>wb,rotationTo:()=>Yb,scale:()=>Su,set:()=>kb,setAxes:()=>Zb,setAxisAngle:()=>Au,slerp:()=>Yo,sqlerp:()=>Qb,sqrLen:()=>Wb,squaredLength:()=>Eu,str:()=>Db});var R={};Mn(R,{add:()=>PA,angle:()=>eb,bezier:()=>JA,ceil:()=>NA,clone:()=>wA,copy:()=>LA,create:()=>Aa,cross:()=>Ko,dist:()=>cb,distance:()=>hu,div:()=>ab,divide:()=>uu,dot:()=>ba,equals:()=>ob,exactEquals:()=>nb,floor:()=>OA,forEach:()=>ub,fromValues:()=>ca,hermite:()=>jA,inverse:()=>zA,len:()=>gu,length:()=>cu,lerp:()=>qA,max:()=>DA,min:()=>UA,mul:()=>ib,multiply:()=>fu,negate:()=>kA,normalize:()=>mu,random:()=>WA,rotateX:()=>QA,rotateY:()=>ZA,rotateZ:()=>$A,round:()=>VA,scale:()=>GA,scaleAndAdd:()=>HA,set:()=>FA,sqrDist:()=>lb,sqrLen:()=>fb,squaredDistance:()=>pu,squaredLength:()=>du,str:()=>rb,sub:()=>sb,subtract:()=>lu,transformMat3:()=>KA,transformMat4:()=>XA,transformQuat:()=>YA,zero:()=>tb});function Aa(){var t=new se(3);return se!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function wA(t){var e=new se(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function cu(t){var e=t[0],r=t[1],n=t[2];return Math.hypot(e,r,n)}function ca(t,e,r){var n=new se(3);return n[0]=t,n[1]=e,n[2]=r,n}function LA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function FA(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function PA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function lu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function fu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function uu(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function NA(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function OA(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function UA(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function DA(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function VA(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function GA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function HA(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function hu(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return Math.hypot(r,n,o)}function pu(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return r*r+n*n+o*o}function du(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function kA(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function zA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function mu(t,e){var r=e[0],n=e[1],o=e[2],s=r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function ba(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ko(t,e,r){var n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2];return t[0]=o*c-s*a,t[1]=s*i-n*c,t[2]=n*a-o*i,t}function qA(t,e,r,n){var o=e[0],s=e[1],i=e[2];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t}function jA(t,e,r,n,o,s){var i=s*s,a=i*(2*s-3)+1,c=i*(s-2)+s,l=i*(s-1),f=i*(3-2*s);return t[0]=e[0]*a+r[0]*c+n[0]*l+o[0]*f,t[1]=e[1]*a+r[1]*c+n[1]*l+o[1]*f,t[2]=e[2]*a+r[2]*c+n[2]*l+o[2]*f,t}function JA(t,e,r,n,o,s){var i=1-s,a=i*i,c=s*s,l=a*i,f=3*s*a,u=3*c*i,h=c*s;return t[0]=e[0]*l+r[0]*f+n[0]*u+o[0]*h,t[1]=e[1]*l+r[1]*f+n[1]*u+o[1]*h,t[2]=e[2]*l+r[2]*f+n[2]*u+o[2]*h,t}function WA(t,e){e=e||1;var r=qt()*2*Math.PI,n=qt()*2-1,o=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=n*e,t}function XA(t,e,r){var n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*o+r[8]*s+r[12])/i,t[1]=(r[1]*n+r[5]*o+r[9]*s+r[13])/i,t[2]=(r[2]*n+r[6]*o+r[10]*s+r[14])/i,t}function KA(t,e,r){var n=e[0],o=e[1],s=e[2];return t[0]=n*r[0]+o*r[3]+s*r[6],t[1]=n*r[1]+o*r[4]+s*r[7],t[2]=n*r[2]+o*r[5]+s*r[8],t}function YA(t,e,r){var n=r[0],o=r[1],s=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=o*l-s*c,u=s*a-n*l,h=n*c-o*a,p=o*h-s*u,d=s*f-n*h,m=n*u-o*f,g=i*2;return f*=g,u*=g,h*=g,p*=2,d*=2,m*=2,t[0]=a+f+p,t[1]=c+u+d,t[2]=l+h+m,t}function QA(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),s[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function ZA(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),s[1]=o[1],s[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function $A(t,e,r,n){var o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),s[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function eb(t,e){var r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2],c=Math.sqrt(r*r+n*n+o*o),l=Math.sqrt(s*s+i*i+a*a),f=c*l,u=f&&ba(t,e)/f;return Math.acos(Math.min(Math.max(u,-1),1))}function tb(t){return t[0]=0,t[1]=0,t[2]=0,t}function rb(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function nb(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function ob(t,e){var r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2];return Math.abs(r-s)<=me*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=me*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(o-a)<=me*Math.max(1,Math.abs(o),Math.abs(a))}var sb=lu,ib=fu,ab=uu,cb=hu,lb=pu,gu=cu,fb=du,ub=(function(){var t=Aa();return function(e,r,n,o,s,i){var a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}})();function hb(){var t=new se(4);return se!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function pb(t){var e=new se(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function db(t,e,r,n){var o=new se(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=n,o}function mb(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function gb(t,e,r,n,o){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t}function Ab(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function bb(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function xb(t){var e=t[0],r=t[1],n=t[2],o=t[3];return Math.hypot(e,r,n,o)}function Tb(t){var e=t[0],r=t[1],n=t[2],o=t[3];return e*e+r*r+n*n+o*o}function yb(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=o*i,t[3]=s*i,t}function Sb(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Mb(t,e,r,n){var o=e[0],s=e[1],i=e[2],a=e[3];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function _b(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function Eb(t,e){var r=t[0],n=t[1],o=t[2],s=t[3],i=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-i)<=me*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-a)<=me*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-c)<=me*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(s-l)<=me*Math.max(1,Math.abs(s),Math.abs(l))}var tw=(function(){var t=hb();return function(e,r,n,o,s,i){var a,c;for(r||(r=4),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}})();function la(){var t=new se(4);return se!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Cb(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Au(t,e,r){r=r*.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function Ib(t,e){var r=Math.acos(e[3])*2,n=Math.sin(r/2);return n>me?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r}function vb(t,e){var r=Mu(t,e);return Math.acos(2*r*r-1)}function bu(t,e,r){var n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+o*l-s*c,t[1]=o*f+i*c+s*a-n*l,t[2]=s*f+i*l+n*c-o*a,t[3]=i*f-n*a-o*c-s*l,t}function Bb(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=o*c+s*a,t[2]=s*c-o*a,t[3]=i*c-n*a,t}function Rb(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-s*a,t[1]=o*c+i*a,t[2]=s*c+n*a,t[3]=i*c-o*a,t}function wb(t,e,r){r*=.5;var n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*a,t[1]=o*c-n*a,t[2]=s*c+i*a,t[3]=i*c-s*a,t}function Lb(t,e){var r=e[0],n=e[1],o=e[2];return t[0]=r,t[1]=n,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-o*o)),t}function xu(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=Math.sqrt(r*r+n*n+o*o),a=Math.exp(s),c=i>0?a*Math.sin(i)/i:0;return t[0]=r*c,t[1]=n*c,t[2]=o*c,t[3]=a*Math.cos(i),t}function Tu(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=Math.sqrt(r*r+n*n+o*o),a=i>0?Math.atan2(i,s)/i:0;return t[0]=r*a,t[1]=n*a,t[2]=o*a,t[3]=.5*Math.log(r*r+n*n+o*o+s*s),t}function Fb(t,e,r){return Tu(t,e),Su(t,t,r),xu(t,t),t}function Yo(t,e,r,n){var o=e[0],s=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],h,p,d,m,g;return p=o*c+s*l+i*f+a*u,p<0&&(p=-p,c=-c,l=-l,f=-f,u=-u),1-p>me?(h=Math.acos(p),d=Math.sin(h),m=Math.sin((1-n)*h)/d,g=Math.sin(n*h)/d):(m=1-n,g=n),t[0]=m*o+g*c,t[1]=m*s+g*l,t[2]=m*i+g*f,t[3]=m*a+g*u,t}function Pb(t){var e=qt(),r=qt(),n=qt(),o=Math.sqrt(1-e),s=Math.sqrt(e);return t[0]=o*Math.sin(2*Math.PI*r),t[1]=o*Math.cos(2*Math.PI*r),t[2]=s*Math.sin(2*Math.PI*n),t[3]=s*Math.cos(2*Math.PI*n),t}function Nb(t,e){var r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-o*a,t[3]=s*a,t}function Ob(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function yu(t,e){var r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var o=0;e[4]>e[0]&&(o=1),e[8]>e[o*3+o]&&(o=2);var s=(o+1)%3,i=(o+2)%3;n=Math.sqrt(e[o*3+o]-e[s*3+s]-e[i*3+i]+1),t[o]=.5*n,n=.5/n,t[3]=(e[s*3+i]-e[i*3+s])*n,t[s]=(e[s*3+o]+e[o*3+s])*n,t[i]=(e[i*3+o]+e[o*3+i])*n}return t}function Ub(t,e,r,n){var o=.5*Math.PI/180;e*=o,r*=o,n*=o;var s=Math.sin(e),i=Math.cos(e),a=Math.sin(r),c=Math.cos(r),l=Math.sin(n),f=Math.cos(n);return t[0]=s*c*f-i*a*l,t[1]=i*a*f+s*c*l,t[2]=i*c*l-s*a*f,t[3]=i*c*f+s*a*l,t}function Db(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var Vb=pb,Gb=db,Hb=mb,kb=gb,zb=Ab,qb=bu,Su=bb,Mu=Sb,jb=Mb,_u=xb,Jb=_u,Eu=Tb,Wb=Eu,xa=yb,Xb=_b,Kb=Eb,Yb=(function(){var t=Aa(),e=ca(1,0,0),r=ca(0,1,0);return function(n,o,s){var i=ba(o,s);return i<-.999999?(Ko(t,e,o),gu(t)<1e-6&&Ko(t,r,o),mu(t,t),Au(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Ko(t,o,s),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,xa(n,n))}})(),Qb=(function(){var t=la(),e=la();return function(r,n,o,s,i,a){return Yo(t,n,i,a),Yo(e,o,s,a),Yo(r,t,e,2*a*(1-a)),r}})(),Zb=(function(){var t=RA();return function(e,r,n,o){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],xa(e,yu(e,t))}})(),P={};Mn(P,{add:()=>nx,angle:()=>Mx,ceil:()=>ox,clone:()=>$b,copy:()=>tx,create:()=>Cu,cross:()=>mx,dist:()=>Lx,distance:()=>Ru,div:()=>wx,divide:()=>Bu,dot:()=>dx,equals:()=>Ix,exactEquals:()=>Cx,floor:()=>sx,forEach:()=>Nx,fromValues:()=>ex,inverse:()=>hx,len:()=>vx,length:()=>Lu,lerp:()=>gx,max:()=>ax,min:()=>ix,mul:()=>Rx,multiply:()=>vu,negate:()=>ux,normalize:()=>px,random:()=>Ax,rotate:()=>Sx,round:()=>cx,scale:()=>lx,scaleAndAdd:()=>fx,set:()=>rx,sqrDist:()=>Fx,sqrLen:()=>Px,squaredDistance:()=>wu,squaredLength:()=>Fu,str:()=>Ex,sub:()=>Bx,subtract:()=>Iu,transformMat2:()=>bx,transformMat2d:()=>xx,transformMat3:()=>Tx,transformMat4:()=>yx,zero:()=>_x});function Cu(){var t=new se(2);return se!=Float32Array&&(t[0]=0,t[1]=0),t}function $b(t){var e=new se(2);return e[0]=t[0],e[1]=t[1],e}function ex(t,e){var r=new se(2);return r[0]=t,r[1]=e,r}function tx(t,e){return t[0]=e[0],t[1]=e[1],t}function rx(t,e,r){return t[0]=e,t[1]=r,t}function nx(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function Iu(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function vu(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function Bu(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function ox(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function sx(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function ix(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function ax(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function cx(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function lx(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function fx(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t}function Ru(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.hypot(r,n)}function wu(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function Lu(t){var e=t[0],r=t[1];return Math.hypot(e,r)}function Fu(t){var e=t[0],r=t[1];return e*e+r*r}function ux(t,e){return t[0]=-e[0],t[1]=-e[1],t}function hx(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function px(t,e){var r=e[0],n=e[1],o=r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t}function dx(t,e){return t[0]*e[0]+t[1]*e[1]}function mx(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t}function gx(t,e,r,n){var o=e[0],s=e[1];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t}function Ax(t,e){e=e||1;var r=qt()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function bx(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t}function xx(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o+r[4],t[1]=r[1]*n+r[3]*o+r[5],t}function Tx(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[3]*o+r[6],t[1]=r[1]*n+r[4]*o+r[7],t}function yx(t,e,r){var n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}function Sx(t,e,r,n){var o=e[0]-r[0],s=e[1]-r[1],i=Math.sin(n),a=Math.cos(n);return t[0]=o*a-s*i+r[0],t[1]=o*i+s*a+r[1],t}function Mx(t,e){var r=t[0],n=t[1],o=e[0],s=e[1],i=Math.sqrt(r*r+n*n)*Math.sqrt(o*o+s*s),a=i&&(r*o+n*s)/i;return Math.acos(Math.min(Math.max(a,-1),1))}function _x(t){return t[0]=0,t[1]=0,t}function Ex(t){return"vec2("+t[0]+", "+t[1]+")"}function Cx(t,e){return t[0]===e[0]&&t[1]===e[1]}function Ix(t,e){var r=t[0],n=t[1],o=e[0],s=e[1];return Math.abs(r-o)<=me*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-s)<=me*Math.max(1,Math.abs(n),Math.abs(s))}var vx=Lu,Bx=Iu,Rx=vu,wx=Bu,Lx=Ru,Fx=wu,Px=Fu,Nx=(function(){var t=Cu();return function(e,r,n,o,s,i){var a,c;for(r||(r=2),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}})(),ts=(1+Math.sqrt(5))/2,rw=2*Math.PI,Qo=2*Math.PI/5,nt=Math.PI/5,Vf=Math.PI/10,Ox=2*Math.atan(ts),fa=Math.PI-Ox,nw=-.5*Math.PI+Math.acos(-1/Math.sqrt(3-ts)),rs=(Math.sqrt(5)-1)/2,Ux=3-Math.sqrt(5),Dx=Math.sqrt(3-ts),ow=Math.sqrt(3)*Dx/ts,Zo=63710072e-1,sw=4*Math.PI*Zo*Zo;ge.setMatrixArrayType(Float64Array);var Ta=class ua{constructor(e){this.vertices=e,this.isWindingCorrect()||this.vertices.reverse()}getArea(){let e=0,r=this.vertices.length;for(let n=0;n<r;n++){let o=(n+1)%r;e+=(this.vertices[o][0]-this.vertices[n][0])*(this.vertices[o][1]+this.vertices[n][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(let r of this.vertices)P.scale(r,r,e);return this}rotate180(){for(let e of this.vertices)P.negate(e,e);return this}reflectY(){for(let e of this.vertices)e[1]=-e[1];return this.vertices.reverse(),this}translate(e){for(let r of this.vertices)P.add(r,r,e);return this}transform(e){for(let r of this.vertices)P.transformMat2(r,r,e);return this}transform2d(e){for(let r of this.vertices)P.transformMat2d(r,r,e);return this}clone(){return new ua(this.vertices.map(r=>P.clone(r)))}getCenter(){let e=this.vertices.length;return this.vertices.reduce((n,o)=>[n[0]+o[0]/e,n[1]+o[1]/e],[0,0])}containsPoint(e){if(!this.isWindingCorrect())throw new Error("Pentagon is not counter-clockwise");let r=this.vertices.length,n=1;for(let o=0;o<r;o++){let s=this.vertices[o],i=this.vertices[(o+1)%r],a=s[0]-i[0],c=s[1]-i[1],l=e[0]-s[0],f=e[1]-s[1],u=a*f-c*l;if(u<0){let h=Math.sqrt(l*l+f*f);n=Math.min(n,u/h)}}return n}splitEdges(e){if(e<=1)return this;let r=[],n=this.vertices.length;for(let o=0;o<n;o++){let s=this.vertices[o],i=this.vertices[(o+1)%n];r.push(P.clone(s));for(let a=1;a<e;a++){let c=a/e,l=P.create();P.lerp(l,s,i,c),r.push(l)}}return new ua(r)}};ge.setMatrixArrayType(Float64Array);var Pu=[0,0],Nu=[0,1],Jt=[.7885966681787006,1.6149108024237764],Ou=[1.6171013659387945,1.054928690397459],Uu=[Math.cos(Vf),Math.sin(Vf)],Vx=2*P.length(Jt)*Math.cos(nt),Gx=nt-Math.atan2(Jt[1],Jt[0]),Hx=2*rs/Vx;[Pu,Nu,Jt,Ou,Uu].forEach(t=>{P.scale(t,t,Hx),P.rotate(t,t,[0,0],Gx)});var kx=new Ta([Pu,Nu,Jt,Ou,Uu]),Du=Math.atan2(Jt[1],Jt[0])-nt,zx=[0,0],$o=rs/Math.cos(nt),Gf=Du+nt,es=[$o*Math.cos(Gf),$o*Math.sin(Gf)],Hf=Du-nt,Sn=[$o*Math.cos(Hf),$o*Math.sin(Hf)],Vu=new Ta([zx,es,Sn]),Gu=jt.fromValues(es[0],es[1],Sn[0],Sn[1]),iw=jt.invert(jt.create(),Gu),qx=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2559257686421274e-24,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),jx=new Float64Array([.0022392089963541657,28831978048607556e-22,508622073997266e-23,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]),Jx=class{applyCoefficients(t,e){let r=Math.sin(t),n=Math.cos(t),o=2*(n-r)*(n+r),s,i;return s=o*e[5]+e[4],i=o*s+e[3],s=o*i-s+e[2],i=o*s-i+e[1],s=o*i-s+e[0],t+2*r*n*s}forward(t){return this.applyCoefficients(t,qx)}inverse(t){return this.applyCoefficients(t,jx)}};ge.setMatrixArrayType(Float64Array);var Hu=new Jx;function kf(t){return t*(Math.PI/180)}function zf(t){return t*(180/Math.PI)}function qf(t){let e=P.length(t),r=Math.atan2(t[1],t[0]);return[e,r]}function Wx([t,e]){let r=t*Math.cos(e),n=t*Math.sin(e);return[r,n]}function Xx(t,[e,r,n]){let o=[e[0]-n[0],e[1]-n[1]],s=[n[0]-r[0],n[1]-r[1]],i=[t[0]-n[0],t[1]-n[1]],a=s[0]*o[1]-s[1]*o[0],c=(s[0]*i[1]-s[1]*i[0])/a,l=(o[0]*i[1]-o[1]*i[0])/a,f=1-(c+l);return[c,l,f]}function Kx(t,[e,r,n]){return[t[0]*e[0]+t[1]*r[0]+t[2]*n[0],t[0]*e[1]+t[1]*r[1]+t[2]*n[1]]}function ha(t){let e=Math.atan2(t[1],t[0]),r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),n=Math.acos(t[2]/r);return[e,n]}function Ir([t,e]){let r=Math.sin(e),n=r*Math.cos(t),o=r*Math.sin(t),s=Math.cos(e);return[n,o,s]}var ku=93;function Yx([t,e]){let r=kf(t+ku),n=kf(e),o=Hu.forward(n),s=Math.PI/2-o;return[r,s]}function zu([t,e]){let r=zf(t)-ku,n=Math.PI/2-e,o=Hu.inverse(n),s=zf(o);return[r,s]}function Qx(t){let e=t.map(s=>Ir(Yx(s))),r=R.create();for(let s of e)R.add(r,r,s);R.normalize(r,r);let[n,o]=zu(ha(r));return(o>89.99||o<-89.99)&&(n=t[0][0]),n=((n+180)%360+360)%360-180,t.map(s=>{let[i,a]=s;for(;i-n>180;)i=i-360;for(;i-n<-180;)i=i+360;return[i,a]})}ge.setMatrixArrayType(Float64Array);var ns=Math.sqrt(5),os=Math.sqrt(.2),qu=Math.sqrt((1-os)/2),ju=Math.sqrt((1+os)/2),Ho=.5,jf=Math.sqrt((2.5-ns)/10),Jf=Math.sqrt((2.5+ns)/10),Wf=Math.sqrt((1+os)/8),Xf=Math.sqrt((1-os)/8),Kf=Math.sqrt((3-ns)/8),Yf=Math.sqrt((3+ns)/8),Zx=[[0,0],[qu,0],[jf,Ho],[-Wf,Kf],[-Wf,-Kf],[jf,-Ho],[-ju,0],[-Xf,-Yf],[Jf,-Ho],[Jf,Ho],[-Xf,Yf],[0,0]],$x=Zx.map(([t,e])=>[-e,t]),ko=$x.map((t,e)=>e===0?[0,0,0,1]:e===11?[0,-1,0,0]:[...t,0,e<6?ju:qu]);ge.setMatrixArrayType(Float64Array);var Ju=["vu","uw","vw","vw","vw"],Tn=["wu","uw","vw","vu","uw"],oa=["wu","uv","wv","wu","uw"],zo=["vu","uv","wv","wu","uw"],eT=[Ju,zo,oa,Tn,oa,zo,oa,Tn,Tn,Tn,zo,zo],tT=[4,2,3,2,0,4,3,2,2,0,3,0],Qf=[0,1,2,4,3,5,7,8,6,11,10,9],Xe=[];function rT(){qo([0,0],0,ko[0]);for(let t=0;t<5;t++){let e=t*Qo,r=e+nt;qo([e,fa],nt,ko[t+1]),qo([r,Math.PI-fa],nt,ko[(t+3)%5+6])}qo([0,Math.PI],0,ko[11])}var _r=0;function qo(t,e,r){if(_r>11)throw new Error(`Too many origins: ${_r}`);let n=aa.create();aa.conjugate(n,r);let o={id:_r,axis:t,quat:r,inverseQuat:n,angle:e,orientation:eT[_r],firstQuintant:tT[_r]};Xe.push(o),_r++}rT();Xe.sort((t,e)=>Qf.indexOf(t.id)-Qf.indexOf(e.id));Xe.forEach((t,e)=>t.id=e);function nT(t,e){let r=e.orientation,n=r===Ju||r===Tn?-1:1,o=(t-e.firstQuintant+5)%5,s=r[o];return{quintant:(e.firstQuintant+n*o+5)%5,orientation:s}}var oT=class{forward([t,e]){return[Math.tan(e),t]}inverse([t,e]){return[e,Math.atan(t)]}},Er=R.create(),yn=R.create(),Zf=R.create(),$f=R.create();function sa(t,e){R.lerp(Er,t,e,.5),R.normalize(Er,Er),R.cross(Er,t,Er);let r=R.length(Er);if(r<1e-8){let n=R.subtract(R.create(),t,e);return .5*R.length(n)}return r}function sT(t,e,r){return R.cross(yn,e,r),R.dot(t,yn)}function iT(t,e,r,n,o){R.cross(yn,n,o);let s=R.dot(e,yn),i=R.dot(r,yn);return R.scale(Zf,e,i),R.scale($f,r,s),R.sub(t,$f,Zf)}function pa(t,e,r,n){let o=R.angle(e,r);if(o<1e-12)return R.lerp(t,e,r,n);let s=Math.sin((1-n)*o)/Math.sin(o),i=Math.sin(n*o)/Math.sin(o),a=R.scale(R.create(),e,s),c=R.scale(R.create(),r,i);return R.add(t,a,c)}ge.setMatrixArrayType(Float64Array);var jo=R.create(),Jo=R.create(),Wo=R.create(),Cr=R.create(),aT=class{constructor(t){this._area=null,this.vertices=t,Object.freeze(this.vertices)}getBoundary(t=1,e=!0){let r=[],n=this.vertices.length;for(let o=0;o<n*t;o++){let s=o/t;r.push(this.slerp(s))}return e&&r.push(r[0]),r}slerp(t){let e=this.vertices.length,r=t%1,n=Math.floor(t%e),o=(n+1)%e;return pa(R.create(),this.vertices[n],this.vertices[o],r)}getTransformedVertices(t){let e=this.vertices.length,r=Math.floor(t%e),n=(r+1)%e,o=(r+e-1)%e,s=R.clone(this.vertices[r]),i=R.clone(this.vertices[n]),a=R.clone(this.vertices[o]);return R.sub(i,i,s),R.sub(a,a,s),[s,i,a]}containsPoint(t){let e=this.vertices.length,r=1/0;for(let n=0;n<e;n++){let[o,s,i]=this.getTransformedVertices(n),a=R.sub(R.create(),t,o);R.normalize(a,a),R.normalize(s,s),R.normalize(i,i);let c=R.cross(R.create(),s,a),l=R.cross(R.create(),a,i),f=R.dot(o,c),u=R.dot(o,l);r=Math.min(r,f,u)}return r}getTriangleArea(t,e,r){R.lerp(jo,e,r,.5),R.lerp(Jo,r,t,.5),R.lerp(Wo,t,e,.5),R.normalize(jo,jo),R.normalize(Jo,Jo),R.normalize(Wo,Wo);let n=sT(jo,Jo,Wo),o=Math.max(-1,Math.min(1,n));return Math.abs(o)<1e-8?2*o:Math.asin(o)*2}getArea(){return this._area===null&&(this._area=this._getArea()),this._area}_getArea(){if(this.vertices.length<3)return 0;if(this.vertices.length===3)return this._area=this.getTriangleArea(this.vertices[0],this.vertices[1],this.vertices[2]),this._area;R.set(Cr,0,0,0);for(let e of this.vertices)R.add(Cr,Cr,e);R.normalize(Cr,Cr);let t=0;for(let e=0;e<this.vertices.length;e++){let r=this.vertices[e],n=this.vertices[(e+1)%this.vertices.length],o=this.getTriangleArea(Cr,r,n);isNaN(o)||(t+=o)}return this._area=t,this._area}isWindingCorrect(){if(!(this.getArea()>0))debugger}};ge.setMatrixArrayType(Float64Array);var Xo=class extends aT{constructor(t){if(t.length!==3)throw new Error("SphericalTriangleShape requires exactly 3 vertices");super(t)}};ge.setMatrixArrayType(Float64Array);var cT=class{forward(t,e,r){let[n,o,s]=e,i=new Xo([n,o,s]),a=R.subtract(R.create(),t,n);R.normalize(a,a);let c=iT(R.create(),n,a,o,s);R.normalize(c,c);let l=sa(n,t)/sa(n,c),f=i.getArea(),u=l/f,h=[1-l,u*new Xo([n,c,s]).getArea(),u*new Xo([n,o,c]).getArea()];return Kx(h,r)}inverse(t,e,r){let[n,o,s]=r,i=new Xo([n,o,s]),a=Xx(t,e),c=1-1e-14;if(a[0]>c)return n;if(a[1]>c)return o;if(a[2]>c)return s;let l=R.create();R.cross(l,o,s);let f=i.getArea(),u=1-a[0],p=a[2]/u*f,d=Math.sin(p),m=Math.sin(p/2),g=2*m*m,b=R.dot(n,o),T=R.dot(o,s),S=R.dot(s,n),M=R.length(l),C=R.dot(n,l),E=d*C+g*(b*T-S),B=g*M*(1+b),_=2/Math.acos(T)*Math.atan2(B,E),y=pa(R.create(),o,s,_),A=sa(n,y),I=this.safeAcos(u*A)/this.safeAcos(A);return pa([0,0,0],n,y,I)}safeAcos(t){return t<.001?2*t+t*t*t/3:Math.acos(1-2*t*t)}},Fe=-1,Se=1;ge.setMatrixArrayType(Float64Array);var lT=([t,e])=>P.fromValues(t-e,e);ge.setMatrixArrayType(Float64Array);var da=P.fromValues(1,0),ma=P.fromValues(0,1),eu=P.negate(P.create(),da),tu=P.negate(P.create(),ma),ia=P.fromValues(0,0),fT=(t,[e,r])=>{let n=ia,o=ia;switch(e===Se&&r===Se?(n=da,o=ma):e===Fe&&r===Se?(n=tu,o=eu):e===Se&&r===Fe?(n=ma,o=da):e===Fe&&r===Fe&&(n=eu,o=tu),t){case 0:return ia;case 1:return n;case 2:return P.add(P.create(),o,n);case 3:return P.scaleAndAdd(P.create(),o,n,2);default:throw new Error(`Invalid Quaternary value: ${t}`)}},ru=t=>[[Se,Se],[Se,Fe],[Se,Se],[Fe,Se]][t];function Wu(t){return Array.from({length:t.length},(e,r)=>t.indexOf(r))}var Xu=[0,1,3,4,5,6,7,2],Ku=[0,1,2,7,3,4,5,6],aw=Wu(Xu),cw=Wu(Ku),uT=(t,e,r,n,o)=>{if(e<=0)return;let s=t[e]||0,i=t[e-1],a=r[0]+r[1],c=!0,l=!0;if(n!==(a===0)?(c=s===1||s===2,l=s===1):(c=s<2,l=s===0),!c)return;let f=l?i:i+4,u=o[f];t[e-1]=u%4,t[e]=(s+4+Math.floor(u/4)-Math.floor(f/4))%4};ge.setMatrixArrayType(Float64Array);var nu=P.fromValues(-1,1),Yu=!0,hT=(t,e,r,n=Yu)=>{let o=BigInt(t),s=r==="vu"||r==="wu"||r==="vw",i=r==="wv"||r==="vw",a=r==="wu"||r==="uw";s&&(o=(1n<<BigInt(2*e))-o-1n);let c=pT(o,e,i,a,n);if(a){let{offset:[l,f],flips:[u,h]}=c;c.offset=[f,l],u===Fe&&P.add(c.offset,c.offset,nu),h===Fe&&P.subtract(c.offset,c.offset,nu)}if(i){let{offset:[l,f],flips:u}=c,h=(1<<e)-(l+f);u[0]=-u[0],c.offset[1]=h,c.flips=u}return c},pT=(t,e,r,n,o=Yu)=>{let s=P.create(),i=[Se,Se],a=BigInt(t),c=[];for(;a>0n||c.length<e;)c.push(Number(a%4n)),a=a>>2n;let l=n?Ku:Xu;for(let u=c.length-1;u>=0;u--)o&&uT(c,u,i,r,l),P.multiply(i,i,ru(c[u]));i[0]=Se,i[1]=Se;for(let u=c.length-1;u>=0;u--){P.scale(s,s,2);let h=fT(c[u],i);P.add(s,s,h),P.multiply(i,i,ru(c[u]))}return{q:c[0]||0,offset:lT(s),flips:i}};var It=.1,lw=[[It*Math.cos(45*Math.PI/180),It*Math.sin(45*Math.PI/180)],[It*Math.cos(113*Math.PI/180),It*Math.sin(113*Math.PI/180)],[It*Math.cos(293*Math.PI/180),It*Math.sin(293*Math.PI/180)],[It*Math.cos(225*Math.PI/180),It*Math.sin(225*Math.PI/180)]];ge.setMatrixArrayType(Float64Array);var dT=!1,mT=P.clone(Sn),gT=P.negate(P.create(),Sn),ya=[0,1,2,3,4].map(t=>{let e=jt.create();return jt.fromRotation(e,Qo*t),e}),ou=P.create();function AT(t,e,r){let n=(dT?Vu:kx).clone();P.transformMat2(ou,r.offset,Gu),r.flips[0]===Se&&r.flips[1]===Fe&&n.rotate180();let{q:o}=r,s=r.flips[0]+r.flips[1];return((s===-2||s===2)&&o>1||s===0&&(o===0||o===3))&&n.reflectY(),r.flips[0]===Fe&&r.flips[1]===Fe?n.rotate180():r.flips[0]===Fe?n.translate(gT):r.flips[1]===Fe&&n.translate(mT),n.translate(ou),n.scale(1/2**t),n.transform(ya[e]),n}function Qu(t){let e=Vu.clone();return e.transform(ya[t]),e}function bT(){let t=[];for(let e of ya)t.push(P.transformMat2(P.create(),es,e));return t.reverse(),new Ta(t)}ge.setMatrixArrayType(Float64Array);var xT=class{constructor(){if(this.vertices=[],this.invocations=0,this.addFaceCenters(),this.addVertices(),this.addMidpoints(),this.vertices.length!==62)throw new Error("Failed to construct CRS: vertices length is not 62");Object.freeze(this.vertices)}getVertex(t){this.invocations++,this.invocations===1e4&&console.warn("Too many CRS invocations, results should be cached");for(let e of this.vertices)if(R.distance(t,e)<1e-5)return e;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){Xe.forEach(t=>this.add(Ir(t.axis)))}addVertices(){let t=Math.atan(Ux);for(let e of Xe)for(let r=0;r<5;r++){let n=(2*r+1)*Math.PI/5,o=Ir([n+e.angle,t]);R.transformQuat(o,o,e.quat),this.add(o)}}addMidpoints(){let t=Math.atan(rs);for(let e of Xe)for(let r=0;r<5;r++){let n=2*r*Math.PI/5,o=Ir([n+e.angle,t]);R.transformQuat(o,o,e.quat),this.add(o)}}add(t){let e=R.normalize(R.create(),t);return this.vertices.find(n=>R.distance(e,n)<1e-5)?!1:(this.vertices.push(e),!0)}};ge.setMatrixArrayType(Float64Array);var TT=new xT,yT=class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.polyhedral=new cT,this.gnomonic=new oT}forward(t,e){let r=Xe[e],n=Ir(t),o=R.create();R.transformQuat(o,n,r.inverseQuat);let s=ha(o),i=this.gnomonic.forward(s);i[1]=i[1]-r.angle;let a=this.getFaceTriangleIndex(i),c=this.shouldReflect(i),l=this.getFaceTriangle(a,c,!1),f=this.getSphericalTriangle(a,e,c);return this.polyhedral.forward(n,f,l)}inverse(t,e){let r=qf(t),n=this.getFaceTriangleIndex(r),o=this.shouldReflect(r),s=this.getFaceTriangle(n,o,!1),i=this.getSphericalTriangle(n,e,o),a=this.polyhedral.inverse(t,s,i);return ha(a)}shouldReflect(t){let[e,r]=t;return Wx([e,this.normalizeGamma(r)])[0]>rs}getFaceTriangleIndex([t,e]){return(Math.floor(e/nt)+10)%10}getFaceTriangle(t,e=!1,r=!1){let n=t;return e&&(n+=r?20:10),this.faceTriangles[n]?this.faceTriangles[n]:(this.faceTriangles[n]=e?this._getReflectedFaceTriangle(t,r):this._getFaceTriangle(t),Object.freeze(this.faceTriangles[n]),this.faceTriangles[n])}_getFaceTriangle(t){let e=Math.floor((t+1)/2)%5,[r,n,o]=Qu(e).getVertices(),s=P.create();return P.lerp(s,n,o,.5),t%2===0?[r,s,n]:[r,o,s]}_getReflectedFaceTriangle(t,e=!1){let[r,n,o]=this._getFaceTriangle(t).map(a=>P.clone(a)),s=t%2===0;P.negate(r,r);let i=s?n:o;return P.scaleAndAdd(r,r,i,e?1+1/Math.cos(fa):2),[r,o,n]}getSphericalTriangle(t,e,r=!1){let n=10*e+t;return r&&(n+=120),this.sphericalTriangles[n]?this.sphericalTriangles[n]:(this.sphericalTriangles[n]=this._getSphericalTriangle(t,e,r),Object.freeze(this.sphericalTriangles[n]),this.sphericalTriangles[n])}_getSphericalTriangle(t,e,r=!1){let n=Xe[e];return this.getFaceTriangle(t,r,!0).map(i=>{let[a,c]=qf(i),l=[a,c+n.angle],f=Ir(this.gnomonic.inverse(l));return R.transformQuat(f,f,n.quat),TT.getVertex(f)})}normalizeGamma(t){let e=t/Qo,r=Math.round(e);return(e-r)*Qo}},vr=2,ga=30,su=58n,ST=0n;function MT(t){if(t===0n)return-1;if(t&1n||(t&0b111n)===0b100n||(t&0b11111n)===0b10000n)return ga;let e=ga-1,r=t>>1n;if(r===0n)return-1;let n=Number(r&0xFFFFFFFFn),o;for(n===0?(r>>=32n,e-=16,o=Number(r)):o=n,(o&65535)===0&&(o>>=16,e-=8),e>=6&&(o&255)===0&&(o>>=8,e-=4),e>=4&&(o&15)===0&&(o>>=4,e-=2);e>-1&&(o&1)===0;)e-=1,o=o>>(e<vr?1:2);return e}function _T(t){let e=MT(t);if(e===-1)return{origin:Xe[0],segment:0,S:0n,resolution:e};let r=su,n=0;if(e===ga){let u=t&1n?1n:t&0b100n?3n:5n;r=su+u,n=u===1n?0:u===3n?32:40}let o=Number(t>>r)+n,s,i;if(e===0)s=Xe[o],i=0;else{let u=Math.floor(o/5);s=Xe[u],i=(o+s.firstQuintant)%5}if(!s)throw new Error(`Could not parse origin: ${o}`);if(e<vr)return{origin:s,segment:i,S:0n,resolution:e};let a=e-vr+1,c=BigInt(2*a),l=(1n<<r)-1n,f=(t&l)>>r-c;return{origin:s,segment:i,S:f,resolution:e}}ge.setMatrixArrayType(Float64Array);var fw=jt.create(),ET=new yT;function CT({S:t,segment:e,origin:r,resolution:n}){let{quintant:o,orientation:s}=nT(e,r);if(n===vr-1)return Qu(o);if(n===vr-2)return bT();let i=n-vr+1,a=hT(t,i,s);return AT(i,o,a)}function Zu(t,{closedRing:e=!0,segments:r="auto"}={closedRing:!0,segments:"auto"}){if(t===ST)return[];let{S:n,segment:o,origin:s,resolution:i}=_T(t);r==="auto"&&(r=Math.max(1,Math.pow(2,6-i)));let u=CT({S:n,segment:o,origin:s,resolution:i}).splitEdges(r).getVertices().map(p=>ET.inverse(p,s.id)).map(p=>zu(p)),h=Qx(u);return e&&h.push(h[0]),h.reverse(),h}function $u(t){return BigInt(`0x${t}`)}var eh=2;var IT=eh*Zo/Math.sqrt(15),th=new Array(31);th[0]=eh*Zo/Math.sqrt(3);for(let t=1;t<=30;t++)th[t]=IT/(1<<t-1);ge.setMatrixArrayType(Float64Array);var Rn=U(ss(),1);var vT=1/Math.PI*180,BT=1/180*Math.PI,RT={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...RT}};var Z=globalThis.mathgl.config;function Sa(t,{precision:e=Z.precision}={}){return t=wT(t),`${parseFloat(t.toPrecision(e))}`}function Pe(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ma(t){return nh(t)}function _a(t){return Ne(t)}function nh(t,e){return Ea(t,r=>r*BT,e)}function Ne(t,e){return Ea(t,r=>r*vT,e)}function is(t,e,r){return Ea(t,n=>Math.max(e,Math.min(r,n)))}function vt(t,e,r){return Pe(t)?t.map((n,o)=>vt(n,e[o],r)):r*e+(1-r)*t}function Me(t,e,r){let n=Z.EPSILON;r&&(Z.EPSILON=r);try{if(t===e)return!0;if(Pe(t)&&Pe(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Me(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=Z.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{Z.EPSILON=n}}function wT(t){return Math.round(t/Z.EPSILON)*Z.EPSILON}function LT(t){return t.clone?t.clone():new Array(t.length)}function Ea(t,e,r){if(Pe(t)){let n=t;r=r||LT(n);for(let o=0;o<r.length&&o<n.length;++o){let s=typeof t=="number"?t:t[o];r[o]=e(s,o,r)}return r}return e(t)}var Bt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Pe(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Z)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Sa(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Me(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let s=e[o],i=typeof r=="number"?r:r[o];this[o]=s+n*(i-s)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(Z.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function FT(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function G(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Rt(t,e,r=""){if(Z.debug&&!FT(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function he(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var wt=class extends Bt{get x(){return this[0]}set x(e){this[0]=G(e)}get y(){return this[1]}set y(e){this[1]=G(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let n=0;n<this.ELEMENTS;++n){let o=this[n]-e[n];r+=o*o}return G(r)}dot(e){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*e[n];return G(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return he(e>=0&&e<this.ELEMENTS,"index is out of range"),G(this[e])}setComponent(e,r){return he(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var re=typeof Float32Array<"u"?Float32Array:Array,_n=Math.random;function Br(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var Rw=Math.PI/180;function PT(){let t=new re(2);return re!=Float32Array&&(t[0]=0,t[1]=0),t}function oh(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t}function sh(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o+r[4],t[1]=r[1]*n+r[3]*o+r[5],t}function as(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[3]*o+r[6],t[1]=r[1]*n+r[4]*o+r[7],t}function cs(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var ww=(function(){let t=PT();return function(e,r,n,o,s,i){let a,c;for(r||(r=2),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}})();function ls(t,e,r){let n=e[0],o=e[1],s=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/s,t[1]=(r[1]*n+r[5]*o)/s,t}function fs(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s||1;return t[0]=(r[0]*n+r[4]*o+r[8]*s)/i,t[1]=(r[1]*n+r[5]*o+r[9]*s)/i,t[2]=(r[2]*n+r[6]*o+r[10]*s)/i,t}function ih(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t[2]=e[2],t}function ah(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t[2]=e[2],t[3]=e[3],t}function us(t,e,r){let n=e[0],o=e[1],s=e[2];return t[0]=r[0]*n+r[3]*o+r[6]*s,t[1]=r[1]*n+r[4]*o+r[7]*s,t[2]=r[2]*n+r[5]*o+r[8]*s,t[3]=e[3],t}var Wt=class extends wt{constructor(e=0,r=0){super(2),Pe(e)&&arguments.length===1?this.copy(e):(Z.debug&&(G(e),G(r)),this[0]=e,this[1]=r)}set(e,r){return this[0]=e,this[1]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return Z.debug&&(G(e.x),G(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return cs(this,this,e),this.check()}transformAsVector(e){return ls(this,this,e),this.check()}transformByMatrix3(e){return as(this,this,e),this.check()}transformByMatrix2x3(e){return sh(this,this,e),this.check()}transformByMatrix2(e){return oh(this,this,e),this.check()}};var wr={};Ae(wr,{add:()=>VT,angle:()=>Ra,bezier:()=>ZT,ceil:()=>GT,clone:()=>OT,copy:()=>UT,create:()=>hs,cross:()=>Xt,dist:()=>ay,distance:()=>hh,div:()=>iy,divide:()=>uh,dot:()=>En,equals:()=>ny,exactEquals:()=>ry,floor:()=>HT,forEach:()=>fy,fromValues:()=>ps,hermite:()=>QT,inverse:()=>XT,len:()=>wa,length:()=>ch,lerp:()=>KT,max:()=>zT,min:()=>kT,mul:()=>sy,multiply:()=>fh,negate:()=>WT,normalize:()=>Ca,random:()=>$T,rotateX:()=>Ia,rotateY:()=>va,rotateZ:()=>Ba,round:()=>qT,scale:()=>jT,scaleAndAdd:()=>JT,set:()=>DT,slerp:()=>YT,sqrDist:()=>cy,sqrLen:()=>ly,squaredDistance:()=>ph,squaredLength:()=>dh,str:()=>ty,sub:()=>oy,subtract:()=>lh,transformMat3:()=>Cn,transformMat4:()=>Kt,transformQuat:()=>In,zero:()=>ey});function hs(){let t=new re(3);return re!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function OT(t){let e=new re(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ch(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function ps(t,e,r){let n=new re(3);return n[0]=t,n[1]=e,n[2]=r,n}function UT(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function DT(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function VT(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function lh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function fh(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function uh(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function GT(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function HT(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function kT(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function zT(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function qT(t,e){return t[0]=Br(e[0]),t[1]=Br(e[1]),t[2]=Br(e[2]),t}function jT(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function JT(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function hh(t,e){let r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(r*r+n*n+o*o)}function ph(t,e){let r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return r*r+n*n+o*o}function dh(t){let e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function WT(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function XT(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Ca(t,e){let r=e[0],n=e[1],o=e[2],s=r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function En(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Xt(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2];return t[0]=o*c-s*a,t[1]=s*i-n*c,t[2]=n*a-o*i,t}function KT(t,e,r,n){let o=e[0],s=e[1],i=e[2];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t}function YT(t,e,r,n){let o=Math.acos(Math.min(Math.max(En(e,r),-1),1)),s=Math.sin(o),i=Math.sin((1-n)*o)/s,a=Math.sin(n*o)/s;return t[0]=i*e[0]+a*r[0],t[1]=i*e[1]+a*r[1],t[2]=i*e[2]+a*r[2],t}function QT(t,e,r,n,o,s){let i=s*s,a=i*(2*s-3)+1,c=i*(s-2)+s,l=i*(s-1),f=i*(3-2*s);return t[0]=e[0]*a+r[0]*c+n[0]*l+o[0]*f,t[1]=e[1]*a+r[1]*c+n[1]*l+o[1]*f,t[2]=e[2]*a+r[2]*c+n[2]*l+o[2]*f,t}function ZT(t,e,r,n,o,s){let i=1-s,a=i*i,c=s*s,l=a*i,f=3*s*a,u=3*c*i,h=c*s;return t[0]=e[0]*l+r[0]*f+n[0]*u+o[0]*h,t[1]=e[1]*l+r[1]*f+n[1]*u+o[1]*h,t[2]=e[2]*l+r[2]*f+n[2]*u+o[2]*h,t}function $T(t,e){e=e===void 0?1:e;let r=_n()*2*Math.PI,n=_n()*2-1,o=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=n*e,t}function Kt(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*o+r[8]*s+r[12])/i,t[1]=(r[1]*n+r[5]*o+r[9]*s+r[13])/i,t[2]=(r[2]*n+r[6]*o+r[10]*s+r[14])/i,t}function Cn(t,e,r){let n=e[0],o=e[1],s=e[2];return t[0]=n*r[0]+o*r[3]+s*r[6],t[1]=n*r[1]+o*r[4]+s*r[7],t[2]=n*r[2]+o*r[5]+s*r[8],t}function In(t,e,r){let n=r[0],o=r[1],s=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=o*l-s*c,u=s*a-n*l,h=n*c-o*a,p=o*h-s*u,d=s*f-n*h,m=n*u-o*f,g=i*2;return f*=g,u*=g,h*=g,p*=2,d*=2,m*=2,t[0]=a+f+p,t[1]=c+u+d,t[2]=l+h+m,t}function Ia(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),s[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function va(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),s[1]=o[1],s[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Ba(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),s[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Ra(t,e){let r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2],c=Math.sqrt((r*r+n*n+o*o)*(s*s+i*i+a*a)),l=c&&En(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function ey(t){return t[0]=0,t[1]=0,t[2]=0,t}function ty(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function ry(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function ny(t,e){let r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))}var oy=lh,sy=fh,iy=uh,ay=hh,cy=ph,wa=ch,ly=dh,fy=(function(){let t=hs();return function(e,r,n,o,s,i){let a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}})();var La=[0,0,0],ds,x=class t extends wt{static get ZERO(){return ds||(ds=new t(0,0,0),Object.freeze(ds)),ds}constructor(e=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Pe(e)?this.copy(e):(Z.debug&&(G(e),G(r),G(n)),this[0]=e,this[1]=r,this[2]=n)}set(e,r,n){return this[0]=e,this[1]=r,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Z.debug&&(G(e.x),G(e.y),G(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=G(e)}angle(e){return Ra(this,e)}cross(e){return Xt(this,this,e),this.check()}rotateX({radians:e,origin:r=La}){return Ia(this,this,r,e),this.check()}rotateY({radians:e,origin:r=La}){return va(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=La}){return Ba(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Kt(this,this,e),this.check()}transformAsVector(e){return fs(this,this,e),this.check()}transformByMatrix3(e){return Cn(this,this,e),this.check()}transformByMatrix2(e){return ih(this,this,e),this.check()}transformByQuaternion(e){return In(this,this,e),this.check()}};var ms,gs=class t extends wt{static get ZERO(){return ms||(ms=new t(0,0,0,0),Object.freeze(ms)),ms}constructor(e=0,r=0,n=0,o=0){super(-0,-0,-0,-0),Pe(e)&&arguments.length===1?this.copy(e):(Z.debug&&(G(e),G(r),G(n),G(o)),this[0]=e,this[1]=r,this[2]=n,this[3]=o)}set(e,r,n,o){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return Z.debug&&(G(e.x),G(e.y),G(e.z),G(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=G(e)}get w(){return this[3]}set w(e){this[3]=G(e)}transform(e){return Kt(this,this,e),this.check()}transformByMatrix3(e){return us(this,this,e),this.check()}transformByMatrix2(e){return ah(this,this,e),this.check()}transformByQuaternion(e){return In(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};var Lr=class extends Bt{toString(){let e="[";if(Z.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=G(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function mh(){let t=new re(9);return re!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function gh(t,e){if(t===e){let r=e[1],n=e[2],o=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=o}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function Ah(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=f*i-a*l,h=-f*s+a*c,p=l*s-i*c,d=r*u+n*h+o*p;return d?(d=1/d,t[0]=u*d,t[1]=(-f*n+o*l)*d,t[2]=(a*n-o*i)*d,t[3]=h*d,t[4]=(f*r-o*c)*d,t[5]=(-a*r+o*s)*d,t[6]=p*d,t[7]=(-l*r+n*c)*d,t[8]=(i*r-n*s)*d,t):null}function bh(t){let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],c=t[7],l=t[8];return e*(l*s-i*c)+r*(-l*o+i*a)+n*(c*o-s*a)}function Fa(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=r[0],p=r[1],d=r[2],m=r[3],g=r[4],b=r[5],T=r[6],S=r[7],M=r[8];return t[0]=h*n+p*i+d*l,t[1]=h*o+p*a+d*f,t[2]=h*s+p*c+d*u,t[3]=m*n+g*i+b*l,t[4]=m*o+g*a+b*f,t[5]=m*s+g*c+b*u,t[6]=T*n+S*i+M*l,t[7]=T*o+S*a+M*f,t[8]=T*s+S*c+M*u,t}function xh(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=r[0],p=r[1];return t[0]=n,t[1]=o,t[2]=s,t[3]=i,t[4]=a,t[5]=c,t[6]=h*n+p*i+l,t[7]=h*o+p*a+f,t[8]=h*s+p*c+u,t}function Th(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=Math.sin(r),p=Math.cos(r);return t[0]=p*n+h*i,t[1]=p*o+h*a,t[2]=p*s+h*c,t[3]=p*i-h*n,t[4]=p*a-h*o,t[5]=p*c-h*s,t[6]=l,t[7]=f,t[8]=u,t}function Pa(t,e,r){let n=r[0],o=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=o*e[3],t[4]=o*e[4],t[5]=o*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function yh(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r+r,a=n+n,c=o+o,l=r*i,f=n*i,u=n*a,h=o*i,p=o*a,d=o*c,m=s*i,g=s*a,b=s*c;return t[0]=1-u-d,t[3]=f-b,t[6]=h+g,t[1]=f+b,t[4]=1-l-d,t[7]=p-m,t[2]=h-g,t[5]=p+m,t[8]=1-l-u,t}var Na;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(Na||(Na={}));var uy=Object.freeze([1,0,0,0,1,0,0,0,1]),z=class extends Lr{static get IDENTITY(){return py()}static get ZERO(){return hy()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Na}constructor(e,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):r.length>0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(uy)}fromObject(e){return this.check()}fromQuaternion(e){return yh(this,e),this.check()}set(e,r,n,o,s,i,a,c,l){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=s,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,n,o,s,i,a,c,l){return this[0]=e,this[1]=o,this[2]=a,this[3]=r,this[4]=s,this[5]=c,this[6]=n,this[7]=i,this[8]=l,this.check()}determinant(){return bh(this)}transpose(){return gh(this,this),this.check()}invert(){return Ah(this,this),this.check()}multiplyLeft(e){return Fa(this,e,this),this.check()}multiplyRight(e){return Fa(this,this,e),this.check()}rotate(e){return Th(this,this,e),this.check()}scale(e){return Array.isArray(e)?Pa(this,this,e):Pa(this,this,[e,e]),this.check()}translate(e){return xh(this,this,e),this.check()}transform(e,r){let n;switch(e.length){case 2:n=as(r||[-0,-0],e,this);break;case 3:n=Cn(r||[-0,-0,-0],e,this);break;case 4:n=us(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Rt(n,e.length),n}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},As,bs=null;function hy(){return As||(As=new z([0,0,0,0,0,0,0,0,0]),Object.freeze(As)),As}function py(){return bs||(bs=new z,Object.freeze(bs)),bs}var xs={};Ae(xs,{add:()=>Dy,adjoint:()=>xy,clone:()=>my,copy:()=>gy,create:()=>dy,decompose:()=>By,determinant:()=>Da,equals:()=>ky,exactEquals:()=>Hy,frob:()=>Uy,fromQuat:()=>ja,fromQuat2:()=>Cy,fromRotation:()=>Sy,fromRotationTranslation:()=>_h,fromRotationTranslationScale:()=>Ry,fromRotationTranslationScaleOrigin:()=>wy,fromScaling:()=>yy,fromTranslation:()=>Ty,fromValues:()=>Ay,fromXRotation:()=>My,fromYRotation:()=>_y,fromZRotation:()=>Ey,frustum:()=>Ja,getRotation:()=>vy,getScaling:()=>Eh,getTranslation:()=>Iy,identity:()=>Mh,invert:()=>Ua,lookAt:()=>Ka,mul:()=>zy,multiply:()=>vn,multiplyScalar:()=>Vy,multiplyScalarAndAdd:()=>Gy,ortho:()=>Xa,orthoNO:()=>Ih,orthoZO:()=>Py,perspective:()=>Wa,perspectiveFromFieldOfView:()=>Fy,perspectiveNO:()=>Ch,perspectiveZO:()=>Ly,rotate:()=>Ha,rotateX:()=>ka,rotateY:()=>za,rotateZ:()=>qa,scale:()=>Ga,set:()=>by,str:()=>Oy,sub:()=>qy,subtract:()=>vh,targetTo:()=>Ny,translate:()=>Va,transpose:()=>Oa});function dy(){let t=new re(16);return re!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function my(t){let e=new re(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function gy(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ay(t,e,r,n,o,s,i,a,c,l,f,u,h,p,d,m){let g=new re(16);return g[0]=t,g[1]=e,g[2]=r,g[3]=n,g[4]=o,g[5]=s,g[6]=i,g[7]=a,g[8]=c,g[9]=l,g[10]=f,g[11]=u,g[12]=h,g[13]=p,g[14]=d,g[15]=m,g}function by(t,e,r,n,o,s,i,a,c,l,f,u,h,p,d,m,g){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t[4]=s,t[5]=i,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=u,t[11]=h,t[12]=p,t[13]=d,t[14]=m,t[15]=g,t}function Mh(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Oa(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],s=e[6],i=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=s,t[11]=e[14],t[12]=o,t[13]=i,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ua(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],p=e[11],d=e[12],m=e[13],g=e[14],b=e[15],T=r*a-n*i,S=r*c-o*i,M=r*l-s*i,C=n*c-o*a,E=n*l-s*a,B=o*l-s*c,_=f*m-u*d,y=f*g-h*d,A=f*b-p*d,I=u*g-h*m,L=u*b-p*m,F=h*b-p*g,w=T*F-S*L+M*I+C*A-E*y+B*_;return w?(w=1/w,t[0]=(a*F-c*L+l*I)*w,t[1]=(o*L-n*F-s*I)*w,t[2]=(m*B-g*E+b*C)*w,t[3]=(h*E-u*B-p*C)*w,t[4]=(c*A-i*F-l*y)*w,t[5]=(r*F-o*A+s*y)*w,t[6]=(g*M-d*B-b*S)*w,t[7]=(f*B-h*M+p*S)*w,t[8]=(i*L-a*A+l*_)*w,t[9]=(n*A-r*L-s*_)*w,t[10]=(d*E-m*M+b*T)*w,t[11]=(u*M-f*E-p*T)*w,t[12]=(a*y-i*I-c*_)*w,t[13]=(r*I-n*y+o*_)*w,t[14]=(m*S-d*C-g*T)*w,t[15]=(f*C-u*S+h*T)*w,t):null}function xy(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],p=e[11],d=e[12],m=e[13],g=e[14],b=e[15],T=r*a-n*i,S=r*c-o*i,M=r*l-s*i,C=n*c-o*a,E=n*l-s*a,B=o*l-s*c,_=f*m-u*d,y=f*g-h*d,A=f*b-p*d,I=u*g-h*m,L=u*b-p*m,F=h*b-p*g;return t[0]=a*F-c*L+l*I,t[1]=o*L-n*F-s*I,t[2]=m*B-g*E+b*C,t[3]=h*E-u*B-p*C,t[4]=c*A-i*F-l*y,t[5]=r*F-o*A+s*y,t[6]=g*M-d*B-b*S,t[7]=f*B-h*M+p*S,t[8]=i*L-a*A+l*_,t[9]=n*A-r*L-s*_,t[10]=d*E-m*M+b*T,t[11]=u*M-f*E-p*T,t[12]=a*y-i*I-c*_,t[13]=r*I-n*y+o*_,t[14]=m*S-d*C-g*T,t[15]=f*C-u*S+h*T,t}function Da(t){let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],c=t[7],l=t[8],f=t[9],u=t[10],h=t[11],p=t[12],d=t[13],m=t[14],g=t[15],b=e*i-r*s,T=e*a-n*s,S=r*a-n*i,M=l*d-f*p,C=l*m-u*p,E=f*m-u*d,B=e*E-r*C+n*M,_=s*E-i*C+a*M,y=l*S-f*T+u*b,A=p*S-d*T+m*b;return c*B-o*_+g*y-h*A}function vn(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],h=e[9],p=e[10],d=e[11],m=e[12],g=e[13],b=e[14],T=e[15],S=r[0],M=r[1],C=r[2],E=r[3];return t[0]=S*n+M*a+C*u+E*m,t[1]=S*o+M*c+C*h+E*g,t[2]=S*s+M*l+C*p+E*b,t[3]=S*i+M*f+C*d+E*T,S=r[4],M=r[5],C=r[6],E=r[7],t[4]=S*n+M*a+C*u+E*m,t[5]=S*o+M*c+C*h+E*g,t[6]=S*s+M*l+C*p+E*b,t[7]=S*i+M*f+C*d+E*T,S=r[8],M=r[9],C=r[10],E=r[11],t[8]=S*n+M*a+C*u+E*m,t[9]=S*o+M*c+C*h+E*g,t[10]=S*s+M*l+C*p+E*b,t[11]=S*i+M*f+C*d+E*T,S=r[12],M=r[13],C=r[14],E=r[15],t[12]=S*n+M*a+C*u+E*m,t[13]=S*o+M*c+C*h+E*g,t[14]=S*s+M*l+C*p+E*b,t[15]=S*i+M*f+C*d+E*T,t}function Va(t,e,r){let n=r[0],o=r[1],s=r[2],i,a,c,l,f,u,h,p,d,m,g,b;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*s+e[12],t[13]=e[1]*n+e[5]*o+e[9]*s+e[13],t[14]=e[2]*n+e[6]*o+e[10]*s+e[14],t[15]=e[3]*n+e[7]*o+e[11]*s+e[15]):(i=e[0],a=e[1],c=e[2],l=e[3],f=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],g=e[10],b=e[11],t[0]=i,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=u,t[6]=h,t[7]=p,t[8]=d,t[9]=m,t[10]=g,t[11]=b,t[12]=i*n+f*o+d*s+e[12],t[13]=a*n+u*o+m*s+e[13],t[14]=c*n+h*o+g*s+e[14],t[15]=l*n+p*o+b*s+e[15]),t}function Ga(t,e,r){let n=r[0],o=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ha(t,e,r,n){let o=n[0],s=n[1],i=n[2],a=Math.sqrt(o*o+s*s+i*i),c,l,f,u,h,p,d,m,g,b,T,S,M,C,E,B,_,y,A,I,L,F,w,D;return a<1e-6?null:(a=1/a,o*=a,s*=a,i*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,u=e[0],h=e[1],p=e[2],d=e[3],m=e[4],g=e[5],b=e[6],T=e[7],S=e[8],M=e[9],C=e[10],E=e[11],B=o*o*f+c,_=s*o*f+i*l,y=i*o*f-s*l,A=o*s*f-i*l,I=s*s*f+c,L=i*s*f+o*l,F=o*i*f+s*l,w=s*i*f-o*l,D=i*i*f+c,t[0]=u*B+m*_+S*y,t[1]=h*B+g*_+M*y,t[2]=p*B+b*_+C*y,t[3]=d*B+T*_+E*y,t[4]=u*A+m*I+S*L,t[5]=h*A+g*I+M*L,t[6]=p*A+b*I+C*L,t[7]=d*A+T*I+E*L,t[8]=u*F+m*w+S*D,t[9]=h*F+g*w+M*D,t[10]=p*F+b*w+C*D,t[11]=d*F+T*w+E*D,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function ka(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[4],i=e[5],a=e[6],c=e[7],l=e[8],f=e[9],u=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*o+l*n,t[5]=i*o+f*n,t[6]=a*o+u*n,t[7]=c*o+h*n,t[8]=l*o-s*n,t[9]=f*o-i*n,t[10]=u*o-a*n,t[11]=h*o-c*n,t}function za(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[0],i=e[1],a=e[2],c=e[3],l=e[8],f=e[9],u=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o-l*n,t[1]=i*o-f*n,t[2]=a*o-u*n,t[3]=c*o-h*n,t[8]=s*n+l*o,t[9]=i*n+f*o,t[10]=a*n+u*o,t[11]=c*n+h*o,t}function qa(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[0],i=e[1],a=e[2],c=e[3],l=e[4],f=e[5],u=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o+l*n,t[1]=i*o+f*n,t[2]=a*o+u*n,t[3]=c*o+h*n,t[4]=l*o-s*n,t[5]=f*o-i*n,t[6]=u*o-a*n,t[7]=h*o-c*n,t}function Ty(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function yy(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Sy(t,e,r){let n=r[0],o=r[1],s=r[2],i=Math.sqrt(n*n+o*o+s*s),a,c,l;return i<1e-6?null:(i=1/i,n*=i,o*=i,s*=i,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=n*n*l+a,t[1]=o*n*l+s*c,t[2]=s*n*l-o*c,t[3]=0,t[4]=n*o*l-s*c,t[5]=o*o*l+a,t[6]=s*o*l+n*c,t[7]=0,t[8]=n*s*l+o*c,t[9]=o*s*l-n*c,t[10]=s*s*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function My(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function _y(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ey(t,e){let r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function _h(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=n+n,c=o+o,l=s+s,f=n*a,u=n*c,h=n*l,p=o*c,d=o*l,m=s*l,g=i*a,b=i*c,T=i*l;return t[0]=1-(p+m),t[1]=u+T,t[2]=h-b,t[3]=0,t[4]=u-T,t[5]=1-(f+m),t[6]=d+g,t[7]=0,t[8]=h+b,t[9]=d-g,t[10]=1-(f+p),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Cy(t,e){let r=new re(3),n=-e[0],o=-e[1],s=-e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=n*n+o*o+s*s+i*i;return u>0?(r[0]=(a*i+f*n+c*s-l*o)*2/u,r[1]=(c*i+f*o+l*n-a*s)*2/u,r[2]=(l*i+f*s+a*o-c*n)*2/u):(r[0]=(a*i+f*n+c*s-l*o)*2,r[1]=(c*i+f*o+l*n-a*s)*2,r[2]=(l*i+f*s+a*o-c*n)*2),_h(t,e,r),t}function Iy(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Eh(t,e){let r=e[0],n=e[1],o=e[2],s=e[4],i=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+n*n+o*o),t[1]=Math.sqrt(s*s+i*i+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function vy(t,e){let r=new re(3);Eh(r,e);let n=1/r[0],o=1/r[1],s=1/r[2],i=e[0]*n,a=e[1]*o,c=e[2]*s,l=e[4]*n,f=e[5]*o,u=e[6]*s,h=e[8]*n,p=e[9]*o,d=e[10]*s,m=i+f+d,g=0;return m>0?(g=Math.sqrt(m+1)*2,t[3]=.25*g,t[0]=(u-p)/g,t[1]=(h-c)/g,t[2]=(a-l)/g):i>f&&i>d?(g=Math.sqrt(1+i-f-d)*2,t[3]=(u-p)/g,t[0]=.25*g,t[1]=(a+l)/g,t[2]=(h+c)/g):f>d?(g=Math.sqrt(1+f-i-d)*2,t[3]=(h-c)/g,t[0]=(a+l)/g,t[1]=.25*g,t[2]=(u+p)/g):(g=Math.sqrt(1+d-i-f)*2,t[3]=(a-l)/g,t[0]=(h+c)/g,t[1]=(u+p)/g,t[2]=.25*g),t}function By(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];let o=n[0],s=n[1],i=n[2],a=n[4],c=n[5],l=n[6],f=n[8],u=n[9],h=n[10];r[0]=Math.sqrt(o*o+s*s+i*i),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+u*u+h*h);let p=1/r[0],d=1/r[1],m=1/r[2],g=o*p,b=s*d,T=i*m,S=a*p,M=c*d,C=l*m,E=f*p,B=u*d,_=h*m,y=g+M+_,A=0;return y>0?(A=Math.sqrt(y+1)*2,t[3]=.25*A,t[0]=(C-B)/A,t[1]=(E-T)/A,t[2]=(b-S)/A):g>M&&g>_?(A=Math.sqrt(1+g-M-_)*2,t[3]=(C-B)/A,t[0]=.25*A,t[1]=(b+S)/A,t[2]=(E+T)/A):M>_?(A=Math.sqrt(1+M-g-_)*2,t[3]=(E-T)/A,t[0]=(b+S)/A,t[1]=.25*A,t[2]=(C+B)/A):(A=Math.sqrt(1+_-g-M)*2,t[3]=(b-S)/A,t[0]=(E+T)/A,t[1]=(C+B)/A,t[2]=.25*A),t}function Ry(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3],c=o+o,l=s+s,f=i+i,u=o*c,h=o*l,p=o*f,d=s*l,m=s*f,g=i*f,b=a*c,T=a*l,S=a*f,M=n[0],C=n[1],E=n[2];return t[0]=(1-(d+g))*M,t[1]=(h+S)*M,t[2]=(p-T)*M,t[3]=0,t[4]=(h-S)*C,t[5]=(1-(u+g))*C,t[6]=(m+b)*C,t[7]=0,t[8]=(p+T)*E,t[9]=(m-b)*E,t[10]=(1-(u+d))*E,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function wy(t,e,r,n,o){let s=e[0],i=e[1],a=e[2],c=e[3],l=s+s,f=i+i,u=a+a,h=s*l,p=s*f,d=s*u,m=i*f,g=i*u,b=a*u,T=c*l,S=c*f,M=c*u,C=n[0],E=n[1],B=n[2],_=o[0],y=o[1],A=o[2],I=(1-(m+b))*C,L=(p+M)*C,F=(d-S)*C,w=(p-M)*E,D=(1-(h+b))*E,W=(g+T)*E,k=(d+S)*B,ne=(g-T)*B,Q=(1-(h+m))*B;return t[0]=I,t[1]=L,t[2]=F,t[3]=0,t[4]=w,t[5]=D,t[6]=W,t[7]=0,t[8]=k,t[9]=ne,t[10]=Q,t[11]=0,t[12]=r[0]+_-(I*_+w*y+k*A),t[13]=r[1]+y-(L*_+D*y+ne*A),t[14]=r[2]+A-(F*_+W*y+Q*A),t[15]=1,t}function ja(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r+r,a=n+n,c=o+o,l=r*i,f=n*i,u=n*a,h=o*i,p=o*a,d=o*c,m=s*i,g=s*a,b=s*c;return t[0]=1-u-d,t[1]=f+b,t[2]=h-g,t[3]=0,t[4]=f-b,t[5]=1-l-d,t[6]=p+m,t[7]=0,t[8]=h+g,t[9]=p-m,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ja(t,e,r,n,o,s,i){let a=1/(r-e),c=1/(o-n),l=1/(s-i);return t[0]=s*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+n)*c,t[10]=(i+s)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=i*s*2*l,t[15]=0,t}function Ch(t,e,r,n,o){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let i=1/(n-o);t[10]=(o+n)*i,t[14]=2*o*n*i}else t[10]=-1,t[14]=-2*n;return t}var Wa=Ch;function Ly(t,e,r,n,o){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let i=1/(n-o);t[10]=o*i,t[14]=o*n*i}else t[10]=-1,t[14]=-n;return t}function Fy(t,e,r,n){let o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),i=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(i+a),l=2/(o+s);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((i-a)*c*.5),t[9]=(o-s)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function Ih(t,e,r,n,o,s,i){let a=1/(e-r),c=1/(n-o),l=1/(s-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=(i+s)*l,t[15]=1,t}var Xa=Ih;function Py(t,e,r,n,o,s,i){let a=1/(e-r),c=1/(n-o),l=1/(s-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=s*l,t[15]=1,t}function Ka(t,e,r,n){let o,s,i,a,c,l,f,u,h,p,d=e[0],m=e[1],g=e[2],b=n[0],T=n[1],S=n[2],M=r[0],C=r[1],E=r[2];return Math.abs(d-M)<1e-6&&Math.abs(m-C)<1e-6&&Math.abs(g-E)<1e-6?Mh(t):(u=d-M,h=m-C,p=g-E,o=1/Math.sqrt(u*u+h*h+p*p),u*=o,h*=o,p*=o,s=T*p-S*h,i=S*u-b*p,a=b*h-T*u,o=Math.sqrt(s*s+i*i+a*a),o?(o=1/o,s*=o,i*=o,a*=o):(s=0,i=0,a=0),c=h*a-p*i,l=p*s-u*a,f=u*i-h*s,o=Math.sqrt(c*c+l*l+f*f),o?(o=1/o,c*=o,l*=o,f*=o):(c=0,l=0,f=0),t[0]=s,t[1]=c,t[2]=u,t[3]=0,t[4]=i,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=f,t[10]=p,t[11]=0,t[12]=-(s*d+i*m+a*g),t[13]=-(c*d+l*m+f*g),t[14]=-(u*d+h*m+p*g),t[15]=1,t)}function Ny(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=n[0],c=n[1],l=n[2],f=o-r[0],u=s-r[1],h=i-r[2],p=f*f+u*u+h*h;p>0&&(p=1/Math.sqrt(p),f*=p,u*=p,h*=p);let d=c*h-l*u,m=l*f-a*h,g=a*u-c*f;return p=d*d+m*m+g*g,p>0&&(p=1/Math.sqrt(p),d*=p,m*=p,g*=p),t[0]=d,t[1]=m,t[2]=g,t[3]=0,t[4]=u*g-h*m,t[5]=h*d-f*g,t[6]=f*m-u*d,t[7]=0,t[8]=f,t[9]=u,t[10]=h,t[11]=0,t[12]=o,t[13]=s,t[14]=i,t[15]=1,t}function Oy(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function Uy(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function Dy(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function vh(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function Vy(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function Gy(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function Hy(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function ky(t,e){let r=t[0],n=t[1],o=t[2],s=t[3],i=t[4],a=t[5],c=t[6],l=t[7],f=t[8],u=t[9],h=t[10],p=t[11],d=t[12],m=t[13],g=t[14],b=t[15],T=e[0],S=e[1],M=e[2],C=e[3],E=e[4],B=e[5],_=e[6],y=e[7],A=e[8],I=e[9],L=e[10],F=e[11],w=e[12],D=e[13],W=e[14],k=e[15];return Math.abs(r-T)<=1e-6*Math.max(1,Math.abs(r),Math.abs(T))&&Math.abs(n-S)<=1e-6*Math.max(1,Math.abs(n),Math.abs(S))&&Math.abs(o-M)<=1e-6*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(s-C)<=1e-6*Math.max(1,Math.abs(s),Math.abs(C))&&Math.abs(i-E)<=1e-6*Math.max(1,Math.abs(i),Math.abs(E))&&Math.abs(a-B)<=1e-6*Math.max(1,Math.abs(a),Math.abs(B))&&Math.abs(c-_)<=1e-6*Math.max(1,Math.abs(c),Math.abs(_))&&Math.abs(l-y)<=1e-6*Math.max(1,Math.abs(l),Math.abs(y))&&Math.abs(f-A)<=1e-6*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(u-I)<=1e-6*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(h-L)<=1e-6*Math.max(1,Math.abs(h),Math.abs(L))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(d-w)<=1e-6*Math.max(1,Math.abs(d),Math.abs(w))&&Math.abs(m-D)<=1e-6*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(g-W)<=1e-6*Math.max(1,Math.abs(g),Math.abs(W))&&Math.abs(b-k)<=1e-6*Math.max(1,Math.abs(b),Math.abs(k))}var zy=vn,qy=vh;function jy(){let t=new re(4);return re!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function Bh(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function Rh(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function wh(t){let e=t[0],r=t[1],n=t[2],o=t[3];return Math.sqrt(e*e+r*r+n*n+o*o)}function Lh(t){let e=t[0],r=t[1],n=t[2],o=t[3];return e*e+r*r+n*n+o*o}function Fh(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=o*i,t[3]=s*i,t}function Ph(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Nh(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function Oh(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*s+r[12]*i,t[1]=r[1]*n+r[5]*o+r[9]*s+r[13]*i,t[2]=r[2]*n+r[6]*o+r[10]*s+r[14]*i,t[3]=r[3]*n+r[7]*o+r[11]*s+r[15]*i,t}function Uh(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2],l=r[3],f=l*n+a*s-c*o,u=l*o+c*n-i*s,h=l*s+i*o-a*n,p=-i*n-a*o-c*s;return t[0]=f*l+p*-i+u*-c-h*-a,t[1]=u*l+p*-a+h*-i-f*-c,t[2]=h*l+p*-c+f*-a-u*-i,t[3]=e[3],t}var cL=(function(){let t=jy();return function(e,r,n,o,s,i){let a,c;for(r||(r=4),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}})();var Za;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Za||(Za={}));var Jy=45*Math.PI/180,Wy=1,Ya=.1,Qa=500,Xy=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),N=class extends Lr{static get IDENTITY(){return Yy()}static get ZERO(){return Ky()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Za}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,o,s,i,a,c,l,f,u,h,p,d,m,g){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=s,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=u,this[11]=h,this[12]=p,this[13]=d,this[14]=m,this[15]=g,this.check()}setRowMajor(e,r,n,o,s,i,a,c,l,f,u,h,p,d,m,g){return this[0]=e,this[1]=s,this[2]=l,this[3]=p,this[4]=r,this[5]=i,this[6]=f,this[7]=d,this[8]=n,this[9]=a,this[10]=u,this[11]=m,this[12]=o,this[13]=c,this[14]=h,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Xy)}fromObject(e){return this.check()}fromQuaternion(e){return ja(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:s,near:i=Ya,far:a=Qa}=e;return a===1/0?Qy(this,r,n,o,s,i):Ja(this,r,n,o,s,i,a),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return Ka(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:s,near:i=Ya,far:a=Qa}=e;return Xa(this,r,n,o,s,i,a),this.check()}orthographic(e){let{fovy:r=Jy,aspect:n=Wy,focalDistance:o=1,near:s=Ya,far:i=Qa}=e;Vh(r);let a=r/2,c=o*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:i})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:s=500}=e;return Vh(r),Wa(this,r,n,o,s),this.check()}determinant(){return Da(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],s=1/n[1],i=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*s,e[2]=this[2]*i,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*s,e[6]=this[6]*i,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*s,e[10]=this[10]*i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],s=1/n[1],i=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*s,e[2]=this[2]*i,e[3]=this[4]*o,e[4]=this[5]*s,e[5]=this[6]*i,e[6]=this[8]*o,e[7]=this[9]*s,e[8]=this[10]*i,e}transpose(){return Oa(this,this),this.check()}invert(){return Ua(this,this),this.check()}multiplyLeft(e){return vn(this,e,this),this.check()}multiplyRight(e){return vn(this,this,e),this.check()}rotateX(e){return ka(this,this,e),this.check()}rotateY(e){return za(this,this,e),this.check()}rotateZ(e){return qa(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return Ha(this,this,e,r),this.check()}scale(e){return Ga(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Va(this,this,e),this.check()}transform(e,r){return e.length===4?(r=Oh(r||[-0,-0,-0,-0],e,this),Rt(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=cs(r||[-0,-0],e,this);break;case 3:o=Kt(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Rt(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=ls(r||[-0,-0],e,this);break;case 3:n=fs(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Rt(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},Ts,ys;function Ky(){return Ts||(Ts=new N([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ts)),Ts}function Yy(){return ys||(ys=new N,Object.freeze(ys)),ys}function Vh(t){if(t>Math.PI*2)throw Error("expected radians")}function Qy(t,e,r,n,o,s){let i=2*s/(r-e),a=2*s/(o-n),c=(r+e)/(r-e),l=(o+n)/(o-n),f=-1,u=-1,h=-2*s;return t[0]=i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=u,t[12]=0,t[13]=0,t[14]=h,t[15]=0,t}function Gh(){let t=new re(4);return re!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Hh(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function $a(t,e,r){r=r*.5;let n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function ec(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+o*l-s*c,t[1]=o*f+i*c+s*a-n*l,t[2]=s*f+i*l+n*c-o*a,t[3]=i*f-n*a-o*c-s*l,t}function kh(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=o*c+s*a,t[2]=s*c-o*a,t[3]=i*c-n*a,t}function zh(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-s*a,t[1]=o*c+i*a,t[2]=s*c+n*a,t[3]=i*c-o*a,t}function qh(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*a,t[1]=o*c-n*a,t[2]=s*c+i*a,t[3]=i*c-s*a,t}function jh(t,e){let r=e[0],n=e[1],o=e[2];return t[0]=r,t[1]=n,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-o*o)),t}function Bn(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],h,p,d,m,g;return h=o*c+s*l+i*f+a*u,h<0&&(h=-h,c=-c,l=-l,f=-f,u=-u),1-h>1e-6?(p=Math.acos(h),g=Math.sin(p),d=Math.sin((1-n)*p)/g,m=Math.sin(n*p)/g):(d=1-n,m=n),t[0]=d*o+m*c,t[1]=d*s+m*l,t[2]=d*i+m*f,t[3]=d*a+m*u,t}function Jh(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-o*a,t[3]=s*a,t}function Wh(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function tc(t,e){let r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let o=0;e[4]>e[0]&&(o=1),e[8]>e[o*3+o]&&(o=2);let s=(o+1)%3,i=(o+2)%3;n=Math.sqrt(e[o*3+o]-e[s*3+s]-e[i*3+i]+1),t[o]=.5*n,n=.5/n,t[3]=(e[s*3+i]-e[i*3+s])*n,t[s]=(e[s*3+o]+e[o*3+s])*n,t[i]=(e[i*3+o]+e[o*3+i])*n}return t}var Xh=Bh;var Kh=Rh,Yh=Ph,Qh=Nh,Zh=wh;var $h=Lh;var ep=Fh;var tp=(function(){let t=hs(),e=ps(1,0,0),r=ps(0,1,0);return function(n,o,s){let i=En(o,s);return i<-.999999?(Xt(t,e,o),wa(t)<1e-6&&Xt(t,r,o),Ca(t,t),$a(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Xt(t,o,s),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,ep(n,n))}})(),SL=(function(){let t=Gh(),e=Gh();return function(r,n,o,s,i,a){return Bn(t,n,i,a),Bn(e,o,s,a),Bn(r,t,e,2*a*(1-a)),r}})(),ML=(function(){let t=mh();return function(e,r,n,o){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],ep(e,tc(e,t))}})();var $y=[0,0,0,1],ot=class extends Bt{constructor(e=0,r=0,n=0,o=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,n,o)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,n,o){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return tc(this,e),this.check()}fromAxisRotation(e,r){return $a(this,e,r),this.check()}identity(){return Hh(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=G(e)}get y(){return this[1]}set y(e){this[1]=G(e)}get z(){return this[2]}set z(e){this[2]=G(e)}get w(){return this[3]}set w(e){this[3]=G(e)}len(){return Zh(this)}lengthSquared(){return $h(this)}dot(e){return Yh(this,e)}rotationTo(e,r){return tp(this,e,r),this.check()}add(e){return Xh(this,this,e),this.check()}calculateW(){return jh(this,this),this.check()}conjugate(){return Wh(this,this),this.check()}invert(){return Jh(this,this),this.check()}lerp(e,r,n){return n===void 0?this.lerp(this,e,r):(Qh(this,e,r,n),this.check())}multiplyRight(e){return ec(this,this,e),this.check()}multiplyLeft(e){return ec(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return kh(this,this,e),this.check()}rotateY(e){return zh(this,this,e),this.check()}rotateZ(e){return qh(this,this,e),this.check()}scale(e){return Kh(this,this,e),this.check()}slerp(e,r,n){let o,s,i;switch(arguments.length){case 1:({start:o=$y,target:s,ratio:i}=e);break;case 2:o=this,s=e,i=r;break;default:o=e,s=r,i=n}return Bn(this,o,s,i),this.check()}transformVector4(e,r=new gs){return Uh(r,e,this),Rt(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var Ke={};Ae(Ke,{EPSILON1:()=>eS,EPSILON10:()=>lS,EPSILON11:()=>fS,EPSILON12:()=>uS,EPSILON13:()=>hS,EPSILON14:()=>pS,EPSILON15:()=>dS,EPSILON16:()=>mS,EPSILON17:()=>gS,EPSILON18:()=>AS,EPSILON19:()=>bS,EPSILON2:()=>tS,EPSILON20:()=>xS,EPSILON3:()=>rS,EPSILON4:()=>nS,EPSILON5:()=>oS,EPSILON6:()=>sS,EPSILON7:()=>iS,EPSILON8:()=>aS,EPSILON9:()=>cS,PI_OVER_FOUR:()=>yS,PI_OVER_SIX:()=>SS,PI_OVER_TWO:()=>TS,TWO_PI:()=>MS});var eS=.1,tS=.01,rS=.001,nS=1e-4,oS=1e-5,sS=1e-6,iS=1e-7,aS=1e-8,cS=1e-9,lS=1e-10,fS=1e-11,uS=1e-12,hS=1e-13,pS=1e-14,dS=1e-15,mS=1e-16,gS=1e-17,AS=1e-18,bS=1e-19,xS=1e-20,TS=Math.PI/2,yS=Math.PI/4,SS=Math.PI/6,MS=Math.PI*2;function Ss(t,e){e=e===void 0?t[0][0]:e;for(let r of t){let n=r[0]-e;n>180?r[0]-=360:n<-180&&(r[0]+=360)}}function _S(t,e,r){let[n,o]=(0,Rn.cellToLatLng)(t),s=e.length;Ss(e,o);let i=e[0]===e[s-1]?s-1:s;for(let a=0;a<i;a++)e[a][0]=vt(o,e[a][0],r),e[a][1]=vt(n,e[a][1],r)}function rp(t,e,r){let n=t(e,r),[o,s]=(0,Rn.cellToLatLng)(n);return[s,o]}function rc(t,e=1){let r=(0,Rn.cellToBoundary)(t,!0);return e!==1?_S(t,r,e):Ss(r),r}function Ms(t){let e=new Float64Array(t.length*2),r=0;for(let n of t)e[r++]=n[0],e[r++]=n[1];return e}var ES={getPentagon:{type:"accessor",value:t=>t.pentagon}},wn=class extends De{indexToBounds(){let{data:e,getPentagon:r}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(n,o)=>{let s=r(n,o),i=Zu(typeof s=="string"?$u(s):s,{closedRing:!0,segments:"auto"});return Ms(i)}}}};wn.layerName="A5Layer";wn.defaultProps=ES;var np=wn;var ir=U(We(),1),od=U(Je(),1),sd=U(Yt(),1);function CS(t){return typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t}function _s(t){if(Array.isArray(t))return t.map(e=>_s(e));if(t&&typeof t=="object"){let e={};for(let[r,n]of Object.entries(t))e[CS(r)]=_s(n);return e}return t}var sp=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",IS=sp+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",vS="["+sp+"]["+IS+"]*",BS=new RegExp("^"+vS+"$");function Es(t,e){let r=[],n=e.exec(t);for(;n;){let o=[];o.startIndex=e.lastIndex-n[0].length;let s=n.length;for(let i=0;i<s;i++)o.push(n[i]);r.push(o),n=e.exec(t)}return r}var Fr=function(t){let e=BS.exec(t);return!(e===null||typeof e>"u")};function ip(t){return typeof t<"u"}var Ln=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Cs=["__proto__","constructor","prototype"];var RS={allowBooleanAttributes:!1,unpairedTags:[]};function up(t,e){e=Object.assign({},RS,e);let r=[],n=!1,o=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=cp(t,s),s.err)return s}else if(t[s]==="<"){let i=s;if(s++,t[s]==="!"){s=lp(t,s);continue}else{let a=!1;t[s]==="/"&&(a=!0,s++);let c="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
|
|
8
|
+
`&&t[s]!=="\r";s++)c+=t[s];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),s--),!DS(c)){let u;return c.trim().length===0?u="Invalid space after '<'.":u="Tag '"+c+"' is an invalid name.",ie("InvalidTag",u,_e(t,s))}let l=FS(t,s);if(l===!1)return ie("InvalidAttr","Attributes for '"+c+"' have open quote.",_e(t,s));let f=l.value;if(s=l.index,f[f.length-1]==="/"){let u=s-f.length;f=f.substring(0,f.length-1);let h=fp(f,e);if(h===!0)n=!0;else return ie(h.err.code,h.err.msg,_e(t,u+h.err.line))}else if(a)if(l.tagClosed){if(f.trim().length>0)return ie("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",_e(t,i));if(r.length===0)return ie("InvalidTag","Closing tag '"+c+"' has not been opened.",_e(t,i));{let u=r.pop();if(c!==u.tagName){let h=_e(t,u.tagStartPos);return ie("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+c+"'.",_e(t,i))}r.length==0&&(o=!0)}}else return ie("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",_e(t,s));else{let u=fp(f,e);if(u!==!0)return ie(u.err.code,u.err.msg,_e(t,s-f.length+u.err.line));if(o===!0)return ie("InvalidXml","Multiple possible root nodes found.",_e(t,s));e.unpairedTags.indexOf(c)!==-1||r.push({tagName:c,tagStartPos:i}),n=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=lp(t,s);continue}else if(t[s+1]==="?"){if(s=cp(t,++s),s.err)return s}else break;else if(t[s]==="&"){let u=OS(t,s);if(u==-1)return ie("InvalidChar","char '&' is not expected.",_e(t,s));s=u}else if(o===!0&&!ap(t[s]))return ie("InvalidXml","Extra text at the end",_e(t,s));t[s]==="<"&&s--}}else{if(ap(t[s]))continue;return ie("InvalidChar","char '"+t[s]+"' is not expected.",_e(t,s))}if(n){if(r.length==1)return ie("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",_e(t,r[0].tagStartPos));if(r.length>0)return ie("InvalidXml","Invalid '"+JSON.stringify(r.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return ie("InvalidXml","Start tag expected.",1);return!0}function ap(t){return t===" "||t===" "||t===`
|
|
9
|
+
`||t==="\r"}function cp(t,e){let r=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){let n=t.substr(r,e-r);if(e>5&&n==="xml")return ie("InvalidXml","XML declaration allowed only at the start of the document.",_e(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function lp(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let r=1;for(e+=8;e<t.length;e++)if(t[e]==="<")r++;else if(t[e]===">"&&(r--,r===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}var wS='"',LS="'";function FS(t,e){let r="",n="",o=!1;for(;e<t.length;e++){if(t[e]===wS||t[e]===LS)n===""?n=t[e]:n!==t[e]||(n="");else if(t[e]===">"&&n===""){o=!0;break}r+=t[e]}return n!==""?!1:{value:r,index:e,tagClosed:o}}var PS=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function fp(t,e){let r=Es(t,PS),n={};for(let o=0;o<r.length;o++){if(r[o][1].length===0)return ie("InvalidAttr","Attribute '"+r[o][2]+"' has no space in starting.",Fn(r[o]));if(r[o][3]!==void 0&&r[o][4]===void 0)return ie("InvalidAttr","Attribute '"+r[o][2]+"' is without value.",Fn(r[o]));if(r[o][3]===void 0&&!e.allowBooleanAttributes)return ie("InvalidAttr","boolean attribute '"+r[o][2]+"' is not allowed.",Fn(r[o]));let s=r[o][2];if(!US(s))return ie("InvalidAttr","Attribute '"+s+"' is an invalid name.",Fn(r[o]));if(!Object.prototype.hasOwnProperty.call(n,s))n[s]=1;else return ie("InvalidAttr","Attribute '"+s+"' is repeated.",Fn(r[o]))}return!0}function NS(t,e){let r=/\d/;for(t[e]==="x"&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(r))break}return-1}function OS(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,NS(t,e);let r=0;for(;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(t[e]===";")break;return-1}return e}function ie(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function US(t){return Fr(t)}function DS(t){return Fr(t)}function _e(t,e){let r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function Fn(t){return t.startIndex+t[1].length}var hp=t=>Ln.includes(t)?"__"+t:t,VS={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:hp};function GS(t,e){if(typeof t!="string")return;let r=t.toLowerCase();if(Ln.some(n=>r===n.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Cs.some(n=>r===n.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function pp(t){return typeof t=="boolean"?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof t=="object"&&t!==null?{enabled:t.enabled!==!1,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:pp(!0)}var dp=function(t){let e=Object.assign({},VS,t),r=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(let{value:n,name:o}of r)n&&GS(n,o);return e.onDangerousProperty===null&&(e.onDangerousProperty=hp),e.processEntities=pp(e.processEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(n=>typeof n=="string"&&n.startsWith("*.")?".."+n.substring(2):n)),e};var Is;typeof Symbol!="function"?Is="@@xmlMetadata":Is=Symbol("XML Node Metadata");var ve=class{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,r){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:r})}addChild(e,r){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),r!==void 0&&(this.child[this.child.length-1][Is]={startIndex:r})}static getMetaDataSymbol(){return Is}};var Nn=class{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,r){let n=Object.create(null),o=0;if(e[r+3]==="O"&&e[r+4]==="C"&&e[r+5]==="T"&&e[r+6]==="Y"&&e[r+7]==="P"&&e[r+8]==="E"){r=r+9;let s=1,i=!1,a=!1,c="";for(;r<e.length;r++)if(e[r]==="<"&&!a){if(i&&Qt(e,"!ENTITY",r)){r+=7;let l,f;if([l,f,r]=this.readEntityExp(e,r+1,this.suppressValidationErr),f.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&o>=this.options.maxEntityCount)throw new Error(`Entity count (${o+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);let u=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n[l]={regx:RegExp(`&${u};`,"g"),val:f},o++}}else if(i&&Qt(e,"!ELEMENT",r)){r+=8;let{index:l}=this.readElementExp(e,r+1);r=l}else if(i&&Qt(e,"!ATTLIST",r))r+=8;else if(i&&Qt(e,"!NOTATION",r)){r+=9;let{index:l}=this.readNotationExp(e,r+1,this.suppressValidationErr);r=l}else if(Qt(e,"!--",r))a=!0;else throw new Error("Invalid DOCTYPE");s++,c=""}else if(e[r]===">"){if(a?e[r-1]==="-"&&e[r-2]==="-"&&(a=!1,s--):s--,s===0)break}else e[r]==="["?i=!0:c+=e[r];if(s!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:r}}readEntityExp(e,r){r=Be(e,r);let n=r;for(;r<e.length&&!/\s/.test(e[r])&&e[r]!=='"'&&e[r]!=="'";)r++;let o=e.substring(n,r);if(Pn(o),r=Be(e,r),!this.suppressValidationErr){if(e.substring(r,r+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[r]==="%")throw new Error("Parameter entities are not supported")}let s="";if([r,s]=this.readIdentifierVal(e,r,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${o}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return r--,[o,s,r]}readNotationExp(e,r){r=Be(e,r);let n=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let o=e.substring(n,r);!this.suppressValidationErr&&Pn(o),r=Be(e,r);let s=e.substring(r,r+6).toUpperCase();if(!this.suppressValidationErr&&s!=="SYSTEM"&&s!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);r+=s.length,r=Be(e,r);let i=null,a=null;if(s==="PUBLIC")[r,i]=this.readIdentifierVal(e,r,"publicIdentifier"),r=Be(e,r),(e[r]==='"'||e[r]==="'")&&([r,a]=this.readIdentifierVal(e,r,"systemIdentifier"));else if(s==="SYSTEM"&&([r,a]=this.readIdentifierVal(e,r,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:o,publicIdentifier:i,systemIdentifier:a,index:--r}}readIdentifierVal(e,r,n){let o="",s=e[r];if(s!=='"'&&s!=="'")throw new Error(`Expected quoted string, found "${s}"`);r++;let i=r;for(;r<e.length&&e[r]!==s;)r++;if(o=e.substring(i,r),e[r]!==s)throw new Error(`Unterminated ${n} value`);return r++,[r,o]}readElementExp(e,r){r=Be(e,r);let n=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let o=e.substring(n,r);if(!this.suppressValidationErr&&!Fr(o))throw new Error(`Invalid element name: "${o}"`);r=Be(e,r);let s="";if(e[r]==="E"&&Qt(e,"MPTY",r))r+=4;else if(e[r]==="A"&&Qt(e,"NY",r))r+=2;else if(e[r]==="("){r++;let i=r;for(;r<e.length&&e[r]!==")";)r++;if(s=e.substring(i,r),e[r]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[r]}"`);return{elementName:o,contentModel:s.trim(),index:r}}readAttlistExp(e,r){r=Be(e,r);let n=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let o=e.substring(n,r);for(Pn(o),r=Be(e,r),n=r;r<e.length&&!/\s/.test(e[r]);)r++;let s=e.substring(n,r);if(!Pn(s))throw new Error(`Invalid attribute name: "${s}"`);r=Be(e,r);let i="";if(e.substring(r,r+8).toUpperCase()==="NOTATION"){if(i="NOTATION",r+=8,r=Be(e,r),e[r]!=="(")throw new Error(`Expected '(', found "${e[r]}"`);r++;let c=[];for(;r<e.length&&e[r]!==")";){let l=r;for(;r<e.length&&e[r]!=="|"&&e[r]!==")";)r++;let f=e.substring(l,r);if(f=f.trim(),!Pn(f))throw new Error(`Invalid notation name: "${f}"`);c.push(f),e[r]==="|"&&(r++,r=Be(e,r))}if(e[r]!==")")throw new Error("Unterminated list of notations");r++,i+=" ("+c.join("|")+")"}else{let c=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;i+=e.substring(c,r);let l=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!l.includes(i.toUpperCase()))throw new Error(`Invalid attribute type: "${i}"`)}r=Be(e,r);let a="";return e.substring(r,r+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",r+=8):e.substring(r,r+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",r+=7):[r,a]=this.readIdentifierVal(e,r,"ATTLIST"),{elementName:o,attributeName:s,attributeType:i,defaultValue:a,index:r}}},Be=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function Qt(t,e,r){for(let n=0;n<e.length;n++)if(e[n]!==t[r+n+1])return!1;return!0}function Pn(t){if(Fr(t))return t;throw new Error(`Invalid entity name ${t}`)}var HS=/^[-+]?0x[a-fA-F0-9]+$/,kS=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,zS={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function nc(t,e={}){if(e=Object.assign({},zS,e),!t||typeof t!="string")return t;let r=t.trim();if(r.length===0)return t;if(e.skipLike!==void 0&&e.skipLike.test(r))return t;if(r==="0")return 0;if(e.hex&&HS.test(r))return WS(r,16);if(isFinite(r)){if(r.includes("e")||r.includes("E"))return jS(t,r,e);{let n=kS.exec(r);if(n){let o=n[1]||"",s=n[2],i=JS(n[3]),a=o?t[s.length+1]===".":t[s.length]===".";if(!e.leadingZeros&&(s.length>1||s.length===1&&!a))return t;{let c=Number(r),l=String(c);if(c===0)return c;if(l.search(/[eE]/)!==-1)return e.eNotation?c:t;if(r.indexOf(".")!==-1)return l==="0"||l===i||l===`${o}${i}`?c:t;let f=s?i:r;return s?f===l||o+f===l?c:t:f===l||f===o+l?c:t}}else return t}}else return XS(t,Number(r),e)}var qS=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function jS(t,e,r){if(!r.eNotation)return t;let n=e.match(qS);if(n){let o=n[1]||"",s=n[3].indexOf("e")===-1?"E":"e",i=n[2],a=o?t[i.length+1]===s:t[i.length]===s;return i.length>1&&a?t:i.length===1&&(n[3].startsWith(`.${s}`)||n[3][0]===s)?Number(e):i.length>0?r.leadingZeros&&!a?(e=(n[1]||"")+n[3],Number(e)):t:Number(e)}else return t}function JS(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substring(0,t.length-1))),t}function WS(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function XS(t,e,r){let n=e===1/0;switch(r.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return n?"Infinity":"-Infinity";default:return t}}function oc(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(let r of t)if(typeof r=="string"&&e===r||r instanceof RegExp&&r.test(e))return!0}:()=>!1}var Zt=class{constructor(e,r={},n){this.pattern=e,this.separator=r.separator||".",this.segments=this._parse(e),this.data=n,this._hasDeepWildcard=this.segments.some(o=>o.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(o=>o.attrName!==void 0),this._hasPositionSelector=this.segments.some(o=>o.position!==void 0)}_parse(e){let r=[],n=0,o="";for(;n<e.length;)e[n]===this.separator?n+1<e.length&&e[n+1]===this.separator?(o.trim()&&(r.push(this._parseSegment(o.trim())),o=""),r.push({type:"deep-wildcard"}),n+=2):(o.trim()&&r.push(this._parseSegment(o.trim())),o="",n++):(o+=e[n],n++);return o.trim()&&r.push(this._parseSegment(o.trim())),r}_parseSegment(e){let r={type:"tag"},n=null,o=e,s=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(s&&(o=s[1]+s[3],s[2])){let f=s[2].slice(1,-1);f&&(n=f)}let i,a=o;if(o.includes("::")){let f=o.indexOf("::");if(i=o.substring(0,f).trim(),a=o.substring(f+2).trim(),!i)throw new Error(`Invalid namespace in pattern: ${e}`)}let c,l=null;if(a.includes(":")){let f=a.lastIndexOf(":"),u=a.substring(0,f).trim(),h=a.substring(f+1).trim();["first","last","odd","even"].includes(h)||/^nth\(\d+\)$/.test(h)?(c=u,l=h):c=a}else c=a;if(!c)throw new Error(`Invalid segment pattern: ${e}`);if(r.tag=c,i&&(r.namespace=i),n)if(n.includes("=")){let f=n.indexOf("=");r.attrName=n.substring(0,f).trim(),r.attrValue=n.substring(f+1).trim()}else r.attrName=n.trim();if(l){let f=l.match(/^nth\((\d+)\)$/);f?(r.position="nth",r.positionValue=parseInt(f[1],10)):r.position=l}return r}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}};var Pr=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard())return this._deepWildcards.push(e),this;let r=e.length,o=e.segments[e.segments.length-1]?.tag;if(!o||o==="*")this._wildcardByDepth.has(r)||this._wildcardByDepth.set(r,[]),this._wildcardByDepth.get(r).push(e);else{let s=`${r}:${o}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(e)}return this}addAll(e){for(let r of e)this.add(r);return this}has(e){return this._patterns.has(e.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(e){return this.findMatch(e)!==null}findMatch(e){let r=e.getDepth(),n=e.getCurrentTag(),o=`${r}:${n}`,s=this._byDepthAndTag.get(o);if(s){for(let a=0;a<s.length;a++)if(e.matches(s[a]))return s[a]}let i=this._wildcardByDepth.get(r);if(i){for(let a=0;a<i.length;a++)if(e.matches(i[a]))return i[a]}for(let a=0;a<this._deepWildcards.length;a++)if(e.matches(this._deepWildcards[a]))return this._deepWildcards[a];return null}};var KS=new Set(["push","pop","reset","updateCurrent","restore"]),Nr=class{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null}push(e,r=null,n=null){if(this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path.length>0){let f=this.path[this.path.length-1];f.values=void 0}let o=this.path.length;this.siblingStacks[o]||(this.siblingStacks[o]=new Map);let s=this.siblingStacks[o],i=n?`${n}:${e}`:e,a=s.get(i)||0,c=0;for(let f of s.values())c+=f;s.set(i,a+1);let l={tag:e,position:c,counter:a};n!=null&&(l.namespace=n),r!=null&&(l.values=r),this.path.push(l)}pop(){if(this.path.length===0)return;this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null;let e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){let r=this.path[this.path.length-1];e!=null&&(r.values=e,this._frozenPathCache=null)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){return this.path.length===0?void 0:this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let r=this.path[this.path.length-1];return r.values!==void 0&&e in r.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,r=!0){let n=e||this.separator;if(n===this.separator&&r===!0){if(this._pathStringCache!==null&&this._pathStringCache!==void 0)return this._pathStringCache;let s=this.path.map(i=>r&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(n);return this._pathStringCache=s,s}return this.path.map(s=>r&&s.namespace?`${s.namespace}:${s.tag}`:s.tag).join(n)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=[],this.siblingStacks=[]}matches(e){let r=e.segments;return r.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(r):this._matchSimple(r)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let r=0;r<e.length;r++){let n=e[r],o=this.path[r],s=r===this.path.length-1;if(!this._matchSegment(n,o,s))return!1}return!0}_matchWithDeepWildcard(e){let r=this.path.length-1,n=e.length-1;for(;n>=0&&r>=0;){let o=e[n];if(o.type==="deep-wildcard"){if(n--,n<0)return!0;let s=e[n],i=!1;for(let a=r;a>=0;a--){let c=a===this.path.length-1;if(this._matchSegment(s,this.path[a],c)){r=a-1,n--,i=!0;break}}if(!i)return!1}else{let s=r===this.path.length-1;if(!this._matchSegment(o,this.path[r],s))return!1;r--,n--}}return n<0}_matchSegment(e,r,n){if(e.tag!=="*"&&e.tag!==r.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==r.namespace)return!1;if(e.attrName!==void 0){if(!n||!r.values||!(e.attrName in r.values))return!1;if(e.attrValue!==void 0){let o=r.values[e.attrName];if(String(o)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!n)return!1;let o=r.counter??0;if(e.position==="first"&&o!==0)return!1;if(e.position==="odd"&&o%2!==1)return!1;if(e.position==="even"&&o%2!==0)return!1;if(e.position==="nth"&&o!==e.positionValue)return!1}return!0}matchesAny(e){return e.matchesAny(this)}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=e.path.map(r=>({...r})),this.siblingStacks=e.siblingStacks.map(r=>new Map(r))}readOnly(){let e=this;return new Proxy(e,{get(r,n,o){if(KS.has(n))return()=>{throw new TypeError(`Cannot call '${n}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};if(n==="path")return r._frozenPathCache===null&&(r._frozenPathCache=Object.freeze(r.path.map(i=>Object.freeze({...i})))),r._frozenPathCache;if(n==="siblingStacks")return r._frozenSiblingsCache===null&&(r._frozenSiblingsCache=Object.freeze(r.siblingStacks.map(i=>Object.freeze(new Map(i))))),r._frozenSiblingsCache;let s=Reflect.get(r,n,o);return typeof s=="function"?s.bind(r):s},set(r,n){throw new TypeError(`Cannot set property '${String(n)}' on a read-only Matcher.`)},deleteProperty(r,n){throw new TypeError(`Cannot delete property '${String(n)}' from a read-only Matcher.`)}})}};function YS(t,e){if(!t)return{};let r=e.attributesGroupName?t[e.attributesGroupName]:t;if(!r)return{};let n={};for(let o in r)if(o.startsWith(e.attributeNamePrefix)){let s=o.substring(e.attributeNamePrefix.length);n[s]=r[o]}else n[o]=r[o];return n}function QS(t){if(!t||typeof t!="string")return;let e=t.indexOf(":");if(e!==-1&&e>0){let r=t.substring(0,e);if(r!=="xmlns")return r}}var On=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,o)=>mp(o,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,o)=>mp(o,16,"&#x")}},this.addExternalEntities=ZS,this.parseXml=nM,this.parseTextData=$S,this.resolveNameSpace=eM,this.buildAttributesMap=rM,this.isItStopNode=aM,this.replaceEntitiesValue=sM,this.readStopNodeData=fM,this.saveTextToParentTag=iM,this.addChild=oM,this.ignoreAttributesFn=oc(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new Nr,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new Pr;let r=this.options.stopNodes;if(r&&r.length>0){for(let n=0;n<r.length;n++){let o=r[n];typeof o=="string"?this.stopNodeExpressionsSet.add(new Zt(o)):o instanceof Zt&&this.stopNodeExpressionsSet.add(o)}this.stopNodeExpressionsSet.seal()}}};function ZS(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let n=e[r],o=n.replace(/[.\-+*:]/g,"\\.");this.lastEntities[n]={regex:new RegExp("&"+o+";","g"),val:t[n]}}}function $S(t,e,r,n,o,s,i){let a=this.options;if(t!==void 0&&(a.trimValues&&!n&&(t=t.trim()),t.length>0)){i||(t=this.replaceEntitiesValue(t,e,r));let c=a.jPath?r.toString():r,l=a.tagValueProcessor(e,t,c,o,s);return l==null?t:typeof l!=typeof t||l!==t?l:a.trimValues||t.trim()===t?ac(t,a.parseTagValue,a.numberParseOptions):t}}function eM(t){if(this.options.removeNSPrefix){let e=t.split(":"),r=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=r+e[1])}return t}var tM=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function rM(t,e,r){let n=this.options;if(n.ignoreAttributes!==!0&&typeof t=="string"){let o=Es(t,tM),s=o.length,i={},a=new Array(s),c=!1,l={};for(let h=0;h<s;h++){let p=this.resolveNameSpace(o[h][1]),d=o[h][4];if(p.length&&d!==void 0){let m=d;n.trimValues&&(m=m.trim()),m=this.replaceEntitiesValue(m,r,this.readonlyMatcher),a[h]=m,l[p]=m,c=!0}}c&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(l);let f=n.jPath?e.toString():this.readonlyMatcher,u=!1;for(let h=0;h<s;h++){let p=this.resolveNameSpace(o[h][1]);if(this.ignoreAttributesFn(p,f))continue;let d=n.attributeNamePrefix+p;if(p.length)if(n.transformAttributeName&&(d=n.transformAttributeName(d)),d=gp(d,n),o[h][4]!==void 0){let m=a[h],g=n.attributeValueProcessor(p,m,f);g==null?i[d]=m:typeof g!=typeof m||g!==m?i[d]=g:i[d]=ac(m,n.parseAttributeValue,n.numberParseOptions),u=!0}else n.allowBooleanAttributes&&(i[d]=!0,u=!0)}if(!u)return;if(n.attributesGroupName){let h={};return h[n.attributesGroupName]=i,h}return i}}var nM=function(t){t=t.replace(/\r\n?/g,`
|
|
10
|
+
`);let e=new ve("!xml"),r=e,n="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.docTypeEntitiesKeys=[],this.lastEntitiesKeys=Object.keys(this.lastEntities),this.htmlEntitiesKeys=this.options.htmlEntities?Object.keys(this.htmlEntities):[];let o=this.options,s=new Nn(o.processEntities),i=t.length;for(let a=0;a<i;a++)if(t[a]==="<"){let l=t.charCodeAt(a+1);if(l===47){let f=Or(t,">",a,"Closing Tag is not closed."),u=t.substring(a+2,f).trim();if(o.removeNSPrefix){let p=u.indexOf(":");p!==-1&&(u=u.substr(p+1))}u=sc(o.transformTagName,u,"",o).tagName,r&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher));let h=this.matcher.getCurrentTag();if(u&&o.unpairedTagsSet.has(u))throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);h&&o.unpairedTagsSet.has(h)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=this.tagsNodeStack.pop(),n="",a=f}else if(l===63){let f=ic(t,a,!1,"?>");if(!f)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,this.readonlyMatcher),!(o.ignoreDeclaration&&f.tagName==="?xml"||o.ignorePiTags)){let u=new ve(f.tagName);u.add(o.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(u[":@"]=this.buildAttributesMap(f.tagExp,this.matcher,f.tagName)),this.addChild(r,u,this.readonlyMatcher,a)}a=f.closeIndex+1}else if(l===33&&t.charCodeAt(a+2)===45&&t.charCodeAt(a+3)===45){let f=Or(t,"-->",a+4,"Comment is not closed.");if(o.commentPropName){let u=t.substring(a+4,f-2);n=this.saveTextToParentTag(n,r,this.readonlyMatcher),r.add(o.commentPropName,[{[o.textNodeName]:u}])}a=f}else if(l===33&&t.charCodeAt(a+2)===68){let f=s.readDocType(t,a);this.docTypeEntities=f.entities,this.docTypeEntitiesKeys=Object.keys(this.docTypeEntities)||[],a=f.i}else if(l===33&&t.charCodeAt(a+2)===91){let f=Or(t,"]]>",a,"CDATA is not closed.")-2,u=t.substring(a+9,f);n=this.saveTextToParentTag(n,r,this.readonlyMatcher);let h=this.parseTextData(u,r.tagname,this.readonlyMatcher,!0,!1,!0,!0);h==null&&(h=""),o.cdataPropName?r.add(o.cdataPropName,[{[o.textNodeName]:u}]):r.add(o.textNodeName,h),a=f+2}else{let f=ic(t,a,o.removeNSPrefix);if(!f){let E=t.substring(Math.max(0,a-50),Math.min(i,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${E}"`)}let u=f.tagName,h=f.rawTagName,p=f.tagExp,d=f.attrExpPresent,m=f.closeIndex;if({tagName:u,tagExp:p}=sc(o.transformTagName,u,p,o),o.strictReservedNames&&(u===o.commentPropName||u===o.cdataPropName||u===o.textNodeName||u===o.attributesGroupName))throw new Error(`Invalid tag name: ${u}`);r&&n&&r.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher,!1));let g=r;g&&o.unpairedTagsSet.has(g.tagname)&&(r=this.tagsNodeStack.pop(),this.matcher.pop());let b=!1;p.length>0&&p.lastIndexOf("/")===p.length-1&&(b=!0,u[u.length-1]==="/"?(u=u.substr(0,u.length-1),p=u):p=p.substr(0,p.length-1),d=u!==p);let T=null,S={},M;M=QS(h),u!==e.tagname&&this.matcher.push(u,{},M),u!==p&&d&&(T=this.buildAttributesMap(p,this.matcher,u),T&&(S=YS(T,o))),u!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let C=a;if(this.isCurrentNodeStopNode){let E="";if(b)a=f.closeIndex;else if(o.unpairedTagsSet.has(u))a=f.closeIndex;else{let _=this.readStopNodeData(t,h,m+1);if(!_)throw new Error(`Unexpected end of ${h}`);a=_.i,E=_.tagContent}let B=new ve(u);T&&(B[":@"]=T),B.add(o.textNodeName,E),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,B,this.readonlyMatcher,C)}else{if(b){({tagName:u,tagExp:p}=sc(o.transformTagName,u,p,o));let E=new ve(u);T&&(E[":@"]=T),this.addChild(r,E,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(o.unpairedTagsSet.has(u)){let E=new ve(u);T&&(E[":@"]=T),this.addChild(r,E,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=f.closeIndex;continue}else{let E=new ve(u);if(this.tagsNodeStack.length>o.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),T&&(E[":@"]=T),this.addChild(r,E,this.readonlyMatcher,C),r=E}n="",a=m}}}else n+=t[a];return e.child};function oM(t,e,r,n){this.options.captureMetaData||(n=void 0);let o=this.options.jPath?r.toString():r,s=this.options.updateTag(e.tagname,o,e[":@"]);s===!1||(typeof s=="string"&&(e.tagname=s),t.addChild(e,n))}function sM(t,e,r){let n=this.options.processEntities;if(!n||!n.enabled)return t;if(n.allowedTags){let o=this.options.jPath?r.toString():r;if(!(Array.isArray(n.allowedTags)?n.allowedTags.includes(e):n.allowedTags(e,o)))return t}if(n.tagFilter){let o=this.options.jPath?r.toString():r;if(!n.tagFilter(e,o))return t}for(let o of this.docTypeEntitiesKeys){let s=this.docTypeEntities[o],i=t.match(s.regx);if(i){if(this.entityExpansionCount+=i.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n.maxTotalExpansions}`);let a=t.length;if(t=t.replace(s.regx,s.val),n.maxExpandedLength&&(this.currentExpandedLength+=t.length-a,this.currentExpandedLength>n.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(let o of this.lastEntitiesKeys){let s=this.lastEntities[o],i=t.match(s.regex);if(i&&(this.entityExpansionCount+=i.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n.maxTotalExpansions}`);t=t.replace(s.regex,s.val)}if(t.indexOf("&")===-1)return t;for(let o of this.htmlEntitiesKeys){let s=this.htmlEntities[o],i=t.match(s.regex);if(i&&(this.entityExpansionCount+=i.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n.maxTotalExpansions}`);t=t.replace(s.regex,s.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t}function iM(t,e,r,n){return t&&(n===void 0&&(n=e.child.length===0),t=this.parseTextData(t,e.tagname,r,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,n),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function aM(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function cM(t,e,r=">"){let n=0,o=[],s=t.length,i=r.charCodeAt(0),a=r.length>1?r.charCodeAt(1):-1;for(let c=e;c<s;c++){let l=t.charCodeAt(c);if(n)l===n&&(n=0);else if(l===34||l===39)n=l;else if(l===i)if(a!==-1){if(t.charCodeAt(c+1)===a)return{data:String.fromCharCode(...o),index:c}}else return{data:String.fromCharCode(...o),index:c};else if(l===9){o.push(32);continue}o.push(l)}}function Or(t,e,r,n){let o=t.indexOf(e,r);if(o===-1)throw new Error(n);return o+e.length-1}function lM(t,e,r,n){let o=t.indexOf(e,r);if(o===-1)throw new Error(n);return o}function ic(t,e,r,n=">"){let o=cM(t,e+1,n);if(!o)return;let s=o.data,i=o.index,a=s.search(/\s/),c=s,l=!0;a!==-1&&(c=s.substring(0,a),s=s.substring(a+1).trimStart());let f=c;if(r){let u=c.indexOf(":");u!==-1&&(c=c.substr(u+1),l=c!==o.data.substr(u+1))}return{tagName:c,tagExp:s,closeIndex:i,attrExpPresent:l,rawTagName:f}}function fM(t,e,r){let n=r,o=1,s=t.length;for(;r<s;r++)if(t[r]==="<"){let i=t.charCodeAt(r+1);if(i===47){let a=lM(t,">",r,`${e} is not closed`);if(t.substring(r+2,a).trim()===e&&(o--,o===0))return{tagContent:t.substring(n,r),i:a};r=a}else if(i===63)r=Or(t,"?>",r+1,"StopNode is not closed.");else if(i===33&&t.charCodeAt(r+2)===45&&t.charCodeAt(r+3)===45)r=Or(t,"-->",r+3,"StopNode is not closed.");else if(i===33&&t.charCodeAt(r+2)===91)r=Or(t,"]]>",r,"StopNode is not closed.")-2;else{let a=ic(t,r,">");a&&((a&&a.tagName)===e&&a.tagExp[a.tagExp.length-1]!=="/"&&o++,r=a.closeIndex)}}}function ac(t,e,r){if(e&&typeof t=="string"){let n=t.trim();return n==="true"?!0:n==="false"?!1:nc(t,r)}else return ip(t)?t:""}function mp(t,e,r){let n=Number.parseInt(t,e);return n>=0&&n<=1114111?String.fromCodePoint(n):r+t+";"}function sc(t,e,r,n){if(t){let o=t(e);r===e&&(r=o),e=o}return e=gp(e,n),{tagName:e,tagExp:r}}function gp(t,e){if(Cs.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return Ln.includes(t)?e.onDangerousProperty(t):t}var cc=ve.getMetaDataSymbol();function uM(t,e){if(!t||typeof t!="object")return{};if(!e)return t;let r={};for(let n in t)if(n.startsWith(e)){let o=n.substring(e.length);r[o]=t[n]}else r[n]=t[n];return r}function lc(t,e,r,n){return Ap(t,e,r,n)}function Ap(t,e,r,n){let o,s={};for(let i=0;i<t.length;i++){let a=t[i],c=hM(a);if(c!==void 0&&c!==e.textNodeName){let l=uM(a[":@"]||{},e.attributeNamePrefix);r.push(c,l)}if(c===e.textNodeName)o===void 0?o=a[c]:o+=""+a[c];else{if(c===void 0)continue;if(a[c]){let l=Ap(a[c],e,r,n),f=dM(l,e);if(a[":@"]?pM(l,a[":@"],n,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),a[cc]!==void 0&&typeof l=="object"&&l!==null&&(l[cc]=a[cc]),s[c]!==void 0&&Object.prototype.hasOwnProperty.call(s,c))Array.isArray(s[c])||(s[c]=[s[c]]),s[c].push(l);else{let u=e.jPath?n.toString():n;e.isArray(c,u,f)?s[c]=[l]:s[c]=l}c!==void 0&&c!==e.textNodeName&&r.pop()}}}return typeof o=="string"?o.length>0&&(s[e.textNodeName]=o):o!==void 0&&(s[e.textNodeName]=o),s}function hM(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let n=e[r];if(n!==":@")return n}}function pM(t,e,r,n){if(e){let o=Object.keys(e),s=o.length;for(let i=0;i<s;i++){let a=o[i],c=a.startsWith(n.attributeNamePrefix)?a.substring(n.attributeNamePrefix.length):a,l=n.jPath?r.toString()+"."+c:r;n.isArray(a,l,!0,!0)?t[a]=[e[a]]:t[a]=e[a]}}}function dM(t,e){let{textNodeName:r}=e,n=Object.keys(t).length;return!!(n===0||n===1&&(t[r]||typeof t[r]=="boolean"||t[r]===0))}var Ur=class{constructor(e){this.externalEntities={},this.options=dp(e)}parse(e,r){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let s=up(e,r);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}let n=new On(this.options);n.addExternalEntities(this.externalEntities);let o=n.parseXml(e);return this.options.preserveOrder||o===void 0?o:lc(o,this.options,n.matcher,n.readonlyMatcher)}addEntity(e,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=r}static getMetaDataSymbol(){return ve.getMetaDataSymbol()}};function fc(t,e){if(e?._parser&&e._parser!=="fast-xml-parser")throw new Error(e?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:e?.removeNSPrefix,textNodeName:e?.textNodeName,isArray:(o,s,i,a)=>!!e?.arrayPaths?.some(l=>s===l),...e?._fastXML},n=mM(t,r);return e?.uncapitalizeKeys?_s(n):n}function mM(t,e){return new Ur({ignoreAttributes:!1,attributeNamePrefix:"",...e}).parse(t)}var gM="4.4.3",Ye={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:gM,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:AM,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(t,e)=>fc(new TextDecoder().decode(t),{...Ye.options.xml,...e?.xml}),parseTextSync:(t,e)=>fc(t,{...Ye.options.xml,...e?.xml})};function AM(t){return t.startsWith("<?xml")}async function Oe(t,e,r,n){return n._parse(t,e,r,n)}function H(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var st={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},bM=st.self||st.window||st.global||{},xM=st.window||st.self||st.global||{},TM=st.global||st.self||st.window||{},yM=st.document||{};var Un=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var bp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),SM=bp&&parseFloat(bp[1])||0;var vs=globalThis,MM=globalThis.document||{},Bs=globalThis.process||{},_M=globalThis.console,JF=globalThis.navigator||{};function xp(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function $t(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||xp()}var uc="4.1.1";function Dr(t,e){if(!t)throw new Error(e||"Assertion failed")}function hc(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return Dr(Number.isFinite(e)&&e>=0),e}function Tp(t){let{logLevel:e,message:r}=t;t.logLevel=hc(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let o=typeof t.message;return Dr(o==="string"||o==="object"),Object.assign(t,{args:n},t.opts)}var er=()=>{},Rs=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...n){return this._log("log",e,r,n)}info(e,r,...n){return this._log("info",e,r,n)}once(e,r,...n){return this._log("once",e,r,n,{once:!0})}_log(e,r,n,o,s={}){let i=Tp({logLevel:r,message:n,args:this._buildArgs(r,n,o),opts:s});return this._createLogFunction(e,i,s)}_buildArgs(e,r,n){return[e,r,...n]}_createLogFunction(e,r,n){if(!this._shouldLog(r.logLevel))return er;let o=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&o!==void 0){if(this._onceCache.has(o))return er;this._onceCache.add(o)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=hc(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function CM(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var ws=class{constructor(e,r,n="sessionStorage"){this.storage=CM(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function yp(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function Sp(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Ls;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ls||(Ls={}));var IM=10;function Mp(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ls[t]||Ls.WHITE)}function _p(t,e,r){return!$t&&typeof t=="string"&&(e&&(t=`\x1B[${Mp(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Mp(r)+IM}m${t}\x1B[49m`)),t}function Ep(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),o=t;for(let s of n){let i=o[s];typeof i=="function"&&(e.find(a=>s===a)||(o[s]=i.bind(t)))}}function Vr(){let t;if($t()&&vs.performance)t=vs?.performance?.now?.();else if("hrtime"in Bs){let e=Bs?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Gr={debug:$t()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},pc={enabled:!0,level:0},dt=class extends Rs{constructor({id:e}={id:""}){super({level:0}),this.VERSION=uc,this._startTs=Vr(),this._deltaTs=Vr(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new ws(`__probe-${this.id}__`,{[this.id]:pc}),this.timeStamp(`${this.id} started`),Ep(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Vr()-this._startTs).toPrecision(10))}getDelta(){return Number((Vr()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:Gr.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:Gr.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...n){return this._log("log",e,r,n,{method:Gr.log,time:!0,once:!0})}log(e,r,...n){return this._log("log",e,r,n,{method:Gr.debug})}info(e,r,...n){return this._log("info",e,r,n,{method:console.info})}once(e,r,...n){return this._log("once",e,r,n,{method:Gr.debug||Gr.info,once:!0})}table(e,r,n){return r?this._log("table",e,r,n&&[n]||[],{method:console.table||er,tag:BM(r)}):er}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||er})}group(e,r,n={collapsed:!1}){let o=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:o})}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||er})}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let n=r.method;Dr(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Vr();let o=vM(this.id,r.message,r);return n.bind(console,o,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(pc),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...pc};this._storage.setConfiguration({[this.id]:{...r,...e}})}};dt.VERSION=uc;function vM(t,e,r){if(typeof e=="string"){let n=r.time?Sp(yp(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=_p(e,r.color,r.background)}return e}function BM(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var dc=new dt({id:"@probe.gl/log"});var mc="4.4.3",RM=mc[0]>="0"&&mc[0]<="9"?`v${mc}`:"";function wM(){let t=new dt({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=RM,globalThis.probe||={},globalThis.probe.loaders=t,t}var gc=wM();var Cp=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer;function Dn(t,e){return Ip(t||{},e)}function Ip(t,e,r=0){if(r>3)return e;let n={...t};for(let[o,s]of Object.entries(e))s&&typeof s=="object"&&!Array.isArray(s)?n[o]=Ip(n[o]||{},e[o],r+1):n[o]=e[o];return n}function Ac(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function bc(t){return globalThis.loaders?.modules?.[t]||null}function LM(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.3"),globalThis._loadersgl_.version}var vp=LM();function Bp(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var it={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},LP=it.self||it.window||it.global||{},FP=it.window||it.self||it.global||{},PP=it.global||it.self||it.window||{},NP=it.document||{};var mt=typeof process!="object"||String(process)!=="[object process]"||process.browser,Vn=typeof importScripts=="function",OP=typeof window<"u"&&typeof window.orientation<"u",Rp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),UP=Rp&&parseFloat(Rp[1])||0;var xc={};function Gn(t={}){let e=t.useLocalLibraries??t.core?.useLocalLibraries,r=t.CDN??t.core?.CDN,n=t.modules;return{...e!==void 0?{useLocalLibraries:e}:{},...r!==void 0?{CDN:r}:{},...n!==void 0?{modules:n}:{}}}async function Ve(t,e=null,r={},n=null){return e&&(t=wp(t,e,r,n)),xc[t]=xc[t]||FM(t),await xc[t]}function wp(t,e,r={},n=null){if(r?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!r.useLocalLibraries&&t.startsWith("http"))return t;n=n||t;let o=r.modules||{};return o[n]?o[n]:mt?r.CDN?(Bp(r.CDN.startsWith("http")),`${r.CDN}/${e}@${vp}/dist/libs/${n}`):Vn?`../src/libs/${n}`:`modules/${e}/src/libs/${n}`:`modules/${e}/dist/libs/${n}`}async function FM(t){if(t.endsWith("wasm"))return await NM(t);if(!mt){let{requireFromFile:r}=globalThis.loaders||{};try{let n=await r?.(t);return n||!t.includes("/dist/libs/")?n:await r?.(t.replace("/dist/libs/","/src/libs/"))}catch(n){if(t.includes("/dist/libs/"))try{return await r?.(t.replace("/dist/libs/","/src/libs/"))}catch{}return console.error(n),null}}if(Vn)return importScripts(t);let e=await OM(t);return PM(e,t)}function PM(t,e){if(!mt){let{requireFromString:n}=globalThis.loaders||{};return n?.(t,e)}if(Vn)return eval.call(globalThis,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function NM(t){let{readFileAsArrayBuffer:e}=globalThis.loaders||{};if(mt||!e||t.startsWith("http"))return await(await fetch(t)).arrayBuffer();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${t}`)}}async function OM(t){let{readFileAsText:e}=globalThis.loaders||{};if(mt||!e||t.startsWith("http"))return await(await fetch(t)).text();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${t}`)}}function Fp(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?Lp(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?Lp(t,0,e):""}function Lp(t,e,r){if(t.byteLength<=e+r)return"";let n=new DataView(t),o="";for(let s=0;s<r;s++)o+=String.fromCharCode(n.getUint8(e+s));return o}function Tc(t){try{return JSON.parse(t)}catch{throw new Error(`Failed to parse JSON from data starting with "${Fp(t)}"`)}}function Hn(...t){let e=t,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let n=e.reduce((i,a)=>i+a.length,0),o=new r(n),s=0;for(let i of e)o.set(i,s),s+=i.length;return o}function tr(t,e,r){let n=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(n).buffer}function Lt(t,e){return H(t>=0),H(e>0),t+(e-1)&~(e-1)}function yc(t,e,r){let n;if(t instanceof ArrayBuffer)n=new Uint8Array(t);else{let o=t.byteOffset,s=t.byteLength;n=new Uint8Array(t.buffer||t.arrayBuffer,o,s)}return e.set(n,r),r+Lt(n.byteLength,4)}function kn(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var rr=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=kn(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(kn()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Ft=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,o=this.stats[r];return o||(e instanceof rr?o=e:o=new rr(r,n),this.stats[r]=o),o}};var UM="Queued Requests",DM="Active Requests",VM="Cancelled Requests",GM="Queued Requests Ever",HM="Active Requests Ever",kM={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Pt=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...kM,...e},this.stats=new Ft({id:this.props.id}),this.stats.get(UM),this.stats.get(DM),this.stats.get(VM),this.stats.get(GM),this.stats.get(HM)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},o=new Promise(s=>(n.resolve=s,n));return this.requestQueue.push(n),this.requestMap.set(e,o),this._issueNewRequests(),o}_issueRequest(e){let{handle:r,resolve:n}=e,o=!1,s=()=>{o||(o=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:s}):Promise.resolve({done:s})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var zM="",Pp={};function Np(t){for(let e in Pp)if(t.startsWith(e)){let r=Pp[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${zM}${t}`),t}function Nt(t){if(t instanceof ArrayBuffer)return t;if(Cp(t))return zn(t);let{buffer:e,byteOffset:r,byteLength:n}=t;return e instanceof ArrayBuffer&&r===0&&n===e.byteLength?e:zn(e,r,n)}function zn(t,e=0,r=t.byteLength-e){let n=new Uint8Array(t,e,r),o=new Uint8Array(n.length);return o.set(n),o.buffer}var Ot={};Ae(Ot,{dirname:()=>jM,filename:()=>qM,join:()=>JM,resolve:()=>WM});function Op(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function qM(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function jM(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function JM(...t){return t=t.map((r,n)=>(n&&(r=r.replace(new RegExp("^/"),"")),n!==t.length-1&&(r=r.replace(new RegExp("/$"),"")),r)),t.join("/")}function WM(...t){let e=[];for(let s=0;s<t.length;s++)e[s]=t[s];let r="",n=!1,o;for(let s=e.length-1;s>=-1&&!n;s--){let i;s>=0?i=e[s]:(o===void 0&&(o=Op()),i=o),i.length!==0&&(r=`${i}/${r}`,n=i.charCodeAt(0)===qn)}return r=XM(r,!n),n?`/${r}`:r.length>0?r:"."}var qn=47,Sc=46;function XM(t,e){let r="",n=-1,o=0,s,i=!1;for(let a=0;a<=t.length;++a){if(a<t.length)s=t.charCodeAt(a);else{if(s===qn)break;s=qn}if(s===qn){if(!(n===a-1||o===1))if(n!==a-1&&o===2){if(r.length<2||!i||r.charCodeAt(r.length-1)!==Sc||r.charCodeAt(r.length-2)!==Sc){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==qn;--l);if(l!==c){r=l===-1?"":r.slice(0,l),n=a,o=0,i=!1;continue}}else if(r.length===2||r.length===1){r="",n=a,o=0,i=!1;continue}}e&&(r.length>0?r+="/..":r="..",i=!0)}else{let c=t.slice(n+1,a);r.length>0?r+=`/${c}`:r=c,i=!1}n=a,o=0}else s===Sc&&o!==-1?++o:o=-1}return r}var jn=class t{static defaultOptions={core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}};optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(e,r,n){n?this.options=Dn({...n,core:t.defaultOptions},r):this.options={...r},this.data=e,this.url=typeof e=="string"?Np(e):"",this.loadOptions=YM(this.options.core?.loadOptions),this.fetch=KM(this.loadOptions)}setProps(e){this.options=Object.assign(this.options,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}};function KM(t){let e=t?.core?.fetch;if(e&&typeof e=="function")return(n,o)=>e(n,o);let r=t?.fetch;return r&&typeof r!="function"?n=>fetch(n,r):n=>fetch(n)}function YM(t){let e={...t};t?.core&&(e.core={...t.core});let r=typeof e.baseUri=="string"?e.baseUri:void 0,n=typeof e.baseUrl=="string"?e.baseUrl:void 0;return(r!==void 0||n!==void 0)&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=n??r),delete e.baseUri,delete e.baseUrl),e}var Hr=class{static type="template";static testURL=e=>!1};function Up(t,e){let r=Ye.parseTextSync?.(t,e),n=r?.ServiceExceptionReport?.ServiceException||r?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof n=="string"?n:n.value||n.code||"Unknown error"}var QM="4.4.3",Jn={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:QM,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:ZM,options:{wms:{throwOnError:!1}},parse:async(t,e)=>Mc(new TextDecoder().decode(t),e),parseSync:(t,e)=>Mc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>Mc(t,e)};function ZM(t){return t.startsWith("<?xml")}function Mc(t,e){let r={...Jn.options.wms,...e?.wms},n=Up(t,r),o=r.minimalErrors?n:`WMS Service error: ${n}`;if(r.throwOnError)throw new Error(o);return o}function nr(t){return Array.isArray(t)?t:t?[t]:[]}function Wn(t){let e=nr(t);return e.length>0&&e.every(r=>typeof r=="string")?e:[]}function Xn(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseFloat(t);default:return}}function Fs(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseInt(t,10);default:return}}function or(t){switch(t){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function _c(t,e){let r=Ye.parseTextSync?.(t,e),n=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,o=$M(n);if(e?.inheritedLayerProps)for(let s of o.layers)Vp(s,null);return e?.includeRawJSON&&(o.json=n),e?.includeXMLText&&(o.xml=t),o}function $M(t){let e={version:String(t.version||""),name:String(t.Service?.Name||"unnamed"),title:t.Service?.Title?String(t.Service?.Title):void 0,abstract:t.Service?.Abstract?String(t.Service?.Abstract):void 0,keywords:Wn(t.Service?.KeywordList?.Keyword),fees:t.Service?.Fees?JSON.stringify(t.Service?.Fees):void 0,accessConstraints:t.Service?.AccessConstraints?JSON.stringify(t.Service?.AccessConstraints):void 0,layerLimit:Fs(t.Service?.LayerLimit),maxWidth:Fs(t.Service?.maxWidth),maxHeight:Fs(t.Service?.maxHeight),layers:[],requests:e_(t.Capability?.Request),exceptions:t_(t.Exception)},r=nr(t.Capability?.Layer);for(let n of r)e.layers.push(Dp(n));for(let[n,o]of Object.entries(e))o===void 0&&delete e[n];return e}function e_(t){let e={};for(let[r,n]of Object.entries(t||{})){let o=Wn(n?.Format);e[r]={mimeTypes:o}}return e}function t_(t){if(nr(t?.Format).length>0)return{mimeTypes:Wn(t)}}function Dp(t){let e={title:String(t?.Title||""),name:t?.Name&&String(t?.Name),abstract:t?.Name&&String(t?.Abstract),keywords:Wn(t.KeywordList?.Keyword)},r=t?.CRS||t?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(e.crs=r);let n=t?.EX_GeographicBoundingBox&&r_(t?.EX_GeographicBoundingBox);n&&(e.geographicBoundingBox=n),n=t?.LatLonBoundingBox&&n_(t?.LatLonBoundingBox),n&&(e.geographicBoundingBox=n);let o=t?.BoundingBox&&o_(t?.BoundingBox);o&&o.length>0&&(e.boundingBoxes=o);let i=nr(t?.Dimension).map(l=>i_(l));i.length&&(e.dimensions=i),t?.opaque&&(e.opaque=or(t?.opaque)),t?.cascaded&&(e.cascaded=or(t?.cascaded)),t?.queryable&&(e.queryable=or(t?.queryable));let a=nr(t?.Layer),c=[];for(let l of a)c.push(Dp(l));c.length>0&&(e.layers=c);for(let[l,f]of Object.entries(e))f===void 0&&delete e[l];return e}function r_(t){let{westBoundLongitude:e,northBoundLatitude:r,eastBoundLongitude:n,southBoundLatitude:o}=t;return[[e,o],[n,r]]}function n_(t){let{minx:e,miny:r,maxx:n,maxy:o}=t;return[[e,r],[n,o]]}function o_(t){return nr(t).map(r=>s_(r))}function s_(t){let{CRS:e,SRS:r,minx:n,miny:o,maxx:s,maxy:i,resx:a,resy:c}=t,l={crs:e||r,boundingBox:[[Xn(n),Xn(o)],[Xn(s),Xn(i)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function i_(t){let{name:e,units:r,value:n}=t,o={name:e,units:r,extent:n};return t.unitSymbol&&(o.unitSymbol=t.unitSymbol),t.default&&(o.defaultValue=t.default),t.multipleValues&&(o.multipleValues=or(t.multipleValues)),t.nearestValue&&(o.nearestValue=or(t.nearestValue)),t.current&&(o.current=or(t.current)),o}function Vp(t,e){e?.geographicBoundingBox&&!t.geographicBoundingBox&&(t.geographicBoundingBox=[...e.geographicBoundingBox]),e?.crs&&!t.crs&&(t.crs=[...e.crs]),e?.boundingBoxes&&!t.boundingBoxes&&(t.boundingBoxes=[...e.boundingBoxes]),e?.dimensions&&!t.dimensions&&(t.dimensions=[...e.dimensions]);for(let r of t.layers||[])Vp(r,t)}var a_="4.4.3",kr={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:a_,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:c_,options:{wms:{}},parse:async(t,e)=>_c(new TextDecoder().decode(t),e?.wms),parseTextSync:(t,e)=>_c(t,e?.wms)};function c_(t){return t.startsWith("<?xml")}function Ec(t,e){let n=(Ye.parseTextSync?.(t,e)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(n)?n:[n]).map(s=>l_(s))}}function l_(t){return{attributes:t||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var Gp={...kr,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(t,e)=>Ec(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>Ec(t,e)};function Cc(t,e){return Ye.parseTextSync?.(t,e)}var Hp={...kr,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(t,e)=>Cc(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>Cc(t,e)};var kp="4.4.3";var f_=globalThis.loaders?.parseImageNode,Ic=typeof Image<"u",vc=typeof ImageBitmap<"u",u_=!!f_,Bc=Un?!0:u_;function zp(t){switch(t){case"auto":return vc||Ic||Bc;case"imagebitmap":return vc;case"image":return Ic;case"data":return Bc;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function qp(){if(vc)return"imagebitmap";if(Ic)return"image";if(Bc)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function jp(t){let e=h_(t);if(!e)throw new Error("Not an image");return e}function Kn(t){switch(jp(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function h_(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var p_=/^data:image\/svg\+xml/,d_=/\.svg((\?|#).*)?$/;function Ps(t){return t&&(p_.test(t)||d_.test(t))}function Jp(t,e){if(Ps(e)){let n=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(s){throw new Error(s.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return Rc(t,e)}function Rc(t,e){if(Ps(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function Ns(t,e,r){let n=Jp(t,r),o=self.URL||self.webkitURL,s=typeof n!="string"&&o.createObjectURL(n);try{return await m_(s||n,e)}finally{s&&o.revokeObjectURL(s)}}async function m_(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,o)=>{try{r.onload=()=>n(r),r.onerror=s=>{let i=s instanceof Error?s.message:"error";o(new Error(i))}}catch(s){o(s)}})}var Wp=!0;async function Xp(t,e,r){let n;Ps(r)?n=await Ns(t,e,r):n=Rc(t,r);let o=e&&e.imagebitmap;return await g_(n,o)}async function g_(t,e=null){if((A_(e)||!Wp)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),Wp=!1}return await createImageBitmap(t)}function A_(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Kp(t){return!y_(t,"ftyp",4)||(t[8]&96)===0?null:b_(t)}function b_(t){switch(x_(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function x_(t,e,r){return String.fromCharCode(...t.slice(e,r))}function T_(t){return[...t].map(e=>e.charCodeAt(0))}function y_(t,e,r=0){let n=T_(e);for(let o=0;o<n.length;++o)if(n[o]!==t[o+r])return!1;return!0}var at=!1,Yn=!0;function sr(t){let e=Qn(t);return M_(e)||C_(e)||__(e)||E_(e)||S_(e)}function S_(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=Kp(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function M_(t){let e=Qn(t);return e.byteLength>=24&&e.getUint32(0,at)===2303741511?{mimeType:"image/png",width:e.getUint32(16,at),height:e.getUint32(20,at)}:null}function __(t){let e=Qn(t);return e.byteLength>=10&&e.getUint32(0,at)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Yn),height:e.getUint16(8,Yn)}:null}function E_(t){let e=Qn(t);return e.byteLength>=14&&e.getUint16(0,at)===16973&&e.getUint32(2,Yn)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Yn),height:e.getUint32(22,Yn)}:null}function C_(t){let e=Qn(t);if(!(e.byteLength>=3&&e.getUint16(0,at)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:o}=I_(),s=2;for(;s+9<e.byteLength;){let i=e.getUint16(s,at);if(o.has(i))return{mimeType:"image/jpeg",height:e.getUint16(s+5,at),width:e.getUint16(s+7,at)};if(!n.has(i))return null;s+=2,s+=e.getUint16(s,at)}return null}function I_(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Qn(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function Yp(t,e){let{mimeType:r}=sr(t)||{},n=globalThis.loaders?.parseImageNode;return H(n),await n(t,r)}async function Qp(t,e,r){e=e||{};let o=(e.image||{}).type||"auto",{url:s}=r||{},i=v_(o),a;switch(i){case"imagebitmap":a=await Xp(t,e,s);break;case"image":a=await Ns(t,e,s);break;case"data":a=await Yp(t,e);break;default:H(!1)}return o==="data"&&(a=Kn(a)),a}function v_(t){switch(t){case"auto":case"data":return qp();default:return zp(t),t}}var B_=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],R_=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],w_={image:{type:"auto",decode:!0}},zr={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:kp,mimeTypes:R_,extensions:B_,parse:Qp,tests:[t=>!!sr(new DataView(t))],options:w_};var wc={};function Lc(t){if(wc[t]===void 0){let e=Un?F_(t):L_(t);wc[t]=e}return wc[t]}function L_(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e;return!!globalThis.loaders?.parseImageNode&&r.includes(t)}function F_(t){switch(t){case"image/avif":case"image/webp":return P_(t);default:return!0}}function P_(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}var Us={name:"Web Map Service (OGC WMS)",id:"wms",module:"wms",version:"0.0.0",extensions:[],mimeTypes:[],type:"wms",fromUrl:!0,fromBlob:!1,defaultOptions:{wms:{}},testURL:t=>t.toLowerCase().includes("wms"),createDataSource:(t,e)=>new Os(t,e)},Os=class extends jn{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,r){super(e,r,Us.defaultOptions),this.substituteCRS84=r.wms?.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...r.wmsParameters,...r.wms?.wmsParameters},this.vendorParameters=r.wms?.vendorParameters||r.vendorParameters||{}}async getMetadata(){let e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){let{boundingBox:r,bbox:n,...o}=e,s={bbox:r?[...r[0],...r[1]]:n,...o};return await this.getMap(s)}normalizeMetadata(e){return e}async getCapabilities(e,r){let n=this.getCapabilitiesURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);let i=await kr.parse(s,this.loadOptions);return this.capabilities=i,i}async getMap(e,r){let n=this.getMapURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);try{return await zr.parse(s,this.loadOptions)}catch{throw this._parseError(s)}}async getFeatureInfo(e,r){let n=this.getFeatureInfoURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),await Gp.parse(s,this.loadOptions)}async getFeatureInfoText(e,r){let n=this.getFeatureInfoURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),new TextDecoder().decode(s)}async describeLayer(e,r){let n=this.describeLayerURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();return this._checkResponse(o,s),await Hp.parse(s,this.loadOptions)}async getLegendGraphic(e,r){let n=this.getLegendGraphicURL(e,r),o=await this.fetch(n),s=await o.arrayBuffer();this._checkResponse(o,s);try{return await zr.parse(s,this.loadOptions)}catch{throw this._parseError(s)}}getCapabilitiesURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",n,r)}getMapURL(e,r){e=this._getWMS130Parameters(e);let n={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetMap",n,r)}getFeatureInfoURL(e,r){e=this._getWMS130Parameters(e);let{boundingBox:n,bbox:o}=e;e.bbox=n?[...n[0],...n[1]]:o;let s={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",s,r)}describeLayerURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",n,r)}getLegendGraphicURL(e,r){let n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",n,r)}_parseWMSUrl(e){let[r,n]=e.split("?"),o=n.split("&"),s={};for(let i of o){let[a,c]=i.split("=");s[a]=c}return{url:r,parameters:s}}_getWMSUrl(e,r,n){let o=this.url,s=!0,i={service:"WMS",version:r.version,request:e,...r,...this.vendorParameters,...n},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(i))(!a.includes(c)||l)&&(o+=s?"?":"&",s=!1,o+=this._getURLParameter(c,l,r));return encodeURI(o)}_getWMS130Parameters(e){let r={...e};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(e,r,n){switch(e){case"crs":n.version!=="1.3.0"?e="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":n.version==="1.3.0"&&(e="crs");break;case"bbox":let o=this._flipBoundingBox(r,n);o&&(r=o);break;case"x":n.version==="1.3.0"&&(e="i");break;case"y":n.version==="1.3.0"&&(e="j");break;default:}return e=e.toUpperCase(),Array.isArray(r)?`${e}=${r.join(",")}`:`${e}=${r?String(r):""}`}_flipBoundingBox(e,r){if(!Array.isArray(e)||e.length!==4)return null;let n=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),o=e;return n?[o[1],o[0],o[3],o[2]]:o}async _fetchArrayBuffer(e){let r=await this.fetch(e),n=await r.arrayBuffer();return this._checkResponse(r,n),n}_checkResponse(e,r){let n=e.headers["content-type"];if(!e.ok||Jn.mimeTypes.includes(n)){let o=Dn(this.loadOptions,{wms:{throwOnError:!0}}),s=Jn.parseSync?.(r,o);throw new Error(s)}}_parseError(e){let r=Jn.parseSync?.(e,this.options.core?.loadOptions);return new Error(r)}};function Ds(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Qe=Math.PI,td=Qe/4,Zp=Qe/180,$p=180/Qe,Vs=512;function gt(t){let[e,r]=t;Ds(Number.isFinite(e)),Ds(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let n=e*Zp,o=r*Zp,s=Vs*(n+Qe)/(2*Qe),i=Vs*(Qe+Math.log(Math.tan(td+o*.5)))/(2*Qe);return[s,i]}function At(t){let[e,r]=t,n=e/Vs*(2*Qe)-Qe,o=2*(Math.atan(Math.exp(r/Vs*(2*Qe)-Qe))-td);return[n*$p,o*$p]}var bU=Math.PI/180;var nd=6378137*Math.PI;function Fc(t){let e=gt(t);return e[0]=(e[0]/256-1)*nd,e[1]=(e[1]/256-1)*nd,e}var Y_={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(t,e)=>console.error(e,t)}},qr=class extends ir.CompositeLayer{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:r,oldProps:n}){let{viewport:o}=this.context;e.dataChanged||r.serviceType!==n.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(o,"image source changed"),0)):(0,ir._deepEqual)(r.layers,n.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(o,"viewport changed")):this.debounce(()=>this.loadImage(o,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:e,image:r,lastRequestParameters:n}=this.state;return r&&new od.BitmapLayer({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:n.srs==="EPSG:4326"?ir.COORDINATE_SYSTEM.LNGLAT:ir.COORDINATE_SYSTEM.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,r){let{lastRequestParameters:n}=this.state;return n?await this.state.imageSource.getFeatureInfoText?.({...n,query_layers:n.layers,x:e,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(e){if(e.data instanceof Hr)return e.data;if(typeof e.data=="string")return(0,sd.createDataSource)(e.data,[Us],{core:{type:e.serviceType,loadOptions:e.loadOptions}});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:e}=this.state;try{this.state.loadCounter++;let r=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(e,r){let{layers:n,serviceType:o}=this.props;if(o==="wms"&&n.length===0)return;let s=e.getBounds(),{width:i,height:a}=e,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=e.resolution?"EPSG:4326":"EPSG:3857");let f={width:i,height:a,boundingBox:[[s[0],s[1]],[s[2],s[3]]],layers:n,crs:l};if(l==="EPSG:3857"){let u=Fc([s[0],s[1]]),h=Fc([s[2],s[3]]);f.boundingBox=[u,h]}try{this.state.loadCounter++,this.props.onImageLoadStart(c);let u=await this.state.imageSource.getImage(f);this.state.lastRequestId<c&&(this.getCurrentLayer()?.props.onImageLoad(c),this.setState({image:u,bounds:s,lastRequestParameters:f,lastRequestId:c}))}catch(u){this.raiseError(u,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(c,u)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,r=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),r)}};qr.layerName="WMSLayer";qr.defaultProps=Y_;var id=U(Je(),1),Q_={getHeight:{type:"accessor",value:0},greatCircle:!0},Zn=class extends id.ArcLayer{};Zn.layerName="GreatCircleLayer";Zn.defaultProps=Q_;var ad=Zn;var Gs=U(Pc(),1),Z_=3,$_=30,eE=2*$_+1,ld=180/Math.PI;function ud(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function fd(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function hd(t){return[fd(t[0]),fd(t[1])]}function pd(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function dd([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*ld,n*ld]}function md(t){let e=Gs.default.fromString(t,!0,10).toString(2);for(;e.length<Z_+eE;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),o=e.substring(3,r),s=o.length/2,i=Gs.default.fromString(n,!0,2).toString(10),a=Gs.default.fromString(o,!0,2).toString(4);for(;a.length<s;)a="0"+a;return`${i}/${a}`}function tE(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let o=e[0];e[0]=e[1],e[1]=o}}function gd(t){let e=t.split("/"),r=parseInt(e[0],10),n=e[1],o=n.length,s=[0,0],i;for(let a=o-1;a>=0;a--){i=o-a;let c=n[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,i-1);tE(u,s,l,f),s[0]+=u*l,s[1]+=u*f}if(r%2===1){let a=s[0];s[0]=s[1],s[1]=a}return{face:r,ij:s,level:i}}var Ad=U(Pc(),1);function rE(t){let e=t.padEnd(16,"0");return Ad.default.fromString(e,16)}var nE=100;function oE({face:t,ij:e,level:r}){let n=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(nE*Math.pow(2,-r))),s=new Float64Array(4*o*2+2),i=0,a=0;for(let c=0;c<4;c++){let l=n[c].slice(0),f=n[c+1],u=(f[0]-l[0])/o,h=(f[1]-l[1])/o;for(let p=0;p<o;p++){l[0]+=u,l[1]+=h;let d=ud(e,r,l),m=hd(d),g=pd(t,m),b=dd(g);Math.abs(b[1])>89.999&&(b[0]=a);let T=b[0]-a;b[0]+=T>180?-360:T<-180?360:0,s[i++]=b[0],s[i++]=b[1],a=b[0]}}return s[i++]=s[0],s[i++]=s[1],s}function sE(t){if(typeof t=="string"){if(t.indexOf("/")>0)return t;t=rE(t)}return md(t.toString())}function bd(t){let e=sE(t),r=gd(e);return oE(r)}var iE={getS2Token:{type:"accessor",value:t=>t.token}},eo=class extends De{indexToBounds(){let{data:e,getS2Token:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,o)=>bd(r(n,o))}}};eo.layerName="S2Layer";eo.defaultProps=iE;var xd=eo;var Nc=512;function aE(t,e){let r=0,n=0,o=1<<t.length,s=o/Nc;for(let i=0;i<t.length;i++){o>>=1;let a=parseInt(t[i]);a%2&&(r|=o),a>1&&(n|=o)}return[[r/s,Nc-n/s],[(r+e)/s,Nc-(n+e)/s]]}function Td(t,e=1){let[r,n]=aE(t,e),[o,s]=At(r),[i,a]=At(n);return[i,s,i,a,o,a,o,s,i,s]}var cE={getQuadkey:{type:"accessor",value:t=>t.quadkey}},to=class extends De{indexToBounds(){let{data:e,extruded:r,getQuadkey:n}=this.props,o=r?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(s,i)=>Td(n(s,i),o),updateTriggers:{getPolygon:o}}}};to.layerName="QuadkeyLayer";to.defaultProps=cE;var yd=to;var Ws=U(We(),1),Hd=U(Je(),1);var ar=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,getRequestPriority:r,requestScheduler:n,onLoad:o,onError:s}){let{index:i,id:a,bbox:c,userData:l,zoom:f}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:h}=this._abortController,p=await n.scheduleRequest(this,r);if(!p){this._isCancelled=!0;return}if(this._isCancelled){p.done();return}let d=null,m;try{d=await e({index:i,id:a,bbox:c,userData:l,zoom:f,signal:h})}catch(g){m=g||!0}finally{p.done()}if(u===this._loaderId){if(this._loader=void 0,this.content=d,this._isCancelled&&!d){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,m?s(m,this):o(this)}}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var oo=U(We(),1);var ae={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var Sd=new x,lE=new x,jr=class t{constructor(e=[0,0,0],r=[0,0,0],n){n=n||Sd.copy(e).add(r).scale(.5),this.center=new x(n),this.halfDiagonal=new x(r).subtract(this.center),this.minimum=new x(e),this.maximum=new x(r)}clone(){return new t(this.minimum,this.maximum,this.center)}equals(e){return this===e||!!e&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){let{halfDiagonal:r}=this,n=lE.from(e.normal),o=r.x*Math.abs(n.x)+r.y*Math.abs(n.y)+r.z*Math.abs(n.z),s=this.center.dot(n)+e.distance;return s-o>0?ae.INSIDE:s+o<0?ae.OUTSIDE:ae.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=Sd.from(e).subtract(this.center),{halfDiagonal:n}=this,o=0,s;return s=Math.abs(r.x)-n.x,s>0&&(o+=s*s),s=Math.abs(r.y)-n.y,s>0&&(o+=s*s),s=Math.abs(r.z)-n.z,s>0&&(o+=s*s),o}};var ro=new x,Md=new x,ct=class t{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new x,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=ro.from(r),this.center=new x().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||!!e&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new t(this.center,this.radius)}union(e){let r=this.center,n=this.radius,o=e.center,s=e.radius,i=ro.copy(o).subtract(r),a=i.magnitude();if(n>=a+s)return this.clone();if(s>=a+n)return e.clone();let c=(n+a+s)*.5;return Md.copy(i).scale((-n+c)/a).add(r),this.center.copy(Md),this.radius=c,this}expand(e){let n=ro.from(e).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(e){this.center.transform(e);let r=xs.getScaling(ro,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let n=ro.from(e).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(e){let r=this.center,n=this.radius,s=e.normal.dot(r)+e.distance;return s<-n?ae.OUTSIDE:s<n?ae.INTERSECTING:ae.INSIDE}};var fE=new x,uE=new x,Hs=new x,ks=new x,zs=new x,hE=new x,pE=new x,bt={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},xt=class t{constructor(e=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new x().from(e),this.halfAxes=new z(r)}get halfSize(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new x(e).len(),new x(r).len(),new x(n).len()]}get quaternion(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),o=new x(e).normalize(),s=new x(r).normalize(),i=new x(n).normalize();return new ot().fromMatrix3(new z([...o,...s,...i]))}fromCenterHalfSizeQuaternion(e,r,n){let o=new ot(n),s=new z().fromQuaternion(o);return s[0]=s[0]*r[0],s[1]=s[1]*r[0],s[2]=s[2]*r[0],s[3]=s[3]*r[1],s[4]=s[4]*r[1],s[5]=s[5]*r[1],s[6]=s[6]*r[2],s[7]=s[7]*r[2],s[8]=s[8]*r[2],this.center=new x().from(e),this.halfAxes=s,this}clone(){return new t(this.center,this.halfAxes)}equals(e){return this===e||!!e&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new ct){let r=this.halfAxes,n=r.getColumn(0,Hs),o=r.getColumn(1,ks),s=r.getColumn(2,zs),i=fE.copy(n).add(o).add(s);return e.center.copy(this.center),e.radius=i.magnitude(),e}intersectPlane(e){let r=this.center,n=e.normal,o=this.halfAxes,s=n.x,i=n.y,a=n.z,c=Math.abs(s*o[bt.COLUMN0ROW0]+i*o[bt.COLUMN0ROW1]+a*o[bt.COLUMN0ROW2])+Math.abs(s*o[bt.COLUMN1ROW0]+i*o[bt.COLUMN1ROW1]+a*o[bt.COLUMN1ROW2])+Math.abs(s*o[bt.COLUMN2ROW0]+i*o[bt.COLUMN2ROW1]+a*o[bt.COLUMN2ROW2]),l=n.dot(r)+e.distance;return l<=-c?ae.OUTSIDE:l>=c?ae.INSIDE:ae.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=uE.from(e).subtract(this.center),n=this.halfAxes,o=n.getColumn(0,Hs),s=n.getColumn(1,ks),i=n.getColumn(2,zs),a=o.magnitude(),c=s.magnitude(),l=i.magnitude();o.normalize(),s.normalize(),i.normalize();let f=0,u;return u=Math.abs(r.dot(o))-a,u>0&&(f+=u*u),u=Math.abs(r.dot(s))-c,u>0&&(f+=u*u),u=Math.abs(r.dot(i))-l,u>0&&(f+=u*u),f}computePlaneDistances(e,r,n=[-0,-0]){let o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=this.center,a=this.halfAxes,c=a.getColumn(0,Hs),l=a.getColumn(1,ks),f=a.getColumn(2,zs),u=hE.copy(c).add(l).add(f).add(i),h=pE.copy(u).subtract(e),p=r.dot(h);return o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).add(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).subtract(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),u.copy(i).add(c).subtract(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).add(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).add(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).subtract(l).add(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),i.copy(u).subtract(c).subtract(l).subtract(f),h.copy(u).subtract(e),p=r.dot(h),o=Math.min(p,o),s=Math.max(p,s),n[0]=o,n[1]=s,n}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,Hs);r.transformAsPoint(e);let n=this.halfAxes.getColumn(1,ks);n.transformAsPoint(e);let o=this.halfAxes.getColumn(2,zs);return o.transformAsPoint(e),this.halfAxes=new z([...r,...n,...o]),this}getTransform(){throw new Error("not implemented")}};var _d=new x,Ed=new x,be=class t{constructor(e=[0,0,1],r=0){this.normal=new x,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return he(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=_d.from(e),this.normal.from(r).normalize();let n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,r,n,o){return this.normal.set(e,r,n),he(Me(this.normal.len(),1)),this.distance=o,this}clone(){return new t(this.normal,this.distance)}equals(e){return Me(this.distance,e.distance)&&Me(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=Ed.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,r)}projectPointOntoPlane(e,r=[0,0,0]){let n=_d.from(e),o=this.getPointDistance(n),s=Ed.copy(this.normal).scale(o);return n.subtract(s).to(r)}};var Cd=[new x([1,0,0]),new x([0,1,0]),new x([0,0,1])],Id=new x,dE=new x,Ee=class t{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*Cd.length;let r=e.center,n=e.radius,o=0;for(let s of Cd){let i=this.planes[o],a=this.planes[o+1];i||(i=this.planes[o]=new be),a||(a=this.planes[o+1]=new be);let c=Id.copy(s).scale(-n).add(r);i.fromPointNormal(c,s);let l=Id.copy(s).scale(n).add(r),f=dE.copy(s).negate();a.fromPointNormal(l,f),o+=2}return this}computeVisibility(e){let r=ae.INSIDE;for(let n of this.planes)switch(e.intersectPlane(n)){case ae.OUTSIDE:return ae.OUTSIDE;case ae.INTERSECTING:r=ae.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(he(Number.isFinite(r),"parentPlaneMask is required."),r===t.MASK_OUTSIDE||r===t.MASK_INSIDE)return r;let n=t.MASK_INSIDE,o=this.planes;for(let s=0;s<this.planes.length;++s){let i=s<31?1<<s:0;if(s<31&&(r&i)===0)continue;let a=o[s],c=e.intersectPlane(a);if(c===ae.OUTSIDE)return t.MASK_OUTSIDE;c===ae.INTERSECTING&&(n|=i)}return n}};Ee.MASK_OUTSIDE=4294967295;Ee.MASK_INSIDE=0;Ee.MASK_INDETERMINATE=2147483647;var PD=new x,ND=new x,OD=new x,UD=new x,DD=new x;var qD=new x,jD=new x,JD=new x,WD=new x,XD=new x,KD=new x,YD=new x,QD=new x,ZD=new x,$D=new x,eV=new x,tV=new x;var lt=new z,gE=new z,AE=new z,qs=new z,vd=new z;function Dc(t,e={}){let r=Ke.EPSILON20,n=10,o=0,s=0,i=gE,a=AE;i.identity(),a.copy(t);let c=r*bE(a);for(;s<n&&xE(a)>c;)TE(a,qs),vd.copy(qs).transpose(),a.multiplyRight(qs),a.multiplyLeft(vd),i.multiplyRight(qs),++o>2&&(++s,o=0);return e.unitary=i.toTarget(e.unitary),e.diagonal=a.toTarget(e.diagonal),e}function bE(t){let e=0;for(let r=0;r<9;++r){let n=t[r];e+=n*n}return Math.sqrt(e)}var Oc=[1,0,0],Uc=[2,2,1];function xE(t){let e=0;for(let r=0;r<3;++r){let n=t[lt.getElementIndex(Uc[r],Oc[r])];e+=2*n*n}return Math.sqrt(e)}function TE(t,e){let r=Ke.EPSILON15,n=0,o=1;for(let l=0;l<3;++l){let f=Math.abs(t[lt.getElementIndex(Uc[l],Oc[l])]);f>n&&(o=l,n=f)}let s=Oc[o],i=Uc[o],a=1,c=0;if(Math.abs(t[lt.getElementIndex(i,s)])>r){let l=t[lt.getElementIndex(i,i)],f=t[lt.getElementIndex(s,s)],u=t[lt.getElementIndex(i,s)],h=(l-f)/2/u,p;h<0?p=-1/(-h+Math.sqrt(1+h*h)):p=1/(h+Math.sqrt(1+h*h)),a=1/Math.sqrt(1+p*p),c=p*a}return z.IDENTITY.to(e),e[lt.getElementIndex(s,s)]=e[lt.getElementIndex(i,i)]=a,e[lt.getElementIndex(i,s)]=c,e[lt.getElementIndex(s,i)]=-c,e}var Ut=new x,yE=new x,SE=new x,ME=new x,_E=new x,EE=new z,CE={diagonal:new z,unitary:new z};function no(t,e=new xt){if(!t||t.length===0)return e.halfAxes=new z([0,0,0,0,0,0,0,0,0]),e.center=new x,e;let r=t.length,n=new x(0,0,0);for(let y of t)n.add(y);let o=1/r;n.multiplyByScalar(o);let s=0,i=0,a=0,c=0,l=0,f=0;for(let y of t){let A=Ut.copy(y).subtract(n);s+=A.x*A.x,i+=A.x*A.y,a+=A.x*A.z,c+=A.y*A.y,l+=A.y*A.z,f+=A.z*A.z}s*=o,i*=o,a*=o,c*=o,l*=o,f*=o;let u=EE;u[0]=s,u[1]=i,u[2]=a,u[3]=i,u[4]=c,u[5]=l,u[6]=a,u[7]=l,u[8]=f;let{unitary:h}=Dc(u,CE),p=e.halfAxes.copy(h),d=p.getColumn(0,SE),m=p.getColumn(1,ME),g=p.getColumn(2,_E),b=-Number.MAX_VALUE,T=-Number.MAX_VALUE,S=-Number.MAX_VALUE,M=Number.MAX_VALUE,C=Number.MAX_VALUE,E=Number.MAX_VALUE;for(let y of t)Ut.copy(y),b=Math.max(Ut.dot(d),b),T=Math.max(Ut.dot(m),T),S=Math.max(Ut.dot(g),S),M=Math.min(Ut.dot(d),M),C=Math.min(Ut.dot(m),C),E=Math.min(Ut.dot(g),E);d=d.multiplyByScalar(.5*(M+b)),m=m.multiplyByScalar(.5*(C+T)),g=g.multiplyByScalar(.5*(E+S)),e.center.copy(d).add(m).add(g);let B=yE.set(b-M,T-C,S-E).multiplyByScalar(.5),_=new z([B[0],0,0,0,B[1],0,0,0,B[2]]);return e.halfAxes.multiplyRight(_),e}var Jr=512,Bd=3,Rd=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],wd=Rd.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),IE=wd.concat([[.25,.5],[.75,.5]]),Vc=class t{constructor(e,r,n){this.x=e,this.y=r,this.z=n}get children(){if(!this._children){let e=this.x*2,r=this.y*2,n=this.z+1;this._children=[new t(e,r,n),new t(e,r+1,n),new t(e+1,r,n),new t(e+1,r+1,n)]}return this._children}update(e){let{viewport:r,cullingVolume:n,elevationBounds:o,minZ:s,maxZ:i,bounds:a,offset:c,project:l}=e,f=this.getBoundingVolume(o,c,l);if(a&&!this.insideBounds(a)||n.computeVisibility(f)<0||l&&this.beyondHorizon(r.cameraPosition,l,o[1]))return!1;if(!this.childVisible){let{z:h}=this;if(h<i&&h>=s){let p=f.distanceTo(r.cameraPosition)*r.scale/r.height;h+=Math.floor(Math.log2(p))}if(h>=i)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let h of this.children)h.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(let r of this._children)r.getSelected(e);return e}beyondHorizon(e,r,n){let o=e[0],s=e[1],i=e[2],a=Math.sqrt(o*o+s*s+i*i),c=Math.atan2(o,-s)*180/Math.PI,l=Math.asin(i/a)*180/Math.PI,[f,u]=Wr(this.x,this.y,this.z),[h,p]=Wr(this.x+1,this.y+1,this.z),d=(f+h)/2,m=d+((c-d+540)%360-180),g=Math.max(f,Math.min(m,h)),b=Math.max(p,Math.min(l,u)),T=r([g,b,n]),S=T[0]*o+T[1]*s+T[2]*i,M=T[0]*T[0]+T[1]*T[1]+T[2]*T[2];return S<=M}insideBounds([e,r,n,o]){let s=Math.pow(2,this.z),i=Jr/s;return this.x*i<n&&this.y*i<o&&(this.x+1)*i>e&&(this.y+1)*i>r}getBoundingVolume(e,r,n){if(n){let c=this.z<1?IE:this.z<2?wd:Rd,l=[];for(let f of c){let u=Wr(this.x+f[0],this.y+f[1],this.z);u[2]=e[0],l.push(n(u)),e[0]!==e[1]&&(u[2]=e[1],l.push(n(u)))}return no(l)}let o=Math.pow(2,this.z),s=Jr/o,i=this.x*s+r*Jr,a=Jr-(this.y+1)*s;return new jr([i,a,e[0]],[i+s,a+s,e[1]])}};function Ld(t,e,r,n){let o=t instanceof oo._GlobeViewport?t.projectPosition:null,s=Object.values(t.getFrustumPlanes()).map(({normal:p,distance:d})=>new be(p.clone().negate(),d)),i=new Ee(s),a=t.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,f=t instanceof oo.WebMercatorViewport&&t.pitch<=60?e:0;if(n){let[p,d,m,g]=n,b=gt([p,g]),T=gt([m,d]);n=[b[0],Jr-b[1],T[0],Jr-T[1]]}let u=new Vc(0,0,0),h={viewport:t,project:o,cullingVolume:i,elevationBounds:[c,l],minZ:f,maxZ:e,bounds:n,offset:0};if(u.update(h),t instanceof oo.WebMercatorViewport&&t.subViewports&&t.subViewports.length>1){for(h.offset=-1;u.update(h)&&!(--h.offset<-Bd););for(h.offset=1;u.update(h)&&!(++h.offset>Bd););}return u.getSelected()}var Tt=512,vE=[-1/0,-1/0,1/0,1/0],Dt={type:"object",value:null,validate:(t,e)=>e.optional&&t===null||typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string"),equal:(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;let r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}};function js(t,e){let r=[e.transformAsPoint([t[0],t[1]]),e.transformAsPoint([t[2],t[1]]),e.transformAsPoint([t[0],t[3]]),e.transformAsPoint([t[2],t[3]])];return[Math.min(...r.map(o=>o[0])),Math.min(...r.map(o=>o[1])),Math.max(...r.map(o=>o[0])),Math.max(...r.map(o=>o[1]))]}function BE(t){return Math.abs(t.split("").reduce((e,r)=>(e<<5)-e+r.charCodeAt(0)|0,0))}function ft(t,e){if(!t||!t.length)return null;let{index:r,id:n}=e;if(Array.isArray(t)){let s=BE(n)%t.length;t=t[s]}let o=t;for(let s of Object.keys(r)){let i=new RegExp(`{${s}}`,"g");o=o.replace(i,String(r[s]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(o=o.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),o}function RE(t,e,r){let n;if(e&&e.length===2){let[o,s]=e,i=t.getBounds({z:o}),a=t.getBounds({z:s});n=[Math.min(i[0],a[0]),Math.min(i[1],a[1]),Math.max(i[2],a[2]),Math.max(i[3],a[3])]}else n=t.getBounds();return t.isGeospatial?[Math.max(n[0],r[0]),Math.max(n[1],r[1]),Math.min(n[2],r[2]),Math.min(n[3],r[3])]:[Math.max(Math.min(n[0],r[2]),r[0]),Math.max(Math.min(n[1],r[3]),r[1]),Math.min(Math.max(n[2],r[0]),r[2]),Math.min(Math.max(n[3],r[1]),r[3])]}function Pd({viewport:t,z:e,cullRect:r}){return(t.subViewports||[t]).map(o=>Gc(o,e||0,r))}function Gc(t,e,r){if(!Array.isArray(e)){let s=r.x-t.x,i=r.y-t.y,{width:a,height:c}=r,l={targetZ:e},f=t.unproject([s,i],l),u=t.unproject([s+a,i],l),h=t.unproject([s,i+c],l),p=t.unproject([s+a,i+c],l);return[Math.min(f[0],u[0],h[0],p[0]),Math.min(f[1],u[1],h[1],p[1]),Math.max(f[0],u[0],h[0],p[0]),Math.max(f[1],u[1],h[1],p[1])]}let n=Gc(t,e[0],r),o=Gc(t,e[1],r);return[Math.min(n[0],o[0]),Math.min(n[1],o[1]),Math.max(n[2],o[2]),Math.max(n[3],o[3])]}function wE(t,e,r){return r?js(t,r).map(o=>o*e/Tt):t.map(n=>n*e/Tt)}function Hc(t,e){return Math.pow(2,t)*Tt/e}function Wr(t,e,r){let n=Hc(r,Tt),o=t/n*360-180,s=Math.PI-2*Math.PI*e/n,i=180/Math.PI*Math.atan(.5*(Math.exp(s)-Math.exp(-s)));return[o,i]}function Fd(t,e,r,n){let o=Hc(r,n);return[t/o*Tt,e/o*Tt]}function kc(t,e,r,n,o=Tt){if(t.isGeospatial){let[l,f]=Wr(e,r,n),[u,h]=Wr(e+1,r+1,n);return{west:l,north:f,east:u,south:h}}let[s,i]=Fd(e,r,n,o),[a,c]=Fd(e+1,r+1,n,o);return{left:s,top:i,right:a,bottom:c}}function LE(t,e,r,n,o){let s=RE(t,null,n),i=Hc(e,r),[a,c,l,f]=wE(s,i,o),u=[];for(let h=Math.floor(a);h<l;h++)for(let p=Math.floor(c);p<f;p++)u.push({x:h,y:p,z:e});return u}function zc({viewport:t,maxZoom:e,minZoom:r,zRange:n,extent:o,tileSize:s=Tt,modelMatrix:i,modelMatrixInverse:a,zoomOffset:c=0,visibleMinZoom:l,visibleMaxZoom:f}){let u=t.isGeospatial?Math.round(t.zoom+Math.log2(Tt/s)+c):Math.ceil(t.zoom+c);if(typeof r=="number"&&Number.isFinite(r)&&u<r){if(!o)return[];u=r}if(typeof e=="number"&&Number.isFinite(e)&&u>e&&(u=e),l!=null&&t.zoom<l)return[];if(f!=null&&t.zoom>f)return[];let h=o;return i&&a&&o&&!t.isGeospatial&&(h=js(o,i)),t.isGeospatial?Ld(t,u,n,o):LE(t,u,s,h||vE,a)}function qc(t){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(t)}function jc(t){return Number.isFinite(t.west)&&Number.isFinite(t.north)&&Number.isFinite(t.east)&&Number.isFinite(t.south)}function Nd(t){let e={},r;return n=>{for(let o in n)if(!FE(n[o],e[o])){r=t(n),e=n;break}return r}}function FE(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}return!1}var Od=1,Js=2,PE="never",NE="no-overlap",so="best-available",OE=5,Dd=0,Vd=1e8,Ud=Vd-Dd-1,UE={[so]:VE,[NE]:GE,[PE]:()=>{}},DE={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}},cr=class{constructor(e){this._getCullBounds=Nd(Pd),this.opts={...DE,...e},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize!==null&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new Pt({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new N,this._modelMatrixInverse=new N}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom)),this._viewport=null}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let e of this._cache.keys()){let r=this._cache.get(e);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(e):r.setNeedsReload()}}update(e,{zRange:r,modelMatrix:n}={zRange:null,modelMatrix:null}){let o=n?new N(n):new N,s=!o.equals(this._modelMatrix);if(!this._viewport||!e.equals(this._viewport)||!Me(this._zRange,r)||s){s&&(this._modelMatrixInverse=o.clone().invert(),this._modelMatrix=o),this._viewport=e,this._zRange=r;let a=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(c=>this._getTile(c,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));let i=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),i&&this._frameNumber++,this._frameNumber}isTileVisible(e,r,n){if(!e.isVisible)return!1;if(r&&this._viewport){let o=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:s}=e;for(let[i,a,c,l]of o){let f;if("west"in s)f=s.west<c&&s.east>i&&s.south<l&&s.north>a;else{if(n&&!N.IDENTITY.equals(n)){let[p,d,m,g]=js([s.left,s.top,s.right,s.bottom],n);s={left:p,top:d,right:m,bottom:g}}let u=Math.min(s.top,s.bottom),h=Math.max(s.top,s.bottom);f=s.left<c&&s.right>i&&u<l&&h>a}if(f)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:r,minZoom:n,zRange:o,modelMatrix:s,modelMatrixInverse:i}){let{tileSize:a,extent:c,zoomOffset:l,visibleMinZoom:f,visibleMaxZoom:u}=this.opts;return zc({viewport:e,maxZoom:r,minZoom:n,zRange:o,tileSize:a,extent:c,modelMatrix:s,modelMatrixInverse:i,zoomOffset:l,visibleMinZoom:f,visibleMaxZoom:u})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){let{tileSize:r}=this.opts;return{bbox:kc(this._viewport,e.x,e.y,e.z,r)}}getParentIndex(e){let r=Math.floor(e.x/2),n=Math.floor(e.y/2),o=e.z-1;return{x:r,y:n,z:o}}updateTileStates(){let e=this.opts.refinementStrategy||so,r=new Array(this._cache.size),n=0;for(let o of this._cache.values())r[n++]=o.isVisible,o.isSelected=!1,o.isVisible=!1;for(let o of this._selectedTiles)o.isSelected=!0,o.isVisible=!0;(typeof e=="function"?e:UE[e])(Array.from(this._cache.values())),n=0;for(let o of this._cache.values())if(r[n++]!==o.isVisible)return!0;return!1}_getRequestPriority(e){if(!e.isSelected&&!e.isVisible)return-1;let r=this._getTileDistancePriority(e);return e.isSelected?Dd+r:Vd+r}_getTileDistancePriority(e){let{width:r,height:n}=this._viewport||{};if(!this._viewport||!r||!n)return 0;try{let o=this._getTileScreenCorners(e.bbox),s=[r/2,n/2];if(o.length===4){if(this._isPointInPolygon(s,o))return 0;let i=o.reduce((a,c,l)=>{let f=o[(l+1)%o.length];return Math.min(a,this._getPointToSegmentDistanceSquared(s,c,f))},Number.MAX_SAFE_INTEGER);return Math.min(i,Ud)}}catch{}return Ud}_getTileScreenCorners(e){return("west"in e?[[e.west,e.south],[e.east,e.south],[e.east,e.north],[e.west,e.north]]:[[e.left,e.top],[e.right,e.top],[e.right,e.bottom],[e.left,e.bottom]]).map(n=>this._viewport.project(n)).filter(([n,o])=>Number.isFinite(n)&&Number.isFinite(o))}_isPointInPolygon(e,r){let n=!1,[o,s]=e;for(let i=0,a=r.length-1;i<r.length;a=i++){let[c,l]=r[i],[f,u]=r[a];l>s!=u>s&&o<(f-c)*(s-l)/(u-l)+c&&(n=!n)}return n}_getPointToSegmentDistanceSquared(e,r,n){let[o,s]=e,[i,a]=r,[c,l]=n,f=c-i,u=l-a,h=f*f+u*u,p=h?Math.max(0,Math.min(1,((o-i)*f+(s-a)*u)/h)):0,d=i+p*f,m=a+p*u,g=o-d,b=s-m;return g*g+b*b}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=[],n=0;for(let o of this._cache.values())o.isLoading&&(n++,!o.isSelected&&!o.isVisible&&r.push(o));for(;e>0&&n>e&&r.length>0;)r.shift().abort(),n--}_rebuildTree(){let{_cache:e}=this;for(let r of e.values())r.parent=null,r.children&&(r.children.length=0);for(let r of e.values()){let n=this._getNearestAncestor(r);r.parent=n,n?.children&&n.children.push(r)}}_resizeCache(){let{_cache:e,opts:r}=this,n=r.maxCacheSize??(r.maxCacheByteSize!==null?1/0:OE*this.selectedTiles.length),o=r.maxCacheByteSize??1/0;if(e.size>n||this._cacheByteSize>o){for(let[i,a]of e)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize!==null?a.byteLength:0,e.delete(i),this.opts.onTileUnload?.(a)),e.size<=n&&this._cacheByteSize<=o)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((i,a)=>i.zoom-a.zoom),this._dirty=!1)}_getTile(e,r){let n=this.getTileId(e),o=this._cache.get(n),s=!1;return!o&&r?(o=new ar(e),Object.assign(o,this.getTileMetadata(o.index)),Object.assign(o,{id:n,zoom:this.getTileZoom(o.index)}),s=!0,this._cache.set(n,o),this._dirty=!0):o&&o.needsReload&&(s=!0),o&&s&&o.loadData({getData:this.opts.getTileData,getRequestPriority:this._getRequestPriority.bind(this),requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),o}_getNearestAncestor(e){let{_minZoom:r=0}=this,n=e.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let o=this._getTile(n);if(o)return o}return null}};function VE(t){for(let e of t)e.state=0;for(let e of t)e.isSelected&&!Gd(e)&&Jc(e);for(let e of t)e.isVisible=!!(e.state&Js)}function GE(t){for(let r of t)r.state=0;for(let r of t)r.isSelected&&Gd(r);let e=Array.from(t).sort((r,n)=>r.zoom-n.zoom);for(let r of e)if(r.isVisible=!!(r.state&Js),r.children&&(r.isVisible||r.state&Od))for(let n of r.children)n.state=Od;else r.isSelected&&Jc(r)}function Gd(t){let e=t;for(;e;){if(e.isLoaded||e.content)return e.state|=Js,!0;e=e.parent}return!1}function Jc(t){for(let e of t.children)e.isLoaded||e.content?e.state|=Js:Jc(e)}var HE={TilesetClass:cr,data:{type:"data",value:[]},dataComparator:Dt.equal,renderSubLayers:{type:"function",value:t=>new Hd.GeoJsonLayer(t)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:t=>console.error(t)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:so,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null},io=class extends Ws.CompositeLayer{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return!!this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&(!e.content||!e.layers||e.layers.every(r=>r.isLoaded)))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:r}=this.state,n=e.propsOrDataChanged||e.updateTriggersChanged,o=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);r?n&&(r.setOptions(this._getTilesetOptions()),o?r.reloadAll():r.tiles.forEach(s=>{s.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:e,maxCacheSize:r,maxCacheByteSize:n,refinementStrategy:o,extent:s,maxZoom:i,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:f,visibleMinZoom:u,visibleMaxZoom:h}=this.props;return{maxCacheSize:r,maxCacheByteSize:n,maxZoom:i,minZoom:a,tileSize:e,refinementStrategy:o,extent:s,maxRequests:c,debounceTime:l,zoomOffset:f,visibleMinZoom:u,visibleMaxZoom:h,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let e=this.state.tileset,{zRange:r,modelMatrix:n}=this.props,o=e.update(this.context.viewport,{zRange:r,modelMatrix:n}),{isLoaded:s}=e,i=this.state.isLoaded!==s,a=this.state.frameNumber!==o;s&&(i||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:o}),this.state.isLoaded=s}_onViewportLoad(){let{tileset:e}=this.state,{onViewportLoad:r}=this.props;r&&r(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,r){this.props.onTileError(e),r.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){let{data:r,getTileData:n,fetch:o}=this.props,{signal:s}=e;return e.url=typeof r=="string"||Array.isArray(r)?ft(r,e):null,n?n(e):o&&e.url?o(e.url,{propName:"data",layer:this,signal:s}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){let r=e.sourceLayer,n=r.props.tile,o=e.info;return o.picked&&(o.tile=n),o.sourceTile=n,o.sourceTileSubLayer=r,o}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){let{visibleMinZoom:e,visibleMaxZoom:r,minZoom:n,extent:o}=this.props,s=this.context.viewport.zoom;if(e!=null&&s<e||r!=null&&s>r||n!=null&&!o&&s<n){for(let a of this.state.tileset.tiles)a.layers=null;return[]}return this.state.tileset.tiles.map(a=>{let c=this.getSubLayerPropsByTile(a);if(!(!a.isLoaded&&!a.content))if(a.layers)c&&a.layers[0]&&Object.keys(c).some(l=>a.layers[0].props[l]!==c[l])&&(a.layers=a.layers.map(l=>l.clone(c)));else{let l=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:a.id,updateTriggers:this.props.updateTriggers}),data:a.content,_offset:0,tile:a});a.layers=(0,Ws._flatten)(l,Boolean).map(f=>f.clone({tile:a,...c}))}return a.layers})}filterSubLayer({layer:e,cullRect:r}){let{tile:n}=e.props,{modelMatrix:o}=this.props;return this.state.tileset.isTileVisible(n,r,o?new N(o):null)}};io.defaultProps=HE;io.layerName="TileLayer";var lr=io;var Jd=U(We(),1),Wd=U(Je(),1);var kE=`struct TripsUniforms {
|
|
11
|
+
fadeTrail: f32,
|
|
12
|
+
trailLength: f32,
|
|
13
|
+
currentTime: f32,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
@group(0) @binding(auto)
|
|
17
|
+
var<uniform> trips: TripsUniforms;
|
|
18
|
+
`,kd=`layout(std140) uniform tripsUniforms {
|
|
11
19
|
bool fadeTrail;
|
|
12
20
|
float trailLength;
|
|
13
21
|
float currentTime;
|
|
14
22
|
} trips;
|
|
15
|
-
`,
|
|
23
|
+
`,zd={name:"trips",source:kE,vs:kd,fs:kd,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};function qd(t,e=t.length,r=!1){let n=new Float32Array(e*2);if(t.length===0)return n;let o=e>t.length,s=r?t.length:Math.max(t.length-1,1);for(let i=0;i<e;i++){let a=o?i%s:Math.min(i,t.length-1),c=o?(a+1)%s:Math.min(a+1,t.length-1);n[i*2]=t[a],n[i*2+1]=t[c]}return n}var jd={" @location(12) rowIndexes: u32,":`
|
|
24
|
+
@location(13) instanceTimestamps: vec2<f32>,`," @location(5) vJointType: f32,":`
|
|
25
|
+
@location(6) vTime: f32,`," attributes.instanceColors.a * layer.opacity\n );":`
|
|
26
|
+
|
|
27
|
+
varyings.vTime = mix(
|
|
28
|
+
attributes.instanceTimestamps.x,
|
|
29
|
+
attributes.instanceTimestamps.y,
|
|
30
|
+
varyings.vPathPosition.y / varyings.vPathLength
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (trips.fadeTrail > 0.5) {
|
|
34
|
+
varyings.vColor.a *=
|
|
35
|
+
1.0 - (trips.currentTime - varyings.vTime) / trips.trailLength;
|
|
36
|
+
}`," // DECKGL_FILTER_COLOR":`
|
|
37
|
+
if (
|
|
38
|
+
varyings.vTime > trips.currentTime ||
|
|
39
|
+
(trips.fadeTrail > 0.5 && varyings.vTime < trips.currentTime - trips.trailLength)
|
|
40
|
+
) {
|
|
41
|
+
discard;
|
|
42
|
+
}`};var zE={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:t=>t.timestamps}},qE={"vs:#decl":`in float instanceTimestamps;
|
|
16
43
|
in float instanceNextTimestamps;
|
|
17
44
|
out float vTime;
|
|
18
45
|
`,"vs:#main-end":`vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;
|
|
19
46
|
`,"fs:#decl":`in float vTime;
|
|
20
|
-
`,"fs
|
|
47
|
+
`,"fs:DECKGL_FILTER_COLOR":`if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {
|
|
21
48
|
discard;
|
|
22
49
|
}
|
|
23
|
-
|
|
50
|
+
if(trips.fadeTrail) {
|
|
24
51
|
color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;
|
|
25
52
|
}
|
|
26
|
-
`},e.modules=[...e.modules,kd],e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){let{fadeTrail:r,trailLength:n,currentTime:o}=this.props,s={fadeTrail:r,trailLength:n,currentTime:o};this.state.model.shaderInputs.setProps({trips:s}),super.draw(e)}};ho.layerName="TripsLayer";ho.defaultProps=U_;var qd=ho;var Jd=D(ls(),1),Wd=D(ot(),1);var ze=D(ls(),1),Ks=D(ot(),1),po=D(Xe(),1);var D_=10;function G_(t,e){let r;return t==null?r=e:typeof t=="object"?r={...t,coverage:e}:r={getHexagon:t,coverage:e},r}var V_={...po.PolygonLayer.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:t=>t.hexagon},extruded:!0},zt=class extends Ks.CompositeLayer{initializeState(){zt._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:r}){if(e.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let n=this._calculateH3DataProps();this.setState(n)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,r=!1,n=!1,{iterable:o,objectInfo:s}=(0,Ks.createIterable)(this.props.data);for(let i of o){s.index++;let a=this.props.getHexagon(i,s),c=(0,ze.getResolution)(a);if(e<0){if(e=c,!this.props.highPrecision)break}else if(e!==c){n=!0;break}if((0,ze.isPentagon)(a)){r=!0;break}}return{resolution:e,edgeLengthKM:e>=0?(0,ze.getHexagonEdgeLengthAvg)(e,"km"):0,hasMultipleRes:n,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:e,hasPentagon:r,hasMultipleRes:n}=this.state,{viewport:o}=this.context;return Boolean(o?.resolution)||n||r||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:n,centerHex:o}=this.state;if(r<0)return;let s=this.props.centerHexagon||(0,ze.latLngToCell)(e.latitude,e.longitude,r);if(o===s)return;if(o)try{if((0,ze.gridDistance)(o,s)*n<D_)return}catch{}let{unitsPerMeter:i}=e.distanceScales,a=rc(s),[c,l]=(0,ze.cellToLatLng)(s),[f,u]=e.projectFlat([l,c]);a=a.map(h=>{let p=e.projectFlat(h);return[(p[0]-f)/i[0],(p[1]-u)/i[1]]}),this.setState({centerHex:s,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:e,material:r,coverage:n,extruded:o,wireframe:s,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,getFillColor:h,getElevation:p,getLineColor:d,getLineWidth:m,transitions:g,updateTriggers:x}=this.props;return{elevationScale:e,extruded:o,coverage:n,wireframe:s,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,material:r,getElevation:p,getFillColor:h,getLineColor:d,getLineWidth:m,transitions:g,updateTriggers:{getFillColor:x.getFillColor,getElevation:x.getElevation,getLineColor:x.getLineColor,getLineWidth:x.getLineWidth}}}_renderPolygonLayer(){let{data:e,getHexagon:r,updateTriggers:n,coverage:o}=this.props,s=this.getSubLayerClass("hexagon-cell-hifi",po.PolygonLayer),i=this._getForwardProps();return i.updateTriggers.getPolygon=G_(n.getHexagon,o),new s(i,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:i.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return _s(rc(l,o))}})}_renderColumnLayer(){let{data:e,getHexagon:r,updateTriggers:n}=this.props,o=this.getSubLayerClass("hexagon-cell",po.ColumnLayer),s=this._getForwardProps();return s.updateTriggers.getPosition=n.getHexagon,new o(s,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:s.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:rp.bind(null,r)})}};zt.defaultProps=V_;zt.layerName="H3HexagonLayer";zt._checkH3Lib=()=>{};var Qs=zt;var H_={getHexagons:{type:"accessor",value:t=>t.hexagons}},mo=class extends De{initializeState(){Qs._checkH3Lib()}updateState({props:e,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:n,getHexagons:o}=e,s=[],{iterable:i,objectInfo:a}=(0,Wd.createIterable)(n);for(let c of i){a.index++;let l=o(c,a),f=(0,Jd.cellsToMultiPolygon)(l,!0);for(let u of f){for(let h of u)Ss(h);s.push(this.getSubLayerRow({polygon:u},c,a.index))}}this.setState({polygons:s})}}indexToBounds(){let{getElevation:e,getFillColor:r,getLineColor:n,getLineWidth:o}=this.props;return{data:this.state.polygons,getPolygon:s=>s.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(n),getLineWidth:this.getSubLayerAccessor(o)}}};mo.layerName="H3ClusterLayer";mo.defaultProps=H_;var Xd=mo;var k0=D(Wc(),1),Wt=D(ot(),1),j0=D(Xe(),1),q0=D(Zs(),1);var Qd="4.4.3";var $s={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},Zd;async function Yc(t){Ac(t.modules);let e=xc("basis");return e||(Zd||=z_(t),await Zd)}async function z_(t){let e=null,r=null;return[e,r]=await Promise.all([await Ve($s.TRANSCODER,"textures",t),await Ve($s.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await k_(e,r)}function k_(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t(r).then(o=>{let{BasisFile:s,initializeBasis:i}=o;i(),n({BasisFile:s})})})}var Xc;async function Kc(t){let e=t.modules||{};return e.basisEncoder?e.basisEncoder:(Xc=Xc||j_(t),await Xc)}async function j_(t){let e=null,r=null;return[e,r]=await Promise.all([await Ve($s.ENCODER,"textures",t),await Ve($s.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await q_(e,r)}function q_(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t(r).then(o=>{let{BasisFile:s,KTX2File:i,initializeBasis:a,BasisEncoder:c}=o;a(),n({BasisFile:s,KTX2File:i,BasisEncoder:c})})})}var J_=["","WEBKIT_","MOZ_"],$d={WEBGL_compressed_texture_s3tc:["bc1-rgb-unorm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rgb-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};var ei=null;function em(t){if(!ei){t=t||W_()||void 0,ei=new Set;for(let e of J_)for(let r in $d)if(t&&t.getExtension(`${e}${r}`))for(let n of $d[r])ei.add(n)}return ei}function W_(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var Ue=[171,75,84,88,32,50,48,187,13,10,26,10];function tm(t){let e=new Uint8Array(t);return!(e.byteLength<Ue.length||e[0]!==Ue[0]||e[1]!==Ue[1]||e[2]!==Ue[2]||e[3]!==Ue[3]||e[4]!==Ue[4]||e[5]!==Ue[5]||e[6]!==Ue[6]||e[7]!==Ue[7]||e[8]!==Ue[8]||e[9]!==Ue[9]||e[10]!==Ue[10]||e[11]!==Ue[11])}var rm=Promise.resolve(),sm={etc1:{basisFormat:0,compressed:!0,format:36196,textureFormat:"etc1-rgb-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:37493,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:33776,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:33779,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:36283,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:36285,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:37808,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:35986,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:34798,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:32856,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:32854,textureFormat:"rgba4unorm-webgl"}},AV=Object.freeze(Object.keys(sm));async function K_(t){let e=rm,r;rm=new Promise(n=>{r=n}),await e;try{return await t()}finally{r()}}async function im(t,e={}){let r=Jn(e);return await K_(async()=>{if(!e.basis?.containerFormat||e.basis.containerFormat==="auto"){if(tm(t)){let o=await Kc(r);return nm(o.KTX2File,t,e)}let{BasisFile:n}=await Yc(r);return Qc(n,t,e)}switch(e.basis.module){case"encoder":let n=await Kc(r);switch(e.basis.containerFormat){case"ktx2":return nm(n.KTX2File,t,e);case"basis":default:return Qc(n.BasisFile,t,e)}case"transcoder":default:let{BasisFile:o}=await Yc(r);return Qc(o,t,e)}})}function Qc(t,e,r){let n=new t(new Uint8Array(e));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");let o=n.getNumImages(),s=[];for(let i=0;i<o;i++){let a=n.getNumLevels(i),c=[];for(let l=0;l<a;l++)c.push(Q_(n,i,l,r));s.push(c)}return s}finally{n.close(),n.delete()}}function Q_(t,e,r,n){let o=t.getImageWidth(e,r),s=t.getImageHeight(e,r),i=t.getHasAlpha(),{compressed:a,format:c,basisFormat:l,textureFormat:f}=am(n,i),u=t.getImageTranscodedSizeInBytes(e,r,l),h=new Uint8Array(u);if(!t.transcodeImage(h,e,r,l,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:o,height:s,data:h,compressed:a,...c!==void 0?{format:c}:{},...f!==void 0?{textureFormat:f}:{},hasAlpha:i}}function nm(t,e,r){let n=new t(new Uint8Array(e));try{if(!n.startTranscoding())throw new Error("failed to start KTX2 transcoding");let o=n.getLevels(),s=[];for(let i=0;i<o;i++)s.push(Z_(n,i,r));return[s]}finally{n.close(),n.delete()}}function Z_(t,e,r){let{alphaFlag:n,height:o,width:s}=t.getImageLevelInfo(e,0,0),{compressed:i,format:a,basisFormat:c,textureFormat:l}=am(r,n),f=t.getImageTranscodedSizeInBytes(e,0,0,c),u=new Uint8Array(f);if(!t.transcodeImage(u,e,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:s,height:o,data:u,compressed:i,...a!==void 0?{format:a}:{},...l!==void 0?{textureFormat:l}:{},levelSize:f,hasAlpha:n}}function am(t,e){let r=t.basis?.format||"auto";r==="auto"&&(r=t.basis?.supportedTextureFormats?om(t.basis.supportedTextureFormats):om()),typeof r=="object"&&(r=e?r.alpha:r.noAlpha);let n=r.toLowerCase(),o=sm[n];if(!o)throw new Error(`Unknown Basis format ${r}`);return o}function om(t=em()){let e=new Set(t);return en(e,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":en(e,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:en(e,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:en(e,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:en(e,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":e.has("etc1-rgb-unorm-webgl")?"etc1":en(e,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function en(t,e){return e.some(r=>t.has(r))}var cm={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:Qd,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}}},Zc={...cm,parse:im};var le=D($c(),1);var $;(function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST=9728]="NEAREST",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})($||($={}));function um(t){return{addressModeU:fm(t.wrapS),addressModeV:fm(t.wrapT),magFilter:$_(t.magFilter),...eC(t.minFilter)}}function fm(t){switch(t){case $.CLAMP_TO_EDGE:return"clamp-to-edge";case $.REPEAT:return"repeat";case $.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function $_(t){switch(t){case $.NEAREST:return"nearest";case $.LINEAR:return"linear";default:return}}function eC(t){switch(t){case $.NEAREST:return{minFilter:"nearest"};case $.LINEAR:return{minFilter:"linear"};case $.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case $.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case $.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case $.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}var hm=[xe("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),xe("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),xe("normal","pbr_normalSampler","normalTexture",["normalTexture"]),xe("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),xe("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),xe("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),xe("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),xe("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),xe("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),xe("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),xe("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),xe("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),xe("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),xe("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),xe("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),xe("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),xe("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"])],tC=new Map(hm.map(t=>[t.slot,t]));function xe(t,e,r,n){return{slot:t,binding:e,displayName:r,pathSegments:n,uvSetUniform:`${t}UVSet`,uvTransformUniform:`${t}UVTransform`}}function pm(){return hm}function dm(t){let e=tC.get(t);if(!e)throw new Error(`Unknown PBR texture transform slot ${t}`);return e}function mm(t){let e=t?.extensions?.KHR_texture_transform;return{offset:e?.offset?[e.offset[0],e.offset[1]]:[0,0],rotation:e?.rotation??0,scale:e?.scale?[e.scale[0],e.scale[1]]:[1,1]}}function el(t){return t?.extensions?.KHR_texture_transform?.texCoord??t?.texCoord??0}function gm(t){let e=new k().set(1,0,0,0,1,0,t.offset[0],t.offset[1],1),r=new k().set(Math.cos(t.rotation),Math.sin(t.rotation),0,-Math.sin(t.rotation),Math.cos(t.rotation),0,0,0,1),n=new k().set(t.scale[0],0,0,0,t.scale[1],0,0,0,1);return Array.from(e.multiplyRight(r).multiplyRight(n))}var rC={NORMAL:["NORMAL","normals"],TANGENT:["TANGENT"],TEXCOORD_0:["TEXCOORD_0","texCoords"],TEXCOORD_1:["TEXCOORD_1","texCoords1"],JOINTS_0:["JOINTS_0"],WEIGHTS_0:["WEIGHTS_0"],COLOR_0:["COLOR_0","colors"]};function rl(t,e,r,n){let o={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};o.defines.USE_TEX_LOD=!0;let{imageBasedLightingEnvironment:s}=n;return s&&(o.bindings.pbr_diffuseEnvSampler=s.diffuseEnvSampler.texture,o.bindings.pbr_specularEnvSampler=s.specularEnvSampler.texture,o.bindings.pbr_brdfLUT=s.brdfLutTexture.texture,o.uniforms.IBLenabled=!0,o.uniforms.scaleIBLAmbient=[1,1]),n?.pbrDebug&&(o.defines.PBR_DEBUG=!0,o.uniforms.scaleDiffBaseMR=[0,0,0,0],o.uniforms.scaleFGDSpec=[0,0,0,0]),$e(r,"NORMAL")&&(o.defines.HAS_NORMALS=!0),$e(r,"TANGENT")&&n?.useTangents&&(o.defines.HAS_TANGENTS=!0),$e(r,"TEXCOORD_0")&&(o.defines.HAS_UV=!0),$e(r,"TEXCOORD_1")&&(o.defines.HAS_UV_1=!0),$e(r,"JOINTS_0")&&$e(r,"WEIGHTS_0")&&(o.defines.HAS_SKIN=!0),$e(r,"COLOR_0")&&(o.defines.HAS_COLORS=!0),n?.imageBasedLightingEnvironment&&(o.defines.USE_IBL=!0),n?.lights&&(o.defines.USE_LIGHTS=!0),e&&(n.validateAttributes!==!1&&nC(e,r),sC(t,e,o,r,n.gltf)),o}function nC(t,e){let r=Am(t,0);r.length>0&&!$e(e,"TEXCOORD_0")&&le.log.warn(`glTF material uses ${r.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();let n=Am(t,1);if(n.length>0&&!$e(e,"TEXCOORD_1")&&le.log.warn(`glTF material uses ${n.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)(),Boolean(t.unlit||t.extensions?.KHR_materials_unlit)||$e(e,"NORMAL"))return;let s=t.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";le.log.warn(`glTF primitive is missing NORMAL while using ${s}; shading will fall back to geometric normals`)()}function Am(t,e){let r=[];for(let n of pm()){let o=oC(t,n.pathSegments);o&&el(o)===e&&r.push(n.displayName)}return r}function $e(t,e){return rC[e].some(r=>Boolean(t[r]))}function oC(t,e){let r=t;for(let n of e)if(r=r?.[n],!r)return null;return r}function sC(t,e,r,n,o){if(r.uniforms.unlit=Boolean(e.unlit||e.extensions?.KHR_materials_unlit),e.pbrMetallicRoughness&&cC(t,e.pbrMetallicRoughness,r,n,o),e.normalTexture){ye(t,e.normalTexture,"pbr_normalSampler",r,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"normal"});let{scale:s=1}=e.normalTexture;r.uniforms.normalScale=s}if(e.occlusionTexture){ye(t,e.occlusionTexture,"pbr_occlusionSampler",r,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"occlusion"});let{strength:s=1}=e.occlusionTexture;r.uniforms.occlusionStrength=s}switch(r.uniforms.emissiveFactor=e.emissiveFactor||[0,0,0],e.emissiveTexture&&ye(t,e.emissiveTexture,"pbr_emissiveSampler",r,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"emissive"}),lC(t,e.extensions,r,o,n),e.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{let{alphaCutoff:s=.5}=e;r.defines.ALPHA_CUTOFF=!0,r.uniforms.alphaCutoffEnabled=!0,r.uniforms.alphaCutoff=s;break}case"BLEND":le.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),iC(r);break}}function iC(t){t.parameters.blend=!0,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="src-alpha",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.blendEquation=$.FUNC_ADD,t.glParameters.blendFunc=[$.SRC_ALPHA,$.ONE_MINUS_SRC_ALPHA,$.ONE,$.ONE_MINUS_SRC_ALPHA]}function aC(t){t.parameters.blend=!0,t.parameters.depthWriteEnabled=!1,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="one",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.depthMask=!1,t.glParameters.blendEquation=$.FUNC_ADD,t.glParameters.blendFunc=[$.ONE,$.ONE_MINUS_SRC_ALPHA,$.ONE,$.ONE_MINUS_SRC_ALPHA]}function cC(t,e,r,n,o){e.baseColorTexture&&ye(t,e.baseColorTexture,"pbr_baseColorSampler",r,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"baseColor"}),r.uniforms.baseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&ye(t,e.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",r,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"metallicRoughness"});let{metallicFactor:s=1,roughnessFactor:i=1}=e;r.uniforms.metallicRoughnessValues=[s,i]}function lC(t,e,r,n,o={}){e&&(fC(e)&&(r.defines.USE_MATERIAL_EXTENSIONS=!0),uC(t,e.KHR_materials_specular,r,n,o),hC(e.KHR_materials_ior,r),pC(t,e.KHR_materials_transmission,r,n,o),dC(t,e.KHR_materials_volume,r,n,o),mC(t,e.KHR_materials_clearcoat,r,n,o),gC(t,e.KHR_materials_sheen,r,n,o),AC(t,e.KHR_materials_iridescence,r,n,o),xC(t,e.KHR_materials_anisotropy,r,n,o),yC(e.KHR_materials_emissive_strength,r))}function fC(t){return Boolean(t.KHR_materials_specular||t.KHR_materials_ior||t.KHR_materials_transmission||t.KHR_materials_volume||t.KHR_materials_clearcoat||t.KHR_materials_sheen||t.KHR_materials_iridescence||t.KHR_materials_anisotropy)}function uC(t,e,r,n,o={}){e&&(e.specularColorFactor&&(r.uniforms.specularColorFactor=e.specularColorFactor),e.specularFactor!==void 0&&(r.uniforms.specularIntensityFactor=e.specularFactor),e.specularColorTexture&&ye(t,e.specularColorTexture,"pbr_specularColorSampler",r,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"specularColor"}),e.specularTexture&&ye(t,e.specularTexture,"pbr_specularIntensitySampler",r,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"specularIntensity"}))}function hC(t,e){t?.ior!==void 0&&(e.uniforms.ior=t.ior)}function pC(t,e,r,n,o={}){e&&(e.transmissionFactor!==void 0&&(r.uniforms.transmissionFactor=e.transmissionFactor),e.transmissionTexture&&ye(t,e.transmissionTexture,"pbr_transmissionSampler",r,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"transmission"}),((e.transmissionFactor??0)>0||e.transmissionTexture)&&(le.log.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),aC(r)))}function dC(t,e,r,n,o={}){e&&(e.thicknessFactor!==void 0&&(r.uniforms.thicknessFactor=e.thicknessFactor),e.thicknessTexture&&ye(t,e.thicknessTexture,"pbr_thicknessSampler",r,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:n,attributes:o,textureTransformSlot:"thickness"}),e.attenuationDistance!==void 0&&(r.uniforms.attenuationDistance=e.attenuationDistance),e.attenuationColor&&(r.uniforms.attenuationColor=e.attenuationColor))}function mC(t,e,r,n,o={}){e&&(e.clearcoatFactor!==void 0&&(r.uniforms.clearcoatFactor=e.clearcoatFactor),e.clearcoatRoughnessFactor!==void 0&&(r.uniforms.clearcoatRoughnessFactor=e.clearcoatRoughnessFactor),e.clearcoatTexture&&ye(t,e.clearcoatTexture,"pbr_clearcoatSampler",r,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"clearcoat"}),e.clearcoatRoughnessTexture&&ye(t,e.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",r,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"clearcoatRoughness"}),e.clearcoatNormalTexture&&ye(t,e.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",r,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:n,attributes:o,textureTransformSlot:"clearcoatNormal"}))}function gC(t,e,r,n,o={}){e&&(e.sheenColorFactor&&(r.uniforms.sheenColorFactor=e.sheenColorFactor),e.sheenRoughnessFactor!==void 0&&(r.uniforms.sheenRoughnessFactor=e.sheenRoughnessFactor),e.sheenColorTexture&&ye(t,e.sheenColorTexture,"pbr_sheenColorSampler",r,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"sheenColor"}),e.sheenRoughnessTexture&&ye(t,e.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",r,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"sheenRoughness"}))}function AC(t,e,r,n,o={}){e&&(e.iridescenceFactor!==void 0&&(r.uniforms.iridescenceFactor=e.iridescenceFactor),e.iridescenceIor!==void 0&&(r.uniforms.iridescenceIor=e.iridescenceIor),(e.iridescenceThicknessMinimum!==void 0||e.iridescenceThicknessMaximum!==void 0)&&(r.uniforms.iridescenceThicknessRange=[e.iridescenceThicknessMinimum??100,e.iridescenceThicknessMaximum??400]),e.iridescenceTexture&&ye(t,e.iridescenceTexture,"pbr_iridescenceSampler",r,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"iridescence"}),e.iridescenceThicknessTexture&&ye(t,e.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",r,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:n,attributes:o,textureTransformSlot:"iridescenceThickness"}))}function xC(t,e,r,n,o={}){e&&(e.anisotropyStrength!==void 0&&(r.uniforms.anisotropyStrength=e.anisotropyStrength),e.anisotropyRotation!==void 0&&(r.uniforms.anisotropyRotation=e.anisotropyRotation),e.anisotropyTexture&&ye(t,e.anisotropyTexture,"pbr_anisotropySampler",r,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"anisotropy"}))}function yC(t,e){t?.emissiveStrength!==void 0&&(e.uniforms.emissiveStrength=t.emissiveStrength)}function ye(t,e,r,n,o={}){let{featureOptions:s={},gltf:i,attributes:a={},textureTransformSlot:c}=o,{define:l,enabledUniformName:f}=s,u=el(e);if(u>1){le.log.warn(`Skipping ${String(r)} because ${u} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();return}if(u===1&&!$e(a,"TEXCOORD_1")){le.log.warn(`Skipping ${String(r)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();return}let h=bC(e,i),p=h.texture?.source?.image;if(!p){le.log.warn(`Skipping unresolved glTF texture for ${String(r)}`)();return}let d={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...h?.texture?.sampler},m={id:h.uniformName||h.id,sampler:um(d)},g;if(p.compressed)g=MC(t,p,m);else{let{width:x,height:b}=t.getExternalImageSize(p);g=t.createTexture({...m,width:x,height:b,data:p})}if(n.bindings[r]=g,l&&(n.defines[l]=!0),f&&(n.uniforms[f]=!0),c){let x=dm(c);n.uniforms[x.uvSetUniform]=u,n.uniforms[x.uvTransformUniform]=gm(mm(e))}n.generatedTextures.push(g)}function bC(t,e){if(t.texture||t.index===void 0||!e?.textures)return t;let r=e.textures[t.index];return r?"texture"in r&&r.texture?{...r,...t,texture:r.texture}:"source"in r?{...t,texture:r}:t:t}function tl(t,e){return t.createTexture({...e,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function xm(t){return t.textureFormat}function TC(t,e,r){let{blockWidth:n=1,blockHeight:o=1}=le.textureFormatDecoder.getInfo(r),s=1;for(let i=1;;i++){let a=Math.max(1,t>>i),c=Math.max(1,e>>i);if(a<n||c<o)break;s++}return s}function MC(t,e,r){let n;if(Array.isArray(e.data)&&e.data[0]?.data?n=e.data:"mipmaps"in e&&Array.isArray(e.mipmaps)?n=e.mipmaps:n=[],n.length===0||!n[0]?.data)return le.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),tl(t,r);let o=n[0],s=o.width??e.width??0,i=o.height??e.height??0;if(s<=0||i<=0)return le.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),tl(t,r);let a=xm(o);if(!a)return le.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),tl(t,r);let c=TC(s,i,a),l=Math.min(n.length,c),f=1;for(let h=1;h<l;h++){let p=n[h];if(!p.data||p.width<=0||p.height<=0){le.log.warn(`createCompressedTexture: mip level ${h} has invalid data/dimensions, truncating`)();break}let d=xm(p);if(d&&d!==a){le.log.warn(`createCompressedTexture: mip level ${h} format '${d}' differs from base '${a}', truncating`)();break}let m=Math.max(1,s>>h),g=Math.max(1,i>>h);if(p.width!==m||p.height!==g){le.log.warn(`createCompressedTexture: mip level ${h} dimensions ${p.width}x${p.height} don't match expected ${m}x${g}, truncating`)();break}f++}let u=t.createTexture({...r,format:a,usage:le.Texture.TEXTURE|le.Texture.COPY_DST,width:s,height:i,mipLevels:f,data:o.data});for(let h=1;h<f;h++)u.writeData(n[h].data,{width:n[h].width,height:n[h].height,mipLevel:h});return u}function ym(t,e=!0){return t??e}function bm(t=[0,0,0],e=!0){return e?t.map(r=>r/255):[...t]}var Mm=D($c(),1);var nl=`precision highp int;
|
|
53
|
+
`},ao=class extends Wd.PathLayer{getShaders(){let e=super.getShaders();return e.inject=this.context.device.type==="webgpu"?jd:qE,e.modules=[...e.modules,zd],e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({...this.context.device.type==="webgpu"?{instanceTimestamps:{size:2,accessor:"getTimestamps",update:this.calculateWebGPUTimestamps,bufferGroup:"path-instance-data"}}:{timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}}})}calculateWebGPUTimestamps(e,{data:r,props:n}){let{pathTesselator:o}=this.state,{instanceCount:s,vertexStarts:i}=o,a=new Float32Array(s*2),{iterable:c,objectInfo:l}=(0,Jd.createIterable)(r);for(let f of c){l.index++;let u=i[l.index],h=i[l.index+1]??s;if(h<=u)continue;let p=n.getTimestamps?.(f,l)??[];a.set(qd(p,h-u,n._pathType==="loop"),u*2)}e.startIndices=i,e.value=a}draw(e){let{fadeTrail:r,trailLength:n,currentTime:o}=this.props,s={fadeTrail:r,trailLength:n,currentTime:o};this.state.model.shaderInputs.setProps({trips:s}),super.draw(e)}};ao.layerName="TripsLayer";ao.defaultProps=zE;var Xd=ao;var Kd=U(ss(),1),Yd=U(We(),1);var Ge=U(ss(),1),Xs=U(We(),1),co=U(Je(),1);var jE=10;function JE(t,e){let r;return t==null?r=e:typeof t=="object"?r={...t,coverage:e}:r={getHexagon:t,coverage:e},r}var WE={...co.PolygonLayer.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:t=>t.hexagon},extruded:!0},Xr=class t extends Xs.CompositeLayer{initializeState(){t._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:r}){if(e.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let n=this._calculateH3DataProps();this.setState(n)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,r=!1,n=!1,{iterable:o,objectInfo:s}=(0,Xs.createIterable)(this.props.data);for(let i of o){s.index++;let a=this.props.getHexagon(i,s),c=(0,Ge.getResolution)(a);if(e<0){if(e=c,!this.props.highPrecision)break}else if(e!==c){n=!0;break}if((0,Ge.isPentagon)(a)){r=!0;break}}return{resolution:e,edgeLengthKM:e>=0?(0,Ge.getHexagonEdgeLengthAvg)(e,"km"):0,hasMultipleRes:n,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:e,hasPentagon:r,hasMultipleRes:n}=this.state,{viewport:o}=this.context;return!!o?.resolution||n||r||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:n,centerHex:o}=this.state;if(r<0)return;let s=this.props.centerHexagon||(0,Ge.latLngToCell)(e.latitude,e.longitude,r);if(o===s)return;if(o)try{if((0,Ge.gridDistance)(o,s)*n<jE)return}catch{}let{unitsPerMeter:i}=e.distanceScales,a=rc(s),[c,l]=(0,Ge.cellToLatLng)(s),[f,u]=e.projectFlat([l,c]);a=a.map(h=>{let p=e.projectFlat(h);return[(p[0]-f)/i[0],(p[1]-u)/i[1]]}),this.setState({centerHex:s,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:e,material:r,coverage:n,extruded:o,wireframe:s,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,getFillColor:h,getElevation:p,getLineColor:d,getLineWidth:m,transitions:g,updateTriggers:b}=this.props;return{elevationScale:e,extruded:o,coverage:n,wireframe:s,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,material:r,getElevation:p,getFillColor:h,getLineColor:d,getLineWidth:m,transitions:g,updateTriggers:{getFillColor:b.getFillColor,getElevation:b.getElevation,getLineColor:b.getLineColor,getLineWidth:b.getLineWidth}}}_renderPolygonLayer(){let{data:e,getHexagon:r,updateTriggers:n,coverage:o}=this.props,s=this.getSubLayerClass("hexagon-cell-hifi",co.PolygonLayer),i=this._getForwardProps();return i.updateTriggers.getPolygon=JE(n.getHexagon,o),new s(i,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:i.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return Ms(rc(l,o))}})}_renderColumnLayer(){let{data:e,getHexagon:r,updateTriggers:n}=this.props,o=this.getSubLayerClass("hexagon-cell",co.ColumnLayer),s=this._getForwardProps();return s.updateTriggers.getPosition=n.getHexagon,new o(s,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:s.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:rp.bind(null,r)})}};Xr.defaultProps=WE;Xr.layerName="H3HexagonLayer";Xr._checkH3Lib=()=>{};var Ks=Xr;var XE={getHexagons:{type:"accessor",value:t=>t.hexagons}},lo=class extends De{initializeState(){Ks._checkH3Lib()}updateState({props:e,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:n,getHexagons:o}=e,s=[],{iterable:i,objectInfo:a}=(0,Yd.createIterable)(n);for(let c of i){a.index++;let l=o(c,a),f=(0,Kd.cellsToMultiPolygon)(l,!0);for(let u of f){for(let h of u)Ss(h);s.push(this.getSubLayerRow({polygon:u},c,a.index))}}this.setState({polygons:s})}}indexToBounds(){let{getElevation:e,getFillColor:r,getLineColor:n,getLineWidth:o}=this.props;return{data:this.state.polygons,getPolygon:s=>s.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(n),getLineWidth:this.getSubLayerAccessor(o)}}};lo.layerName="H3ClusterLayer";lo.defaultProps=XE;var Qd=lo;var K0=U(Wc(),1),zt=U(We(),1),Y0=U(Je(),1),Q0=U(Ys(),1);function tm(t,e=!0){return t??e}function rm(t=[0,0,0],e=!0){return e?t.map(r=>r/255):[...t]}var om=U(Xc(),1);var Kc=`precision highp int;
|
|
27
54
|
|
|
28
55
|
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
29
56
|
struct AmbientLight {
|
|
@@ -103,7 +130,7 @@ float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
|
|
|
103
130
|
}
|
|
104
131
|
|
|
105
132
|
// #endif
|
|
106
|
-
`;var
|
|
133
|
+
`;var nm=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
107
134
|
const MAX_LIGHTS: i32 = 5;
|
|
108
135
|
|
|
109
136
|
struct AmbientLight {
|
|
@@ -182,7 +209,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
182
209
|
);
|
|
183
210
|
return distanceAttenuation / max(coneFactor, 0.0001);
|
|
184
211
|
}
|
|
185
|
-
`;var
|
|
212
|
+
`;var fr=5,KE={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},sm={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[KE,fr]},defaultUniforms:Zs(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:nm,vs:Kc,fs:Kc,getUniforms:YE};function YE(t,e={}){if(t=t&&{...t},!t)return Zs();t.lights&&(t={...t,...ZE(t.lights),lights:void 0});let{useByteColors:r,ambientLight:n,pointLights:o,spotLights:s,directionalLights:i}=t||{};if(!(n||o&&o.length>0||s&&s.length>0||i&&i.length>0))return{...Zs(),enabled:0};let c={...Zs(),...QE({useByteColors:r,ambientLight:n,pointLights:o,spotLights:s,directionalLights:i})};return t.enabled!==void 0&&(c.enabled=t.enabled?1:0),c}function QE({useByteColors:t,ambientLight:e,pointLights:r=[],spotLights:n=[],directionalLights:o=[]}){let s=im(),i=0,a=0,c=0,l=0;for(let f of r){if(i>=fr)break;s[i]={...s[i],color:Qs(f,t),position:f.position,attenuation:f.attenuation||[1,0,0]},i++,a++}for(let f of n){if(i>=fr)break;s[i]={...s[i],color:Qs(f,t),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:eC(f)},i++,c++}for(let f of o){if(i>=fr)break;s[i]={...s[i],color:Qs(f,t),direction:f.direction},i++,l++}return r.length+n.length+o.length>fr&&om.log.warn(`MAX_LIGHTS exceeded, truncating to ${fr}`)(),{ambientColor:Qs(e,t),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:s}}function ZE(t){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;case"spot":e.spotLights?.push(r);break;default:}return e}function Qs(t={},e){let{color:r=[0,0,0],intensity:n=1}=t;return rm(r,tm(e,!0)).map(s=>s*n)}function Zs(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:im()}}function im(){return Array.from({length:fr},()=>$E())}function $E(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function eC(t){let e=t.innerConeAngle??0,r=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(r)]}var tC=`#ifdef USE_IBL
|
|
186
213
|
@group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;
|
|
187
214
|
@group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;
|
|
188
215
|
@group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;
|
|
@@ -190,12 +217,12 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
190
217
|
@group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>;
|
|
191
218
|
@group(2) @binding(auto) var pbr_brdfLUTSampler: sampler;
|
|
192
219
|
#endif
|
|
193
|
-
`,
|
|
220
|
+
`,am=`#ifdef USE_IBL
|
|
194
221
|
uniform samplerCube pbr_diffuseEnvSampler;
|
|
195
222
|
uniform samplerCube pbr_specularEnvSampler;
|
|
196
223
|
uniform sampler2D pbr_brdfLUT;
|
|
197
224
|
#endif
|
|
198
|
-
`,
|
|
225
|
+
`,cm={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:tC,vs:am,fs:am};var lm=`out vec3 pbr_vPosition;
|
|
199
226
|
out vec2 pbr_vUV0;
|
|
200
227
|
out vec2 pbr_vUV1;
|
|
201
228
|
|
|
@@ -237,7 +264,7 @@ void pbr_setPositionNormalTangentUV(
|
|
|
237
264
|
|
|
238
265
|
pbr_vUV1 = uv1;
|
|
239
266
|
}
|
|
240
|
-
`,
|
|
267
|
+
`,fm=`precision highp float;
|
|
241
268
|
|
|
242
269
|
layout(std140) uniform pbrMaterialUniforms {
|
|
243
270
|
// Material is unlit
|
|
@@ -297,6 +324,7 @@ layout(std140) uniform pbrMaterialUniforms {
|
|
|
297
324
|
bool anisotropyMapEnabled;
|
|
298
325
|
|
|
299
326
|
float emissiveStrength;
|
|
327
|
+
float dispersion;
|
|
300
328
|
|
|
301
329
|
// IBL
|
|
302
330
|
bool IBLenabled;
|
|
@@ -342,6 +370,25 @@ layout(std140) uniform pbrMaterialUniforms {
|
|
|
342
370
|
mat3 iridescenceThicknessUVTransform;
|
|
343
371
|
int anisotropyUVSet;
|
|
344
372
|
mat3 anisotropyUVTransform;
|
|
373
|
+
|
|
374
|
+
float bumpFactor;
|
|
375
|
+
bool bumpMapEnabled;
|
|
376
|
+
float diffuseTransmissionFactor;
|
|
377
|
+
bool diffuseTransmissionMapEnabled;
|
|
378
|
+
vec3 diffuseTransmissionColorFactor;
|
|
379
|
+
bool diffuseTransmissionColorMapEnabled;
|
|
380
|
+
vec3 multiscatterColorFactor;
|
|
381
|
+
bool multiscatterColorMapEnabled;
|
|
382
|
+
float scatterAnisotropy;
|
|
383
|
+
|
|
384
|
+
int bumpUVSet;
|
|
385
|
+
mat3 bumpUVTransform;
|
|
386
|
+
int diffuseTransmissionUVSet;
|
|
387
|
+
mat3 diffuseTransmissionUVTransform;
|
|
388
|
+
int diffuseTransmissionColorUVSet;
|
|
389
|
+
mat3 diffuseTransmissionColorUVTransform;
|
|
390
|
+
int multiscatterColorUVSet;
|
|
391
|
+
mat3 multiscatterColorUVTransform;
|
|
345
392
|
} pbrMaterial;
|
|
346
393
|
|
|
347
394
|
// Samplers
|
|
@@ -396,6 +443,18 @@ uniform sampler2D pbr_iridescenceThicknessSampler;
|
|
|
396
443
|
#ifdef HAS_ANISOTROPYMAP
|
|
397
444
|
uniform sampler2D pbr_anisotropySampler;
|
|
398
445
|
#endif
|
|
446
|
+
#ifdef HAS_BUMPMAP
|
|
447
|
+
uniform sampler2D pbr_bumpSampler;
|
|
448
|
+
#endif
|
|
449
|
+
#ifdef HAS_DIFFUSETRANSMISSIONMAP
|
|
450
|
+
uniform sampler2D pbr_diffuseTransmissionSampler;
|
|
451
|
+
#endif
|
|
452
|
+
#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP
|
|
453
|
+
uniform sampler2D pbr_diffuseTransmissionColorSampler;
|
|
454
|
+
#endif
|
|
455
|
+
#ifdef HAS_MULTISCATTERCOLORMAP
|
|
456
|
+
uniform sampler2D pbr_multiscatterColorSampler;
|
|
457
|
+
#endif
|
|
399
458
|
// Inputs from vertex shader
|
|
400
459
|
|
|
401
460
|
in vec3 pbr_vPosition;
|
|
@@ -428,11 +487,31 @@ struct PBRInfo {
|
|
|
428
487
|
vec3 specularColor; // color contribution from specular lighting
|
|
429
488
|
vec3 n; // normal at surface point
|
|
430
489
|
vec3 v; // vector from surface point to camera
|
|
490
|
+
vec3 l; // direction from the surface toward the current light
|
|
491
|
+
vec3 h; // half vector between the current light and camera
|
|
431
492
|
};
|
|
432
493
|
|
|
433
494
|
const float M_PI = 3.141592653589793;
|
|
434
495
|
const float c_MinRoughness = 0.04;
|
|
435
496
|
|
|
497
|
+
// Widen sub-pixel specular lobes using the screen-space normal footprint.
|
|
498
|
+
// This is geometric specular antialiasing: the normal variance is converted
|
|
499
|
+
// into an additional squared perceptual roughness before evaluating BRDFs.
|
|
500
|
+
float widenSpecularRoughness(float perceptualRoughness, vec3 normal)
|
|
501
|
+
{
|
|
502
|
+
vec3 normalDerivativeX = dFdx(normal);
|
|
503
|
+
vec3 normalDerivativeY = dFdy(normal);
|
|
504
|
+
float normalVariance =
|
|
505
|
+
dot(normalDerivativeX, normalDerivativeX) +
|
|
506
|
+
dot(normalDerivativeY, normalDerivativeY);
|
|
507
|
+
float kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);
|
|
508
|
+
return clamp(
|
|
509
|
+
sqrt(perceptualRoughness * perceptualRoughness + kernelRoughnessSquared),
|
|
510
|
+
c_MinRoughness,
|
|
511
|
+
1.0
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
|
|
436
515
|
vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor);
|
|
437
516
|
|
|
438
517
|
vec4 SRGBtoLINEAR(vec4 srgbIn)
|
|
@@ -499,6 +578,18 @@ vec3 getNormal(mat3 tbn, vec2 uv)
|
|
|
499
578
|
vec3 n = normalize(tbn[2].xyz);
|
|
500
579
|
#endif
|
|
501
580
|
|
|
581
|
+
#ifdef HAS_BUMPMAP
|
|
582
|
+
vec2 bumpUV = getMaterialUV(pbrMaterial.bumpUVSet, pbrMaterial.bumpUVTransform);
|
|
583
|
+
vec2 bumpTexelSize = 1.0 / vec2(textureSize(pbr_bumpSampler, 0));
|
|
584
|
+
float bumpHeight = texture(pbr_bumpSampler, bumpUV).r;
|
|
585
|
+
vec2 bumpGradient = vec2(
|
|
586
|
+
texture(pbr_bumpSampler, bumpUV + vec2(bumpTexelSize.x, 0.0)).r - bumpHeight,
|
|
587
|
+
texture(pbr_bumpSampler, bumpUV + vec2(0.0, bumpTexelSize.y)).r - bumpHeight
|
|
588
|
+
);
|
|
589
|
+
n = normalize(n - pbrMaterial.bumpFactor *
|
|
590
|
+
(tbn[0] * bumpGradient.x + tbn[1] * bumpGradient.y));
|
|
591
|
+
#endif
|
|
592
|
+
|
|
502
593
|
return n;
|
|
503
594
|
}
|
|
504
595
|
|
|
@@ -517,17 +608,38 @@ vec3 getClearcoatNormal(mat3 tbn, vec3 baseNormal, vec2 uv)
|
|
|
517
608
|
#ifdef USE_IBL
|
|
518
609
|
vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
|
|
519
610
|
{
|
|
520
|
-
|
|
521
|
-
float
|
|
611
|
+
#ifdef USE_SCENE_ENVIRONMENT
|
|
612
|
+
float maximumMipLevel = max(pbrScene.environmentMipCount - 1.0, 0.0);
|
|
613
|
+
float rotationSine = sin(pbrScene.environmentRotation);
|
|
614
|
+
float rotationCosine = cos(pbrScene.environmentRotation);
|
|
615
|
+
mat2 environmentRotation = mat2(rotationCosine, rotationSine, -rotationSine, rotationCosine);
|
|
616
|
+
vec3 environmentNormal = vec3(environmentRotation * n.xz, n.y).xzy;
|
|
617
|
+
vec3 environmentReflection = vec3(environmentRotation * reflection.xz, reflection.y).xzy;
|
|
618
|
+
#else
|
|
619
|
+
float maximumMipLevel = 9.0;
|
|
620
|
+
vec3 environmentNormal = n;
|
|
621
|
+
vec3 environmentReflection = reflection;
|
|
622
|
+
#endif
|
|
623
|
+
float lod = pbrInfo.perceptualRoughness * maximumMipLevel;
|
|
522
624
|
// retrieve a scale and bias to F0. See [1], Figure 3
|
|
523
|
-
|
|
524
|
-
vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))
|
|
525
|
-
|
|
625
|
+
vec4 brdfSample = texture(pbr_brdfLUT,
|
|
626
|
+
vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness));
|
|
627
|
+
vec4 diffuseSample = texture(pbr_diffuseEnvSampler, environmentNormal);
|
|
526
628
|
|
|
527
629
|
#ifdef USE_TEX_LOD
|
|
528
|
-
|
|
630
|
+
vec4 specularSample = textureLod(pbr_specularEnvSampler, environmentReflection, lod);
|
|
529
631
|
#else
|
|
530
|
-
|
|
632
|
+
vec4 specularSample = texture(pbr_specularEnvSampler, environmentReflection);
|
|
633
|
+
#endif
|
|
634
|
+
|
|
635
|
+
#ifdef USE_SCENE_ENVIRONMENT
|
|
636
|
+
vec3 brdf = brdfSample.rgb;
|
|
637
|
+
vec3 diffuseLight = diffuseSample.rgb;
|
|
638
|
+
vec3 specularLight = specularSample.rgb;
|
|
639
|
+
#else
|
|
640
|
+
vec3 brdf = SRGBtoLINEAR(brdfSample).rgb;
|
|
641
|
+
vec3 diffuseLight = SRGBtoLINEAR(diffuseSample).rgb;
|
|
642
|
+
vec3 specularLight = SRGBtoLINEAR(specularSample).rgb;
|
|
531
643
|
#endif
|
|
532
644
|
|
|
533
645
|
vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
|
|
@@ -537,7 +649,11 @@ vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
|
|
|
537
649
|
diffuse *= pbrMaterial.scaleIBLAmbient.x;
|
|
538
650
|
specular *= pbrMaterial.scaleIBLAmbient.y;
|
|
539
651
|
|
|
652
|
+
#ifdef USE_SCENE_ENVIRONMENT
|
|
653
|
+
return (diffuse + specular) * max(pbrScene.environmentIntensity, 0.0);
|
|
654
|
+
#else
|
|
540
655
|
return diffuse + specular;
|
|
656
|
+
#endif
|
|
541
657
|
}
|
|
542
658
|
#endif
|
|
543
659
|
|
|
@@ -611,16 +727,125 @@ vec2 rotateDirection(vec2 direction, float rotation)
|
|
|
611
727
|
return vec2(direction.x * c - direction.y * s, direction.x * s + direction.y * c);
|
|
612
728
|
}
|
|
613
729
|
|
|
614
|
-
vec3
|
|
730
|
+
vec3 encodeLinearSRGB(vec3 linearColor)
|
|
615
731
|
{
|
|
616
|
-
|
|
617
|
-
|
|
732
|
+
vec3 positiveColor = max(linearColor, vec3(0.0));
|
|
733
|
+
return mix(
|
|
734
|
+
positiveColor * 12.92,
|
|
735
|
+
1.055 * pow(positiveColor, vec3(1.0 / 2.4)) - 0.055,
|
|
736
|
+
greaterThan(positiveColor, vec3(0.0031308))
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
vec3 toneMapKhronosPBRNeutral(vec3 color)
|
|
741
|
+
{
|
|
742
|
+
const float startCompression = 0.76;
|
|
743
|
+
float darkestChannel = min(color.r, min(color.g, color.b));
|
|
744
|
+
float offset = darkestChannel < 0.08
|
|
745
|
+
? darkestChannel - 6.25 * darkestChannel * darkestChannel
|
|
746
|
+
: 0.04;
|
|
747
|
+
color -= vec3(offset);
|
|
748
|
+
|
|
749
|
+
float peak = maxComponent(color);
|
|
750
|
+
if (peak < startCompression) {
|
|
751
|
+
return color;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
float compressionRange = 1.0 - startCompression;
|
|
755
|
+
float compressedPeak = 1.0 - compressionRange * compressionRange /
|
|
756
|
+
(peak + compressionRange - startCompression);
|
|
757
|
+
color *= compressedPeak / max(peak, 0.0001);
|
|
758
|
+
float desaturation = 1.0 - 1.0 / (0.15 * (peak - compressedPeak) + 1.0);
|
|
759
|
+
return mix(color, vec3(compressedPeak), desaturation);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
vec3 applySceneColorManagement(vec3 sceneColor)
|
|
763
|
+
{
|
|
764
|
+
#ifdef USE_SCENE_COLOR_MANAGEMENT
|
|
765
|
+
vec3 color = max(sceneColor, vec3(0.0)) * max(pbrScene.exposure, 0.0);
|
|
766
|
+
if (pbrScene.toneMapMode == 1) {
|
|
767
|
+
color /= vec3(1.0) + color;
|
|
768
|
+
} else if (pbrScene.toneMapMode == 2) {
|
|
769
|
+
color = toneMapKhronosPBRNeutral(color);
|
|
770
|
+
} else if (pbrScene.toneMapMode == 3) {
|
|
771
|
+
color = clamp(
|
|
772
|
+
(color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14),
|
|
773
|
+
vec3(0.0),
|
|
774
|
+
vec3(1.0)
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
return pbrScene.outputEncoding == 0 ? color : encodeLinearSRGB(color);
|
|
778
|
+
#else
|
|
779
|
+
return pow(max(sceneColor, vec3(0.0)), vec3(1.0 / 2.2));
|
|
780
|
+
#endif
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
float dielectricSchlick(float reflectance, float cosine)
|
|
784
|
+
{
|
|
785
|
+
return reflectance + (1.0 - reflectance) * pow(clamp(1.0 - cosine, 0.0, 1.0), 5.0);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
vec3 evaluateIridescenceSensitivity(float opticalPathDifference, vec3 phaseShift)
|
|
789
|
+
{
|
|
790
|
+
float phase = 2.0 * M_PI * opticalPathDifference * 1.0e-9;
|
|
791
|
+
vec3 sensitivity = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);
|
|
792
|
+
vec3 position = vec3(1.6810e6, 1.7953e6, 2.2084e6);
|
|
793
|
+
vec3 variance = vec3(4.3278e9, 9.3046e9, 6.6121e9);
|
|
794
|
+
vec3 xyz = sensitivity * sqrt(2.0 * M_PI * variance) *
|
|
795
|
+
cos(position * phase + phaseShift) * exp(-phase * phase * variance);
|
|
796
|
+
xyz.x += 9.7470e-14 * sqrt(2.0 * M_PI * 4.5282e9) *
|
|
797
|
+
cos(2.2399e6 * phase + phaseShift.x) * exp(-4.5282e9 * phase * phase);
|
|
798
|
+
xyz /= 1.0685e-7;
|
|
799
|
+
return mat3(
|
|
800
|
+
3.2404542, -0.9692660, 0.0556434,
|
|
801
|
+
-1.5371385, 1.8760108, -0.2040259,
|
|
802
|
+
-0.4985314, 0.0415560, 1.0572252
|
|
803
|
+
) * xyz;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
vec3 getIridescenceTint(float iridescence, float thickness, float NdotV, vec3 baseReflectance)
|
|
807
|
+
{
|
|
808
|
+
if (iridescence <= 0.0 || thickness <= 0.0) {
|
|
809
|
+
return baseReflectance;
|
|
618
810
|
}
|
|
619
811
|
|
|
620
|
-
float
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
812
|
+
float filmIor = max(pbrMaterial.iridescenceIor, 1.0);
|
|
813
|
+
float sineSquared = (1.0 - NdotV * NdotV) / (filmIor * filmIor);
|
|
814
|
+
float cosineSquared = 1.0 - sineSquared;
|
|
815
|
+
if (cosineSquared <= 0.0) {
|
|
816
|
+
return mix(baseReflectance, vec3(1.0), iridescence);
|
|
817
|
+
}
|
|
818
|
+
float filmCosine = sqrt(cosineSquared);
|
|
819
|
+
float firstInterfaceReflectance = dielectricSchlick(getDielectricF0(filmIor), NdotV);
|
|
820
|
+
float transmittedEnergy = 1.0 - firstInterfaceReflectance;
|
|
821
|
+
|
|
822
|
+
vec3 baseIor = (vec3(1.0) + sqrt(clamp(baseReflectance, vec3(0.0), vec3(0.9999)))) /
|
|
823
|
+
(vec3(1.0) - sqrt(clamp(baseReflectance, vec3(0.0), vec3(0.9999))));
|
|
824
|
+
vec3 secondInterfaceF0 = (baseIor - vec3(filmIor)) / (baseIor + vec3(filmIor));
|
|
825
|
+
secondInterfaceF0 *= secondInterfaceF0;
|
|
826
|
+
vec3 secondInterfaceReflectance = secondInterfaceF0 +
|
|
827
|
+
(vec3(1.0) - secondInterfaceF0) * pow(1.0 - filmCosine, 5.0);
|
|
828
|
+
vec3 phaseShift = vec3(M_PI);
|
|
829
|
+
phaseShift += mix(vec3(0.0), vec3(M_PI), lessThan(baseIor, vec3(filmIor)));
|
|
830
|
+
float opticalPathDifference = 2.0 * filmIor * thickness * filmCosine;
|
|
831
|
+
vec3 combinedReflectance = clamp(
|
|
832
|
+
firstInterfaceReflectance * secondInterfaceReflectance,
|
|
833
|
+
vec3(0.00001),
|
|
834
|
+
vec3(0.9999)
|
|
835
|
+
);
|
|
836
|
+
vec3 recurringAmplitude = sqrt(combinedReflectance);
|
|
837
|
+
vec3 interfaceResponse = transmittedEnergy * transmittedEnergy * secondInterfaceReflectance /
|
|
838
|
+
(vec3(1.0) - combinedReflectance);
|
|
839
|
+
vec3 reflectedSpectrum = vec3(firstInterfaceReflectance) + interfaceResponse;
|
|
840
|
+
vec3 harmonicAmplitude = interfaceResponse - vec3(transmittedEnergy);
|
|
841
|
+
for (int harmonic = 1; harmonic <= 2; harmonic++) {
|
|
842
|
+
harmonicAmplitude *= recurringAmplitude;
|
|
843
|
+
reflectedSpectrum += harmonicAmplitude * 2.0 * evaluateIridescenceSensitivity(
|
|
844
|
+
float(harmonic) * opticalPathDifference,
|
|
845
|
+
float(harmonic) * phaseShift
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
return mix(baseReflectance, clamp(reflectedSpectrum, vec3(0.0), vec3(1.0)), iridescence);
|
|
624
849
|
}
|
|
625
850
|
|
|
626
851
|
vec3 getVolumeAttenuation(float thickness)
|
|
@@ -635,6 +860,176 @@ vec3 getVolumeAttenuation(float thickness)
|
|
|
635
860
|
return exp(-attenuationCoefficient * thickness);
|
|
636
861
|
}
|
|
637
862
|
|
|
863
|
+
// KHR_materials_volume_scatter is an active draft. This evaluates a local,
|
|
864
|
+
// thickness-aware single-scattering approximation rather than random walk.
|
|
865
|
+
vec3 getDiffuseTransmissionAttenuation(
|
|
866
|
+
PBRInfo pbrInfo,
|
|
867
|
+
vec3 multiscatterColor,
|
|
868
|
+
float thickness
|
|
869
|
+
)
|
|
870
|
+
{
|
|
871
|
+
vec3 volumeAttenuation = getVolumeAttenuation(thickness);
|
|
872
|
+
float scatteringStrength = maxComponent(multiscatterColor);
|
|
873
|
+
if (thickness <= 0.0 || scatteringStrength <= 0.0001) {
|
|
874
|
+
return volumeAttenuation;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
float anisotropy = clamp(pbrMaterial.scatterAnisotropy, -0.95, 0.95);
|
|
878
|
+
float scatteringCosine = clamp(dot(-pbrInfo.v, pbrInfo.l), -1.0, 1.0);
|
|
879
|
+
float phaseDenominator = max(
|
|
880
|
+
1.0 + anisotropy * anisotropy - 2.0 * anisotropy * scatteringCosine,
|
|
881
|
+
0.0001
|
|
882
|
+
);
|
|
883
|
+
float phaseWeight = clamp(
|
|
884
|
+
(1.0 - anisotropy * anisotropy) / pow(phaseDenominator, 1.5),
|
|
885
|
+
0.0,
|
|
886
|
+
4.0
|
|
887
|
+
);
|
|
888
|
+
float scatteringDepth = thickness / max(pbrMaterial.attenuationDistance, 0.0001);
|
|
889
|
+
float scatteringProbability = 1.0 - exp(-scatteringDepth);
|
|
890
|
+
vec3 scatteringColor = clamp(multiscatterColor, vec3(0.0), vec3(1.0));
|
|
891
|
+
return mix(
|
|
892
|
+
volumeAttenuation,
|
|
893
|
+
volumeAttenuation * mix(vec3(1.0), scatteringColor * phaseWeight, scatteringColor),
|
|
894
|
+
scatteringProbability
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
vec3 calculateDiffuseTransmissionLight(
|
|
899
|
+
PBRInfo pbrInfo,
|
|
900
|
+
vec3 lightColor,
|
|
901
|
+
vec3 diffuseTransmissionColor,
|
|
902
|
+
float diffuseTransmission,
|
|
903
|
+
vec3 multiscatterColor,
|
|
904
|
+
float thickness
|
|
905
|
+
)
|
|
906
|
+
{
|
|
907
|
+
float oppositeHemisphere = max(dot(-pbrInfo.n, pbrInfo.l), 0.0);
|
|
908
|
+
if (oppositeHemisphere <= 0.0 || diffuseTransmission <= 0.0) {
|
|
909
|
+
return vec3(0.0);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
vec3 nonReflectedEnergy = vec3(1.0) - clamp(pbrInfo.reflectance0, vec3(0.0), vec3(1.0));
|
|
913
|
+
vec3 attenuatedColor = getDiffuseTransmissionAttenuation(
|
|
914
|
+
pbrInfo,
|
|
915
|
+
multiscatterColor,
|
|
916
|
+
thickness
|
|
917
|
+
);
|
|
918
|
+
return lightColor * diffuseTransmissionColor * nonReflectedEnergy *
|
|
919
|
+
attenuatedColor * (diffuseTransmission * oppositeHemisphere / M_PI);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
#ifdef USE_IBL
|
|
923
|
+
vec3 calculateDiffuseTransmissionIBL(
|
|
924
|
+
PBRInfo pbrInfo,
|
|
925
|
+
vec3 diffuseTransmissionColor,
|
|
926
|
+
float diffuseTransmission,
|
|
927
|
+
vec3 multiscatterColor,
|
|
928
|
+
float thickness
|
|
929
|
+
)
|
|
930
|
+
{
|
|
931
|
+
if (diffuseTransmission <= 0.0) {
|
|
932
|
+
return vec3(0.0);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
#ifdef USE_SCENE_ENVIRONMENT
|
|
936
|
+
float rotationSine = sin(pbrScene.environmentRotation);
|
|
937
|
+
float rotationCosine = cos(pbrScene.environmentRotation);
|
|
938
|
+
mat2 environmentRotation = mat2(rotationCosine, rotationSine, -rotationSine, rotationCosine);
|
|
939
|
+
vec3 oppositeNormal = vec3(environmentRotation * -pbrInfo.n.xz, -pbrInfo.n.y).xzy;
|
|
940
|
+
vec3 environmentColor = texture(pbr_diffuseEnvSampler, oppositeNormal).rgb *
|
|
941
|
+
max(pbrScene.environmentIntensity, 0.0);
|
|
942
|
+
#else
|
|
943
|
+
vec3 environmentColor = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, -pbrInfo.n)).rgb;
|
|
944
|
+
#endif
|
|
945
|
+
vec3 nonReflectedEnergy = vec3(1.0) - clamp(pbrInfo.reflectance0, vec3(0.0), vec3(1.0));
|
|
946
|
+
return environmentColor * diffuseTransmissionColor * nonReflectedEnergy *
|
|
947
|
+
getDiffuseTransmissionAttenuation(pbrInfo, multiscatterColor, thickness) *
|
|
948
|
+
diffuseTransmission * pbrMaterial.scaleIBLAmbient.x;
|
|
949
|
+
}
|
|
950
|
+
#endif
|
|
951
|
+
|
|
952
|
+
#ifdef USE_TRANSMISSION_FRAMEBUFFER
|
|
953
|
+
vec3 sampleTransmittedSceneColor(
|
|
954
|
+
vec3 position,
|
|
955
|
+
vec3 normal,
|
|
956
|
+
vec3 viewDirection,
|
|
957
|
+
float thickness,
|
|
958
|
+
float perceptualRoughness,
|
|
959
|
+
float indexOfRefraction
|
|
960
|
+
)
|
|
961
|
+
{
|
|
962
|
+
vec3 refractionDirection = refract(
|
|
963
|
+
-viewDirection,
|
|
964
|
+
normal,
|
|
965
|
+
1.0 / max(indexOfRefraction, 1.0)
|
|
966
|
+
);
|
|
967
|
+
vec3 refractedPosition = position + refractionDirection * thickness;
|
|
968
|
+
vec4 clipPosition = pbrScene.projectionMatrix *
|
|
969
|
+
pbrScene.viewMatrix * vec4(refractedPosition, 1.0);
|
|
970
|
+
vec2 textureCoordinate = clipPosition.xy / max(clipPosition.w, 0.0001) * 0.5 + 0.5;
|
|
971
|
+
textureCoordinate = clamp(textureCoordinate, vec2(0.001), vec2(0.999));
|
|
972
|
+
|
|
973
|
+
vec2 blurRadius = perceptualRoughness * perceptualRoughness * 8.0 /
|
|
974
|
+
max(pbrScene.framebufferSize, vec2(1.0));
|
|
975
|
+
vec3 sceneColor = texture(pbr_transmissionFramebufferSampler, textureCoordinate).rgb * 0.4;
|
|
976
|
+
sceneColor += texture(
|
|
977
|
+
pbr_transmissionFramebufferSampler,
|
|
978
|
+
textureCoordinate + vec2(blurRadius.x, 0.0)
|
|
979
|
+
).rgb * 0.15;
|
|
980
|
+
sceneColor += texture(
|
|
981
|
+
pbr_transmissionFramebufferSampler,
|
|
982
|
+
textureCoordinate - vec2(blurRadius.x, 0.0)
|
|
983
|
+
).rgb * 0.15;
|
|
984
|
+
sceneColor += texture(
|
|
985
|
+
pbr_transmissionFramebufferSampler,
|
|
986
|
+
textureCoordinate + vec2(0.0, blurRadius.y)
|
|
987
|
+
).rgb * 0.15;
|
|
988
|
+
sceneColor += texture(
|
|
989
|
+
pbr_transmissionFramebufferSampler,
|
|
990
|
+
textureCoordinate - vec2(0.0, blurRadius.y)
|
|
991
|
+
).rgb * 0.15;
|
|
992
|
+
return max(sceneColor, vec3(0.0));
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
vec3 getTransmittedSceneColor(
|
|
996
|
+
vec3 position,
|
|
997
|
+
vec3 normal,
|
|
998
|
+
vec3 viewDirection,
|
|
999
|
+
float thickness,
|
|
1000
|
+
float perceptualRoughness
|
|
1001
|
+
)
|
|
1002
|
+
{
|
|
1003
|
+
if (pbrMaterial.dispersion <= 0.0) {
|
|
1004
|
+
return sampleTransmittedSceneColor(
|
|
1005
|
+
position,
|
|
1006
|
+
normal,
|
|
1007
|
+
viewDirection,
|
|
1008
|
+
thickness,
|
|
1009
|
+
perceptualRoughness,
|
|
1010
|
+
pbrMaterial.ior
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
float halfSpread = (max(pbrMaterial.ior, 1.0) - 1.0) * 0.025 * pbrMaterial.dispersion;
|
|
1015
|
+
vec3 indicesOfRefraction = max(
|
|
1016
|
+
vec3(pbrMaterial.ior - halfSpread, pbrMaterial.ior, pbrMaterial.ior + halfSpread),
|
|
1017
|
+
vec3(1.0)
|
|
1018
|
+
);
|
|
1019
|
+
return vec3(
|
|
1020
|
+
sampleTransmittedSceneColor(
|
|
1021
|
+
position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.r
|
|
1022
|
+
).r,
|
|
1023
|
+
sampleTransmittedSceneColor(
|
|
1024
|
+
position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.g
|
|
1025
|
+
).g,
|
|
1026
|
+
sampleTransmittedSceneColor(
|
|
1027
|
+
position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.b
|
|
1028
|
+
).b
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
#endif
|
|
1032
|
+
|
|
638
1033
|
PBRInfo createClearcoatPBRInfo(PBRInfo basePBRInfo, vec3 clearcoatNormal, float clearcoatRoughness)
|
|
639
1034
|
{
|
|
640
1035
|
float perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
|
|
@@ -655,7 +1050,9 @@ PBRInfo createClearcoatPBRInfo(PBRInfo basePBRInfo, vec3 clearcoatNormal, float
|
|
|
655
1050
|
vec3(0.0),
|
|
656
1051
|
vec3(0.04),
|
|
657
1052
|
clearcoatNormal,
|
|
658
|
-
basePBRInfo.v
|
|
1053
|
+
basePBRInfo.v,
|
|
1054
|
+
basePBRInfo.l,
|
|
1055
|
+
basePBRInfo.h
|
|
659
1056
|
);
|
|
660
1057
|
}
|
|
661
1058
|
|
|
@@ -701,28 +1098,72 @@ vec3 calculateSheenContribution(
|
|
|
701
1098
|
return vec3(0.0);
|
|
702
1099
|
}
|
|
703
1100
|
|
|
704
|
-
float
|
|
705
|
-
float
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
1101
|
+
float alpha = max(sheenRoughness * sheenRoughness, 0.0001);
|
|
1102
|
+
float inverseAlpha = 1.0 / alpha;
|
|
1103
|
+
float sineSquared = max(1.0 - pbrInfo.NdotH * pbrInfo.NdotH, 0.0);
|
|
1104
|
+
float distribution = (2.0 + inverseAlpha) * pow(sineSquared, inverseAlpha * 0.5) /
|
|
1105
|
+
(2.0 * M_PI);
|
|
1106
|
+
float visibility = 1.0 / max(
|
|
1107
|
+
4.0 * (pbrInfo.NdotL + pbrInfo.NdotV - pbrInfo.NdotL * pbrInfo.NdotV),
|
|
1108
|
+
0.0001
|
|
1109
|
+
);
|
|
1110
|
+
return pbrInfo.NdotL * lightColor * sheenColor * distribution * visibility *
|
|
711
1111
|
(1.0 - pbrInfo.metalness);
|
|
712
1112
|
}
|
|
713
1113
|
|
|
714
|
-
|
|
1114
|
+
vec3 calculateAnisotropicLightColor(
|
|
715
1115
|
PBRInfo pbrInfo,
|
|
1116
|
+
vec3 lightColor,
|
|
716
1117
|
vec3 anisotropyTangent,
|
|
717
1118
|
float anisotropyStrength
|
|
718
1119
|
) {
|
|
719
1120
|
if (anisotropyStrength <= 0.0) {
|
|
720
|
-
return
|
|
1121
|
+
return calculateFinalColor(pbrInfo, lightColor);
|
|
721
1122
|
}
|
|
722
1123
|
|
|
723
1124
|
vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));
|
|
724
|
-
float
|
|
725
|
-
|
|
1125
|
+
float tangentRoughness = mix(
|
|
1126
|
+
pbrInfo.alphaRoughness,
|
|
1127
|
+
1.0,
|
|
1128
|
+
anisotropyStrength * anisotropyStrength
|
|
1129
|
+
);
|
|
1130
|
+
float bitangentRoughness = clamp(pbrInfo.alphaRoughness, 0.001, 1.0);
|
|
1131
|
+
float roughnessProduct = tangentRoughness * bitangentRoughness;
|
|
1132
|
+
vec3 distributionVector = vec3(
|
|
1133
|
+
bitangentRoughness * dot(anisotropyTangent, pbrInfo.h),
|
|
1134
|
+
tangentRoughness * dot(anisotropyBitangent, pbrInfo.h),
|
|
1135
|
+
roughnessProduct * pbrInfo.NdotH
|
|
1136
|
+
);
|
|
1137
|
+
float distributionFactor = roughnessProduct /
|
|
1138
|
+
max(dot(distributionVector, distributionVector), 0.000001);
|
|
1139
|
+
float distribution = roughnessProduct * distributionFactor * distributionFactor / M_PI;
|
|
1140
|
+
float viewMask = pbrInfo.NdotL * length(vec3(
|
|
1141
|
+
tangentRoughness * dot(anisotropyTangent, pbrInfo.v),
|
|
1142
|
+
bitangentRoughness * dot(anisotropyBitangent, pbrInfo.v),
|
|
1143
|
+
pbrInfo.NdotV
|
|
1144
|
+
));
|
|
1145
|
+
float lightMask = pbrInfo.NdotV * length(vec3(
|
|
1146
|
+
tangentRoughness * dot(anisotropyTangent, pbrInfo.l),
|
|
1147
|
+
bitangentRoughness * dot(anisotropyBitangent, pbrInfo.l),
|
|
1148
|
+
pbrInfo.NdotL
|
|
1149
|
+
));
|
|
1150
|
+
float visibility = clamp(0.5 / max(viewMask + lightMask, 0.000001), 0.0, 1.0);
|
|
1151
|
+
vec3 fresnel = specularReflection(pbrInfo);
|
|
1152
|
+
vec3 diffuseContribution = (vec3(1.0) - fresnel) * diffuse(pbrInfo);
|
|
1153
|
+
return pbrInfo.NdotL * lightColor *
|
|
1154
|
+
(diffuseContribution + fresnel * distribution * visibility);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
vec3 getAnisotropicReflection(PBRInfo pbrInfo, vec3 anisotropyTangent, float anisotropyStrength)
|
|
1158
|
+
{
|
|
1159
|
+
if (anisotropyStrength <= 0.0) {
|
|
1160
|
+
return -normalize(reflect(pbrInfo.v, pbrInfo.n));
|
|
1161
|
+
}
|
|
1162
|
+
vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));
|
|
1163
|
+
vec3 anisotropicNormal = normalize(cross(anisotropyBitangent, pbrInfo.v));
|
|
1164
|
+
anisotropicNormal = normalize(cross(anisotropicNormal, anisotropyBitangent));
|
|
1165
|
+
float bend = anisotropyStrength * (1.0 - pbrInfo.perceptualRoughness);
|
|
1166
|
+
return -normalize(reflect(pbrInfo.v, normalize(mix(pbrInfo.n, anisotropicNormal, bend))));
|
|
726
1167
|
}
|
|
727
1168
|
|
|
728
1169
|
vec3 calculateMaterialLightColor(
|
|
@@ -736,8 +1177,12 @@ vec3 calculateMaterialLightColor(
|
|
|
736
1177
|
vec3 anisotropyTangent,
|
|
737
1178
|
float anisotropyStrength
|
|
738
1179
|
) {
|
|
739
|
-
|
|
740
|
-
|
|
1180
|
+
vec3 color = calculateAnisotropicLightColor(
|
|
1181
|
+
pbrInfo,
|
|
1182
|
+
lightColor,
|
|
1183
|
+
anisotropyTangent,
|
|
1184
|
+
anisotropyStrength
|
|
1185
|
+
);
|
|
741
1186
|
color += calculateClearcoatContribution(
|
|
742
1187
|
pbrInfo,
|
|
743
1188
|
lightColor,
|
|
@@ -754,6 +1199,8 @@ void PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {
|
|
|
754
1199
|
pbrInfo.NdotH = 0.0;
|
|
755
1200
|
pbrInfo.LdotH = 0.0;
|
|
756
1201
|
pbrInfo.VdotH = 1.0;
|
|
1202
|
+
pbrInfo.l = pbrInfo.n;
|
|
1203
|
+
pbrInfo.h = pbrInfo.n;
|
|
757
1204
|
}
|
|
758
1205
|
|
|
759
1206
|
void PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {
|
|
@@ -766,6 +1213,8 @@ void PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {
|
|
|
766
1213
|
pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0);
|
|
767
1214
|
pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0);
|
|
768
1215
|
pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0);
|
|
1216
|
+
pbrInfo.l = l;
|
|
1217
|
+
pbrInfo.h = h;
|
|
769
1218
|
}
|
|
770
1219
|
|
|
771
1220
|
void PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {
|
|
@@ -791,7 +1240,7 @@ vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {
|
|
|
791
1240
|
return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
|
|
792
1241
|
}
|
|
793
1242
|
|
|
794
|
-
vec4 pbr_filterColor(vec4
|
|
1243
|
+
vec4 pbr_filterColor(vec4 vertexColor)
|
|
795
1244
|
{
|
|
796
1245
|
vec2 baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);
|
|
797
1246
|
vec2 metallicRoughnessUV = getMaterialUV(
|
|
@@ -843,13 +1292,26 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
843
1292
|
pbrMaterial.anisotropyUVSet,
|
|
844
1293
|
pbrMaterial.anisotropyUVTransform
|
|
845
1294
|
);
|
|
1295
|
+
vec2 diffuseTransmissionUV = getMaterialUV(
|
|
1296
|
+
pbrMaterial.diffuseTransmissionUVSet,
|
|
1297
|
+
pbrMaterial.diffuseTransmissionUVTransform
|
|
1298
|
+
);
|
|
1299
|
+
vec2 diffuseTransmissionColorUV = getMaterialUV(
|
|
1300
|
+
pbrMaterial.diffuseTransmissionColorUVSet,
|
|
1301
|
+
pbrMaterial.diffuseTransmissionColorUVTransform
|
|
1302
|
+
);
|
|
1303
|
+
vec2 multiscatterColorUV = getMaterialUV(
|
|
1304
|
+
pbrMaterial.multiscatterColorUVSet,
|
|
1305
|
+
pbrMaterial.multiscatterColorUVTransform
|
|
1306
|
+
);
|
|
846
1307
|
|
|
847
1308
|
// The albedo may be defined from a base texture or a flat color
|
|
848
1309
|
#ifdef HAS_BASECOLORMAP
|
|
849
1310
|
vec4 baseColor =
|
|
850
|
-
SRGBtoLINEAR(texture(pbr_baseColorSampler, baseColorUV)) *
|
|
1311
|
+
SRGBtoLINEAR(texture(pbr_baseColorSampler, baseColorUV)) *
|
|
1312
|
+
pbrMaterial.baseColorFactor * vertexColor;
|
|
851
1313
|
#else
|
|
852
|
-
vec4 baseColor = pbrMaterial.baseColorFactor;
|
|
1314
|
+
vec4 baseColor = pbrMaterial.baseColorFactor * vertexColor;
|
|
853
1315
|
#endif
|
|
854
1316
|
|
|
855
1317
|
#ifdef ALPHA_CUTOFF
|
|
@@ -882,6 +1344,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
882
1344
|
metallic = clamp(metallic, 0.0, 1.0);
|
|
883
1345
|
mat3 tbn = getTBN(normalUV);
|
|
884
1346
|
vec3 n = getNormal(tbn, normalUV); // normal at surface point
|
|
1347
|
+
perceptualRoughness = widenSpecularRoughness(perceptualRoughness, n);
|
|
885
1348
|
vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
|
|
886
1349
|
float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
|
|
887
1350
|
#ifdef USE_MATERIAL_EXTENSIONS
|
|
@@ -891,8 +1354,14 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
891
1354
|
abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||
|
|
892
1355
|
maxComponent(abs(pbrMaterial.specularColorFactor - vec3(1.0))) > 0.0001 ||
|
|
893
1356
|
abs(pbrMaterial.ior - 1.5) > 0.0001 ||
|
|
1357
|
+
pbrMaterial.dispersion > 0.0001 ||
|
|
894
1358
|
pbrMaterial.transmissionMapEnabled ||
|
|
895
1359
|
pbrMaterial.transmissionFactor > 0.0001 ||
|
|
1360
|
+
pbrMaterial.diffuseTransmissionMapEnabled ||
|
|
1361
|
+
pbrMaterial.diffuseTransmissionColorMapEnabled ||
|
|
1362
|
+
pbrMaterial.diffuseTransmissionFactor > 0.0001 ||
|
|
1363
|
+
pbrMaterial.multiscatterColorMapEnabled ||
|
|
1364
|
+
maxComponent(pbrMaterial.multiscatterColorFactor) > 0.0001 ||
|
|
896
1365
|
pbrMaterial.clearcoatMapEnabled ||
|
|
897
1366
|
pbrMaterial.clearcoatRoughnessMapEnabled ||
|
|
898
1367
|
pbrMaterial.clearcoatFactor > 0.0001 ||
|
|
@@ -943,7 +1412,9 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
943
1412
|
diffuseColor,
|
|
944
1413
|
specularColor,
|
|
945
1414
|
n,
|
|
946
|
-
v
|
|
1415
|
+
v,
|
|
1416
|
+
n,
|
|
1417
|
+
n
|
|
947
1418
|
);
|
|
948
1419
|
|
|
949
1420
|
#ifdef USE_LIGHTS
|
|
@@ -1001,7 +1472,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1001
1472
|
color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
|
|
1002
1473
|
#endif
|
|
1003
1474
|
|
|
1004
|
-
return vec4(
|
|
1475
|
+
return vec4(applySceneColorManagement(color), baseColor.a);
|
|
1005
1476
|
}
|
|
1006
1477
|
|
|
1007
1478
|
float specularIntensity = pbrMaterial.specularIntensityFactor;
|
|
@@ -1030,6 +1501,30 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1030
1501
|
thickness *= texture(pbr_thicknessSampler, thicknessUV).g;
|
|
1031
1502
|
#endif
|
|
1032
1503
|
|
|
1504
|
+
float diffuseTransmission = clamp(pbrMaterial.diffuseTransmissionFactor, 0.0, 1.0);
|
|
1505
|
+
#ifdef HAS_DIFFUSETRANSMISSIONMAP
|
|
1506
|
+
if (pbrMaterial.diffuseTransmissionMapEnabled) {
|
|
1507
|
+
diffuseTransmission *= texture(pbr_diffuseTransmissionSampler, diffuseTransmissionUV).a;
|
|
1508
|
+
}
|
|
1509
|
+
#endif
|
|
1510
|
+
diffuseTransmission *= (1.0 - metallic) * (1.0 - transmission);
|
|
1511
|
+
vec3 diffuseTransmissionColor = pbrMaterial.diffuseTransmissionColorFactor;
|
|
1512
|
+
#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP
|
|
1513
|
+
if (pbrMaterial.diffuseTransmissionColorMapEnabled) {
|
|
1514
|
+
diffuseTransmissionColor *= SRGBtoLINEAR(
|
|
1515
|
+
texture(pbr_diffuseTransmissionColorSampler, diffuseTransmissionColorUV)
|
|
1516
|
+
).rgb;
|
|
1517
|
+
}
|
|
1518
|
+
#endif
|
|
1519
|
+
vec3 multiscatterColor = pbrMaterial.multiscatterColorFactor;
|
|
1520
|
+
#ifdef HAS_MULTISCATTERCOLORMAP
|
|
1521
|
+
if (pbrMaterial.multiscatterColorMapEnabled) {
|
|
1522
|
+
multiscatterColor *= SRGBtoLINEAR(
|
|
1523
|
+
texture(pbr_multiscatterColorSampler, multiscatterColorUV)
|
|
1524
|
+
).rgb;
|
|
1525
|
+
}
|
|
1526
|
+
#endif
|
|
1527
|
+
|
|
1033
1528
|
float clearcoatFactor = pbrMaterial.clearcoatFactor;
|
|
1034
1529
|
float clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;
|
|
1035
1530
|
#ifdef HAS_CLEARCOATMAP
|
|
@@ -1045,6 +1540,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1045
1540
|
clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);
|
|
1046
1541
|
clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
|
|
1047
1542
|
vec3 clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);
|
|
1543
|
+
clearcoatRoughness = widenSpecularRoughness(clearcoatRoughness, clearcoatNormal);
|
|
1048
1544
|
|
|
1049
1545
|
vec3 sheenColor = pbrMaterial.sheenColorFactor;
|
|
1050
1546
|
float sheenRoughness = pbrMaterial.sheenRoughnessFactor;
|
|
@@ -1097,13 +1593,6 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1097
1593
|
if (length(anisotropyTangent) < 0.0001) {
|
|
1098
1594
|
anisotropyTangent = normalize(tbn[0]);
|
|
1099
1595
|
}
|
|
1100
|
-
float anisotropyViewAlignment = abs(dot(v, anisotropyTangent));
|
|
1101
|
-
perceptualRoughness = mix(
|
|
1102
|
-
perceptualRoughness,
|
|
1103
|
-
clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),
|
|
1104
|
-
anisotropyStrength
|
|
1105
|
-
);
|
|
1106
|
-
|
|
1107
1596
|
// Roughness is authored as perceptual roughness; as is convention,
|
|
1108
1597
|
// convert to material roughness by squaring the perceptual roughness [2].
|
|
1109
1598
|
float alphaRoughness = perceptualRoughness * perceptualRoughness;
|
|
@@ -1113,17 +1602,24 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1113
1602
|
vec3(dielectricF0) * specularFactor * specularIntensity,
|
|
1114
1603
|
vec3(1.0)
|
|
1115
1604
|
);
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1605
|
+
dielectricSpecularF0 = getIridescenceTint(
|
|
1606
|
+
iridescence,
|
|
1607
|
+
iridescenceThickness,
|
|
1608
|
+
NdotV,
|
|
1609
|
+
dielectricSpecularF0
|
|
1121
1610
|
);
|
|
1122
1611
|
vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0);
|
|
1123
|
-
diffuseColor *= (1.0 - metallic) * (1.0 - transmission);
|
|
1612
|
+
diffuseColor *= (1.0 - metallic) * (1.0 - transmission) * (1.0 - diffuseTransmission);
|
|
1124
1613
|
vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);
|
|
1125
1614
|
|
|
1126
|
-
float
|
|
1615
|
+
float clearcoatViewFresnel = dielectricSchlick(
|
|
1616
|
+
0.04,
|
|
1617
|
+
clamp(abs(dot(clearcoatNormal, v)), 0.0, 1.0)
|
|
1618
|
+
);
|
|
1619
|
+
float sheenDirectionalAlbedo = maxComponent(sheenColor) *
|
|
1620
|
+
(0.157 + 0.343 * (1.0 - NdotV)) * (1.0 - sheenRoughness * 0.5);
|
|
1621
|
+
float baseLayerEnergy = (1.0 - clearcoatFactor * clearcoatViewFresnel) *
|
|
1622
|
+
(1.0 - clamp(sheenDirectionalAlbedo, 0.0, 1.0));
|
|
1127
1623
|
diffuseColor *= baseLayerEnergy;
|
|
1128
1624
|
specularColor *= baseLayerEnergy;
|
|
1129
1625
|
|
|
@@ -1153,7 +1649,9 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1153
1649
|
diffuseColor,
|
|
1154
1650
|
specularColor,
|
|
1155
1651
|
n,
|
|
1156
|
-
v
|
|
1652
|
+
v,
|
|
1653
|
+
n,
|
|
1654
|
+
n
|
|
1157
1655
|
);
|
|
1158
1656
|
|
|
1159
1657
|
|
|
@@ -1187,6 +1685,14 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1187
1685
|
anisotropyTangent,
|
|
1188
1686
|
anisotropyStrength
|
|
1189
1687
|
);
|
|
1688
|
+
color += calculateDiffuseTransmissionLight(
|
|
1689
|
+
pbrInfo,
|
|
1690
|
+
lighting_getDirectionalLight(i).color,
|
|
1691
|
+
diffuseTransmissionColor,
|
|
1692
|
+
diffuseTransmission,
|
|
1693
|
+
multiscatterColor,
|
|
1694
|
+
thickness
|
|
1695
|
+
);
|
|
1190
1696
|
}
|
|
1191
1697
|
}
|
|
1192
1698
|
|
|
@@ -1206,6 +1712,14 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1206
1712
|
anisotropyTangent,
|
|
1207
1713
|
anisotropyStrength
|
|
1208
1714
|
);
|
|
1715
|
+
color += calculateDiffuseTransmissionLight(
|
|
1716
|
+
pbrInfo,
|
|
1717
|
+
lighting_getPointLight(i).color / attenuation,
|
|
1718
|
+
diffuseTransmissionColor,
|
|
1719
|
+
diffuseTransmission,
|
|
1720
|
+
multiscatterColor,
|
|
1721
|
+
thickness
|
|
1722
|
+
);
|
|
1209
1723
|
}
|
|
1210
1724
|
}
|
|
1211
1725
|
|
|
@@ -1224,6 +1738,14 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1224
1738
|
anisotropyTangent,
|
|
1225
1739
|
anisotropyStrength
|
|
1226
1740
|
);
|
|
1741
|
+
color += calculateDiffuseTransmissionLight(
|
|
1742
|
+
pbrInfo,
|
|
1743
|
+
lighting_getSpotLight(i).color / attenuation,
|
|
1744
|
+
diffuseTransmissionColor,
|
|
1745
|
+
diffuseTransmission,
|
|
1746
|
+
multiscatterColor,
|
|
1747
|
+
thickness
|
|
1748
|
+
);
|
|
1227
1749
|
}
|
|
1228
1750
|
}
|
|
1229
1751
|
#endif
|
|
@@ -1231,8 +1753,11 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1231
1753
|
// Calculate lighting contribution from image based lighting source (IBL)
|
|
1232
1754
|
#ifdef USE_IBL
|
|
1233
1755
|
if (pbrMaterial.IBLenabled) {
|
|
1234
|
-
color += getIBLContribution(
|
|
1235
|
-
|
|
1756
|
+
color += getIBLContribution(
|
|
1757
|
+
pbrInfo,
|
|
1758
|
+
n,
|
|
1759
|
+
getAnisotropicReflection(pbrInfo, anisotropyTangent, anisotropyStrength)
|
|
1760
|
+
);
|
|
1236
1761
|
color += calculateClearcoatIBLContribution(
|
|
1237
1762
|
pbrInfo,
|
|
1238
1763
|
clearcoatNormal,
|
|
@@ -1240,6 +1765,13 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1240
1765
|
clearcoatFactor,
|
|
1241
1766
|
clearcoatRoughness
|
|
1242
1767
|
);
|
|
1768
|
+
color += calculateDiffuseTransmissionIBL(
|
|
1769
|
+
pbrInfo,
|
|
1770
|
+
diffuseTransmissionColor,
|
|
1771
|
+
diffuseTransmission,
|
|
1772
|
+
multiscatterColor,
|
|
1773
|
+
thickness
|
|
1774
|
+
);
|
|
1243
1775
|
color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;
|
|
1244
1776
|
}
|
|
1245
1777
|
#endif
|
|
@@ -1261,7 +1793,22 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1261
1793
|
color += emissive * pbrMaterial.emissiveStrength;
|
|
1262
1794
|
|
|
1263
1795
|
if (transmission > 0.0) {
|
|
1796
|
+
#ifdef USE_TRANSMISSION_FRAMEBUFFER
|
|
1797
|
+
float dielectricFresnel = getDielectricF0(pbrMaterial.ior);
|
|
1798
|
+
float transmissionFresnel = dielectricFresnel +
|
|
1799
|
+
(1.0 - dielectricFresnel) * pow(1.0 - NdotV, 5.0);
|
|
1800
|
+
vec3 transmittedColor = getTransmittedSceneColor(
|
|
1801
|
+
pbr_vPosition,
|
|
1802
|
+
n,
|
|
1803
|
+
v,
|
|
1804
|
+
thickness,
|
|
1805
|
+
perceptualRoughness
|
|
1806
|
+
);
|
|
1807
|
+
color += transmittedColor * getVolumeAttenuation(thickness) *
|
|
1808
|
+
transmission * (1.0 - transmissionFresnel);
|
|
1809
|
+
#else
|
|
1264
1810
|
color = mix(color, color * getVolumeAttenuation(thickness), transmission);
|
|
1811
|
+
#endif
|
|
1265
1812
|
}
|
|
1266
1813
|
|
|
1267
1814
|
// This section uses mix to override final color for reference app visualization
|
|
@@ -1282,10 +1829,14 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
1282
1829
|
|
|
1283
1830
|
}
|
|
1284
1831
|
|
|
1832
|
+
#ifdef USE_TRANSMISSION_FRAMEBUFFER
|
|
1833
|
+
float alpha = clamp(baseColor.a, 0.0, 1.0);
|
|
1834
|
+
#else
|
|
1285
1835
|
float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);
|
|
1286
|
-
|
|
1836
|
+
#endif
|
|
1837
|
+
return vec4(applySceneColorManagement(color), alpha);
|
|
1287
1838
|
}
|
|
1288
|
-
`;var
|
|
1839
|
+
`;var um=`struct PBRFragmentInputs {
|
|
1289
1840
|
pbr_vPosition: vec3f,
|
|
1290
1841
|
pbr_vUV0: vec2f,
|
|
1291
1842
|
pbr_vUV1: vec2f,
|
|
@@ -1387,6 +1938,7 @@ struct pbrMaterialUniforms {
|
|
|
1387
1938
|
anisotropyMapEnabled: i32,
|
|
1388
1939
|
|
|
1389
1940
|
emissiveStrength: f32,
|
|
1941
|
+
dispersion: f32,
|
|
1390
1942
|
|
|
1391
1943
|
// IBL
|
|
1392
1944
|
IBLenabled: i32,
|
|
@@ -1432,6 +1984,25 @@ struct pbrMaterialUniforms {
|
|
|
1432
1984
|
iridescenceThicknessUVTransform: mat3x3f,
|
|
1433
1985
|
anisotropyUVSet: i32,
|
|
1434
1986
|
anisotropyUVTransform: mat3x3f,
|
|
1987
|
+
|
|
1988
|
+
bumpFactor: f32,
|
|
1989
|
+
bumpMapEnabled: i32,
|
|
1990
|
+
diffuseTransmissionFactor: f32,
|
|
1991
|
+
diffuseTransmissionMapEnabled: i32,
|
|
1992
|
+
diffuseTransmissionColorFactor: vec3f,
|
|
1993
|
+
diffuseTransmissionColorMapEnabled: i32,
|
|
1994
|
+
multiscatterColorFactor: vec3f,
|
|
1995
|
+
multiscatterColorMapEnabled: i32,
|
|
1996
|
+
scatterAnisotropy: f32,
|
|
1997
|
+
|
|
1998
|
+
bumpUVSet: i32,
|
|
1999
|
+
bumpUVTransform: mat3x3f,
|
|
2000
|
+
diffuseTransmissionUVSet: i32,
|
|
2001
|
+
diffuseTransmissionUVTransform: mat3x3f,
|
|
2002
|
+
diffuseTransmissionColorUVSet: i32,
|
|
2003
|
+
diffuseTransmissionColorUVTransform: mat3x3f,
|
|
2004
|
+
multiscatterColorUVSet: i32,
|
|
2005
|
+
multiscatterColorUVTransform: mat3x3f,
|
|
1435
2006
|
}
|
|
1436
2007
|
|
|
1437
2008
|
@group(3) @binding(auto) var<uniform> pbrMaterial : pbrMaterialUniforms;
|
|
@@ -1505,6 +2076,22 @@ struct pbrMaterialUniforms {
|
|
|
1505
2076
|
@group(3) @binding(auto) var pbr_anisotropySampler: texture_2d<f32>;
|
|
1506
2077
|
@group(3) @binding(auto) var pbr_anisotropySamplerSampler: sampler;
|
|
1507
2078
|
#endif
|
|
2079
|
+
#ifdef HAS_BUMPMAP
|
|
2080
|
+
@group(3) @binding(auto) var pbr_bumpSampler: texture_2d<f32>;
|
|
2081
|
+
@group(3) @binding(auto) var pbr_bumpSamplerSampler: sampler;
|
|
2082
|
+
#endif
|
|
2083
|
+
#ifdef HAS_DIFFUSETRANSMISSIONMAP
|
|
2084
|
+
@group(3) @binding(auto) var pbr_diffuseTransmissionSampler: texture_2d<f32>;
|
|
2085
|
+
@group(3) @binding(auto) var pbr_diffuseTransmissionSamplerSampler: sampler;
|
|
2086
|
+
#endif
|
|
2087
|
+
#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP
|
|
2088
|
+
@group(3) @binding(auto) var pbr_diffuseTransmissionColorSampler: texture_2d<f32>;
|
|
2089
|
+
@group(3) @binding(auto) var pbr_diffuseTransmissionColorSamplerSampler: sampler;
|
|
2090
|
+
#endif
|
|
2091
|
+
#ifdef HAS_MULTISCATTERCOLORMAP
|
|
2092
|
+
@group(3) @binding(auto) var pbr_multiscatterColorSampler: texture_2d<f32>;
|
|
2093
|
+
@group(3) @binding(auto) var pbr_multiscatterColorSamplerSampler: sampler;
|
|
2094
|
+
#endif
|
|
1508
2095
|
// Encapsulate the various inputs used by the various functions in the shading equation
|
|
1509
2096
|
// We store values in this struct to simplify the integration of alternative implementations
|
|
1510
2097
|
// of the shading terms, outlined in the Readme.MD Appendix.
|
|
@@ -1523,11 +2110,30 @@ struct PBRInfo {
|
|
|
1523
2110
|
specularColor: vec3f, // color contribution from specular lighting
|
|
1524
2111
|
n: vec3f, // normal at surface point
|
|
1525
2112
|
v: vec3f, // vector from surface point to camera
|
|
2113
|
+
l: vec3f, // direction from the surface toward the current light
|
|
2114
|
+
h: vec3f // half vector between the current light and camera
|
|
1526
2115
|
};
|
|
1527
2116
|
|
|
1528
2117
|
const M_PI = 3.141592653589793;
|
|
1529
2118
|
const c_MinRoughness = 0.04;
|
|
1530
2119
|
|
|
2120
|
+
// Widen sub-pixel specular lobes using the screen-space normal footprint.
|
|
2121
|
+
// This is geometric specular antialiasing: the normal variance is converted
|
|
2122
|
+
// into an additional squared perceptual roughness before evaluating BRDFs.
|
|
2123
|
+
fn widenSpecularRoughness(perceptualRoughness: f32, normal: vec3f) -> f32 {
|
|
2124
|
+
let normalDerivativeX = dpdx(normal);
|
|
2125
|
+
let normalDerivativeY = dpdy(normal);
|
|
2126
|
+
let normalVariance =
|
|
2127
|
+
dot(normalDerivativeX, normalDerivativeX) +
|
|
2128
|
+
dot(normalDerivativeY, normalDerivativeY);
|
|
2129
|
+
let kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);
|
|
2130
|
+
return clamp(
|
|
2131
|
+
sqrt(perceptualRoughness * perceptualRoughness + kernelRoughnessSquared),
|
|
2132
|
+
c_MinRoughness,
|
|
2133
|
+
1.0
|
|
2134
|
+
);
|
|
2135
|
+
}
|
|
2136
|
+
|
|
1531
2137
|
fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f
|
|
1532
2138
|
{
|
|
1533
2139
|
var linOut: vec3f = srgbIn.xyz;
|
|
@@ -1563,7 +2169,7 @@ fn getTBN(uv: vec2f) -> mat3x3f
|
|
|
1563
2169
|
let tex_dy: vec3f = dpdy(vec3f(uv, 0.0));
|
|
1564
2170
|
var t: vec3f = (tex_dy.y * pos_dx - tex_dx.y * pos_dy) / (tex_dx.x * tex_dy.y - tex_dy.x * tex_dx.y);
|
|
1565
2171
|
|
|
1566
|
-
var ng: vec3f = cross(
|
|
2172
|
+
var ng: vec3f = cross(pos_dy, pos_dx);
|
|
1567
2173
|
#ifdef HAS_NORMALS
|
|
1568
2174
|
ng = normalize(fragmentInputs.pbr_vNormal);
|
|
1569
2175
|
#endif
|
|
@@ -1605,6 +2211,26 @@ fn getNormal(tbn: mat3x3f, uv: vec2f) -> vec3f
|
|
|
1605
2211
|
);
|
|
1606
2212
|
#endif
|
|
1607
2213
|
|
|
2214
|
+
#ifdef HAS_BUMPMAP
|
|
2215
|
+
let bumpUV = getMaterialUV(pbrMaterial.bumpUVSet, pbrMaterial.bumpUVTransform);
|
|
2216
|
+
let bumpTexelSize = 1.0 / vec2f(textureDimensions(pbr_bumpSampler, 0));
|
|
2217
|
+
let bumpHeight = textureSample(pbr_bumpSampler, pbr_bumpSamplerSampler, bumpUV).r;
|
|
2218
|
+
let bumpGradient = vec2f(
|
|
2219
|
+
textureSample(
|
|
2220
|
+
pbr_bumpSampler,
|
|
2221
|
+
pbr_bumpSamplerSampler,
|
|
2222
|
+
bumpUV + vec2f(bumpTexelSize.x, 0.0)
|
|
2223
|
+
).r - bumpHeight,
|
|
2224
|
+
textureSample(
|
|
2225
|
+
pbr_bumpSampler,
|
|
2226
|
+
pbr_bumpSamplerSampler,
|
|
2227
|
+
bumpUV + vec2f(0.0, bumpTexelSize.y)
|
|
2228
|
+
).r - bumpHeight
|
|
2229
|
+
);
|
|
2230
|
+
n = normalize(n - pbrMaterial.bumpFactor *
|
|
2231
|
+
(tbn[0] * bumpGradient.x + tbn[1] * bumpGradient.y));
|
|
2232
|
+
#endif
|
|
2233
|
+
|
|
1608
2234
|
return n;
|
|
1609
2235
|
}
|
|
1610
2236
|
|
|
@@ -1629,45 +2255,71 @@ fn getClearcoatNormal(tbn: mat3x3f, baseNormal: vec3f, uv: vec2f) -> vec3f
|
|
|
1629
2255
|
#ifdef USE_IBL
|
|
1630
2256
|
fn getIBLContribution(pbrInfo: PBRInfo, n: vec3f, reflection: vec3f) -> vec3f
|
|
1631
2257
|
{
|
|
1632
|
-
|
|
1633
|
-
let
|
|
2258
|
+
#ifdef USE_SCENE_ENVIRONMENT
|
|
2259
|
+
let maximumMipLevel = max(pbrScene.environmentMipCount - 1.0, 0.0);
|
|
2260
|
+
let rotationSine = sin(pbrScene.environmentRotation);
|
|
2261
|
+
let rotationCosine = cos(pbrScene.environmentRotation);
|
|
2262
|
+
let environmentRotation = mat2x2f(
|
|
2263
|
+
vec2f(rotationCosine, rotationSine),
|
|
2264
|
+
vec2f(-rotationSine, rotationCosine)
|
|
2265
|
+
);
|
|
2266
|
+
let rotatedNormal = environmentRotation * n.xz;
|
|
2267
|
+
let rotatedReflection = environmentRotation * reflection.xz;
|
|
2268
|
+
let environmentNormal = vec3f(rotatedNormal.x, n.y, rotatedNormal.y);
|
|
2269
|
+
let environmentReflection = vec3f(rotatedReflection.x, reflection.y, rotatedReflection.y);
|
|
2270
|
+
#else
|
|
2271
|
+
let maximumMipLevel = 9.0;
|
|
2272
|
+
let environmentNormal = n;
|
|
2273
|
+
let environmentReflection = reflection;
|
|
2274
|
+
#endif
|
|
2275
|
+
let lod = pbrInfo.perceptualRoughness * maximumMipLevel;
|
|
1634
2276
|
// retrieve a scale and bias to F0. See [1], Figure 3
|
|
1635
|
-
let
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
var
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
)
|
|
1654
|
-
).rgb;
|
|
2277
|
+
let brdfSample = textureSampleLevel(
|
|
2278
|
+
pbr_brdfLUT,
|
|
2279
|
+
pbr_brdfLUTSampler,
|
|
2280
|
+
vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness),
|
|
2281
|
+
0.0
|
|
2282
|
+
);
|
|
2283
|
+
let diffuseSample = textureSampleLevel(
|
|
2284
|
+
pbr_diffuseEnvSampler,
|
|
2285
|
+
pbr_diffuseEnvSamplerSampler,
|
|
2286
|
+
environmentNormal,
|
|
2287
|
+
0.0
|
|
2288
|
+
);
|
|
2289
|
+
var specularSample = textureSampleLevel(
|
|
2290
|
+
pbr_specularEnvSampler,
|
|
2291
|
+
pbr_specularEnvSamplerSampler,
|
|
2292
|
+
environmentReflection,
|
|
2293
|
+
0.0
|
|
2294
|
+
);
|
|
1655
2295
|
#ifdef USE_TEX_LOD
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
2296
|
+
specularSample = textureSampleLevel(
|
|
2297
|
+
pbr_specularEnvSampler,
|
|
2298
|
+
pbr_specularEnvSamplerSampler,
|
|
2299
|
+
environmentReflection,
|
|
2300
|
+
lod
|
|
2301
|
+
);
|
|
2302
|
+
#endif
|
|
2303
|
+
|
|
2304
|
+
#ifdef USE_SCENE_ENVIRONMENT
|
|
2305
|
+
let brdf = brdfSample.rgb;
|
|
2306
|
+
let diffuseLight = diffuseSample.rgb;
|
|
2307
|
+
let specularLight = specularSample.rgb;
|
|
2308
|
+
#else
|
|
2309
|
+
let brdf = SRGBtoLINEAR(brdfSample).rgb;
|
|
2310
|
+
let diffuseLight = SRGBtoLINEAR(diffuseSample).rgb;
|
|
2311
|
+
let specularLight = SRGBtoLINEAR(specularSample).rgb;
|
|
1664
2312
|
#endif
|
|
1665
2313
|
|
|
1666
2314
|
let diffuse = diffuseLight * pbrInfo.diffuseColor * pbrMaterial.scaleIBLAmbient.x;
|
|
1667
2315
|
let specular =
|
|
1668
2316
|
specularLight * (pbrInfo.specularColor * brdf.x + brdf.y) * pbrMaterial.scaleIBLAmbient.y;
|
|
1669
2317
|
|
|
2318
|
+
#ifdef USE_SCENE_ENVIRONMENT
|
|
2319
|
+
return (diffuse + specular) * max(pbrScene.environmentIntensity, 0.0);
|
|
2320
|
+
#else
|
|
1670
2321
|
return diffuse + specular;
|
|
2322
|
+
#endif
|
|
1671
2323
|
}
|
|
1672
2324
|
#endif
|
|
1673
2325
|
|
|
@@ -1737,17 +2389,131 @@ fn rotateDirection(direction: vec2f, rotation: f32) -> vec2f {
|
|
|
1737
2389
|
return vec2f(direction.x * c - direction.y * s, direction.x * s + direction.y * c);
|
|
1738
2390
|
}
|
|
1739
2391
|
|
|
1740
|
-
fn
|
|
1741
|
-
|
|
1742
|
-
|
|
2392
|
+
fn encodeLinearSRGB(linearColor: vec3f) -> vec3f {
|
|
2393
|
+
let positiveColor = max(linearColor, vec3f(0.0));
|
|
2394
|
+
return select(
|
|
2395
|
+
positiveColor * 12.92,
|
|
2396
|
+
1.055 * pow(positiveColor, vec3f(1.0 / 2.4)) - 0.055,
|
|
2397
|
+
positiveColor > vec3f(0.0031308)
|
|
2398
|
+
);
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
fn toneMapKhronosPBRNeutral(inputColor: vec3f) -> vec3f {
|
|
2402
|
+
let startCompression = 0.76;
|
|
2403
|
+
let darkestChannel = min(inputColor.r, min(inputColor.g, inputColor.b));
|
|
2404
|
+
let offset = select(
|
|
2405
|
+
0.04,
|
|
2406
|
+
darkestChannel - 6.25 * darkestChannel * darkestChannel,
|
|
2407
|
+
darkestChannel < 0.08
|
|
2408
|
+
);
|
|
2409
|
+
var color = inputColor - vec3f(offset);
|
|
2410
|
+
let peak = maxComponent(color);
|
|
2411
|
+
if (peak < startCompression) {
|
|
2412
|
+
return color;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
let compressionRange = 1.0 - startCompression;
|
|
2416
|
+
let compressedPeak = 1.0 - compressionRange * compressionRange /
|
|
2417
|
+
(peak + compressionRange - startCompression);
|
|
2418
|
+
color *= compressedPeak / max(peak, 0.0001);
|
|
2419
|
+
let desaturation = 1.0 - 1.0 / (0.15 * (peak - compressedPeak) + 1.0);
|
|
2420
|
+
return mix(color, vec3f(compressedPeak), desaturation);
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
fn applySceneColorManagement(sceneColor: vec3f) -> vec3f {
|
|
2424
|
+
#ifdef USE_SCENE_COLOR_MANAGEMENT
|
|
2425
|
+
var color = max(sceneColor, vec3f(0.0)) * max(pbrScene.exposure, 0.0);
|
|
2426
|
+
if (pbrScene.toneMapMode == 1) {
|
|
2427
|
+
color /= vec3f(1.0) + color;
|
|
2428
|
+
} else if (pbrScene.toneMapMode == 2) {
|
|
2429
|
+
color = toneMapKhronosPBRNeutral(color);
|
|
2430
|
+
} else if (pbrScene.toneMapMode == 3) {
|
|
2431
|
+
color = clamp(
|
|
2432
|
+
(color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14),
|
|
2433
|
+
vec3f(0.0),
|
|
2434
|
+
vec3f(1.0)
|
|
2435
|
+
);
|
|
1743
2436
|
}
|
|
2437
|
+
if (pbrScene.outputEncoding == 0) {
|
|
2438
|
+
return color;
|
|
2439
|
+
}
|
|
2440
|
+
return encodeLinearSRGB(color);
|
|
2441
|
+
#else
|
|
2442
|
+
return pow(max(sceneColor, vec3f(0.0)), vec3f(1.0 / 2.2));
|
|
2443
|
+
#endif
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
fn dielectricSchlick(reflectance: f32, cosine: f32) -> f32 {
|
|
2447
|
+
return reflectance + (1.0 - reflectance) * pow(clamp(1.0 - cosine, 0.0, 1.0), 5.0);
|
|
2448
|
+
}
|
|
1744
2449
|
|
|
1745
|
-
|
|
1746
|
-
let
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
2450
|
+
fn evaluateIridescenceSensitivity(opticalPathDifference: f32, phaseShift: vec3f) -> vec3f {
|
|
2451
|
+
let phase = 2.0 * M_PI * opticalPathDifference * 1.0e-9;
|
|
2452
|
+
let sensitivity = vec3f(5.4856e-13, 4.4201e-13, 5.2481e-13);
|
|
2453
|
+
let position = vec3f(1.6810e6, 1.7953e6, 2.2084e6);
|
|
2454
|
+
let variance = vec3f(4.3278e9, 9.3046e9, 6.6121e9);
|
|
2455
|
+
var xyz = sensitivity * sqrt(2.0 * M_PI * variance) *
|
|
2456
|
+
cos(position * phase + phaseShift) * exp(-phase * phase * variance);
|
|
2457
|
+
xyz.x += 9.7470e-14 * sqrt(2.0 * M_PI * 4.5282e9) *
|
|
2458
|
+
cos(2.2399e6 * phase + phaseShift.x) * exp(-4.5282e9 * phase * phase);
|
|
2459
|
+
xyz /= 1.0685e-7;
|
|
2460
|
+
return mat3x3f(
|
|
2461
|
+
vec3f(3.2404542, -0.9692660, 0.0556434),
|
|
2462
|
+
vec3f(-1.5371385, 1.8760108, -0.2040259),
|
|
2463
|
+
vec3f(-0.4985314, 0.0415560, 1.0572252)
|
|
2464
|
+
) * xyz;
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
fn getIridescenceTint(
|
|
2468
|
+
iridescence: f32,
|
|
2469
|
+
thickness: f32,
|
|
2470
|
+
NdotV: f32,
|
|
2471
|
+
baseReflectance: vec3f
|
|
2472
|
+
) -> vec3f {
|
|
2473
|
+
if (iridescence <= 0.0 || thickness <= 0.0) {
|
|
2474
|
+
return baseReflectance;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
let filmIor = max(pbrMaterial.iridescenceIor, 1.0);
|
|
2478
|
+
let sineSquared = (1.0 - NdotV * NdotV) / (filmIor * filmIor);
|
|
2479
|
+
let cosineSquared = 1.0 - sineSquared;
|
|
2480
|
+
if (cosineSquared <= 0.0) {
|
|
2481
|
+
return mix(baseReflectance, vec3f(1.0), iridescence);
|
|
2482
|
+
}
|
|
2483
|
+
let filmCosine = sqrt(cosineSquared);
|
|
2484
|
+
let firstInterfaceReflectance = dielectricSchlick(getDielectricF0(filmIor), NdotV);
|
|
2485
|
+
let transmittedEnergy = 1.0 - firstInterfaceReflectance;
|
|
2486
|
+
let squareRootReflectance = sqrt(clamp(baseReflectance, vec3f(0.0), vec3f(0.9999)));
|
|
2487
|
+
let baseIor = (vec3f(1.0) + squareRootReflectance) /
|
|
2488
|
+
(vec3f(1.0) - squareRootReflectance);
|
|
2489
|
+
var secondInterfaceF0 = (baseIor - vec3f(filmIor)) / (baseIor + vec3f(filmIor));
|
|
2490
|
+
secondInterfaceF0 *= secondInterfaceF0;
|
|
2491
|
+
let secondInterfaceReflectance = secondInterfaceF0 +
|
|
2492
|
+
(vec3f(1.0) - secondInterfaceF0) * pow(1.0 - filmCosine, 5.0);
|
|
2493
|
+
let phaseShift = vec3f(M_PI) + select(
|
|
2494
|
+
vec3f(0.0),
|
|
2495
|
+
vec3f(M_PI),
|
|
2496
|
+
baseIor < vec3f(filmIor)
|
|
2497
|
+
);
|
|
2498
|
+
let opticalPathDifference = 2.0 * filmIor * thickness * filmCosine;
|
|
2499
|
+
let combinedReflectance = clamp(
|
|
2500
|
+
firstInterfaceReflectance * secondInterfaceReflectance,
|
|
2501
|
+
vec3f(0.00001),
|
|
2502
|
+
vec3f(0.9999)
|
|
2503
|
+
);
|
|
2504
|
+
let recurringAmplitude = sqrt(combinedReflectance);
|
|
2505
|
+
let interfaceResponse = transmittedEnergy * transmittedEnergy * secondInterfaceReflectance /
|
|
2506
|
+
(vec3f(1.0) - combinedReflectance);
|
|
2507
|
+
var reflectedSpectrum = vec3f(firstInterfaceReflectance) + interfaceResponse;
|
|
2508
|
+
var harmonicAmplitude = interfaceResponse - vec3f(transmittedEnergy);
|
|
2509
|
+
for (var harmonic = 1; harmonic <= 2; harmonic++) {
|
|
2510
|
+
harmonicAmplitude *= recurringAmplitude;
|
|
2511
|
+
reflectedSpectrum += harmonicAmplitude * 2.0 * evaluateIridescenceSensitivity(
|
|
2512
|
+
f32(harmonic) * opticalPathDifference,
|
|
2513
|
+
f32(harmonic) * phaseShift
|
|
2514
|
+
);
|
|
2515
|
+
}
|
|
2516
|
+
return mix(baseReflectance, clamp(reflectedSpectrum, vec3f(0.0), vec3f(1.0)), iridescence);
|
|
1751
2517
|
}
|
|
1752
2518
|
|
|
1753
2519
|
fn getVolumeAttenuation(thickness: f32) -> vec3f {
|
|
@@ -1761,6 +2527,195 @@ fn getVolumeAttenuation(thickness: f32) -> vec3f {
|
|
|
1761
2527
|
return exp(-attenuationCoefficient * thickness);
|
|
1762
2528
|
}
|
|
1763
2529
|
|
|
2530
|
+
// KHR_materials_volume_scatter is an active draft. This evaluates a local,
|
|
2531
|
+
// thickness-aware single-scattering approximation rather than random walk.
|
|
2532
|
+
fn getDiffuseTransmissionAttenuation(
|
|
2533
|
+
pbrInfo: PBRInfo,
|
|
2534
|
+
multiscatterColor: vec3f,
|
|
2535
|
+
thickness: f32
|
|
2536
|
+
) -> vec3f {
|
|
2537
|
+
let volumeAttenuation = getVolumeAttenuation(thickness);
|
|
2538
|
+
let scatteringStrength = maxComponent(multiscatterColor);
|
|
2539
|
+
if (thickness <= 0.0 || scatteringStrength <= 0.0001) {
|
|
2540
|
+
return volumeAttenuation;
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
let anisotropy = clamp(pbrMaterial.scatterAnisotropy, -0.95, 0.95);
|
|
2544
|
+
let scatteringCosine = clamp(dot(-pbrInfo.v, pbrInfo.l), -1.0, 1.0);
|
|
2545
|
+
let phaseDenominator = max(
|
|
2546
|
+
1.0 + anisotropy * anisotropy - 2.0 * anisotropy * scatteringCosine,
|
|
2547
|
+
0.0001
|
|
2548
|
+
);
|
|
2549
|
+
let phaseWeight = clamp(
|
|
2550
|
+
(1.0 - anisotropy * anisotropy) / pow(phaseDenominator, 1.5),
|
|
2551
|
+
0.0,
|
|
2552
|
+
4.0
|
|
2553
|
+
);
|
|
2554
|
+
let scatteringDepth = thickness / max(pbrMaterial.attenuationDistance, 0.0001);
|
|
2555
|
+
let scatteringProbability = 1.0 - exp(-scatteringDepth);
|
|
2556
|
+
let scatteringColor = clamp(multiscatterColor, vec3f(0.0), vec3f(1.0));
|
|
2557
|
+
return mix(
|
|
2558
|
+
volumeAttenuation,
|
|
2559
|
+
volumeAttenuation * mix(vec3f(1.0), scatteringColor * phaseWeight, scatteringColor),
|
|
2560
|
+
scatteringProbability
|
|
2561
|
+
);
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
fn calculateDiffuseTransmissionLight(
|
|
2565
|
+
pbrInfo: PBRInfo,
|
|
2566
|
+
lightColor: vec3f,
|
|
2567
|
+
diffuseTransmissionColor: vec3f,
|
|
2568
|
+
diffuseTransmission: f32,
|
|
2569
|
+
multiscatterColor: vec3f,
|
|
2570
|
+
thickness: f32
|
|
2571
|
+
) -> vec3f {
|
|
2572
|
+
let oppositeHemisphere = max(dot(-pbrInfo.n, pbrInfo.l), 0.0);
|
|
2573
|
+
if (oppositeHemisphere <= 0.0 || diffuseTransmission <= 0.0) {
|
|
2574
|
+
return vec3f(0.0);
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
let nonReflectedEnergy = vec3f(1.0) - clamp(pbrInfo.reflectance0, vec3f(0.0), vec3f(1.0));
|
|
2578
|
+
let attenuatedColor = getDiffuseTransmissionAttenuation(
|
|
2579
|
+
pbrInfo,
|
|
2580
|
+
multiscatterColor,
|
|
2581
|
+
thickness
|
|
2582
|
+
);
|
|
2583
|
+
return lightColor * diffuseTransmissionColor * nonReflectedEnergy *
|
|
2584
|
+
attenuatedColor * (diffuseTransmission * oppositeHemisphere / M_PI);
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
#ifdef USE_IBL
|
|
2588
|
+
fn calculateDiffuseTransmissionIBL(
|
|
2589
|
+
pbrInfo: PBRInfo,
|
|
2590
|
+
diffuseTransmissionColor: vec3f,
|
|
2591
|
+
diffuseTransmission: f32,
|
|
2592
|
+
multiscatterColor: vec3f,
|
|
2593
|
+
thickness: f32
|
|
2594
|
+
) -> vec3f {
|
|
2595
|
+
if (diffuseTransmission <= 0.0) {
|
|
2596
|
+
return vec3f(0.0);
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
#ifdef USE_SCENE_ENVIRONMENT
|
|
2600
|
+
let rotationSine = sin(pbrScene.environmentRotation);
|
|
2601
|
+
let rotationCosine = cos(pbrScene.environmentRotation);
|
|
2602
|
+
let environmentRotation = mat2x2f(
|
|
2603
|
+
vec2f(rotationCosine, rotationSine),
|
|
2604
|
+
vec2f(-rotationSine, rotationCosine)
|
|
2605
|
+
);
|
|
2606
|
+
let rotatedNormal = environmentRotation * -pbrInfo.n.xz;
|
|
2607
|
+
let oppositeNormal = vec3f(rotatedNormal.x, -pbrInfo.n.y, rotatedNormal.y);
|
|
2608
|
+
let environmentColor = textureSampleLevel(
|
|
2609
|
+
pbr_diffuseEnvSampler,
|
|
2610
|
+
pbr_diffuseEnvSamplerSampler,
|
|
2611
|
+
oppositeNormal,
|
|
2612
|
+
0.0
|
|
2613
|
+
).rgb * max(pbrScene.environmentIntensity, 0.0);
|
|
2614
|
+
#else
|
|
2615
|
+
let environmentColor = SRGBtoLINEAR(
|
|
2616
|
+
textureSampleLevel(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, -pbrInfo.n, 0.0)
|
|
2617
|
+
).rgb;
|
|
2618
|
+
#endif
|
|
2619
|
+
let nonReflectedEnergy = vec3f(1.0) - clamp(pbrInfo.reflectance0, vec3f(0.0), vec3f(1.0));
|
|
2620
|
+
return environmentColor * diffuseTransmissionColor * nonReflectedEnergy *
|
|
2621
|
+
getDiffuseTransmissionAttenuation(pbrInfo, multiscatterColor, thickness) *
|
|
2622
|
+
diffuseTransmission * pbrMaterial.scaleIBLAmbient.x;
|
|
2623
|
+
}
|
|
2624
|
+
#endif
|
|
2625
|
+
|
|
2626
|
+
#ifdef USE_TRANSMISSION_FRAMEBUFFER
|
|
2627
|
+
fn sampleTransmittedSceneColor(
|
|
2628
|
+
position: vec3f,
|
|
2629
|
+
normal: vec3f,
|
|
2630
|
+
viewDirection: vec3f,
|
|
2631
|
+
thickness: f32,
|
|
2632
|
+
perceptualRoughness: f32,
|
|
2633
|
+
indexOfRefraction: f32
|
|
2634
|
+
) -> vec3f {
|
|
2635
|
+
let refractionDirection = refract(
|
|
2636
|
+
-viewDirection,
|
|
2637
|
+
normal,
|
|
2638
|
+
1.0 / max(indexOfRefraction, 1.0)
|
|
2639
|
+
);
|
|
2640
|
+
let refractedPosition = position + refractionDirection * thickness;
|
|
2641
|
+
let clipPosition = pbrScene.projectionMatrix *
|
|
2642
|
+
pbrScene.viewMatrix * vec4f(refractedPosition, 1.0);
|
|
2643
|
+
var textureCoordinate = clipPosition.xy / max(clipPosition.w, 0.0001) * 0.5 + 0.5;
|
|
2644
|
+
textureCoordinate.y = 1.0 - textureCoordinate.y;
|
|
2645
|
+
textureCoordinate = clamp(textureCoordinate, vec2f(0.001), vec2f(0.999));
|
|
2646
|
+
|
|
2647
|
+
let blurRadius = perceptualRoughness * perceptualRoughness * 8.0 /
|
|
2648
|
+
max(pbrScene.framebufferSize, vec2f(1.0));
|
|
2649
|
+
var sceneColor = textureSampleLevel(
|
|
2650
|
+
pbr_transmissionFramebufferSampler,
|
|
2651
|
+
pbr_transmissionFramebufferSamplerSampler,
|
|
2652
|
+
textureCoordinate,
|
|
2653
|
+
0.0
|
|
2654
|
+
).rgb * 0.4;
|
|
2655
|
+
sceneColor += textureSampleLevel(
|
|
2656
|
+
pbr_transmissionFramebufferSampler,
|
|
2657
|
+
pbr_transmissionFramebufferSamplerSampler,
|
|
2658
|
+
textureCoordinate + vec2f(blurRadius.x, 0.0),
|
|
2659
|
+
0.0
|
|
2660
|
+
).rgb * 0.15;
|
|
2661
|
+
sceneColor += textureSampleLevel(
|
|
2662
|
+
pbr_transmissionFramebufferSampler,
|
|
2663
|
+
pbr_transmissionFramebufferSamplerSampler,
|
|
2664
|
+
textureCoordinate - vec2f(blurRadius.x, 0.0),
|
|
2665
|
+
0.0
|
|
2666
|
+
).rgb * 0.15;
|
|
2667
|
+
sceneColor += textureSampleLevel(
|
|
2668
|
+
pbr_transmissionFramebufferSampler,
|
|
2669
|
+
pbr_transmissionFramebufferSamplerSampler,
|
|
2670
|
+
textureCoordinate + vec2f(0.0, blurRadius.y),
|
|
2671
|
+
0.0
|
|
2672
|
+
).rgb * 0.15;
|
|
2673
|
+
sceneColor += textureSampleLevel(
|
|
2674
|
+
pbr_transmissionFramebufferSampler,
|
|
2675
|
+
pbr_transmissionFramebufferSamplerSampler,
|
|
2676
|
+
textureCoordinate - vec2f(0.0, blurRadius.y),
|
|
2677
|
+
0.0
|
|
2678
|
+
).rgb * 0.15;
|
|
2679
|
+
return max(sceneColor, vec3f(0.0));
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
fn getTransmittedSceneColor(
|
|
2683
|
+
position: vec3f,
|
|
2684
|
+
normal: vec3f,
|
|
2685
|
+
viewDirection: vec3f,
|
|
2686
|
+
thickness: f32,
|
|
2687
|
+
perceptualRoughness: f32
|
|
2688
|
+
) -> vec3f {
|
|
2689
|
+
if (pbrMaterial.dispersion <= 0.0) {
|
|
2690
|
+
return sampleTransmittedSceneColor(
|
|
2691
|
+
position,
|
|
2692
|
+
normal,
|
|
2693
|
+
viewDirection,
|
|
2694
|
+
thickness,
|
|
2695
|
+
perceptualRoughness,
|
|
2696
|
+
pbrMaterial.ior
|
|
2697
|
+
);
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
let halfSpread = (max(pbrMaterial.ior, 1.0) - 1.0) * 0.025 * pbrMaterial.dispersion;
|
|
2701
|
+
let indicesOfRefraction = max(
|
|
2702
|
+
vec3f(pbrMaterial.ior - halfSpread, pbrMaterial.ior, pbrMaterial.ior + halfSpread),
|
|
2703
|
+
vec3f(1.0)
|
|
2704
|
+
);
|
|
2705
|
+
return vec3f(
|
|
2706
|
+
sampleTransmittedSceneColor(
|
|
2707
|
+
position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.r
|
|
2708
|
+
).r,
|
|
2709
|
+
sampleTransmittedSceneColor(
|
|
2710
|
+
position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.g
|
|
2711
|
+
).g,
|
|
2712
|
+
sampleTransmittedSceneColor(
|
|
2713
|
+
position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.b
|
|
2714
|
+
).b
|
|
2715
|
+
);
|
|
2716
|
+
}
|
|
2717
|
+
#endif
|
|
2718
|
+
|
|
1764
2719
|
fn createClearcoatPBRInfo(
|
|
1765
2720
|
basePBRInfo: PBRInfo,
|
|
1766
2721
|
clearcoatNormal: vec3f,
|
|
@@ -1784,7 +2739,9 @@ fn createClearcoatPBRInfo(
|
|
|
1784
2739
|
vec3f(0.0),
|
|
1785
2740
|
vec3f(0.04),
|
|
1786
2741
|
clearcoatNormal,
|
|
1787
|
-
basePBRInfo.v
|
|
2742
|
+
basePBRInfo.v,
|
|
2743
|
+
basePBRInfo.l,
|
|
2744
|
+
basePBRInfo.h
|
|
1788
2745
|
);
|
|
1789
2746
|
}
|
|
1790
2747
|
|
|
@@ -1830,28 +2787,75 @@ fn calculateSheenContribution(
|
|
|
1830
2787
|
return vec3f(0.0);
|
|
1831
2788
|
}
|
|
1832
2789
|
|
|
1833
|
-
let
|
|
1834
|
-
let
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
2790
|
+
let alpha = max(sheenRoughness * sheenRoughness, 0.0001);
|
|
2791
|
+
let inverseAlpha = 1.0 / alpha;
|
|
2792
|
+
let sineSquared = max(1.0 - pbrInfo.NdotH * pbrInfo.NdotH, 0.0);
|
|
2793
|
+
let distribution = (2.0 + inverseAlpha) * pow(sineSquared, inverseAlpha * 0.5) /
|
|
2794
|
+
(2.0 * M_PI);
|
|
2795
|
+
let visibility = 1.0 / max(
|
|
2796
|
+
4.0 * (pbrInfo.NdotL + pbrInfo.NdotV - pbrInfo.NdotL * pbrInfo.NdotV),
|
|
2797
|
+
0.0001
|
|
2798
|
+
);
|
|
2799
|
+
return pbrInfo.NdotL * lightColor * sheenColor * distribution * visibility *
|
|
1840
2800
|
(1.0 - pbrInfo.metalness);
|
|
1841
2801
|
}
|
|
1842
2802
|
|
|
1843
|
-
fn
|
|
2803
|
+
fn calculateAnisotropicLightColor(
|
|
1844
2804
|
pbrInfo: PBRInfo,
|
|
2805
|
+
lightColor: vec3f,
|
|
1845
2806
|
anisotropyTangent: vec3f,
|
|
1846
2807
|
anisotropyStrength: f32
|
|
1847
|
-
) ->
|
|
2808
|
+
) -> vec3f {
|
|
1848
2809
|
if (anisotropyStrength <= 0.0) {
|
|
1849
|
-
return
|
|
2810
|
+
return calculateFinalColor(pbrInfo, lightColor);
|
|
1850
2811
|
}
|
|
1851
2812
|
|
|
1852
2813
|
let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));
|
|
1853
|
-
let
|
|
1854
|
-
|
|
2814
|
+
let tangentRoughness = mix(
|
|
2815
|
+
pbrInfo.alphaRoughness,
|
|
2816
|
+
1.0,
|
|
2817
|
+
anisotropyStrength * anisotropyStrength
|
|
2818
|
+
);
|
|
2819
|
+
let bitangentRoughness = clamp(pbrInfo.alphaRoughness, 0.001, 1.0);
|
|
2820
|
+
let roughnessProduct = tangentRoughness * bitangentRoughness;
|
|
2821
|
+
let distributionVector = vec3f(
|
|
2822
|
+
bitangentRoughness * dot(anisotropyTangent, pbrInfo.h),
|
|
2823
|
+
tangentRoughness * dot(anisotropyBitangent, pbrInfo.h),
|
|
2824
|
+
roughnessProduct * pbrInfo.NdotH
|
|
2825
|
+
);
|
|
2826
|
+
let distributionFactor = roughnessProduct /
|
|
2827
|
+
max(dot(distributionVector, distributionVector), 0.000001);
|
|
2828
|
+
let distribution = roughnessProduct * distributionFactor * distributionFactor / M_PI;
|
|
2829
|
+
let viewMask = pbrInfo.NdotL * length(vec3f(
|
|
2830
|
+
tangentRoughness * dot(anisotropyTangent, pbrInfo.v),
|
|
2831
|
+
bitangentRoughness * dot(anisotropyBitangent, pbrInfo.v),
|
|
2832
|
+
pbrInfo.NdotV
|
|
2833
|
+
));
|
|
2834
|
+
let lightMask = pbrInfo.NdotV * length(vec3f(
|
|
2835
|
+
tangentRoughness * dot(anisotropyTangent, pbrInfo.l),
|
|
2836
|
+
bitangentRoughness * dot(anisotropyBitangent, pbrInfo.l),
|
|
2837
|
+
pbrInfo.NdotL
|
|
2838
|
+
));
|
|
2839
|
+
let visibility = clamp(0.5 / max(viewMask + lightMask, 0.000001), 0.0, 1.0);
|
|
2840
|
+
let fresnel = specularReflection(pbrInfo);
|
|
2841
|
+
let diffuseContribution = (vec3f(1.0) - fresnel) * diffuse(pbrInfo);
|
|
2842
|
+
return pbrInfo.NdotL * lightColor *
|
|
2843
|
+
(diffuseContribution + fresnel * distribution * visibility);
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
fn getAnisotropicReflection(
|
|
2847
|
+
pbrInfo: PBRInfo,
|
|
2848
|
+
anisotropyTangent: vec3f,
|
|
2849
|
+
anisotropyStrength: f32
|
|
2850
|
+
) -> vec3f {
|
|
2851
|
+
if (anisotropyStrength <= 0.0) {
|
|
2852
|
+
return -normalize(reflect(pbrInfo.v, pbrInfo.n));
|
|
2853
|
+
}
|
|
2854
|
+
let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));
|
|
2855
|
+
var anisotropicNormal = normalize(cross(anisotropyBitangent, pbrInfo.v));
|
|
2856
|
+
anisotropicNormal = normalize(cross(anisotropicNormal, anisotropyBitangent));
|
|
2857
|
+
let bend = anisotropyStrength * (1.0 - pbrInfo.perceptualRoughness);
|
|
2858
|
+
return -normalize(reflect(pbrInfo.v, normalize(mix(pbrInfo.n, anisotropicNormal, bend))));
|
|
1855
2859
|
}
|
|
1856
2860
|
|
|
1857
2861
|
fn calculateMaterialLightColor(
|
|
@@ -1865,8 +2869,12 @@ fn calculateMaterialLightColor(
|
|
|
1865
2869
|
anisotropyTangent: vec3f,
|
|
1866
2870
|
anisotropyStrength: f32
|
|
1867
2871
|
) -> vec3f {
|
|
1868
|
-
|
|
1869
|
-
|
|
2872
|
+
var color = calculateAnisotropicLightColor(
|
|
2873
|
+
pbrInfo,
|
|
2874
|
+
lightColor,
|
|
2875
|
+
anisotropyTangent,
|
|
2876
|
+
anisotropyStrength
|
|
2877
|
+
);
|
|
1870
2878
|
color += calculateClearcoatContribution(
|
|
1871
2879
|
pbrInfo,
|
|
1872
2880
|
lightColor,
|
|
@@ -1883,6 +2891,8 @@ fn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {
|
|
|
1883
2891
|
(*pbrInfo).NdotH = 0.0;
|
|
1884
2892
|
(*pbrInfo).LdotH = 0.0;
|
|
1885
2893
|
(*pbrInfo).VdotH = 1.0;
|
|
2894
|
+
(*pbrInfo).l = (*pbrInfo).n;
|
|
2895
|
+
(*pbrInfo).h = (*pbrInfo).n;
|
|
1886
2896
|
}
|
|
1887
2897
|
|
|
1888
2898
|
fn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection: vec3<f32>) {
|
|
@@ -1895,6 +2905,8 @@ fn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection:
|
|
|
1895
2905
|
(*pbrInfo).NdotH = clamp(dot(n, h), 0.0, 1.0);
|
|
1896
2906
|
(*pbrInfo).LdotH = clamp(dot(l, h), 0.0, 1.0);
|
|
1897
2907
|
(*pbrInfo).VdotH = clamp(dot(v, h), 0.0, 1.0);
|
|
2908
|
+
(*pbrInfo).l = l;
|
|
2909
|
+
(*pbrInfo).h = h;
|
|
1898
2910
|
}
|
|
1899
2911
|
|
|
1900
2912
|
fn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight) {
|
|
@@ -1920,7 +2932,7 @@ fn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {
|
|
|
1920
2932
|
return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
|
|
1921
2933
|
}
|
|
1922
2934
|
|
|
1923
|
-
fn pbr_filterColor(
|
|
2935
|
+
fn pbr_filterColor(vertexColor: vec4<f32>) -> vec4<f32> {
|
|
1924
2936
|
let baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);
|
|
1925
2937
|
let metallicRoughnessUV = getMaterialUV(
|
|
1926
2938
|
pbrMaterial.metallicRoughnessUVSet,
|
|
@@ -1971,13 +2983,25 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
1971
2983
|
pbrMaterial.anisotropyUVSet,
|
|
1972
2984
|
pbrMaterial.anisotropyUVTransform
|
|
1973
2985
|
);
|
|
2986
|
+
let diffuseTransmissionUV = getMaterialUV(
|
|
2987
|
+
pbrMaterial.diffuseTransmissionUVSet,
|
|
2988
|
+
pbrMaterial.diffuseTransmissionUVTransform
|
|
2989
|
+
);
|
|
2990
|
+
let diffuseTransmissionColorUV = getMaterialUV(
|
|
2991
|
+
pbrMaterial.diffuseTransmissionColorUVSet,
|
|
2992
|
+
pbrMaterial.diffuseTransmissionColorUVTransform
|
|
2993
|
+
);
|
|
2994
|
+
let multiscatterColorUV = getMaterialUV(
|
|
2995
|
+
pbrMaterial.multiscatterColorUVSet,
|
|
2996
|
+
pbrMaterial.multiscatterColorUVTransform
|
|
2997
|
+
);
|
|
1974
2998
|
|
|
1975
2999
|
// The albedo may be defined from a base texture or a flat color
|
|
1976
|
-
var baseColor: vec4<f32> = pbrMaterial.baseColorFactor;
|
|
3000
|
+
var baseColor: vec4<f32> = pbrMaterial.baseColorFactor * vertexColor;
|
|
1977
3001
|
#ifdef HAS_BASECOLORMAP
|
|
1978
3002
|
baseColor = SRGBtoLINEAR(
|
|
1979
3003
|
textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, baseColorUV)
|
|
1980
|
-
) * pbrMaterial.baseColorFactor;
|
|
3004
|
+
) * pbrMaterial.baseColorFactor * vertexColor;
|
|
1981
3005
|
#endif
|
|
1982
3006
|
|
|
1983
3007
|
#ifdef ALPHA_CUTOFF
|
|
@@ -2012,6 +3036,7 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2012
3036
|
metallic = clamp(metallic, 0.0, 1.0);
|
|
2013
3037
|
let tbn = getTBN(normalUV);
|
|
2014
3038
|
let n = getNormal(tbn, normalUV); // normal at surface point
|
|
3039
|
+
perceptualRoughness = widenSpecularRoughness(perceptualRoughness, n);
|
|
2015
3040
|
let v = normalize(pbrProjection.camera - fragmentInputs.pbr_vPosition); // Vector from surface point to camera
|
|
2016
3041
|
let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
|
|
2017
3042
|
var useExtendedPBR = false;
|
|
@@ -2022,8 +3047,14 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2022
3047
|
abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||
|
|
2023
3048
|
maxComponent(abs(pbrMaterial.specularColorFactor - vec3f(1.0))) > 0.0001 ||
|
|
2024
3049
|
abs(pbrMaterial.ior - 1.5) > 0.0001 ||
|
|
3050
|
+
pbrMaterial.dispersion > 0.0001 ||
|
|
2025
3051
|
pbrMaterial.transmissionMapEnabled != 0 ||
|
|
2026
3052
|
pbrMaterial.transmissionFactor > 0.0001 ||
|
|
3053
|
+
pbrMaterial.diffuseTransmissionMapEnabled != 0 ||
|
|
3054
|
+
pbrMaterial.diffuseTransmissionColorMapEnabled != 0 ||
|
|
3055
|
+
pbrMaterial.diffuseTransmissionFactor > 0.0001 ||
|
|
3056
|
+
pbrMaterial.multiscatterColorMapEnabled != 0 ||
|
|
3057
|
+
maxComponent(pbrMaterial.multiscatterColorFactor) > 0.0001 ||
|
|
2027
3058
|
pbrMaterial.clearcoatMapEnabled != 0 ||
|
|
2028
3059
|
pbrMaterial.clearcoatRoughnessMapEnabled != 0 ||
|
|
2029
3060
|
pbrMaterial.clearcoatFactor > 0.0001 ||
|
|
@@ -2071,7 +3102,9 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2071
3102
|
diffuseColor,
|
|
2072
3103
|
specularColor,
|
|
2073
3104
|
n,
|
|
2074
|
-
v
|
|
3105
|
+
v,
|
|
3106
|
+
n,
|
|
3107
|
+
n
|
|
2075
3108
|
);
|
|
2076
3109
|
|
|
2077
3110
|
#ifdef USE_LIGHTS
|
|
@@ -2137,7 +3170,7 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2137
3170
|
color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
|
|
2138
3171
|
#endif
|
|
2139
3172
|
|
|
2140
|
-
return vec4<f32>(
|
|
3173
|
+
return vec4<f32>(applySceneColorManagement(color), baseColor.a);
|
|
2141
3174
|
}
|
|
2142
3175
|
|
|
2143
3176
|
var specularIntensity = pbrMaterial.specularIntensityFactor;
|
|
@@ -2184,6 +3217,42 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2184
3217
|
).g;
|
|
2185
3218
|
#endif
|
|
2186
3219
|
|
|
3220
|
+
var diffuseTransmission = clamp(pbrMaterial.diffuseTransmissionFactor, 0.0, 1.0);
|
|
3221
|
+
#ifdef HAS_DIFFUSETRANSMISSIONMAP
|
|
3222
|
+
if (pbrMaterial.diffuseTransmissionMapEnabled != 0) {
|
|
3223
|
+
diffuseTransmission *= textureSample(
|
|
3224
|
+
pbr_diffuseTransmissionSampler,
|
|
3225
|
+
pbr_diffuseTransmissionSamplerSampler,
|
|
3226
|
+
diffuseTransmissionUV
|
|
3227
|
+
).a;
|
|
3228
|
+
}
|
|
3229
|
+
#endif
|
|
3230
|
+
diffuseTransmission *= (1.0 - metallic) * (1.0 - transmission);
|
|
3231
|
+
var diffuseTransmissionColor = pbrMaterial.diffuseTransmissionColorFactor;
|
|
3232
|
+
#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP
|
|
3233
|
+
if (pbrMaterial.diffuseTransmissionColorMapEnabled != 0) {
|
|
3234
|
+
diffuseTransmissionColor *= SRGBtoLINEAR(
|
|
3235
|
+
textureSample(
|
|
3236
|
+
pbr_diffuseTransmissionColorSampler,
|
|
3237
|
+
pbr_diffuseTransmissionColorSamplerSampler,
|
|
3238
|
+
diffuseTransmissionColorUV
|
|
3239
|
+
)
|
|
3240
|
+
).rgb;
|
|
3241
|
+
}
|
|
3242
|
+
#endif
|
|
3243
|
+
var multiscatterColor = pbrMaterial.multiscatterColorFactor;
|
|
3244
|
+
#ifdef HAS_MULTISCATTERCOLORMAP
|
|
3245
|
+
if (pbrMaterial.multiscatterColorMapEnabled != 0) {
|
|
3246
|
+
multiscatterColor *= SRGBtoLINEAR(
|
|
3247
|
+
textureSample(
|
|
3248
|
+
pbr_multiscatterColorSampler,
|
|
3249
|
+
pbr_multiscatterColorSamplerSampler,
|
|
3250
|
+
multiscatterColorUV
|
|
3251
|
+
)
|
|
3252
|
+
).rgb;
|
|
3253
|
+
}
|
|
3254
|
+
#endif
|
|
3255
|
+
|
|
2187
3256
|
var clearcoatFactor = pbrMaterial.clearcoatFactor;
|
|
2188
3257
|
var clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;
|
|
2189
3258
|
#ifdef HAS_CLEARCOATMAP
|
|
@@ -2207,6 +3276,7 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2207
3276
|
clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);
|
|
2208
3277
|
clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
|
|
2209
3278
|
let clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);
|
|
3279
|
+
clearcoatRoughness = widenSpecularRoughness(clearcoatRoughness, clearcoatNormal);
|
|
2210
3280
|
|
|
2211
3281
|
var sheenColor = pbrMaterial.sheenColorFactor;
|
|
2212
3282
|
var sheenRoughness = pbrMaterial.sheenRoughnessFactor;
|
|
@@ -2282,13 +3352,6 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2282
3352
|
if (length(anisotropyTangent) < 0.0001) {
|
|
2283
3353
|
anisotropyTangent = normalize(tbn[0]);
|
|
2284
3354
|
}
|
|
2285
|
-
let anisotropyViewAlignment = abs(dot(v, anisotropyTangent));
|
|
2286
|
-
perceptualRoughness = mix(
|
|
2287
|
-
perceptualRoughness,
|
|
2288
|
-
clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),
|
|
2289
|
-
anisotropyStrength
|
|
2290
|
-
);
|
|
2291
|
-
|
|
2292
3355
|
// Roughness is authored as perceptual roughness; as is convention,
|
|
2293
3356
|
// convert to material roughness by squaring the perceptual roughness [2].
|
|
2294
3357
|
let alphaRoughness = perceptualRoughness * perceptualRoughness;
|
|
@@ -2298,17 +3361,24 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2298
3361
|
vec3f(dielectricF0) * specularFactor * specularIntensity,
|
|
2299
3362
|
vec3f(1.0)
|
|
2300
3363
|
);
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
3364
|
+
dielectricSpecularF0 = getIridescenceTint(
|
|
3365
|
+
iridescence,
|
|
3366
|
+
iridescenceThickness,
|
|
3367
|
+
NdotV,
|
|
3368
|
+
dielectricSpecularF0
|
|
2306
3369
|
);
|
|
2307
3370
|
var diffuseColor = baseColor.rgb * (vec3f(1.0) - dielectricSpecularF0);
|
|
2308
|
-
diffuseColor *= (1.0 - metallic) * (1.0 - transmission);
|
|
3371
|
+
diffuseColor *= (1.0 - metallic) * (1.0 - transmission) * (1.0 - diffuseTransmission);
|
|
2309
3372
|
var specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);
|
|
2310
3373
|
|
|
2311
|
-
let
|
|
3374
|
+
let clearcoatViewFresnel = dielectricSchlick(
|
|
3375
|
+
0.04,
|
|
3376
|
+
clamp(abs(dot(clearcoatNormal, v)), 0.0, 1.0)
|
|
3377
|
+
);
|
|
3378
|
+
let sheenDirectionalAlbedo = maxComponent(sheenColor) *
|
|
3379
|
+
(0.157 + 0.343 * (1.0 - NdotV)) * (1.0 - sheenRoughness * 0.5);
|
|
3380
|
+
let baseLayerEnergy = (1.0 - clearcoatFactor * clearcoatViewFresnel) *
|
|
3381
|
+
(1.0 - clamp(sheenDirectionalAlbedo, 0.0, 1.0));
|
|
2312
3382
|
diffuseColor *= baseLayerEnergy;
|
|
2313
3383
|
specularColor *= baseLayerEnergy;
|
|
2314
3384
|
|
|
@@ -2338,7 +3408,9 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2338
3408
|
diffuseColor,
|
|
2339
3409
|
specularColor,
|
|
2340
3410
|
n,
|
|
2341
|
-
v
|
|
3411
|
+
v,
|
|
3412
|
+
n,
|
|
3413
|
+
n
|
|
2342
3414
|
);
|
|
2343
3415
|
|
|
2344
3416
|
#ifdef USE_LIGHTS
|
|
@@ -2371,6 +3443,14 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2371
3443
|
anisotropyTangent,
|
|
2372
3444
|
anisotropyStrength
|
|
2373
3445
|
);
|
|
3446
|
+
color += calculateDiffuseTransmissionLight(
|
|
3447
|
+
pbrInfo,
|
|
3448
|
+
lighting_getDirectionalLight(i).color,
|
|
3449
|
+
diffuseTransmissionColor,
|
|
3450
|
+
diffuseTransmission,
|
|
3451
|
+
multiscatterColor,
|
|
3452
|
+
thickness
|
|
3453
|
+
);
|
|
2374
3454
|
}
|
|
2375
3455
|
}
|
|
2376
3456
|
|
|
@@ -2393,6 +3473,14 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2393
3473
|
anisotropyTangent,
|
|
2394
3474
|
anisotropyStrength
|
|
2395
3475
|
);
|
|
3476
|
+
color += calculateDiffuseTransmissionLight(
|
|
3477
|
+
pbrInfo,
|
|
3478
|
+
lighting_getPointLight(i).color / attenuation,
|
|
3479
|
+
diffuseTransmissionColor,
|
|
3480
|
+
diffuseTransmission,
|
|
3481
|
+
multiscatterColor,
|
|
3482
|
+
thickness
|
|
3483
|
+
);
|
|
2396
3484
|
}
|
|
2397
3485
|
}
|
|
2398
3486
|
|
|
@@ -2411,6 +3499,14 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2411
3499
|
anisotropyTangent,
|
|
2412
3500
|
anisotropyStrength
|
|
2413
3501
|
);
|
|
3502
|
+
color += calculateDiffuseTransmissionLight(
|
|
3503
|
+
pbrInfo,
|
|
3504
|
+
lighting_getSpotLight(i).color / attenuation,
|
|
3505
|
+
diffuseTransmissionColor,
|
|
3506
|
+
diffuseTransmission,
|
|
3507
|
+
multiscatterColor,
|
|
3508
|
+
thickness
|
|
3509
|
+
);
|
|
2414
3510
|
}
|
|
2415
3511
|
}
|
|
2416
3512
|
#endif
|
|
@@ -2418,8 +3514,11 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2418
3514
|
// Calculate lighting contribution from image based lighting source (IBL)
|
|
2419
3515
|
#ifdef USE_IBL
|
|
2420
3516
|
if (pbrMaterial.IBLenabled != 0) {
|
|
2421
|
-
color += getIBLContribution(
|
|
2422
|
-
|
|
3517
|
+
color += getIBLContribution(
|
|
3518
|
+
pbrInfo,
|
|
3519
|
+
n,
|
|
3520
|
+
getAnisotropicReflection(pbrInfo, anisotropyTangent, anisotropyStrength)
|
|
3521
|
+
);
|
|
2423
3522
|
color += calculateClearcoatIBLContribution(
|
|
2424
3523
|
pbrInfo,
|
|
2425
3524
|
clearcoatNormal,
|
|
@@ -2427,6 +3526,13 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2427
3526
|
clearcoatFactor,
|
|
2428
3527
|
clearcoatRoughness
|
|
2429
3528
|
);
|
|
3529
|
+
color += calculateDiffuseTransmissionIBL(
|
|
3530
|
+
pbrInfo,
|
|
3531
|
+
diffuseTransmissionColor,
|
|
3532
|
+
diffuseTransmission,
|
|
3533
|
+
multiscatterColor,
|
|
3534
|
+
thickness
|
|
3535
|
+
);
|
|
2430
3536
|
color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;
|
|
2431
3537
|
}
|
|
2432
3538
|
#endif
|
|
@@ -2450,7 +3556,22 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2450
3556
|
color += emissive * pbrMaterial.emissiveStrength;
|
|
2451
3557
|
|
|
2452
3558
|
if (transmission > 0.0) {
|
|
3559
|
+
#ifdef USE_TRANSMISSION_FRAMEBUFFER
|
|
3560
|
+
let dielectricFresnel = getDielectricF0(pbrMaterial.ior);
|
|
3561
|
+
let transmissionFresnel = dielectricFresnel +
|
|
3562
|
+
(1.0 - dielectricFresnel) * pow(1.0 - NdotV, 5.0);
|
|
3563
|
+
let transmittedColor = getTransmittedSceneColor(
|
|
3564
|
+
fragmentInputs.pbr_vPosition,
|
|
3565
|
+
n,
|
|
3566
|
+
v,
|
|
3567
|
+
thickness,
|
|
3568
|
+
perceptualRoughness
|
|
3569
|
+
);
|
|
3570
|
+
color += transmittedColor * getVolumeAttenuation(thickness) *
|
|
3571
|
+
transmission * (1.0 - transmissionFresnel);
|
|
3572
|
+
#else
|
|
2453
3573
|
color = mix(color, color * getVolumeAttenuation(thickness), transmission);
|
|
3574
|
+
#endif
|
|
2454
3575
|
}
|
|
2455
3576
|
|
|
2456
3577
|
// This section uses mix to override final color for reference app visualization
|
|
@@ -2470,16 +3591,20 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2470
3591
|
#endif
|
|
2471
3592
|
}
|
|
2472
3593
|
|
|
3594
|
+
#ifdef USE_TRANSMISSION_FRAMEBUFFER
|
|
3595
|
+
let alpha = clamp(baseColor.a, 0.0, 1.0);
|
|
3596
|
+
#else
|
|
2473
3597
|
let alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);
|
|
2474
|
-
|
|
3598
|
+
#endif
|
|
3599
|
+
return vec4<f32>(applySceneColorManagement(color), alpha);
|
|
2475
3600
|
}
|
|
2476
|
-
`;var
|
|
3601
|
+
`;var hm=`layout(std140) uniform pbrProjectionUniforms {
|
|
2477
3602
|
mat4 modelViewProjectionMatrix;
|
|
2478
3603
|
mat4 modelMatrix;
|
|
2479
3604
|
mat4 normalMatrix;
|
|
2480
3605
|
vec3 camera;
|
|
2481
3606
|
} pbrProjection;
|
|
2482
|
-
`,
|
|
3607
|
+
`,rC=`struct pbrProjectionUniforms {
|
|
2483
3608
|
modelViewProjectionMatrix: mat4x4<f32>,
|
|
2484
3609
|
modelMatrix: mat4x4<f32>,
|
|
2485
3610
|
normalMatrix: mat4x4<f32>,
|
|
@@ -2487,10 +3612,27 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
2487
3612
|
};
|
|
2488
3613
|
|
|
2489
3614
|
@group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;
|
|
2490
|
-
`,wm={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:vC,vs:vm,fs:vm,getUniforms:t=>t,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var ol={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,emissiveFactor:[0,0,0],metallicRoughnessValues:[1,1],metallicRoughnessMapEnabled:!1,occlusionMapEnabled:!1,occlusionStrength:1,alphaCutoffEnabled:!1,alphaCutoff:.5,IBLenabled:!1,scaleIBLAmbient:[1,1],scaleDiffBaseMR:[0,0,0,0],scaleFGDSpec:[0,0,0,0],specularColorFactor:[1,1,1],specularIntensityFactor:1,specularColorMapEnabled:!1,specularIntensityMapEnabled:!1,ior:1.5,transmissionFactor:0,transmissionMapEnabled:!1,thicknessFactor:0,attenuationDistance:1e9,attenuationColor:[1,1,1],clearcoatFactor:0,clearcoatRoughnessFactor:0,clearcoatMapEnabled:!1,clearcoatRoughnessMapEnabled:!1,sheenColorFactor:[0,0,0],sheenRoughnessFactor:0,sheenColorMapEnabled:!1,sheenRoughnessMapEnabled:!1,iridescenceFactor:0,iridescenceIor:1.3,iridescenceThicknessRange:[100,400],iridescenceMapEnabled:!1,anisotropyStrength:0,anisotropyRotation:0,anisotropyDirection:[1,0],anisotropyMapEnabled:!1,emissiveStrength:1,baseColorUVSet:0,baseColorUVTransform:[1,0,0,0,1,0,0,0,1],metallicRoughnessUVSet:0,metallicRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],normalUVSet:0,normalUVTransform:[1,0,0,0,1,0,0,0,1],occlusionUVSet:0,occlusionUVTransform:[1,0,0,0,1,0,0,0,1],emissiveUVSet:0,emissiveUVTransform:[1,0,0,0,1,0,0,0,1],specularColorUVSet:0,specularColorUVTransform:[1,0,0,0,1,0,0,0,1],specularIntensityUVSet:0,specularIntensityUVTransform:[1,0,0,0,1,0,0,0,1],transmissionUVSet:0,transmissionUVTransform:[1,0,0,0,1,0,0,0,1],thicknessUVSet:0,thicknessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatUVSet:0,clearcoatUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatRoughnessUVSet:0,clearcoatRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatNormalUVSet:0,clearcoatNormalUVTransform:[1,0,0,0,1,0,0,0,1],sheenColorUVSet:0,sheenColorUVTransform:[1,0,0,0,1,0,0,0,1],sheenRoughnessUVSet:0,sheenRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceUVSet:0,iridescenceUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceThicknessUVSet:0,iridescenceThicknessUVTransform:[1,0,0,0,1,0,0,0,1],anisotropyUVSet:0,anisotropyUVTransform:[1,0,0,0,1,0,0,0,1]},name:"pbrMaterial",firstBindingSlot:0,bindingLayout:[{name:"pbrMaterial",group:3},{name:"pbr_baseColorSampler",group:3},{name:"pbr_normalSampler",group:3},{name:"pbr_emissiveSampler",group:3},{name:"pbr_metallicRoughnessSampler",group:3},{name:"pbr_occlusionSampler",group:3},{name:"pbr_specularColorSampler",group:3},{name:"pbr_specularIntensitySampler",group:3},{name:"pbr_transmissionSampler",group:3},{name:"pbr_thicknessSampler",group:3},{name:"pbr_clearcoatSampler",group:3},{name:"pbr_clearcoatRoughnessSampler",group:3},{name:"pbr_clearcoatNormalSampler",group:3},{name:"pbr_sheenColorSampler",group:3},{name:"pbr_sheenRoughnessSampler",group:3},{name:"pbr_iridescenceSampler",group:3},{name:"pbr_iridescenceThicknessSampler",group:3},{name:"pbr_anisotropySampler",group:3}],dependencies:[Em,Cm,wm],source:Rm,vs:Bm,fs:Im,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_THICKNESSMAP:!1,HAS_CLEARCOATMAP:!1,HAS_CLEARCOATROUGHNESSMAP:!1,HAS_CLEARCOATNORMALMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_SHEENROUGHNESSMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_IRIDESCENCETHICKNESSMAP:!1,HAS_ANISOTROPYMAP:!1,USE_MATERIAL_EXTENSIONS:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:t=>t,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",clearcoatRoughnessMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",sheenRoughnessMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>",baseColorUVSet:"i32",baseColorUVTransform:"mat3x3<f32>",metallicRoughnessUVSet:"i32",metallicRoughnessUVTransform:"mat3x3<f32>",normalUVSet:"i32",normalUVTransform:"mat3x3<f32>",occlusionUVSet:"i32",occlusionUVTransform:"mat3x3<f32>",emissiveUVSet:"i32",emissiveUVTransform:"mat3x3<f32>",specularColorUVSet:"i32",specularColorUVTransform:"mat3x3<f32>",specularIntensityUVSet:"i32",specularIntensityUVTransform:"mat3x3<f32>",transmissionUVSet:"i32",transmissionUVTransform:"mat3x3<f32>",thicknessUVSet:"i32",thicknessUVTransform:"mat3x3<f32>",clearcoatUVSet:"i32",clearcoatUVTransform:"mat3x3<f32>",clearcoatRoughnessUVSet:"i32",clearcoatRoughnessUVTransform:"mat3x3<f32>",clearcoatNormalUVSet:"i32",clearcoatNormalUVTransform:"mat3x3<f32>",sheenColorUVSet:"i32",sheenColorUVTransform:"mat3x3<f32>",sheenRoughnessUVSet:"i32",sheenRoughnessUVTransform:"mat3x3<f32>",iridescenceUVSet:"i32",iridescenceUVTransform:"mat3x3<f32>",iridescenceThicknessUVSet:"i32",iridescenceThicknessUVTransform:"mat3x3<f32>",anisotropyUVSet:"i32",anisotropyUVTransform:"mat3x3<f32>"}};var Om=D(Wc(),1),Um=D(Zs(),1);var Lm=`layout(std140) uniform meshUniforms {
|
|
3615
|
+
`,pm={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:rC,vs:hm,fs:hm,getUniforms:t=>t,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var $s={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,emissiveFactor:[0,0,0],metallicRoughnessValues:[1,1],metallicRoughnessMapEnabled:!1,occlusionMapEnabled:!1,occlusionStrength:1,alphaCutoffEnabled:!1,alphaCutoff:.5,IBLenabled:!1,scaleIBLAmbient:[1,1],scaleDiffBaseMR:[0,0,0,0],scaleFGDSpec:[0,0,0,0],specularColorFactor:[1,1,1],specularIntensityFactor:1,specularColorMapEnabled:!1,specularIntensityMapEnabled:!1,ior:1.5,transmissionFactor:0,transmissionMapEnabled:!1,thicknessFactor:0,attenuationDistance:1e9,attenuationColor:[1,1,1],clearcoatFactor:0,clearcoatRoughnessFactor:0,clearcoatMapEnabled:!1,clearcoatRoughnessMapEnabled:!1,sheenColorFactor:[0,0,0],sheenRoughnessFactor:0,sheenColorMapEnabled:!1,sheenRoughnessMapEnabled:!1,iridescenceFactor:0,iridescenceIor:1.3,iridescenceThicknessRange:[100,400],iridescenceMapEnabled:!1,anisotropyStrength:0,anisotropyRotation:0,anisotropyDirection:[1,0],anisotropyMapEnabled:!1,emissiveStrength:1,dispersion:0,baseColorUVSet:0,baseColorUVTransform:[1,0,0,0,1,0,0,0,1],metallicRoughnessUVSet:0,metallicRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],normalUVSet:0,normalUVTransform:[1,0,0,0,1,0,0,0,1],occlusionUVSet:0,occlusionUVTransform:[1,0,0,0,1,0,0,0,1],emissiveUVSet:0,emissiveUVTransform:[1,0,0,0,1,0,0,0,1],specularColorUVSet:0,specularColorUVTransform:[1,0,0,0,1,0,0,0,1],specularIntensityUVSet:0,specularIntensityUVTransform:[1,0,0,0,1,0,0,0,1],transmissionUVSet:0,transmissionUVTransform:[1,0,0,0,1,0,0,0,1],thicknessUVSet:0,thicknessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatUVSet:0,clearcoatUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatRoughnessUVSet:0,clearcoatRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatNormalUVSet:0,clearcoatNormalUVTransform:[1,0,0,0,1,0,0,0,1],sheenColorUVSet:0,sheenColorUVTransform:[1,0,0,0,1,0,0,0,1],sheenRoughnessUVSet:0,sheenRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceUVSet:0,iridescenceUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceThicknessUVSet:0,iridescenceThicknessUVTransform:[1,0,0,0,1,0,0,0,1],anisotropyUVSet:0,anisotropyUVTransform:[1,0,0,0,1,0,0,0,1],bumpFactor:1,bumpMapEnabled:!1,diffuseTransmissionFactor:0,diffuseTransmissionMapEnabled:!1,diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorMapEnabled:!1,multiscatterColorFactor:[0,0,0],multiscatterColorMapEnabled:!1,scatterAnisotropy:0,bumpUVSet:0,bumpUVTransform:[1,0,0,0,1,0,0,0,1],diffuseTransmissionUVSet:0,diffuseTransmissionUVTransform:[1,0,0,0,1,0,0,0,1],diffuseTransmissionColorUVSet:0,diffuseTransmissionColorUVTransform:[1,0,0,0,1,0,0,0,1],multiscatterColorUVSet:0,multiscatterColorUVTransform:[1,0,0,0,1,0,0,0,1]},name:"pbrMaterial",firstBindingSlot:0,bindingLayout:[{name:"pbrMaterial",group:3},{name:"pbr_baseColorSampler",group:3},{name:"pbr_normalSampler",group:3},{name:"pbr_emissiveSampler",group:3},{name:"pbr_metallicRoughnessSampler",group:3},{name:"pbr_occlusionSampler",group:3},{name:"pbr_specularColorSampler",group:3},{name:"pbr_specularIntensitySampler",group:3},{name:"pbr_transmissionSampler",group:3},{name:"pbr_thicknessSampler",group:3},{name:"pbr_clearcoatSampler",group:3},{name:"pbr_clearcoatRoughnessSampler",group:3},{name:"pbr_clearcoatNormalSampler",group:3},{name:"pbr_sheenColorSampler",group:3},{name:"pbr_sheenRoughnessSampler",group:3},{name:"pbr_iridescenceSampler",group:3},{name:"pbr_iridescenceThicknessSampler",group:3},{name:"pbr_anisotropySampler",group:3},{name:"pbr_bumpSampler",group:3},{name:"pbr_diffuseTransmissionSampler",group:3},{name:"pbr_diffuseTransmissionColorSampler",group:3},{name:"pbr_multiscatterColorSampler",group:3}],dependencies:[sm,cm,pm],source:um,vs:lm,fs:fm,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_THICKNESSMAP:!1,HAS_CLEARCOATMAP:!1,HAS_CLEARCOATROUGHNESSMAP:!1,HAS_CLEARCOATNORMALMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_SHEENROUGHNESSMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_IRIDESCENCETHICKNESSMAP:!1,HAS_ANISOTROPYMAP:!1,HAS_BUMPMAP:!1,HAS_DIFFUSETRANSMISSIONMAP:!1,HAS_DIFFUSETRANSMISSIONCOLORMAP:!1,HAS_MULTISCATTERCOLORMAP:!1,USE_MATERIAL_EXTENSIONS:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:t=>t,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",clearcoatRoughnessMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",sheenRoughnessMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32",dispersion:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>",baseColorUVSet:"i32",baseColorUVTransform:"mat3x3<f32>",metallicRoughnessUVSet:"i32",metallicRoughnessUVTransform:"mat3x3<f32>",normalUVSet:"i32",normalUVTransform:"mat3x3<f32>",occlusionUVSet:"i32",occlusionUVTransform:"mat3x3<f32>",emissiveUVSet:"i32",emissiveUVTransform:"mat3x3<f32>",specularColorUVSet:"i32",specularColorUVTransform:"mat3x3<f32>",specularIntensityUVSet:"i32",specularIntensityUVTransform:"mat3x3<f32>",transmissionUVSet:"i32",transmissionUVTransform:"mat3x3<f32>",thicknessUVSet:"i32",thicknessUVTransform:"mat3x3<f32>",clearcoatUVSet:"i32",clearcoatUVTransform:"mat3x3<f32>",clearcoatRoughnessUVSet:"i32",clearcoatRoughnessUVTransform:"mat3x3<f32>",clearcoatNormalUVSet:"i32",clearcoatNormalUVTransform:"mat3x3<f32>",sheenColorUVSet:"i32",sheenColorUVTransform:"mat3x3<f32>",sheenRoughnessUVSet:"i32",sheenRoughnessUVTransform:"mat3x3<f32>",iridescenceUVSet:"i32",iridescenceUVTransform:"mat3x3<f32>",iridescenceThicknessUVSet:"i32",iridescenceThicknessUVTransform:"mat3x3<f32>",anisotropyUVSet:"i32",anisotropyUVTransform:"mat3x3<f32>",bumpFactor:"f32",bumpMapEnabled:"i32",diffuseTransmissionFactor:"f32",diffuseTransmissionMapEnabled:"i32",diffuseTransmissionColorFactor:"vec3<f32>",diffuseTransmissionColorMapEnabled:"i32",multiscatterColorFactor:"vec3<f32>",multiscatterColorMapEnabled:"i32",scatterAnisotropy:"f32",bumpUVSet:"i32",bumpUVTransform:"mat3x3<f32>",diffuseTransmissionUVSet:"i32",diffuseTransmissionUVTransform:"mat3x3<f32>",diffuseTransmissionColorUVSet:"i32",diffuseTransmissionColorUVTransform:"mat3x3<f32>",multiscatterColorUVSet:"i32",multiscatterColorUVTransform:"mat3x3<f32>"}};var Y;(function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST=9728]="NEAREST",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(Y||(Y={}));var ee=U(Xc(),1);var dm=[ce("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),ce("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),ce("normal","pbr_normalSampler","normalTexture",["normalTexture"]),ce("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),ce("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),ce("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),ce("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),ce("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),ce("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),ce("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),ce("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),ce("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),ce("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),ce("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),ce("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),ce("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),ce("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"]),ce("bump","pbr_bumpSampler","EXT_materials_bump.bumpTexture",["extensions","EXT_materials_bump","bumpTexture"]),ce("diffuseTransmission","pbr_diffuseTransmissionSampler","KHR_materials_diffuse_transmission.diffuseTransmissionTexture",["extensions","KHR_materials_diffuse_transmission","diffuseTransmissionTexture"]),ce("diffuseTransmissionColor","pbr_diffuseTransmissionColorSampler","KHR_materials_diffuse_transmission.diffuseTransmissionColorTexture",["extensions","KHR_materials_diffuse_transmission","diffuseTransmissionColorTexture"]),ce("multiscatterColor","pbr_multiscatterColorSampler","KHR_materials_volume_scatter.multiscatterColorTexture",["extensions","KHR_materials_volume_scatter","multiscatterColorTexture"])],nC=new Map(dm.map(t=>[t.slot,t]));function ce(t,e,r,n){return{slot:t,binding:e,displayName:r,pathSegments:n,colorSpace:t==="baseColor"||t==="emissive"||t==="specularColor"||t==="sheenColor"||t==="diffuseTransmissionColor"||t==="multiscatterColor"?"srgb":"linear",uvSetUniform:`${t}UVSet`,uvTransformUniform:`${t}UVTransform`}}function mm(){return dm}function gm(t){let e=nC.get(t);if(!e)throw new Error(`Unknown PBR texture transform slot ${t}`);return e}function Am(t){let e=t?.extensions?.KHR_texture_transform;return{offset:e?.offset?[e.offset[0],e.offset[1]]:[0,0],rotation:e?.rotation??0,scale:e?.scale?[e.scale[0],e.scale[1]]:[1,1]}}function Yc(t){return t?.extensions?.KHR_texture_transform?.texCoord??t?.texCoord??0}function bm(t){let e=new z().set(1,0,0,0,1,0,t.offset[0],t.offset[1],1),r=new z().set(Math.cos(t.rotation),Math.sin(t.rotation),0,-Math.sin(t.rotation),Math.cos(t.rotation),0,0,0,1),n=new z().set(t.scale[0],0,0,0,t.scale[1],0,0,0,1);return Array.from(e.multiplyRight(r).multiplyRight(n))}function Tm(t={}){let e=t.wrapS??t.parameters?.[Y.TEXTURE_WRAP_S],r=t.wrapT??t.parameters?.[Y.TEXTURE_WRAP_T],n=t.magFilter??t.parameters?.[Y.TEXTURE_MAG_FILTER],o=t.minFilter??t.parameters?.[Y.TEXTURE_MIN_FILTER],s=xm(e),i=xm(r),a=oC(n);return{...s?{addressModeU:s}:{},...i?{addressModeV:i}:{},...a?{magFilter:a}:{},...sC(o)}}function xm(t){switch(t){case Y.CLAMP_TO_EDGE:return"clamp-to-edge";case Y.REPEAT:return"repeat";case Y.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function oC(t){switch(t){case Y.NEAREST:return"nearest";case Y.LINEAR:return"linear";default:return}}function sC(t){switch(t){case Y.NEAREST:return{minFilter:"nearest"};case Y.LINEAR:return{minFilter:"linear"};case Y.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case Y.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case Y.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case Y.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}var iC={NORMAL:["NORMAL","normals"],TANGENT:["TANGENT"],TEXCOORD_0:["TEXCOORD_0","texCoords"],TEXCOORD_1:["TEXCOORD_1","texCoords1"],JOINTS_0:["JOINTS_0"],WEIGHTS_0:["WEIGHTS_0"],COLOR_0:["COLOR_0","colors"]};function Qc(t,e,r,n){let o={defines:{MANUAL_SRGB:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};o.defines.USE_TEX_LOD=!0;let{imageBasedLightingEnvironment:s}=n;return s&&(o.bindings.pbr_diffuseEnvSampler=s.diffuseEnvSampler.texture,o.bindings.pbr_specularEnvSampler=s.specularEnvSampler.texture,o.bindings.pbr_brdfLUT=s.brdfLutTexture.texture,o.uniforms.IBLenabled=!0,o.uniforms.scaleIBLAmbient=[1,1]),n?.pbrDebug&&(o.defines.PBR_DEBUG=!0,o.uniforms.scaleDiffBaseMR=[0,0,0,0],o.uniforms.scaleFGDSpec=[0,0,0,0]),Ze(r,"NORMAL")&&(o.defines.HAS_NORMALS=!0),Ze(r,"TANGENT")&&n?.useTangents&&(o.defines.HAS_TANGENTS=!0),Ze(r,"TEXCOORD_0")&&(o.defines.HAS_UV=!0),Ze(r,"TEXCOORD_1")&&(o.defines.HAS_UV_1=!0),Ze(r,"JOINTS_0")&&Ze(r,"WEIGHTS_0")&&(o.defines.HAS_SKIN=!0),Ze(r,"COLOR_0")&&(o.defines.HAS_COLORS=!0),n?.imageBasedLightingEnvironment&&(o.defines.USE_IBL=!0),n?.lights&&(o.defines.USE_LIGHTS=!0),e&&(n.validateAttributes!==!1&&aC(e,r),lC(t,e,o,r,n.gltf)),o}function aC(t,e){let r=ym(t,0);r.length>0&&!Ze(e,"TEXCOORD_0")&&ee.log.warn(`glTF material uses ${r.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();let n=ym(t,1);if(n.length>0&&!Ze(e,"TEXCOORD_1")&&ee.log.warn(`glTF material uses ${n.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)(),!!(t.unlit||t.extensions?.KHR_materials_unlit)||Ze(e,"NORMAL"))return;let s=t.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";ee.log.warn(`glTF primitive is missing NORMAL while using ${s}; shading will fall back to geometric normals`)()}function ym(t,e){let r=[];for(let n of mm()){let o=cC(t,n.pathSegments);o&&Yc(o)===e&&r.push(n.displayName)}return r}function Ze(t,e){return iC[e].some(r=>!!t[r])}function cC(t,e){let r=t;for(let n of e)if(r=r?.[n],!r)return null;return r}function lC(t,e,r,n,o){if(r.uniforms.unlit=!!(e.unlit||e.extensions?.KHR_materials_unlit),e.pbrMetallicRoughness&&hC(t,e.pbrMetallicRoughness,r,n,o),e.normalTexture){le(t,e.normalTexture,"pbr_normalSampler",r,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"normal"});let{scale:s=1}=e.normalTexture;r.uniforms.normalScale=s}if(e.occlusionTexture){le(t,e.occlusionTexture,"pbr_occlusionSampler",r,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"occlusion"});let{strength:s=1}=e.occlusionTexture;r.uniforms.occlusionStrength=s}switch(r.uniforms.emissiveFactor=e.emissiveFactor||[0,0,0],e.emissiveTexture&&le(t,e.emissiveTexture,"pbr_emissiveSampler",r,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"emissive"}),pC(t,e.extensions,r,o,n),e.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{let{alphaCutoff:s=.5}=e;r.defines.ALPHA_CUTOFF=!0,r.uniforms.alphaCutoffEnabled=!0,r.uniforms.alphaCutoff=s;break}case"BLEND":ee.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),fC(r);break}}function fC(t){t.parameters.blend=!0,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="src-alpha",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.blendEquation=Y.FUNC_ADD,t.glParameters.blendFunc=[Y.SRC_ALPHA,Y.ONE_MINUS_SRC_ALPHA,Y.ONE,Y.ONE_MINUS_SRC_ALPHA]}function uC(t){t.parameters.blend=!0,t.parameters.depthWriteEnabled=!1,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="one",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.depthMask=!1,t.glParameters.blendEquation=Y.FUNC_ADD,t.glParameters.blendFunc=[Y.ONE,Y.ONE_MINUS_SRC_ALPHA,Y.ONE,Y.ONE_MINUS_SRC_ALPHA]}function hC(t,e,r,n,o){e.baseColorTexture&&le(t,e.baseColorTexture,"pbr_baseColorSampler",r,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"baseColor"}),r.uniforms.baseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&le(t,e.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",r,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"metallicRoughness"});let{metallicFactor:s=1,roughnessFactor:i=1}=e;r.uniforms.metallicRoughnessValues=[s,i]}function pC(t,e,r,n,o={}){e&&(dC(e)&&(r.defines.USE_MATERIAL_EXTENSIONS=!0),mC(t,e.KHR_materials_specular,r,n,o),gC(e.KHR_materials_ior,r),bC(t,e.EXT_materials_bump,r,n,o),AC(t,e.KHR_materials_transmission,r,n,o),xC(t,e.KHR_materials_diffuse_transmission,r,n,o),TC(t,e.KHR_materials_volume,r,n,o),yC(t,e.KHR_materials_volume_scatter,e.KHR_materials_volume,r,n,o),SC(e.KHR_materials_dispersion,r),MC(t,e.KHR_materials_clearcoat,r,n,o),_C(t,e.KHR_materials_sheen,r,n,o),EC(t,e.KHR_materials_iridescence,r,n,o),CC(t,e.KHR_materials_anisotropy,r,n,o),IC(e.KHR_materials_emissive_strength,r))}function dC(t){return!!(t.KHR_materials_specular||t.KHR_materials_ior||t.EXT_materials_bump||t.KHR_materials_transmission||t.KHR_materials_diffuse_transmission||t.KHR_materials_volume||t.KHR_materials_volume_scatter||t.KHR_materials_dispersion||t.KHR_materials_clearcoat||t.KHR_materials_sheen||t.KHR_materials_iridescence||t.KHR_materials_anisotropy)}function mC(t,e,r,n,o={}){e&&(e.specularColorFactor&&(r.uniforms.specularColorFactor=e.specularColorFactor),e.specularFactor!==void 0&&(r.uniforms.specularIntensityFactor=e.specularFactor),e.specularColorTexture&&le(t,e.specularColorTexture,"pbr_specularColorSampler",r,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"specularColor"}),e.specularTexture&&le(t,e.specularTexture,"pbr_specularIntensitySampler",r,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"specularIntensity"}))}function gC(t,e){t?.ior!==void 0&&(e.uniforms.ior=t.ior)}function AC(t,e,r,n,o={}){e&&(e.transmissionFactor!==void 0&&(r.uniforms.transmissionFactor=e.transmissionFactor),e.transmissionTexture&&le(t,e.transmissionTexture,"pbr_transmissionSampler",r,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"transmission"}),((e.transmissionFactor??0)>0||e.transmissionTexture)&&(ee.log.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),uC(r)))}function bC(t,e,r,n,o={}){e&&(r.uniforms.bumpFactor=Math.max(e.bumpFactor??1,0),e.bumpTexture&&le(t,e.bumpTexture,"pbr_bumpSampler",r,{featureOptions:{define:"HAS_BUMPMAP",enabledUniformName:"bumpMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"bump"}))}function xC(t,e,r,n,o={}){e&&(r.uniforms.diffuseTransmissionFactor=Math.min(Math.max(e.diffuseTransmissionFactor??0,0),1),r.uniforms.diffuseTransmissionColorFactor=e.diffuseTransmissionColorFactor||[1,1,1],e.diffuseTransmissionTexture&&le(t,e.diffuseTransmissionTexture,"pbr_diffuseTransmissionSampler",r,{featureOptions:{define:"HAS_DIFFUSETRANSMISSIONMAP",enabledUniformName:"diffuseTransmissionMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"diffuseTransmission"}),e.diffuseTransmissionColorTexture&&le(t,e.diffuseTransmissionColorTexture,"pbr_diffuseTransmissionColorSampler",r,{featureOptions:{define:"HAS_DIFFUSETRANSMISSIONCOLORMAP",enabledUniformName:"diffuseTransmissionColorMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"diffuseTransmissionColor"}))}function TC(t,e,r,n,o={}){e&&(e.thicknessFactor!==void 0&&(r.uniforms.thicknessFactor=e.thicknessFactor),e.thicknessTexture&&le(t,e.thicknessTexture,"pbr_thicknessSampler",r,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:n,attributes:o,textureTransformSlot:"thickness"}),e.attenuationDistance!==void 0&&(r.uniforms.attenuationDistance=e.attenuationDistance),e.attenuationColor&&(r.uniforms.attenuationColor=e.attenuationColor))}function yC(t,e,r,n,o,s={}){!e||!r||(n.uniforms.multiscatterColorFactor=e.multiscatterColorFactor||e.multiscatterColor||[0,0,0],n.uniforms.scatterAnisotropy=Math.min(Math.max(e.scatterAnisotropy??0,-.999),.999),e.multiscatterColorTexture&&le(t,e.multiscatterColorTexture,"pbr_multiscatterColorSampler",n,{featureOptions:{define:"HAS_MULTISCATTERCOLORMAP",enabledUniformName:"multiscatterColorMapEnabled"},gltf:o,attributes:s,textureTransformSlot:"multiscatterColor"}))}function SC(t,e){t?.dispersion!==void 0&&(e.uniforms.dispersion=Math.max(t.dispersion,0))}function MC(t,e,r,n,o={}){e&&(e.clearcoatFactor!==void 0&&(r.uniforms.clearcoatFactor=e.clearcoatFactor),e.clearcoatRoughnessFactor!==void 0&&(r.uniforms.clearcoatRoughnessFactor=e.clearcoatRoughnessFactor),e.clearcoatTexture&&le(t,e.clearcoatTexture,"pbr_clearcoatSampler",r,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"clearcoat"}),e.clearcoatRoughnessTexture&&le(t,e.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",r,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"clearcoatRoughness"}),e.clearcoatNormalTexture&&le(t,e.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",r,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:n,attributes:o,textureTransformSlot:"clearcoatNormal"}))}function _C(t,e,r,n,o={}){e&&(e.sheenColorFactor&&(r.uniforms.sheenColorFactor=e.sheenColorFactor),e.sheenRoughnessFactor!==void 0&&(r.uniforms.sheenRoughnessFactor=e.sheenRoughnessFactor),e.sheenColorTexture&&le(t,e.sheenColorTexture,"pbr_sheenColorSampler",r,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"sheenColor"}),e.sheenRoughnessTexture&&le(t,e.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",r,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"sheenRoughness"}))}function EC(t,e,r,n,o={}){e&&(e.iridescenceFactor!==void 0&&(r.uniforms.iridescenceFactor=e.iridescenceFactor),e.iridescenceIor!==void 0&&(r.uniforms.iridescenceIor=e.iridescenceIor),(e.iridescenceThicknessMinimum!==void 0||e.iridescenceThicknessMaximum!==void 0)&&(r.uniforms.iridescenceThicknessRange=[e.iridescenceThicknessMinimum??100,e.iridescenceThicknessMaximum??400]),e.iridescenceTexture&&le(t,e.iridescenceTexture,"pbr_iridescenceSampler",r,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"iridescence"}),e.iridescenceThicknessTexture&&le(t,e.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",r,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:n,attributes:o,textureTransformSlot:"iridescenceThickness"}))}function CC(t,e,r,n,o={}){e&&(e.anisotropyStrength!==void 0&&(r.uniforms.anisotropyStrength=e.anisotropyStrength),e.anisotropyRotation!==void 0&&(r.uniforms.anisotropyRotation=e.anisotropyRotation),e.anisotropyTexture&&le(t,e.anisotropyTexture,"pbr_anisotropySampler",r,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"anisotropy"}))}function IC(t,e){t?.emissiveStrength!==void 0&&(e.uniforms.emissiveStrength=t.emissiveStrength)}function le(t,e,r,n,o={}){let{featureOptions:s={},gltf:i,attributes:a={},textureTransformSlot:c}=o,{define:l,enabledUniformName:f}=s,u=Yc(e);if(u>1){ee.log.warn(`Skipping ${String(r)} because ${u} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();return}if(u===1&&!Ze(a,"TEXCOORD_1")){ee.log.warn(`Skipping ${String(r)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();return}let h=vC(e,i),p=h.texture?.source?.image;if(!p){ee.log.warn(`Skipping unresolved glTF texture for ${String(r)}`)();return}let d={id:h.uniformName||h.id,sampler:{addressModeU:"repeat",addressModeV:"repeat",minFilter:"linear",magFilter:"linear",...Tm(h.texture.sampler)}},m=Mm(t,p,d);if(n.bindings[r]=m,l&&(n.defines[l]=!0),f&&(n.uniforms[f]=!0),c){let g=gm(c);n.uniforms[g.uvSetUniform]=u,n.uniforms[g.uvTransformUniform]=bm(Am(e))}n.generatedTextures.push(m)}function Mm(t,e,r){if("compressed"in e)return RC(t,e,{id:r.id,sampler:r.sampler});let n=r.width!==void 0&&r.height!==void 0?{width:r.width,height:r.height}:t.getExternalImageSize(e),o=r.sampler.mipmapFilter==="nearest"||r.sampler.mipmapFilter==="linear",s=o?t.getMipLevelCount(n.width,n.height):1,i=t.createTexture({id:r.id,sampler:r.sampler,width:n.width,height:n.height,mipLevels:s,...o?{usage:ee.Texture.SAMPLE|ee.Texture.RENDER|ee.Texture.COPY_DST|ee.Texture.COPY_SRC}:{},...r.colorSpace?{format:r.colorSpace==="srgb"?"rgba8unorm-srgb":"rgba8unorm"}:{},data:e});return s>1&&(t.type==="webgl"?i.generateMipmapsWebGL():t.type==="webgpu"&&t.generateMipmapsWebGPU(i)),i}function vC(t,e){if(t.texture||t.index===void 0||!e?.textures)return t;let r=e.textures[t.index];return r?"texture"in r&&r.texture?{...r,...t,texture:r.texture}:"source"in r?{...t,texture:r}:t:t}function ei(t,e){return t.createTexture({...e,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function Sm(t){return t.textureFormat}function BC(t,e,r){let{blockWidth:n=1,blockHeight:o=1}=ee.textureFormatDecoder.getInfo(r),s=1;for(let i=1;;i++){let a=Math.max(1,t>>i),c=Math.max(1,e>>i);if(a<n||c<o)break;s++}return s}function RC(t,e,r){let n;if(Array.isArray(e.data)&&e.data[0]?.data?n=e.data:"mipmaps"in e&&Array.isArray(e.mipmaps)?n=e.mipmaps:n=[],n.length===0||!n[0]?.data)return ee.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),ei(t,r);let o=n[0],s=o.width??e.width??0,i=o.height??e.height??0;if(s<=0||i<=0)return ee.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),ei(t,r);let a=Sm(o);if(!a)return ee.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),ei(t,r);if(!t.isTextureFormatSupported(a))return ee.log.warn(`createCompressedTexture: ${t.type} device does not support '${a}', creating fallback`)(),ei(t,r);let c=BC(s,i,a),l=Math.min(n.length,c),f=1;for(let h=1;h<l;h++){let p=n[h];if(!p.data||p.width<=0||p.height<=0){ee.log.warn(`createCompressedTexture: mip level ${h} has invalid data/dimensions, truncating`)();break}let d=Sm(p);if(d&&d!==a){ee.log.warn(`createCompressedTexture: mip level ${h} format '${d}' differs from base '${a}', truncating`)();break}let m=Math.max(1,s>>h),g=Math.max(1,i>>h);if(p.width!==m||p.height!==g){ee.log.warn(`createCompressedTexture: mip level ${h} dimensions ${p.width}x${p.height} don't match expected ${m}x${g}, truncating`)();break}f++}let u=t.createTexture({...r,format:a,usage:ee.Texture.TEXTURE|ee.Texture.COPY_DST,width:s,height:i,mipLevels:f,data:o.data});for(let h=1;h<f;h++)u.writeData(n[h].data,{width:n[h].width,height:n[h].height,mipLevel:h});return u}var Rm=U(Wc(),1),wm=U(Ys(),1);var _m=`layout(std140) uniform meshUniforms {
|
|
2491
3616
|
bool pickFeatureIds;
|
|
2492
3617
|
} mesh;
|
|
2493
|
-
`,
|
|
3618
|
+
`,wC=`struct MeshUniforms {
|
|
3619
|
+
pickFeatureIds: f32,
|
|
3620
|
+
};
|
|
3621
|
+
|
|
3622
|
+
@group(0) @binding(auto) var<uniform> mesh: MeshUniforms;
|
|
3623
|
+
`,Em={name:"mesh",vs:_m,fs:_m,source:wC,uniformTypes:{pickFeatureIds:"f32"}};var LC=$s.source.replace(/fn pbr_setPositionNormalTangentUV\([\s\S]*?\n}\n/,`fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)
|
|
3624
|
+
{
|
|
3625
|
+
fragmentInputs.pbr_vPosition = position.xyz;
|
|
3626
|
+
fragmentInputs.pbr_vNormal = normal.xyz;
|
|
3627
|
+
fragmentInputs.pbr_vTBN = mat3x3f(
|
|
3628
|
+
vec3f(1.0, 0.0, 0.0),
|
|
3629
|
+
vec3f(0.0, 1.0, 0.0),
|
|
3630
|
+
vec3f(0.0, 0.0, 1.0)
|
|
3631
|
+
);
|
|
3632
|
+
fragmentInputs.pbr_vUV0 = uv;
|
|
3633
|
+
fragmentInputs.pbr_vUV1 = uv;
|
|
3634
|
+
}
|
|
3635
|
+
`).replace(/pbrProjection\.camera/g,"project.cameraPosition"),Cm={...$s,source:LC};var Im=`#version 300 es
|
|
2494
3636
|
#define SHADER_NAME simple-mesh-layer-vs
|
|
2495
3637
|
in vec3 positions;
|
|
2496
3638
|
in vec3 normals;
|
|
@@ -2549,7 +3691,7 @@ geometry.uv = pbr_vUV0;
|
|
|
2549
3691
|
#endif
|
|
2550
3692
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
2551
3693
|
}
|
|
2552
|
-
`;var
|
|
3694
|
+
`;var vm=`#version 300 es
|
|
2553
3695
|
#define SHADER_NAME simple-mesh-layer-fs
|
|
2554
3696
|
precision highp float;
|
|
2555
3697
|
uniform sampler2D sampler;
|
|
@@ -2578,7 +3720,131 @@ fragColor = vec4(lightColor, color.a * layer.opacity);
|
|
|
2578
3720
|
#endif
|
|
2579
3721
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
2580
3722
|
}
|
|
2581
|
-
`;function wC(t){let e=t.positions||t.POSITION,r=e.value.length/e.size;t.COLOR_0||t.colors||(t.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var LC={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},go=class extends Um.SimpleMeshLayer{getShaders(){let e=super.getShaders();return e.modules.push(ol,Fm),{...e,vs:Pm,fs:Nm}}initializeState(){let{featureIds:e}=this.props;super.initializeState();let r=this.getAttributeManager();e&&r.add({rowIndexes:{type:"uint32",size:1,noAlloc:!0,update:this.calculateFeatureIdsPickingIndexes}})}updateState(e){super.updateState(e);let{props:r,oldProps:n}=e;r.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(e){let{featureIds:r}=this.props,{model:n}=this.state;if(!n)return;let o={pickFeatureIds:Boolean(r)},s={camera:this.context.viewport.cameraPosition};n.shaderInputs.setProps({pbrProjection:s,mesh:o}),super.draw(e)}getModel(e){let{id:r}=this.props,n=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:n});let o=this.getShaders();return wC(e.attributes),new Om.Model(this.context.device,{...this.getShaders(),id:r,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...o.defines,...n?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:n?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){let{model:r}=this.state;if(r){let{mesh:n}=this.props,o=this.parseMaterial(e,n);this.setState({parsedPBRMaterial:o});let{pbr_baseColorSampler:s}=o.bindings,{emptyTexture:i}=this.state,a={sampler:s||i,hasTexture:Boolean(s)},{camera:c,...l}={...o.bindings,...o.uniforms};r.shaderInputs.setProps({simpleMesh:a,pbrMaterial:l})}}parseMaterial(e,r){let n=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return rl(this.context.device,{unlit:n,...e},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingIndexes(e){let r=this.props.featureIds;e.value=new Uint32Array(r)}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}};go.layerName="MeshLayer";go.defaultProps=LC;var Dm=go;var J0=D(rr(),1);var Tt=6356752314245179e-9,FC={radii:[6378137,6378137,Tt],radiiSquared:[6378137*6378137,6378137*6378137,Tt*Tt],oneOverRadii:[1/6378137,1/6378137,1/Tt],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(Tt*Tt)],maximumRadius:Math.max(6378137,6378137,Tt),centerToleranceSquared:.1};function ni(t){return t}var d4=new y;function PC(t,e=[],r=ni){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Gm(t,e=[]){return PC(t,e,Q._cartographicRadians?ni:Ea)}function NC(t,e,r=ni){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Vm(t,e){return NC(t,e,Q._cartographicRadians?ni:Sa)}var Hm=1e-14,OC=new y,zm={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},sl={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Ao={east:new y,north:new y,up:new y,west:new y,south:new y,down:new y},UC=new y,DC=new y,GC=new y;function il(t,e,r,n,o,s){let i=zm[e]&&zm[e][r];he(i&&(!n||n===i));let a,c,l,f=OC.copy(o);if(_e(f.x,0,Hm)&&_e(f.y,0,Hm)){let h=Math.sign(f.z);a=UC.fromArray(sl[e]),e!=="east"&&e!=="west"&&a.scale(h),c=DC.fromArray(sl[r]),r!=="east"&&r!=="west"&&c.scale(h),l=GC.fromArray(sl[n]),n!=="east"&&n!=="west"&&l.scale(h)}else{let{up:h,east:p,north:d}=Ao;p.set(-f.y,f.x,0).normalize(),t.geodeticSurfaceNormal(f,h),d.copy(h).cross(p);let{down:m,west:g,south:x}=Ao;m.copy(h).scale(-1),g.copy(p).scale(-1),x.copy(d).scale(-1),a=Ao[e],c=Ao[r],l=Ao[n]}return s[0]=a.x,s[1]=a.y,s[2]=a.z,s[3]=0,s[4]=c.x,s[5]=c.y,s[6]=c.z,s[7]=0,s[8]=l.x,s[9]=l.y,s[10]=l.z,s[11]=0,s[12]=f.x,s[13]=f.y,s[14]=f.z,s[15]=1,s}var tn=new y,VC=new y,HC=new y;function km(t,e,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:o,centerToleranceSquared:s}=e;tn.from(t);let i=tn.x,a=tn.y,c=tn.z,l=n.x,f=n.y,u=n.z,h=i*i*l*l,p=a*a*f*f,d=c*c*u*u,m=h+p+d,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;let x=VC;if(x.copy(t).scale(g),m<s)return x.to(r);let b=o.x,M=o.y,E=o.z,C=HC;C.set(x.x*b*2,x.y*M*2,x.z*E*2);let _=(1-g)*tn.len()/(.5*C.len()),R=0,S,T,A,B;do{_-=R,S=1/(1+_*b),T=1/(1+_*M),A=1/(1+_*E);let L=S*S,F=T*T,w=A*A,U=L*S,W=F*T,z=w*A;B=h*L+p*F+d*w-1;let K=-2*(h*U*b+p*W*M+d*z*E);R=B/K}while(Math.abs(B)>Ge.EPSILON12);return tn.scale([S,T,A]).to(r)}var oi=new y,jm=new y,jC=new y,et=new y,qC=new y,si=new y,G=class{constructor(e=0,r=0,n=0){this.centerToleranceSquared=Ge.EPSILON1,he(e>=0),he(r>=0),he(n>=0),this.radii=new y(e,r,n),this.radiiSquared=new y(e*e,r*r,n*n),this.radiiToTheFourth=new y(e*e*e*e,r*r*r*r,n*n*n*n),this.oneOverRadii=new y(e===0?0:1/e,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new y(e===0?0:1/(e*e),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(e,r,n),this.maximumRadius=Math.max(e,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let n=jm,o=jC,[,,s]=e;this.geodeticSurfaceNormalCartographic(e,n),o.copy(this.radiiSquared).scale(n);let i=Math.sqrt(n.dot(o));return o.scale(1/i),n.scale(s),o.add(n),o.to(r)}cartesianToCartographic(e,r=[0,0,0]){si.from(e);let n=this.scaleToGeodeticSurface(si,et);if(!n)return;let o=this.geodeticSurfaceNormal(n,jm),s=qC;s.copy(si).subtract(n);let i=Math.atan2(o.y,o.x),a=Math.asin(o.z),c=Math.sign(tr.dot(s,si))*tr.length(s);return Vm([i,a,c],r)}eastNorthUpToFixedFrame(e,r=new N){return il(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,n,o,s=new N){return il(this,e,r,n,o,s)}geocentricSurfaceNormal(e,r=[0,0,0]){return oi.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let n=Gm(e),o=n[0],s=n[1],i=Math.cos(s);return oi.set(i*Math.cos(o),i*Math.sin(o),Math.sin(s)).normalize(),oi.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return oi.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return km(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){et.from(e);let n=et.x,o=et.y,s=et.z,i=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*i.x+o*o*i.y+s*s*i.z);return et.multiplyScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return et.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return et.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,n=[0,0,0]){he(_e(this.radii.x,this.radii.y,Ge.EPSILON15)),he(this.radii.z>0),et.from(e);let o=et.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(o)>=this.radii.z-r))return et.set(0,0,o).to(n)}};G.WGS84=new G(6378137,6378137,Tt);var ii=class{item;previous;next;constructor(e,r,n){this.item=e,this.previous=r,this.next=n}};var ai=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new ii(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let n=e.next;e.next=r,this.tail===e?this.tail=r:n.previous=r,r.next=n,r.previous=e,++this._length}};var ci=class{_list;_sentinel;_trimTiles;constructor(){this._list=new ai,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(e,r))}unloadTile(e,r,n){let o=r._cacheNode;o&&(this._list.remove(o),r._cacheNode=null,n&&n(e,r))}unloadTiles(e,r){let n=this._trimTiles;this._trimTiles=!1;let o=this._list,s=e.maximumMemoryUsage*1024*1024,i=this._sentinel,a=o.head;for(;a!==i&&(e.gpuMemoryUsageInBytes>s||n);){let c=a.item;a=a.next,this.unloadTile(e,c,r)}}trim(){this._trimTiles=!0}};function qm(t,e){H(t),H(e);let{rtcCenter:r,gltfUpAxis:n}=e,{computedTransform:o,boundingVolume:{center:s}}=t,i=new N(o);switch(r&&i.translate(r),n){case"Z":break;case"Y":let h=new N().rotateX(Math.PI/2);i=i.multiplyRight(h);break;case"X":let p=new N().rotateY(-Math.PI/2);i=i.multiplyRight(p);break;default:break}e.isQuantized&&i.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new y(s);e.cartesianModelMatrix=i,e.cartesianOrigin=a;let c=G.WGS84.cartesianToCartographic(a,new y),f=G.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=f.multiplyRight(i),e.cartographicOrigin=c;let u=WC(e);u&&(e.cartesianModelMatrix=new N(i).multiplyRight(u.matrix),e.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=N.IDENTITY),e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var JC=1e6**2;function WC(t){let e=t.gltf;if(!e)return null;let r=typeof e.scene=="number"?e.scene:0,o=e.scenes?.[r]?.nodes?.[0];if(!o?.matrix)return null;let s=o.matrix;return s[12]*s[12]+s[13]*s[13]+s[14]*s[14]<=JC?null:o}var Jm=new y,al=new y,cl=new ce([new pe,new pe,new pe,new pe,new pe,new pe]);function Xm(t,e){let{cameraDirection:r,cameraUp:n,height:o}=t,{metersPerUnit:s}=t.distanceScales,i=li(t,t.center),a=G.WGS84.eastNorthUpToFixedFrame(i),c=t.unprojectPosition(t.cameraPosition),l=G.WGS84.cartographicToCartesian(c,new y),f=new y(a.transformAsVector(new y(r).scale(s))).normalize(),u=new y(a.transformAsVector(new y(n).scale(s))).normalize();XC(t);let h=t.constructor,{longitude:p,latitude:d,width:m,bearing:g,zoom:x}=t,b=new h({longitude:p,latitude:d,height:o,width:m,bearing:g,zoom:x,pitch:0});return{camera:{position:l,direction:f,up:u},viewport:t,topDownViewport:b,height:o,cullingVolume:cl,frameNumber:e,sseDenominator:1.15}}function Ym(t,e,r){if(r===0||t.length<=r)return[t,[]];let n=[],{longitude:o,latitude:s}=e.viewport;for(let[l,f]of t.entries()){let[u,h]=f.header.mbs,p=Math.abs(o-u),d=Math.abs(s-h),m=Math.sqrt(d*d+p*p);n.push([l,m])}let i=n.sort((l,f)=>l[1]-f[1]),a=[];for(let l=0;l<r;l++)a.push(t[i[l][0]]);let c=[];for(let l=r;l<i.length;l++)c.push(t[i[l][0]]);return[a,c]}function XC(t){let e=t.getFrustumPlanes(),r=Wm(e.near,t.cameraPosition),n=li(t,r),o=li(t,t.cameraPosition,al),s=0;cl.planes[s++].fromPointNormal(n,Jm.copy(n).subtract(o));for(let i in e){if(i==="near")continue;let a=e[i],c=Wm(a,r,al),l=li(t,c,al);cl.planes[s++].fromPointNormal(l,Jm.copy(n).subtract(l))}}function Wm(t,e,r=new y){let n=t.normal.dot(e);return r.copy(t.normal).scale(t.distance-n).add(e),r}function li(t,e,r=new y){let n=t.unprojectPosition(e);return G.WGS84.cartographicToCartesian(n,r)}var YC=6378137,KC=6378137,ll=6356752314245179e-9,rn=new y;function Km(t,e){if(t instanceof Ze){let{halfAxes:r}=t,n=QC(r);return Math.log2(ll/(n+e[2]))}else if(t instanceof He){let{radius:r}=t;return Math.log2(ll/(r+e[2]))}else if(t.width&&t.height){let{width:r,height:n}=t,o=Math.log2(YC/r),s=Math.log2(KC/n);return(o+s)/2}return 1}function fl(t,e,r){G.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],rn);let n=Math.sqrt(Math.pow(rn[0]-r[0],2)+Math.pow(rn[1]-r[1],2)+Math.pow(rn[2]-r[2],2));return Math.log2(ll/(n+e[2]))}function Qm(t,e,r){let[n,o,s,i]=t;return fl({xmin:n,xmax:s,ymin:o,ymax:i,zmin:0,zmax:0},e,r)}function QC(t){t.getColumn(0,rn);let e=t.getColumn(1),r=t.getColumn(2);return rn.add(e).add(r).len()}var dg=D(rr(),1);var Be={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},Te;(function(t){t[t.ADD=1]="ADD",t[t.REPLACE=2]="REPLACE"})(Te||(Te={}));var ke;(function(t){t.EMPTY="empty",t.SCENEGRAPH="scenegraph",t.POINTCLOUD="pointcloud",t.MESH="mesh"})(ke||(ke={}));var de;(function(t){t.I3S="I3S",t.TILES3D="TILES3D"})(de||(de={}));var Mt;(function(t){t.GEOMETRIC_ERROR="geometricError",t.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(Mt||(Mt={}));var Zm={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function rg(t){return t!=null}var Me=new y,fi=new y,ZC=new y,$C=new y,Ar=new y,$m=new y,eg=new y,tg=new y;function ui(t,e,r){if(H(t,"3D Tile: boundingVolume must be defined"),t.box)return og(t.box,e,r);if(t.region)return tB(t.region);if(t.sphere)return eB(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function ng(t,e){if(t.box)return rB(e);if(t.region){let[r,n,o,s,i,a]=t.region;return[[Ne(r),Ne(n),i],[Ne(o),Ne(s),a]]}if(t.sphere)return nB(e);throw new Error("Unkown boundingVolume type")}function og(t,e,r){let n=new y(t[0],t[1],t[2]);e.transform(n,n);let o=[];if(t.length===10){let l=t.slice(3,6),f=new it;f.fromArray(t,6);let u=new y([1,0,0]),h=new y([0,1,0]),p=new y([0,0,1]);u.transformByQuaternion(f),u.scale(l[0]),h.transformByQuaternion(f),h.scale(l[1]),p.transformByQuaternion(f),p.scale(l[2]),o=[...u.toArray(),...h.toArray(),...p.toArray()]}else o=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];let s=e.transformAsVector(o.slice(0,3)),i=e.transformAsVector(o.slice(3,6)),a=e.transformAsVector(o.slice(6,9)),c=new k([s[0],s[1],s[2],i[0],i[1],i[2],a[0],a[1],a[2]]);return rg(r)?(r.center=n,r.halfAxes=c,r):new Ze(n,c)}function eB(t,e,r){let n=new y(t[0],t[1],t[2]);e.transform(n,n);let o=e.getScale(fi),s=Math.max(Math.max(o[0],o[1]),o[2]),i=t[3]*s;return rg(r)?(r.center=n,r.radius=i,r):new He(n,i)}function tB(t){let[e,r,n,o,s,i]=t,a=G.WGS84.cartographicToCartesian([Ne(e),Ne(o),s],ZC),c=G.WGS84.cartographicToCartesian([Ne(n),Ne(r),i],$C),l=new y().addVectors(a,c).multiplyByScalar(.5);return G.WGS84.cartesianToCartographic(l,Ar),G.WGS84.cartographicToCartesian([Ne(n),Ar[1],Ar[2]],$m),G.WGS84.cartographicToCartesian([Ar[0],Ne(o),Ar[2]],eg),G.WGS84.cartographicToCartesian([Ar[0],Ar[1],i],tg),og([...l,...$m.subtract(l),...eg.subtract(l),...tg.subtract(l)],new N)}function rB(t){let e=sg(),{halfAxes:r}=t,n=new y(r.getColumn(0)),o=new y(r.getColumn(1)),s=new y(r.getColumn(2));for(let i=0;i<2;i++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)Me.copy(t.center),Me.add(n),Me.add(o),Me.add(s),ig(e,Me),s.negate();o.negate()}n.negate()}return e}function nB(t){let e=sg(),{center:r,radius:n}=t,o=G.WGS84.scaleToGeodeticSurface(r,Me),s;o?s=G.WGS84.geodeticSurfaceNormal(o):s=new y(0,0,1);let i=new y(s[2],-s[1],0);i.len()>0?i.normalize():i=new y(0,1,0);let a=i.clone().cross(s);for(let c of[i,a,s]){fi.copy(c).scale(n);for(let l=0;l<2;l++)Me.copy(r),Me.add(fi),ig(e,Me),fi.negate()}return e}function sg(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function ig(t,e){G.WGS84.cartesianToCartographic(e,Me),t[0][0]=Math.min(t[0][0],Me[0]),t[0][1]=Math.min(t[0][1],Me[1]),t[0][2]=Math.min(t[0][2],Me[2]),t[1][0]=Math.max(t[1][0],Me[0]),t[1][1]=Math.max(t[1][1],Me[1]),t[1][2]=Math.max(t[1][2],Me[2])}var eH=new y,tH=new y,rH=new N,nH=new y,oH=new y,sH=new y;function oB(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function sB(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){let r=t.dynamicScreenSpaceErrorComputedDensity,n=t.dynamicScreenSpaceErrorFactor;return oB(e,r)*n}return 0}function ag(t,e,r){let n=t.tileset,o=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,s=r?o:t.lodMetricValue;if(s===0)return 0;let i=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:c}=e,{viewDistanceScale:l}=n.options,f=s*a*(l||1)/(i*c);return f-=sB(n,i),f}var ul=new y,cg=new y,kt=new y,lg=new y,iB=new y,hl=new N,fg=new N;function ug(t,e){if(t.lodMetricValue===0||isNaN(t.lodMetricValue))return"DIG";let r=2*pl(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function pl(t,e){let{topDownViewport:r}=e,n=t.header.mbs[1],o=t.header.mbs[0],s=t.header.mbs[2],i=t.header.mbs[3],a=[...t.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);G.WGS84.cartographicToCartesian(c,ul),cg.copy(ul).subtract(a).normalize(),G.WGS84.eastNorthUpToFixedFrame(a,hl),fg.copy(hl).invert(),kt.copy(ul).transform(fg);let l=Math.sqrt(kt[0]*kt[0]+kt[1]*kt[1]),f=l*l/kt[2];lg.copy([kt[0],kt[1],f]);let h=lg.transform(hl).subtract(a).normalize(),d=cg.cross(h).normalize().scale(i).add(a),m=G.WGS84.cartesianToCartographic(d),g=r.project([o,n,s]),x=r.project(m);return iB.copy(g).subtract(x).magnitude()}function hg(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}var xo=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return H(e<this._array.length),this._array[e]}set(e,r){H(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){H(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){H(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var aB={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},ht=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new xo;_emptyTraversalStack=new xo;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...aB,...e}}traverse(e,r,n){this.root=e,this.options={...this.options,...n},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let n=this._traversalStack;for(e._selectionDepth=1,n.push(e);n.length>0;){let s=n.pop(),i=!1;this.canTraverse(s,r)&&(this.updateChildTiles(s,r),i=this.updateAndPushChildren(s,r,n,s.hasRenderContent?s._selectionDepth+1:s._selectionDepth));let a=s.parent,c=Boolean(!a||a._shouldRefine),l=!i;s.hasRenderContent?s.refine===Te.ADD?(this.loadTile(s,r),this.selectTile(s,r)):s.refine===Te.REPLACE&&(this.loadTile(s,r),l&&this.selectTile(s,r)):(this.emptyTiles[s.id]=s,this.loadTile(s,r),l&&this.selectTile(s,r)),this.touchTile(s,r),s._shouldRefine=i&&c}let o=new Date().getTime();(this.traversalFinished(r)||o-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=o,this.options.onTraversalEnd(r))}updateChildTiles(e,r){let n=e.children;for(let o of n)this.updateTile(o,r)}updateAndPushChildren(e,r,n,o){let{loadSiblings:s,skipLevelOfDetail:i}=this.options,a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===Te.REPLACE&&e.hasRenderContent&&!i,l=!1,f=!0;for(let u of a)if(u._selectionDepth=o,u.isVisibleAndInRequestVolume?(n.find(u)&&n.delete(u),n.push(u),l=!0):(c||s)&&(this.loadTile(u,r),this.touchTile(u,r)),c){let h;if(u._inRequestVolume?u.hasRenderContent?h=u.contentAvailable:h=this.executeEmptyTraversal(u,r):h=!1,f=f&&h,!f)return!1}return l||(f=!1),f}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){this.shouldLoadTile(e)&&(e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,r):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,r,n=!1){let o=e._screenSpaceError;return n&&(o=e.getScreenSpaceError(r,!0)),o>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let n=[];if(this.options.viewportTraversersMap)for(let o in this.options.viewportTraversersMap)this.options.viewportTraversersMap[o]===r.viewport.id&&n.push(o);else n.push(r.viewport.id);e.updateVisibility(r,n)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let n=!1;for(let o of e.children)o.updateVisibility(r),n=n||o.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,r){let n=!0,o=this._emptyTraversalStack;for(o.push(e);o.length>0;){let s=o.pop(),i=!s.hasRenderContent&&this.canTraverse(s,r),a=!s.hasRenderContent&&s.children.length===0;if(!i&&!s.contentAvailable&&!a&&(n=!1),this.updateTile(s,r),s.isVisibleAndInRequestVolume||(this.loadTile(s,r),this.touchTile(s,r)),i){let c=s.children;for(let l of c)o.push(l)}}return e.hasEmptyContent||n}};var pg=new y;function cB(t){return t!=null}var xr=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Be.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new N;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new ht({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new N;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(e,r,n,o=""){this.header=r,this.tileset=e,this.id=o||r.id,this.url=r.url,this.parent=n,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Be.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Be.UNLOADED}get contentExpired(){return this.contentState===Be.EXPIRED}get contentFailed(){return this.contentState===Be.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=ng(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,r){switch(this.tileset.type){case de.I3S:return pl(this,e);case de.TILES3D:return ag(this,e,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let e=this.tileset._traverser,{skipLevelOfDetail:r}=e.options,n=this.refine===Te.ADD||r;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Be.UNLOADED)return-1;let o=this.parent,i=o&&(!n||this._screenSpaceError===0||o.hasTilesetContent)?o._screenSpaceError:this._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-i,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Be.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Be.UNLOADED,!1;try{let n=this.tileset.getTileUrl(this.contentUrl),o=this.tileset.loader,s=this.tileset.loadOptions[o.id]||{},i={...this.tileset.loadOptions,[o.id]:{...s,isTileset:this.type==="json",...this._getLoaderSpecificOptions(o.id)}};return this.content=await(0,dg.load)(n,o,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Be.READY,this._onContentLoaded(),!0}catch(n){throw this.contentState=Be.FAILED,n}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Be.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let n=this.parent,o=n?n._visibilityPlaneMask:ce.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let s=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(s)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,o),this._visible=this._visibilityPlaneMask!==ce.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}visibility(e,r){let{cullingVolume:n}=e,{boundingVolume:o}=this;return n.computeVisibilityWithPlaneMask(o,r)}contentVisibility(){return!0}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return pg.subVectors(r.center,e.position),e.direction.dot(pg)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(cB(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=Be.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new N(e.transform):new N;let r=this.parent,n=this.tileset,o=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new N(o).multiplyRight(this.transform);let s=r&&r._initialTransform?r._initialTransform.clone():new N;this._initialTransform=new N(s).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Be.UNLOADED,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=ce.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||Te.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=ui(e.boundingVolume,this.computedTransform,this.boundingVolume);let r=e.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=ui(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=ui(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new N){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return hg(this.tileset.tileset)}}};var hi=class extends ht{compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let n=e.children.length>0;if(e.hasTilesetContent&&n){let i=e.children[0];this.updateTileVisibility(i,r),e._visible=i._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let o=e.refine===Te.REPLACE,s=e._optimChildrenWithinParent===Zm.USE_OPTIMIZATION;if(o&&s&&n&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:n}=e;return!n||n.hasTilesetContent||n.refine!==Te.ADD?!1:!this.shouldRefine(e,r,!0)}};var mg=D(rr(),1);var pi=class{frameNumberMap=new Map;register(e,r){let n=this.frameNumberMap.get(e)||new Map,o=n.get(r)||0;n.set(r,o+1),this.frameNumberMap.set(e,n)}deregister(e,r){let n=this.frameNumberMap.get(e);if(!n)return;let o=n.get(r)||1;n.set(r,o-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var dl={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},di=class{_statusMap;pendingTilesRegister=new pi;constructor(){this._statusMap={}}add(e,r,n,o){if(!this._statusMap[r]){let{frameNumber:s,viewport:{id:i}}=o;this._statusMap[r]={request:e,callback:n,key:r,frameState:o,status:dl.REQUESTED},this.pendingTilesRegister.register(i,s),e().then(a=>{this._statusMap[r].status=dl.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,o)}).catch(a=>{this._statusMap[r].status=dl.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),n(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:n,viewport:{id:o}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(o,n);let{frameNumber:s,viewport:{id:i}}=r;this.pendingTilesRegister.register(i,s),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var mi=class extends ht{_tileManager;constructor(e){super(e),this._tileManager=new di}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=ug(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let n=e.header.children||[],o=e.children,s=e.tileset;for(let i of n){let a=`${i.id}-${r.viewport.id}`,c=o&&o.find(l=>l.id===a);if(c)c&&this.updateTile(c,r);else{let l=()=>this._loadTile(i.id,s);this._tileManager.find(a)?this._tileManager.update(a,r):(s.tileset.nodePages&&(l=()=>s.tileset.nodePagesTile.formTileFromNodePages(i.id)),this._tileManager.add(l,a,u=>this._onTileLoad(u,e,a),r))}}return!1}async _loadTile(e,r){let{loader:n}=r,o=r.getTileUrl(`${r.url}/nodes/${e}`),s={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await(0,mg.load)(o,n,s)}_onTileLoad(e,r,n){let o=new xr(r.tileset,e,r,n);r.children.push(o);let s=this._tileManager.find(o.id).frameState;this.updateTile(o,s),this._frameNumber===s.frameNumber&&(this.traversalFinished(s)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(o,s)}};var lB={description:"",ellipsoid:G.WGS84,modelMatrix:new N,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},gi="Tiles In Tileset(s)",ml="Tiles In Memory",gg="Tiles In View",Ag="Tiles To Render",xg="Tiles Loaded",gl="Tiles Loading",yg="Tiles Unloaded",bg="Failed Tile Loads",Tg="Points/Vertices",Al="Tile Memory Use",Mg="Maximum Screen Space Error",yo=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new ci;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,r){this.options={...lB,...r},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||Ot.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new Pt({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new Ft({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let n=e;return this.queryParams.length&&(n=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),n}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let n=[];for(let o of r){let s=o.id;this._needTraverse(s)?n.push(s):this.traverseCounter--}for(let o of r){let s=o.id;if(this.roots[s]||(this.roots[s]=this._initializeTileHeaders(this.tileset,null)),!n.includes(s))continue;let i=Xm(o,this._frameNumber);this._traverser.traverse(this.roots[s],i,this.options)}}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],o=Object.values(this._traverser.selectedTiles),[s,i]=Ym(o,e,this.options.maximumTilesSelected);n.selectedTiles=s;for(let a of i)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let s in this.frameStateData){let i=this.frameStateData[s];this.selectedTiles=this.selectedTiles.concat(i.selectedTiles),this._requestedTiles=this._requestedTiles.concat(i._requestedTiles),this._emptyTiles=this._emptyTiles.concat(i._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles.map(s=>s.id)),n=this.selectedTiles.some(s=>!s.tileDrawn),o=0;if(n){for(let s of r)this._heldTiles.add(s);for(let s of this._heldTiles){if(r.has(s))continue;let i=this._tiles[s];i&&i.contentAvailable?(i._selectedFrame=this._frameNumber,this.selectedTiles.push(i),o++):this._heldTiles.delete(s)}}else this._heldTiles=r;o>0&&setTimeout(()=>{this.selectTiles()},0);for(let s of this.selectedTiles)this._tiles[s.id]=s;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let n=new Set(e.map(i=>i.id)),o=new Set(r.map(i=>i.id)),s=e.filter(i=>!o.has(i.id)).length>0;return s=s||r.filter(i=>!n.has(i.id)).length>0,s}_loadTiles(){this._requestedTiles.sort((e,r)=>e._priority-r._priority);for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r))}_updateStats(){let e=0,r=0;for(let n of this.selectedTiles)n.contentAvailable&&n.content&&(e++,n.content.pointCount?r+=n.content.pointCount:r+=n.content.vertexCount);this.stats.get(gg).count=this.selectedTiles.length,this.stats.get(Ag).count=e,this.stats.get(Tg).count=r,this.stats.get(Mg).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===de.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===de.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===de.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let e=this.tileset.fullExtent;if(e){let{xmin:n,xmax:o,ymin:s,ymax:i,zmin:a,zmax:c}=e;this.cartographicCenter=new y(n+(o-n)/2,s+(i-s)/2,a+(c-a)/2),this.cartesianCenter=new y,G.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=fl(e,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[n,o,s,i]=r;this.cartographicCenter=new y(n+(s-n)/2,o+(i-o)/2,0),this.cartesianCenter=new y,G.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=Qm(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new y,this.zoom=1}calculateViewPropsTiles3D(){let e=this.root,{center:r}=e.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new y,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new y,G.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new y(0,0,-G.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=Km(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(gi),this.stats.get(gl),this.stats.get(ml),this.stats.get(gg),this.stats.get(Ag),this.stats.get(xg),this.stats.get(yg),this.stats.get(bg),this.stats.get(Tg),this.stats.get(Al,"memory"),this.stats.get(Mg)}_initializeTileHeaders(e,r){let n=new xr(this,e.root,r);if(r&&(r.children.push(n),n.depth=r.depth+1),this.type===de.TILES3D){let o=[];for(o.push(n);o.length>0;){let s=o.pop();this.stats.get(gi).incrementCount();let i=s.header.children||[];for(let a of i){let c=new xr(this,a,s);if(c.contentUrl?.includes("?session=")){let f=new URL(c.contentUrl).searchParams.get("session");f&&(this._queryParams.session=f)}s.children.push(c),c.depth=s.depth+1,o.push(c)}}}return n}_initializeTraverser(){let e;switch(this.type){case de.TILES3D:e=hi;break;case de.I3S:e=mi;break;default:e=ht}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r;try{this._onStartTileLoading(),r=await e.loadContent()}catch(n){this._onTileLoadError(e,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}_onTileLoadError(e,r){this.stats.get(bg).incrementCount();let n=r.message||r.toString(),o=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,o)}_onTileLoad(e,r){if(r){if(this.type===de.I3S){let n=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(gi).reset(),this.stats.get(gi).addCount(n)}e&&e.content&&qm(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===de.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===de.TILES3D){let{extensionsRemoved:r=[]}=e.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(gl).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(gl).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(xg).incrementCount(),this.stats.get(ml).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(Al).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(ml).decrementCount(),this.stats.get(yg).incrementCount(),this.stats.get(Al).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let n of r.children)e.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,n=[];for(n.push(r);n.length>0;){e=n.pop();for(let o of e.children)n.push(o);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){let r=new URLSearchParams(e.queryString),n=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){let e=this.loadOptions.i3s;e&&typeof e=="object"&&"token"in e&&(this._queryParams.token=e.token)}};var Ai="4.4.3";var yr={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},e8=Object.keys(yr);function xl(t,e,r){H(t instanceof ArrayBuffer);let n=new TextDecoder("utf8"),o=new Uint8Array(t,e,r);return n.decode(o)}function Eg(t,e=0){let r=new DataView(t);return`${String.fromCharCode(r.getUint8(e+0))}${String.fromCharCode(r.getUint8(e+1))}${String.fromCharCode(r.getUint8(e+2))}${String.fromCharCode(r.getUint8(e+3))}`}var fB="1.5.6",uB="1.4.1",yl=`https://www.gstatic.com/draco/versioned/decoders/${fB}`,me={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},bo={[me.DECODER]:`${yl}/${me.DECODER}`,[me.DECODER_WASM]:`${yl}/${me.DECODER_WASM}`,[me.FALLBACK_DECODER]:`${yl}/${me.FALLBACK_DECODER}`,[me.ENCODER]:`https://raw.githubusercontent.com/google/draco/${uB}/javascript/${me.ENCODER}`},bl;async function _g(t={},e){let r=t.modules||{};return r.draco3d?bl||=r.draco3d.createDecoderModule({}).then(n=>({draco:n})):bl||=hB(t,e),await bl}function Sg(t,e){if(t&&typeof t=="object"){if(t.default)return t.default;if(t[e])return t[e]}return t}async function hB(t,e){let r,n;switch(e){case"js":r=await Ve(bo[me.FALLBACK_DECODER],"draco",t,me.FALLBACK_DECODER);break;case"wasm":default:try{[r,n]=await Promise.all([await Ve(bo[me.DECODER],"draco",t,me.DECODER),await Ve(bo[me.DECODER_WASM],"draco",t,me.DECODER_WASM)])}catch{r=null,n=null}}return r=Sg(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,!r&&!gt&&([r,n]=await Promise.all([await Ve(bo[me.DECODER],"draco",{...t,useLocalLibraries:!0},me.DECODER),await Ve(bo[me.DECODER_WASM],"draco",{...t,useLocalLibraries:!0},me.DECODER_WASM)]),r=Sg(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule),await pB(r,n)}function pB(t,e){if(typeof t!="function")throw new Error("DracoDecoderModule could not be loaded");let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t({...r,onModuleLoaded:o=>n({draco:o})})})}var Cg="4.4.3";function Bg(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function br(t){let e=1/0,r=1/0,n=1/0,o=-1/0,s=-1/0,i=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],u=a[l+1],h=a[l+2];e=f<e?f:e,r=u<r?u:r,n=h<n?h:n,o=f>o?f:o,s=u>s?u:s,i=h>i?h:i}return[[e,r,n],[o,s,i]]}function Tl(t,e,r){let n=Bg(e.value),o=r||Ig(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:n}]},nullable:!1,metadata:o}}function Ig(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}function vg(t,e,r){let n=wg(e.metadata),o=[],s=dB(e.attributes);for(let i in t){let a=t[i],c=Rg(i,a,s[i]);o.push(c)}if(r){let i=Rg("indices",r);o.push(i)}return{fields:o,metadata:n}}function dB(t){let e={};for(let r in t){let n=t[r];e[n.name||"undefined"]=n}return e}function Rg(t,e,r){let n=r?wg(r.metadata):void 0;return Tl(t,e,n)}function wg(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var Lg={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},mB={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},gB=4,To=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let o=this.decoder.GetEncodedGeometryType(n),s=o===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(o){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(n,s);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(n,s);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!s.ptr){let h=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(h)}let a=this._getDracoLoaderData(s,o,r),c=this._getMeshData(s,a,r),l=br(c.attributes),f=vg(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:s.num_points(),boundingBox:l},...c,schema:f}}finally{this.draco.destroy(n),s&&this.draco.destroy(s)}}_getDracoLoaderData(e,r,n){let o=this._getTopLevelMetadata(e),s=this._getDracoAttributes(e,n);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:o,attributes:s}}_getDracoAttributes(e,r){let n={};for(let o=0;o<e.num_attributes();o++){let s=this.decoder.GetAttribute(e,o),i=this._getAttributeMetadata(e,o);n[s.unique_id()]={unique_id:s.unique_id(),attribute_type:s.attribute_type(),data_type:s.data_type(),num_components:s.num_components(),byte_offset:s.byte_offset(),byte_stride:s.byte_stride(),normalized:s.normalized(),attribute_index:o,metadata:i};let a=this._getQuantizationTransform(s,r);a&&(n[s.unique_id()].quantization_transform=a);let c=this._getOctahedronTransform(s,r);c&&(n[s.unique_id()].octahedron_transform=c)}return n}_getMeshData(e,r,n){let o=this._getMeshAttributes(r,e,n);if(!o.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(n.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:o,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:o,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:o}}_getMeshAttributes(e,r,n){let o={};for(let s of Object.values(e.attributes)){let i=this._deduceAttributeName(s,n);s.name=i;let a=this._getAttributeValues(r,s);if(a){let{value:c,size:l}=a;o[i]={value:c,size:l,byteOffset:s.byte_offset,byteStride:s.byte_stride,normalized:s.normalized}}}return o}_getTriangleListIndices(e){let n=e.num_faces()*3,o=n*gB,s=this.draco._malloc(o);try{return this.decoder.GetTrianglesUInt32Array(e,o,s),new Uint32Array(this.draco.HEAPF32.buffer,s,n).slice()}finally{this.draco._free(s)}}_getTriangleStripIndices(e){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),yB(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){let n=mB[r.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;let o=r.num_components,i=e.num_points()*o,a=i*n.BYTES_PER_ELEMENT,c=AB(this.draco,n),l,f=this.draco._malloc(a);try{let u=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,u,c,a,f),l=new n(this.draco.HEAPF32.buffer,f,i).slice()}finally{this.draco._free(f)}return{value:l,size:o}}_deduceAttributeName(e,r){let n=e.unique_id;for(let[i,a]of Object.entries(r.extraAttributes||{}))if(a===n)return i;let o=e.attribute_type;for(let i in Lg)if(this.draco[i]===o)return Lg[i];let s=r.attributeNameEntry||"name";return e.metadata[s]?e.metadata[s].string:`CUSTOM_ATTRIBUTE_${n}`}_getTopLevelMetadata(e){let r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){let n=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};let r={},n=this.metadataQuerier.NumEntries(e);for(let o=0;o<n;o++){let s=this.metadataQuerier.GetEntryName(e,o);r[s]=this._getDracoMetadataField(e,s)}return r}_getDracoMetadataField(e,r){let n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,n);let o=xB(n);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:o}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){let{quantizedAttributes:r=[],octahedronAttributes:n=[]}=e,o=[...r,...n];for(let s of o)this.decoder.SkipAttributeTransform(this.draco[s])}_getQuantizationTransform(e,r){let{quantizedAttributes:n=[]}=r,o=e.attribute_type();if(n.map(i=>this.decoder[i]).includes(o)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(a=>i.min_value(a))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:n=[]}=r,o=e.attribute_type();if(n.map(i=>this.decoder[i]).includes(o)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function AB(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function xB(t){let e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}function yB(t){let e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}var Fg={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:Cg,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},Mo={...Fg,parse:bB};async function bB(t,e){let{draco:r}=await _g(Jn(e),e?.draco?.decoderType||"wasm"),n=new To(r);try{return n.parseSync(t,e?.draco)}finally{n.destroy()}}var TB={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ae={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},O={...TB,...ae};var Ml={[ae.DOUBLE]:Float64Array,[ae.FLOAT]:Float32Array,[ae.UNSIGNED_SHORT]:Uint16Array,[ae.UNSIGNED_INT]:Uint32Array,[ae.UNSIGNED_BYTE]:Uint8Array,[ae.BYTE]:Int8Array,[ae.SHORT]:Int16Array,[ae.INT]:Int32Array},MB={DOUBLE:ae.DOUBLE,FLOAT:ae.FLOAT,UNSIGNED_SHORT:ae.UNSIGNED_SHORT,UNSIGNED_INT:ae.UNSIGNED_INT,UNSIGNED_BYTE:ae.UNSIGNED_BYTE,BYTE:ae.BYTE,SHORT:ae.SHORT,INT:ae.INT},El="Failed to convert GL type",fe=class{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(let r in Ml)if(Ml[r]===e)return r;throw new Error(El)}static fromName(e){let r=MB[e];if(!r)throw new Error(El);return r}static getArrayType(e){switch(e){case ae.UNSIGNED_SHORT_5_6_5:case ae.UNSIGNED_SHORT_4_4_4_4:case ae.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=Ml[e];if(!r)throw new Error(El);return r}}static getByteSize(e){return fe.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(fe.getArrayType(e))}static createTypedArray(e,r,n=0,o){o===void 0&&(o=(r.byteLength-n)/fe.getByteSize(e));let s=ArrayBuffer.isView(r)?r.buffer:r,i=fe.getArrayType(e);return new i(s,n,o)}};function Pg(t,e){if(!t)throw new Error(`math.gl assertion failed. ${e}`)}function Sl(t,e=[0,0,0]){let r=t>>11&31,n=t>>5&63,o=t&31;return e[0]=r<<3,e[1]=n<<2,e[2]=o<<3,e}var N8=1/256;var O8=new Zt,U8=new y,D8=new Zt,G8=new Zt,V8=new Uint8Array(1);function Ng(t,e=255){return fs(t,0,e)/e*2-1}function Og(t){return t<0?-1:1}function Ug(t,e,r,n){if(Pg(n),t<0||t>r||e<0||e>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(n.x=Ng(t,r),n.y=Ng(e,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){let o=n.x;n.x=(1-Math.abs(n.y))*Og(o),n.y=(1-Math.abs(o))*Og(n.y)}return n.normalize()}function _l(t,e,r){return Ug(t,e,255,r)}var Et=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,r){this.json=e,this.buffer=r}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,r=O.UNSIGNED_INT,n=1){let o=this.json[e];return o&&Number.isFinite(o.byteOffset)?this._getTypedArrayFromBinary(e,r,n,1,o.byteOffset):o}getPropertyArray(e,r,n){let o=this.json[e];return o&&Number.isFinite(o.byteOffset)?("componentType"in o&&(r=fe.fromName(o.componentType)),this._getTypedArrayFromBinary(e,r,n,this.featuresLength,o.byteOffset)):this._getTypedArrayFromArray(e,r,o)}getProperty(e,r,n,o,s){let i=this.json[e];if(!i)return i;let a=this.getPropertyArray(e,r,n);if(n===1)return a[o];for(let c=0;c<n;++c)s[c]=a[n*o+c];return s}_getTypedArrayFromBinary(e,r,n,o,s){let i=this._cachedTypedArrays,a=i[e];return a||(a=fe.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+s,o*n),i[e]=a),a}_getTypedArrayFromArray(e,r,n){let o=this._cachedTypedArrays,s=o[e];if(!s){if(ArrayBuffer.isView(n)){let i=n.byteOffset,c=n.byteLength/fe.getByteSize(r);s=fe.createTypedArray(r,n.buffer,i,c)}else if(n instanceof ArrayBuffer)s=fe.createTypedArray(r,n);else{let i=fe.getArrayType(r);s=new i(n)}o[e]=s}return s}};var EB={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},SB={SCALAR:(t,e)=>t[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},_B={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};function Dg(t,e,r,n){let{componentType:o}=t;H(t.componentType);let s=typeof o=="string"?fe.fromName(o):o,i=EB[t.type],a=SB[t.type],c=_B[t.type];return r+=t.byteOffset,{values:fe.createTypedArray(s,e,r,i*n),type:s,size:i,unpacker:a,packer:c}}var pt=t=>t!==void 0;function Gg(t,e,r){if(!e)return null;let n=t.getExtension("3DTILES_batch_table_hierarchy"),o=e.HIERARCHY;return o&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=o,n=o),n?CB(n,r):null}function CB(t,e){let r,n,o,s=t.instancesLength,i=t.classes,a=t.classIds,c=t.parentCounts,l=t.parentIds,f=s;pt(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,o=getBinaryAccessor(a),a=o.createArrayBufferView(e.buffer,e.byteOffset+a.byteOffset,s));let u;if(pt(c))for(pt(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,o=getBinaryAccessor(c),c=o.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,s)),u=new Uint16Array(s),f=0,r=0;r<s;++r)u[r]=f,f+=c[r];pt(l)&&pt(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,o=getBinaryAccessor(l),l=o.createArrayBufferView(e.buffer,e.byteOffset+l.byteOffset,f));let h=i.length;for(r=0;r<h;++r){let g=i[r].length,x=i[r].instances,b=getBinaryProperties(g,x,e);i[r].instances=combine(b,x)}let p=new Array(h).fill(0),d=new Uint16Array(s);for(r=0;r<s;++r)n=a[r],d[r]=p[n],++p[n];let m={classes:i,classIds:a,classIndexes:d,parentCounts:c,parentIndexes:u,parentIds:l};return RB(m),m}function nn(t,e,r){if(!t)return;let n=t.parentCounts;return t.parentIds?r(t,e):n>0?BB(t,e,r):IB(t,e,r)}function BB(t,e,r){let n=t.classIds,o=t.parentCounts,s=t.parentIds,i=t.parentIndexes,a=n.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,f=scratchStack;for(f.length=0,f.push(e);f.length>0;){if(e=f.pop(),c[e]===l)continue;c[e]=l;let u=r(t,e);if(pt(u))return u;let h=o[e],p=i[e];for(let d=0;d<h;++d){let m=s[p+d];m!==e&&f.push(m)}}return null}function IB(t,e,r){let n=!0;for(;n;){let o=r(t,e);if(pt(o))return o;let s=t.parentIds[e];n=s!==e,e=s}throw new Error("traverseHierarchySingleParent")}function RB(t){let e=[],n=t.classIds.length;for(let o=0;o<n;++o)Vg(t,o,stack)}function Vg(t,e,r){let n=t.parentCounts,o=t.parentIds,s=t.parentIndexes,a=t.classIds.length;if(!pt(o))return;assert(e<a,`Parent index ${e} exceeds the total number of instances: ${a}`),assert(r.indexOf(e)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(e);let c=pt(n)?n[e]:1,l=pt(n)?s[e]:e;for(let f=0;f<c;++f){let u=o[l+f];u!==e&&Vg(t,u,r)}r.pop(e)}function we(t){return t!=null}var xi=(t,e)=>t,vB={HIERARCHY:!0,extensions:!0,extras:!0},Tr=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,r,n,o={}){H(n>=0),this.json=e||{},this.binary=r,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(let s in this.json)vB[s]||(this._properties[s]=this.json[s]);this._binaryProperties=this._initializeBinaryProperties(),o["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Gg(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,r){if(this._checkBatchId(e),H(typeof r=="string",r),this._hierarchy){let n=nn(this._hierarchy,e,(o,s)=>{let i=o.classIds[s];return o.classes[i].name===r});return we(n)}return!1}isExactClass(e,r){return H(typeof r=="string",r),this.getExactClassName(e)===r}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){let r=this._hierarchy.classIds[e];return this._hierarchy.classes[r].name}}hasProperty(e,r){return this._checkBatchId(e),H(typeof r=="string",r),we(this._properties[r])||this._hasPropertyInHierarchy(e,r)}getPropertyNames(e,r){this._checkBatchId(e),r=we(r)?r:[],r.length=0;let n=Object.keys(this._properties);return r.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(e,r),r}getProperty(e,r){if(this._checkBatchId(e),H(typeof r=="string",r),this._binaryProperties){let o=this._binaryProperties[r];if(we(o))return this._getBinaryProperty(o,e)}let n=this._properties[r];if(we(n))return xi(n[e],!0);if(this._hierarchy){let o=this._getHierarchyProperty(e,r);if(we(o))return o}}setProperty(e,r,n){let o=this.featureCount;if(this._checkBatchId(e),H(typeof r=="string",r),this._binaryProperties){let i=this._binaryProperties[r];if(i){this._setBinaryProperty(i,e,n);return}}if(this._hierarchy&&this._setHierarchyProperty(this,e,r,n))return;let s=this._properties[r];we(s)||(this._properties[r]=new Array(o),s=this._properties[r]),s[e]=xi(n,!0)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,r){return e.unpack(e.typedArray,r)}_setBinaryProperty(e,r,n){e.pack(n,e.typedArray,r)}_initializeBinaryProperties(){let e=null;for(let r in this._properties){let n=this._properties[r],o=this._initializeBinaryProperty(r,n);o&&(e=e||{},e[r]=o)}return e}_initializeBinaryProperty(e,r){if("byteOffset"in r){let n=r;H(this.binary,`Property ${e} requires a batch table binary.`),H(n.type,`Property ${e} requires a type.`);let o=Dg(n,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:o.values,componentCount:o.size,unpack:o.unpacker,pack:o.packer}}return null}_hasPropertyInHierarchy(e,r){if(!this._hierarchy)return!1;let n=nn(this._hierarchy,e,(o,s)=>{let i=o.classIds[s],a=o.classes[i].instances;return we(a[r])});return we(n)}_getPropertyNamesInHierarchy(e,r){nn(this._hierarchy,e,(n,o)=>{let s=n.classIds[o],i=n.classes[s].instances;for(let a in i)i.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(e,r){return nn(this._hierarchy,e,(n,o)=>{let s=n.classIds[o],i=n.classes[s],a=n.classIndexes[o],c=i.instances[r];return we(c)?we(c.typedArray)?this._getBinaryProperty(c,a):xi(c[a],!0):null})}_setHierarchyProperty(e,r,n,o){let s=nn(this._hierarchy,r,(i,a)=>{let c=i.classIds[a],l=i.classes[c],f=i.classIndexes[a],u=l.instances[n];return we(u)?(H(a===r,`Inherited property "${n}" is read-only.`),we(u.typedArray)?this._setBinaryProperty(u,f,o):u[f]=xi(o,!0),!0):!1});return we(s)}};function jt(t,e,r=0){let n=new DataView(e);if(t.magic=n.getUint32(r,!0),r+=4,t.version=n.getUint32(r,!0),r+=4,t.byteLength=n.getUint32(r,!0),r+=4,t.version!==1)throw new Error(`3D Tile Version ${t.version} not supported`);return r}var on=4,Hg="b3dm tile in legacy format.";function sn(t,e,r){let n=new DataView(e),o;t.header=t.header||{};let s=n.getUint32(r,!0);r+=on;let i=n.getUint32(r,!0);r+=on;let a=n.getUint32(r,!0);r+=on;let c=n.getUint32(r,!0);return r+=on,a>=570425344?(r-=on*2,o=s,a=i,c=0,s=0,i=0,console.warn(Hg)):c>=570425344&&(r-=on,o=a,a=s,c=i,s=0,i=0,console.warn(Hg)),t.header.featureTableJsonByteLength=s,t.header.featureTableBinaryByteLength=i,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=c,t.header.batchLength=o,r}function an(t,e,r,n){return r=wB(t,e,r,n),r=LB(t,e,r,n),r}function wB(t,e,r,n){let{featureTableJsonByteLength:o,featureTableBinaryByteLength:s,batchLength:i}=t.header||{};if(t.featureTableJson={BATCH_LENGTH:i||0},o&&o>0){let a=xl(e,r,o);t.featureTableJson=JSON.parse(a)}return r+=o||0,t.featureTableBinary=new Uint8Array(e,r,s),r+=s||0,r}function LB(t,e,r,n){let{batchTableJsonByteLength:o,batchTableBinaryByteLength:s}=t.header||{};if(o&&o>0){let i=xl(e,r,o);t.batchTableJson=JSON.parse(i),r+=o,s&&s>0&&(t.batchTableBinary=new Uint8Array(e,r,s),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=s)}return r}function Cl(t,e,r){if(!e&&(!t||!t.batchIds||!r))return null;let{batchIds:n,isRGB565:o,pointCount:s=0}=t;if(n&&r){let i=new Uint8ClampedArray(s*3);for(let a=0;a<s;a++){let c=n[a],f=r.getProperty(c,"dimensions").map(u=>u*255);i[a*3]=f[0],i[a*3+1]=f[1],i[a*3+2]=f[2]}return{type:O.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}if(e&&o){let i=new Uint8ClampedArray(s*3);for(let a=0;a<s;a++){let c=Sl(e[a]);i[a*3]=c[0],i[a*3+1]=c[1],i[a*3+2]=c[2]}return{type:O.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}return e&&e.length===s*3?{type:O.UNSIGNED_BYTE,value:e,size:3,normalized:!0}:{type:O.UNSIGNED_BYTE,value:e||new Uint8ClampedArray,size:4,normalized:!0}}var zg=new y;function kg(t,e){if(!e)return null;if(t.isOctEncoded16P){let r=new Float32Array((t.pointsLength||0)*3);for(let n=0;n<(t.pointsLength||0);n++)_l(e[n*2],e[n*2+1],zg),zg.toArray(r,n*3);return{type:O.FLOAT,size:2,value:r}}return{type:O.FLOAT,size:2,value:e}}function jg(t,e,r){return t.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(t.isQuantized=!1,FB(t,e)):{type:O.UNSIGNED_SHORT,value:e,size:3,normalized:!0}:e}function FB(t,e){let r=new y,n=new Float32Array(t.pointCount*3);for(let o=0;o<t.pointCount;o++)r.set(e[o*3],e[o*3+1],e[o*3+2]).scale(1/t.quantizedRange).multiply(t.quantizedVolumeScale).add(t.quantizedVolumeOffset).toArray(n,o*3);return n}async function qg(t,e,r,n,o){r=jt(t,e,r),r=sn(t,e,r),r=an(t,e,r,n),PB(t);let{featureTable:s,batchTable:i}=NB(t);return await VB(t,s,i,n,o),OB(t,s,n),UB(t,s,i),DB(t,s),r}function PB(t){t.attributes={positions:null,colors:null,normals:null,batchIds:null},t.isQuantized=!1,t.isTranslucent=!1,t.isRGB565=!1,t.isOctEncoded16P=!1}function NB(t){let e=new Et(t.featureTableJson,t.featureTableBinary),r=e.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");e.featuresLength=r,t.featuresLength=r,t.pointsLength=r,t.pointCount=r,t.rtcCenter=e.getGlobalProperty("RTC_CENTER",O.FLOAT,3);let n=GB(t,e);return{featureTable:e,batchTable:n}}function OB(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.positions){if(e.hasProperty("POSITION"))t.attributes.positions=e.getPropertyArray("POSITION",O.FLOAT,3);else if(e.hasProperty("POSITION_QUANTIZED")){let n=e.getPropertyArray("POSITION_QUANTIZED",O.UNSIGNED_SHORT,3);if(t.isQuantized=!0,t.quantizedRange=(1<<16)-1,t.quantizedVolumeScale=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",O.FLOAT,3),!t.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(t.quantizedVolumeOffset=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",O.FLOAT,3),!t.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");t.attributes.positions=jg(t,n,r)}}if(!t.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function UB(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.colors){let n=null;e.hasProperty("RGBA")?(n=e.getPropertyArray("RGBA",O.UNSIGNED_BYTE,4),t.isTranslucent=!0):e.hasProperty("RGB")?n=e.getPropertyArray("RGB",O.UNSIGNED_BYTE,3):e.hasProperty("RGB565")&&(n=e.getPropertyArray("RGB565",O.UNSIGNED_SHORT,1),t.isRGB565=!0),t.attributes.colors=Cl(t,n,r)}e.hasProperty("CONSTANT_RGBA")&&(t.constantRGBA=e.getGlobalProperty("CONSTANT_RGBA",O.UNSIGNED_BYTE,4))}function DB(t,e){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.normals){let r=null;e.hasProperty("NORMAL")?r=e.getPropertyArray("NORMAL",O.FLOAT,3):e.hasProperty("NORMAL_OCT16P")&&(r=e.getPropertyArray("NORMAL_OCT16P",O.UNSIGNED_BYTE,2),t.isOctEncoded16P=!0),t.attributes.normals=kg(t,r)}}function GB(t,e){let r=null;if(!t.batchIds&&e.hasProperty("BATCH_ID")&&(t.batchIds=e.getPropertyArray("BATCH_ID",O.UNSIGNED_SHORT,1),t.batchIds)){let n=e.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:o,batchTableBinary:s}=t;r=new Tr(o,s,n)}return r}async function VB(t,e,r,n,o){let s,i,a,c=t.batchTableJson&&t.batchTableJson.extensions&&t.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);let l=e.getExtension("3DTILES_draco_point_compression");if(l){i=l.properties;let u=l.byteOffset,h=l.byteLength;if(!i||!Number.isFinite(u)||!h)throw new Error("Draco properties, byteOffset, and byteLength must be defined");s=(t.featureTableBinary||[]).slice(u,u+h),t.hasPositions=Number.isFinite(i.POSITION),t.hasColors=Number.isFinite(i.RGB)||Number.isFinite(i.RGBA),t.hasNormals=Number.isFinite(i.NORMAL),t.hasBatchIds=Number.isFinite(i.BATCH_ID),t.isTranslucent=Number.isFinite(i.RGBA)}if(!s)return!0;let f={buffer:s,properties:{...i,...a},featureTableProperties:i,batchTableProperties:a,dequantizeInShader:!1};return await HB(t,f,n,o)}async function HB(t,e,r,n){if(!n)return;let o={...r,draco:{...r?.draco,extraAttributes:e.batchTableProperties||{}}};delete o["3d-tiles"];let s=await Oe(e.buffer,Mo,o,n),i=s.attributes.POSITION&&s.attributes.POSITION.value,a=s.attributes.COLOR_0&&s.attributes.COLOR_0.value,c=s.attributes.NORMAL&&s.attributes.NORMAL.value,l=s.attributes.BATCH_ID&&s.attributes.BATCH_ID.value,f=i&&s.attributes.POSITION.value.quantization,u=c&&s.attributes.NORMAL.value.quantization;if(f){let p=s.POSITION.data.quantization,d=p.range;t.quantizedVolumeScale=new y(d,d,d),t.quantizedVolumeOffset=new y(p.minValues),t.quantizedRange=(1<<p.quantizationBits)-1,t.isQuantizedDraco=!0}u&&(t.octEncodedRange=(1<<s.NORMAL.data.quantization.quantizationBits)-1,t.isOctEncodedDraco=!0);let h={};if(e.batchTableProperties)for(let p of Object.keys(e.batchTableProperties))s.attributes[p]&&s.attributes[p].value&&(h[p.toLowerCase()]=s.attributes[p].value);t.attributes={positions:i,colors:Cl(t,a,void 0),normals:c,batchIds:l,...h}}var Bl={};be(Bl,{createExtMeshFeatures:()=>oI,decode:()=>$B,encode:()=>eI,name:()=>ZB});function ue(t,e){if(!t)throw new Error(e||"assert failed: gltf")}var yi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bi={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var zB=1.33,Jg=["SCALAR","VEC2","VEC3","VEC4"],kB=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],jB=new Map(kB),qB={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},JB={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},WB={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Ti(t){return Jg[t-1]||Jg[0]}function qt(t){let e=jB.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function cn(t,e){let r=WB[t.componentType],n=qB[t.type],o=JB[t.componentType],s=t.count*n,i=t.count*n*o;ue(i>=0&&i<=e.byteLength);let a=bi[t.componentType],c=yi[t.type];return{ArrayType:r,length:s,byteLength:i,componentByteSize:a,numberOfComponentsInElement:c}}function Eo(t){let{images:e,bufferViews:r}=t;e=e||[],r=r||[];let n=e.map(i=>i.bufferView);r=r.filter(i=>!n.includes(i));let o=r.reduce((i,a)=>i+a.byteLength,0),s=e.reduce((i,a)=>{let{width:c,height:l}=a.image;return i+c*l},0);return o+Math.ceil(4*s*zB)}function Wg(t,e,r){let n=t.bufferViews[r];ue(n);let o=n.buffer,s=e[o];ue(s);let i=(n.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,i,n.byteLength)}function Xg(t,e,r){let n=typeof r=="number"?t.accessors?.[r]:r;if(!n)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let o=t.bufferViews?.[n.bufferView||0];if(!o)throw new Error(`No gltf buffer view for accessor ${o}`);let{arrayBuffer:s,byteOffset:i}=e[o.buffer],a=(i||0)+(n.byteOffset||0)+(o.byteOffset||0),{ArrayType:c,length:l,componentByteSize:f,numberOfComponentsInElement:u}=cn(n,o),h=f*u,p=o.byteStride||h;if(typeof o.byteStride>"u"||o.byteStride===h)return new c(s,a,l);let d=new c(l);for(let m=0;m<n.count;m++){let g=new c(s,a+m*p,u);d.set(g,m*u)}return d}function XB(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var j=class{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||XB(),buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){let r=this.getUsedExtensions().find(o=>o===e),n=this.getRequiredExtensions().find(o=>o===e);return typeof r=="string"||typeof n=="string"}getExtension(e){let r=this.getUsedExtensions().find(o=>o===e),n=this.json.extensions||{};return r?n[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(n=>n===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;let n=this.json[e]&&this.json[e][r];if(!n)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return n}getTypedArrayForBufferView(e){e=this.getBufferView(e);let r=e.buffer,n=this.gltf.buffers[r];ue(n);let o=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,o,e.byteLength)}getTypedArrayForAccessor(e){let r=this.getAccessor(e);return Xg(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);let r=this.getBufferView(e.bufferView),o=this.getBuffer(r.buffer).data,s=r.byteOffset||0;return new Uint8Array(o,s,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,n){return e.extensions=e.extensions||{},e.extensions[r]=n,this.registerUsedExtension(r),this}setObjectExtension(e,r,n){let o=e.extensions||{};o[r]=n}removeObjectExtension(e,r){let n=e?.extensions||{};if(n[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let o=this.json.extensionsRemoved;o.includes(r)||o.push(r)}delete n[r]}addExtension(e,r={}){return ue(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return ue(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(e)||r.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){let{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){let{meshIndex:r,matrix:n}=e;this.json.nodes=this.json.nodes||[];let o={mesh:r};return n&&(o.matrix=n),this.json.nodes.push(o),this.json.nodes.length-1}addMesh(e){let{attributes:r,indices:n,material:o,mode:s=4}=e,a={primitives:[{attributes:this._addAttributes(r),mode:s}]};if(n){let c=this._addIndices(n);a.primitives[0].indices=c}return Number.isFinite(o)&&(a.primitives[0].material=o),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){let n={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(n),this.json.meshes.length-1}addImage(e,r){let n=ur(e),o=r||n?.mimeType,i={bufferView:this.addBufferView(e),mimeType:o};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(e,r=0,n=this.byteLength){let o=e.byteLength;ue(Number.isFinite(o)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);let s={buffer:r,byteOffset:n,byteLength:o};return this.byteLength+=Lt(o,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(s),this.json.bufferViews.length-1}addAccessor(e,r){let n={bufferView:e,type:Ti(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){let n=this.addBufferView(e),o={min:r.min,max:r.max};(!o.min||!o.max)&&(o=this._getAccessorMinMax(e,r.size));let s={size:r.size,componentType:qt(e),count:Math.round(e.length/r.size),min:o.min,max:o.max};return this.addAccessor(n,Object.assign(s,r))}addTexture(e){let{imageIndex:r}=e,n={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){let e=this.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r),o=0;for(let s of this.sourceBuffers||[])o=Tc(s,n,o);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r],this.gltf.buffers=[{arrayBuffer:r,byteOffset:0,byteLength:r.byteLength}]}_removeStringFromArray(e,r){let n=!0;for(;n;){let o=e.indexOf(r);o>-1?e.splice(o,1):n=!1}}_addAttributes(e={}){let r={};for(let n in e){let o=e[n],s=this._getGltfAttributeName(n),i=this.addBinaryBuffer(o.value,o);r[s]=i}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){let n={min:null,max:null};if(e.length<r)return n;n.min=[],n.max=[];let o=e.subarray(0,r);for(let s of o)n.min.push(s),n.max.push(s);for(let s=r;s<e.length;s+=r)for(let i=0;i<r;i++)n.min[0+i]=Math.min(n.min[0+i],e[s+i]),n.max[0+i]=Math.max(n.max[0+i],e[s+i]);return n}};function Yg(t){return(t%1+1)%1}var Kg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},YB={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},Qg={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function So(t,e){return Qg[e]*Kg[t]}function ln(t,e,r,n){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;let o=t.getTypedArrayForBufferView(e),s=fn(o,"SCALAR",r,n+1);return s instanceof BigInt64Array||s instanceof BigUint64Array?null:s}function fn(t,e,r,n=1){let o=Kg[e],s=YB[r],i=Qg[r],a=n*o,c=a*i,l=t.buffer,f=t.byteOffset;return f%i!==0&&(l=new Uint8Array(l).slice(f,f+c).buffer,f=0),new s(Nt(l),f,a)}function un(t,e,r){let n=`TEXCOORD_${e.texCoord||0}`,o=r.attributes[n],s=t.getTypedArrayForAccessor(o),i=t.gltf.json,a=e.index,c=i.textures?.[a]?.source;if(typeof c<"u"){let l=i.images?.[c]?.mimeType,f=t.gltf.images?.[c];if(f&&typeof f.width<"u"){let u=[];for(let h=0;h<s.length;h+=2){let p=KB(f,l,s,h,e.channels);u.push(p)}return u}}return[]}function Mi(t,e,r,n,o){if(!r?.length)return;let s=[];for(let f of r){let u=n.findIndex(h=>h===f);u===-1&&(u=n.push(f)-1),s.push(u)}let i=new Uint32Array(s),a=t.gltf.buffers.push({arrayBuffer:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength})-1,c=t.addBufferView(i,a,0),l=t.addAccessor(c,{size:1,componentType:qt(i),count:i.length});o.attributes[e]=l}function KB(t,e,r,n,o=[0]){let s={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},i=r[n],a=r[n+1],c=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(c=4);let l=QB(i,a,t,c),f=0;for(let u of o){let h=typeof u=="number"?Object.values(s)[u]:s[u],p=l+h.offset,d=eo(t);if(d.data.length<=p)throw new Error(`${d.data.length} <= ${p}`);let m=d.data[p];f|=m<<h.shift}return f}function QB(t,e,r,n=1){let o=r.width,s=Yg(t)*(o-1),i=Math.round(s),a=r.height,c=Yg(e)*(a-1),l=Math.round(c),f=r.components?r.components:n;return(l*o+i)*f}function Ei(t,e,r,n,o){let s=[];for(let i=0;i<e;i++){let a=r[i],c=r[i+1]-r[i];if(c+a>n)break;let l=a/o,f=c/o;s.push(t.slice(l,l+f))}return s}function Si(t,e,r){let n=[];for(let o=0;o<e;o++){let s=o*r;n.push(t.slice(s,s+r))}return n}function _i(t,e,r,n){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(n){let o=[],s=new TextDecoder("utf8"),i=0;for(let a=0;a<t;a++){let c=n[a+1]-n[a];if(c+i<=e.length){let l=e.subarray(i,c+i),f=s.decode(l);o.push(f),i+=c}}return o}return[]}var hn="EXT_mesh_features",ZB=hn;async function $B(t,e){let r=new j(t);tI(r,e)}function eI(t,e){let r=new j(t);return nI(r,e),r.createBinaryChunk(),r.gltf}function tI(t,e){let r=t.gltf.json;if(r.meshes)for(let n of r.meshes)for(let o of n.primitives)rI(t,o,e)}function rI(t,e,r){if(!r?.gltf?.loadBuffers)return;let o=e.extensions?.[hn]?.featureIds;if(o)for(let s of o){let i;if(typeof s.attribute<"u"){let a=`_FEATURE_ID_${s.attribute}`,c=e.attributes[a];i=t.getTypedArrayForAccessor(c)}else typeof s.texture<"u"&&r?.gltf?.loadImages?i=un(t,s.texture,e):i=[];s.data=i}}function nI(t,e){let r=t.gltf.json.meshes;if(r)for(let n of r)for(let o of n.primitives)sI(t,o)}function oI(t,e,r,n){e.extensions||(e.extensions={});let o=e.extensions[hn];o||(o={featureIds:[]},e.extensions[hn]=o);let{featureIds:s}=o,i={featureCount:r.length,propertyTable:n,data:r};s.push(i),t.addObjectExtension(e,hn,o)}function sI(t,e){let r=e.extensions?.[hn];if(!r)return;let n=r.featureIds;n.forEach((o,s)=>{if(o.data){let{accessorKey:i,index:a}=iI(e.attributes),c=new Uint32Array(o.data);n[s]={featureCount:c.length,propertyTable:o.propertyTable,attribute:a},t.gltf.buffers.push({arrayBuffer:c.buffer,byteOffset:c.byteOffset,byteLength:c.byteLength});let l=t.addBufferView(c),f=t.addAccessor(l,{size:1,componentType:qt(c),count:c.length});e.attributes[i]=f}})}function iI(t){let e="_FEATURE_ID_",r=Object.keys(t).filter(s=>s.indexOf(e)===0),n=-1;for(let s of r){let i=Number(s.substring(e.length));i>n&&(n=i)}return n++,{accessorKey:`${e}${n}`,index:n}}var vl={};be(vl,{createExtStructuralMetadata:()=>II,decode:()=>cI,encode:()=>lI,name:()=>aI});var pn="EXT_structural_metadata",aI=pn;async function cI(t,e){let r=new j(t);fI(r,e)}function lI(t,e){let r=new j(t);return CI(r,e),r.createBinaryChunk(),r.gltf}function fI(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(pn);r&&(e.gltf?.loadImages&&uI(t,r),hI(t,r))}function uI(t,e){let r=e.propertyTextures,n=t.gltf.json;if(r&&n.meshes)for(let o of n.meshes)for(let s of o.primitives)dI(t,r,s,e)}function hI(t,e){let r=e.schema;if(!r)return;let n=r.classes,o=e.propertyTables;if(n&&o)for(let s in n){let i=pI(o,s);i&&gI(t,r,i)}}function pI(t,e){for(let r of t)if(r.class===e)return r;return null}function dI(t,e,r,n){if(!e)return;let s=r.extensions?.[pn]?.propertyTextures;if(s)for(let i of s){let a=e[i];mI(t,a,r,n)}}function mI(t,e,r,n){if(!e.properties)return;n.dataAttributeNames||(n.dataAttributeNames=[]);let o=e.class;for(let s in e.properties){let i=`${o}_${s}`,a=e.properties?.[s];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=un(t,a,r);l!==null&&(Mi(t,i,l,c,r),a.data=c,n.dataAttributeNames.push(i))}}function gI(t,e,r){let n=e.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let o=r.count;for(let s in n.properties){let i=n.properties[s],a=r.properties?.[s];if(a){let c=AI(t,e,i,o,a);a.data=c}}}function AI(t,e,r,n,o){let s=[],i=o.values,a=t.getTypedArrayForBufferView(i),c=xI(t,r,o,n),l=yI(t,o,n);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{s=bI(r,n,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{s=_i(n,a,c,l);break}case"ENUM":{s=TI(e,r,n,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return s}function xI(t,e,r,n){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?ln(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",n):null}function yI(t,e,r){return typeof e.stringOffsets<"u"?ln(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function bI(t,e,r,n){let o=t.array,s=t.count,i=So(t.type,t.componentType),a=r.byteLength/i,c;return t.componentType?c=fn(r,t.type,t.componentType,a):c=r,o?n?Ei(c,e,n,r.length,i):s?Si(c,e,s):[]:c}function TI(t,e,r,n,o){let s=e.enumType;if(!s)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let i=t.enums?.[s];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${s}`);let a=i.valueType||"UINT16",c=So(e.type,a),l=n.byteLength/c,f=fn(n,e.type,a,l);if(f||(f=n),e.array){if(o)return MI({valuesData:f,numberOfElements:r,arrayOffsets:o,valuesDataBytesLength:n.length,elementSize:c,enumEntry:i});let u=e.count;return u?EI(f,r,u,i):[]}return Rl(f,0,r,i)}function MI(t){let{valuesData:e,numberOfElements:r,arrayOffsets:n,valuesDataBytesLength:o,elementSize:s,enumEntry:i}=t,a=[];for(let c=0;c<r;c++){let l=n[c],f=n[c+1]-n[c];if(f+l>o)break;let u=l/s,h=f/s,p=Rl(e,u,h,i);a.push(p)}return a}function EI(t,e,r,n){let o=[];for(let s=0;s<e;s++){let i=r*s,a=Rl(t,i,r,n);o.push(a)}return o}function Rl(t,e,r,n){let o=[];for(let s=0;s<r;s++)if(t instanceof BigInt64Array||t instanceof BigUint64Array)o.push("");else{let i=t[e+s],a=SI(n,i);a?o.push(a.name):o.push("")}return o}function SI(t,e){for(let r of t.values)if(r.value===e)return r;return null}var _I="schemaClassId";function CI(t,e){let r=t.getExtension(pn);if(r&&r.propertyTables)for(let n of r.propertyTables){let o=n.class,s=r.schema?.classes?.[o];n.properties&&s&&BI(n,s,t)}}function BI(t,e,r){for(let n in t.properties){let o=t.properties[n].data;if(o){let s=e.properties[n];if(s){let i=wI(o,s,r);t.properties[n]=i}}}}function II(t,e,r=_I){let n=t.getExtension(pn);n||(n=t.addExtension(pn)),n.schema=RI(e,r,n.schema);let o=vI(e,r,n.schema);return n.propertyTables||(n.propertyTables=[]),n.propertyTables.push(o)-1}function RI(t,e,r){let n=r??{id:"schema_id"},o={properties:{}};for(let s of t){let i={type:s.elementType,componentType:s.componentType};o.properties[s.name]=i}return n.classes={},n.classes[e]=o,n}function vI(t,e,r){let n={class:e,count:0},o=0,s=r.classes?.[e];for(let i of t){if(o===0&&(o=i.values.length),o!==i.values.length&&i.values.length)throw new Error("Illegal values in attributes");s?.properties[i.name]&&(n.properties||(n.properties={}),n.properties[i.name]={values:0,data:i.values})}return n.count=o,n}function wI(t,e,r){let n={values:0};if(e.type==="STRING"){let{stringData:o,stringOffsets:s}=PI(t);n.stringOffsets=Il(s,r),n.values=Il(o,r)}else if(e.type==="SCALAR"&&e.componentType){let o=FI(t,e.componentType);n.values=Il(o,r)}return n}var LI={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function FI(t,e){let r=[];for(let o of t)r.push(Number(o));let n=LI[e];if(!n)throw new Error("Illegal component type");return new n(r)}function PI(t){let e=new TextEncoder,r=[],n=0;for(let c of t){let l=e.encode(c);n+=l.length,r.push(l)}let o=new Uint8Array(n),s=[],i=0;for(let c of r)o.set(c,i),s.push(i),i+=c.length;s.push(i);let a=new Uint32Array(s);return{stringData:o,stringOffsets:a}}function Il(t,e){return e.gltf.buffers.push({arrayBuffer:Nt(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength}),e.addBufferView(t)}var wl={};be(wl,{decode:()=>OI,name:()=>NI});var Zg="EXT_feature_metadata",NI=Zg;async function OI(t,e){let r=new j(t);UI(r,e)}function UI(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(Zg);r&&(e.gltf?.loadImages&&DI(t,r),GI(t,r))}function DI(t,e){let r=e.schema;if(!r)return;let n=r.classes,{featureTextures:o}=e;if(n&&o)for(let s in n){let i=n[s],a=HI(o,s);a&&kI(t,a,i)}}function GI(t,e){let r=e.schema;if(!r)return;let n=r.classes,o=e.featureTables;if(n&&o)for(let s in n){let i=VI(o,s);i&&zI(t,r,i)}}function VI(t,e){for(let r in t){let n=t[r];if(n.class===e)return n}return null}function HI(t,e){for(let r in t){let n=t[r];if(n.class===e)return n}return null}function zI(t,e,r){if(!r.class)return;let n=e.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let o=r.count;for(let s in n.properties){let i=n.properties[s],a=r.properties?.[s];if(a){let c=jI(t,e,i,o,a);a.data=c}}}function kI(t,e,r){let n=e.class;for(let o in r.properties){let s=e?.properties?.[o];if(s){let i=YI(t,s,n);s.data=i}}}function jI(t,e,r,n,o){let s=[],i=o.bufferView,a=t.getTypedArrayForBufferView(i),c=qI(t,r,o,n),l=JI(t,r,o,n);return r.type==="STRING"||r.componentType==="STRING"?s=_i(n,a,c,l):WI(r)&&(s=XI(r,n,a,c)),s}function qI(t,e,r,n){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?ln(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",n):null}function JI(t,e,r,n){return typeof r.stringOffsetBufferView<"u"?ln(t,r.stringOffsetBufferView,r.offsetType||"UINT32",n):null}function WI(t){let e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function XI(t,e,r,n){let o=t.type==="ARRAY",s=t.componentCount,i="SCALAR",a=t.componentType||t.type,c=So(i,a),l=r.byteLength/c,f=fn(r,i,a,l);return o?n?Ei(f,e,n,r.length,c):s?Si(f,e,s):[]:f}function YI(t,e,r){let n=t.gltf.json;if(!n.meshes)return[];let o=[];for(let s of n.meshes)for(let i of s.primitives)KI(t,r,e,o,i);return o}function KI(t,e,r,n,o){let s={channels:r.channels,...r.texture},i=un(t,s,o);i&&Mi(t,e,i,n,o)}var $g="4.4.3";var dn=!0,e0=1735152710,Pl=12,Ci=8,QI=1313821514,ZI=5130562,$I=0,e2=0,t2=1;function r2(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function t0(t,e=0,r={}){let n=new DataView(t),{magic:o=e0}=r,s=n.getUint32(e,!1);return s===o||s===e0}function r0(t,e,r=0,n={}){let o=new DataView(e),s=r2(o,r+0),i=o.getUint32(r+4,dn),a=o.getUint32(r+8,dn);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:s,version:i,json:{},binChunks:[]}),r+=Pl,t.version){case 1:return n2(t,o,r);case 2:return o2(t,o,r,n={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function n2(t,e,r){H(t.header.byteLength>Pl+Ci);let n=e.getUint32(r+0,dn),o=e.getUint32(r+4,dn);return r+=Ci,H(o===$I),Ll(t,e,r,n),r+=n,r+=Fl(t,e,r,t.header.byteLength),r}function o2(t,e,r,n){return H(t.header.byteLength>Pl+Ci),s2(t,e,r,n),r+t.header.byteLength}function s2(t,e,r,n){for(;r+8<=t.header.byteLength;){let o=e.getUint32(r+0,dn),s=e.getUint32(r+4,dn);switch(r+=Ci,s){case QI:Ll(t,e,r,o);break;case ZI:Fl(t,e,r,o);break;case e2:n.strict||Ll(t,e,r,o);break;case t2:n.strict||Fl(t,e,r,o);break;default:break}r+=Lt(o,4)}return r}function Ll(t,e,r,n){let o=new Uint8Array(e.buffer,r,n),i=new TextDecoder("utf8").decode(o);return t.json=JSON.parse(i),Lt(n,4)}function Fl(t,e,r,n){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:n,arrayBuffer:e.buffer}),Lt(n,4)}function Nl(t,e,r){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;let o=r?.baseUrl||i2(e?.core?.baseUrl);if(!o)throw new Error(`'baseUrl' must be provided to resolve relative url ${t}`);return o.endsWith("/")?`${o}${t}`:`${o}/${t}`}function i2(t){if(!t)return;if(t.endsWith("/"))return t;let e=t.lastIndexOf("/");return e>=0?t.slice(0,e+1):""}var Ul={};be(Ul,{decode:()=>x2,name:()=>A2});var a2="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",c2="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",l2=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),f2=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),u2={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h2={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function n0(t,e,r,n,o,s="NONE"){let i=await p2();g2(i,i.exports[h2[o]],t,e,r,n,i.exports[u2[s||"NONE"]])}var Ol;async function p2(){return Ol||(Ol=d2()),Ol}async function d2(){let t=a2;WebAssembly.validate(l2)&&(t=c2,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let e=await WebAssembly.instantiate(m2(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function m2(t){let e=new Uint8Array(t.length);for(let n=0;n<t.length;++n){let o=t.charCodeAt(n);e[n]=o>96?o-71:o>64?o-65:o>47?o+4:o>46?63:62}let r=0;for(let n=0;n<t.length;++n)e[r++]=e[n]<60?f2[e[n]]:(e[n]-60)*64+e[++n];return e.buffer.slice(0,r)}function g2(t,e,r,n,o,s,i){let a=t.exports.sbrk,c=n+3&-4,l=a(c*o),f=a(s.length),u=new Uint8Array(t.exports.memory.buffer);u.set(s,f);let h=e(l,n,o,f,s.length);if(h===0&&i&&i(l,c,o),r.set(u.subarray(l,l+n*o)),a(l-a(0)),h!==0)throw new Error(`Malformed buffer data: ${h}`)}var Bi="EXT_meshopt_compression",A2=Bi;async function x2(t,e){let r=new j(t);if(!e?.gltf?.decompressMeshes||!e.gltf?.loadBuffers)return;let n=[];for(let o of t.json.bufferViews||[])n.push(y2(r,o));await Promise.all(n),r.removeExtension(Bi)}async function y2(t,e){let r=t.getObjectExtension(e,Bi);if(r){let{byteOffset:n=0,byteLength:o=0,byteStride:s,count:i,mode:a,filter:c="NONE",buffer:l}=r,f=t.gltf.buffers[l],u=new Uint8Array(f.arrayBuffer,f.byteOffset+n,o),h=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);await n0(h,i,s,u,a,c),t.removeObjectExtension(e,Bi)}}var Dl={};be(Dl,{name:()=>b2,preprocess:()=>T2});var mn="EXT_texture_webp",b2=mn;function T2(t,e){let r=new j(t);if(!Fc("image/webp")){if(r.getRequiredExtensions().includes(mn))throw new Error(`gltf: Required extension ${mn} not supported by browser`);return}let{json:n}=r;for(let o of n.textures||[]){let s=r.getObjectExtension(o,mn);s&&(o.source=s.source),r.removeObjectExtension(o,mn)}r.removeExtension(mn)}var Gl={};be(Gl,{name:()=>M2,preprocess:()=>E2});var Ii="KHR_texture_basisu",M2=Ii;function E2(t,e){let r=new j(t),{json:n}=r;for(let o of n.textures||[]){let s=r.getObjectExtension(o,Ii);s&&(o.source=s.source,r.removeObjectExtension(o,Ii))}r.removeExtension(Ii)}var Hl={};be(Hl,{decode:()=>I2,encode:()=>R2,name:()=>C2,preprocess:()=>B2});function o0(t){let e={};for(let r in t){let n=t[r];if(r!=="indices"){let o=Vl(n);e[r]=o}}return e}function Vl(t){let{buffer:e,size:r,count:n}=S2(t);return{value:e,size:r,byteOffset:0,count:n,type:Ti(r),componentType:qt(e)}}function S2(t){let e=t,r=1,n=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=_2(e,Float32Array)),n=e.length/r),{buffer:e,size:r,count:n}}function _2(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}var Jt="KHR_draco_mesh_compression",C2=Jt;function B2(t,e,r){let n=new j(t);for(let o of s0(n))n.getObjectExtension(o,Jt)}async function I2(t,e,r){if(!e?.gltf?.decompressMeshes)return;let n=new j(t),o=[];for(let s of s0(n))n.getObjectExtension(s,Jt)&&o.push(v2(n,s,e,r));await Promise.all(o),n.removeExtension(Jt)}function R2(t,e={}){let r=new j(t);for(let n of r.json.meshes||[])w2(n,e),r.addRequiredExtension(Jt)}async function v2(t,e,r,n){let o=t.getObjectExtension(e,Jt);if(!o)return;let s=t.getTypedArrayForBufferView(o.bufferView),i=ar(s.buffer,s.byteOffset),a={...r};delete a["3d-tiles"];let c=await Oe(i,Mo,a,n),l=o0(c.attributes);for(let[f,u]of Object.entries(l))if(f in e.attributes){let h=e.attributes[f],p=t.getAccessor(h);p?.min&&p?.max&&(u.min=p.min,u.max=p.max)}e.attributes=l,c.indices&&(e.indices=Vl(c.indices)),t.removeObjectExtension(e,Jt),L2(e)}function w2(t,e,r=4,n,o){if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let s=n.DracoWriter.encodeSync({attributes:t}),i=o?.parseSync?.({attributes:t}),a=n._addFauxAttributes(i.attributes),c=n.addBufferView(s);return{primitives:[{attributes:a,mode:r,extensions:{[Jt]:{bufferView:c,attributes:a}}}]}}function L2(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*s0(t){for(let e of t.json.meshes||[])for(let r of e.primitives)yield r}var zl={};be(zl,{decode:()=>O2,name:()=>F2});var vi="KHR_texture_transform",F2=vi,Ri=new y,P2=new k,N2=new k;async function O2(t,e){if(!new j(t).hasExtension(vi)||!e.gltf?.loadBuffers)return;let o=t.json.materials||[];for(let s=0;s<o.length;s++)U2(s,t)}function U2(t,e){let r=e.json.materials?.[t],n=[r?.pbrMetallicRoughness?.baseColorTexture,r?.emissiveTexture,r?.normalTexture,r?.occlusionTexture,r?.pbrMetallicRoughness?.metallicRoughnessTexture],o=[];for(let s of n)s&&s?.extensions?.[vi]&&D2(e,t,s,o)}function D2(t,e,r,n){let o=G2(r,n);if(!o)return;let s=t.json.meshes||[];for(let i of s)for(let a of i.primitives){let c=a.material;Number.isFinite(c)&&e===c&&V2(t,a,o)}}function G2(t,e){let r=t.extensions?.[vi],{texCoord:n=0}=t,{texCoord:o=n}=r;if(!(e.findIndex(([i,a])=>i===n&&a===o)!==-1)){let i=k2(r);return n!==o&&(t.texCoord=o),e.push([n,o]),{originalTexCoord:n,texCoord:o,matrix:i}}return null}function V2(t,e,r){let{originalTexCoord:n,texCoord:o,matrix:s}=r,i=e.attributes[`TEXCOORD_${n}`];if(Number.isFinite(i)){let a=t.json.accessors?.[i];if(a&&a.bufferView!==void 0){let c=t.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:f}=t.buffers[c.buffer],u=(f||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:h,length:p}=cn(a,c),d=bi[a.componentType],m=yi[a.type],g=c.byteStride||d*m,x=new Float32Array(p);for(let b=0;b<a.count;b++){let M=new h(l,u+b*g,2);Ri.set(M[0],M[1],1),Ri.transformByMatrix3(s),x.set([Ri[0],Ri[1]],b*m)}n===o?H2(a,t,x,a.bufferView):z2(o,a,e,t,x)}}}}function H2(t,e,r,n){t.componentType=5126,t.byteOffset=0;let i=(e.json.accessors||[]).reduce((l,f)=>f.bufferView===n?l+1:l,0)>1;e.buffers.push({arrayBuffer:Nt(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength});let a=e.buffers.length-1;if(e.json.bufferViews=e.json.bufferViews||[],i){e.json.bufferViews.push({buffer:a,byteLength:r.buffer.byteLength,byteOffset:0}),t.bufferView=e.json.bufferViews.length-1;return}let c=e.json.bufferViews[n];c&&(c.buffer=a,c.byteOffset=0,c.byteLength=r.buffer.byteLength,c.byteStride!==void 0&&delete c.byteStride)}function z2(t,e,r,n,o){n.buffers.push({arrayBuffer:Nt(o.buffer),byteOffset:0,byteLength:o.buffer.byteLength}),n.json.bufferViews=n.json.bufferViews||[];let s=n.json.bufferViews;s.push({buffer:n.buffers.length-1,byteLength:o.buffer.byteLength,byteOffset:0});let i=n.json.accessors;i&&(i.push({bufferView:s?.length-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),r.attributes[`TEXCOORD_${t}`]=i.length-1)}function k2(t){let{offset:e=[0,0],rotation:r=0,scale:n=[1,1]}=t,o=new k().set(1,0,0,0,1,0,e[0],e[1],1),s=P2.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),i=N2.set(n[0],0,0,0,n[1],0,0,0,1);return o.multiplyRight(s).multiplyRight(i)}var kl={};be(kl,{decode:()=>q2,encode:()=>J2,name:()=>j2});var Mr="KHR_lights_punctual",j2=Mr;async function q2(t){let e=new j(t),{json:r}=e,n=e.getExtension(Mr);n&&(e.json.lights=n.lights,e.removeExtension(Mr));for(let o of r.nodes||[]){let s=e.getObjectExtension(o,Mr);s&&(o.light=s.light),e.removeObjectExtension(o,Mr)}}async function J2(t){let e=new j(t),{json:r}=e;if(r.lights){let n=e.addExtension(Mr);ue(!n.lights),n.lights=r.lights,delete r.lights}if(e.json.lights){for(let n of e.json.lights){let o=n.node;e.addObjectExtension(o,Mr,n)}delete e.json.lights}}var jl={};be(jl,{decode:()=>X2,encode:()=>Y2,name:()=>W2});var _o="KHR_materials_unlit",W2=_o;async function X2(t){let e=new j(t),{json:r}=e;for(let n of r.materials||[])n.extensions&&n.extensions.KHR_materials_unlit&&(n.unlit=!0),e.removeObjectExtension(n,_o);e.removeExtension(_o)}function Y2(t){let e=new j(t),{json:r}=e;if(e.materials)for(let n of r.materials||[])n.unlit&&(delete n.unlit,e.addObjectExtension(n,_o,{}),e.addExtension(_o))}var ql={};be(ql,{decode:()=>Q2,encode:()=>Z2,name:()=>K2});var Co="KHR_techniques_webgl",K2=Co;async function Q2(t){let e=new j(t),{json:r}=e,n=e.getExtension(Co);if(n){let o=$2(n,e);for(let s of r.materials||[]){let i=e.getObjectExtension(s,Co);i&&(s.technique=Object.assign({},i,o[i.technique]),s.technique.values=e3(s.technique,e)),e.removeObjectExtension(s,Co)}e.removeExtension(Co)}}async function Z2(t,e){}function $2(t,e){let{programs:r=[],shaders:n=[],techniques:o=[]}=t,s=new TextDecoder;return n.forEach(i=>{if(Number.isFinite(i.bufferView))i.code=s.decode(e.getTypedArrayForBufferView(i.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(i=>{i.fragmentShader=n[i.fragmentShader],i.vertexShader=n[i.vertexShader]}),o.forEach(i=>{i.program=r[i.program]}),o}function e3(t,e){let r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(n=>{t.uniforms[n].value&&!(n in r)&&(r[n]=t.uniforms[n].value)}),Object.keys(r).forEach(n=>{typeof r[n]=="object"&&r[n].index!==void 0&&(r[n].texture=e.getTexture(r[n].index))}),r}var i0=[vl,Bl,Ul,Dl,Gl,Hl,kl,jl,ql,zl,wl];function a0(t,e={},r){let n=i0.filter(o=>l0(o.name,e));for(let o of n)o.preprocess?.(t,e,r)}async function c0(t,e={},r){let n=i0.filter(o=>l0(o.name,e));for(let o of n)await o.decode?.(t,e,r)}function l0(t,e){let r=e?.gltf?.excludeExtensions||{};return!(t in r&&!r[t])}var Jl="KHR_binary_glTF";function f0(t){let e=new j(t),{json:r}=e;for(let n of r.images||[]){let o=e.getObjectExtension(n,Jl);o&&Object.assign(n,o),e.removeObjectExtension(n,Jl)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(Jl)}var u0={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},r3={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},Wl=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,r){this.json=e.json;let n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${n.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),f0(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(let r in u0)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){let n=e[r];if(!(!n||Array.isArray(n))){e[r]=[];for(let o in n){let s=n[o];s.id=s.id||o;let i=e[r].length;e[r].push(s),this.idToIndexMap[r][o]=i}}}_convertObjectIdsToArrayIndices(e){for(let r in u0)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(let r of e.textures)this._convertTextureIds(r);for(let r of e.meshes)this._convertMeshIds(r);for(let r of e.nodes)this._convertNodeIds(r);for(let r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(let r of e.primitives){let{attributes:n,indices:o,material:s}=r;for(let i in n)n[i]=this._convertIdToIndex(n[i],"accessor");o&&(r.indices=this._convertIdToIndex(o,"accessor")),s&&(r.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(let n of e[r])for(let o in n){let s=n[o],i=this._convertIdToIndex(s,o);n[o]=i}}_convertIdToIndex(e,r){let n=r3[r];if(n in this.idToIndexMap){let o=this.idToIndexMap[n][e];if(!Number.isFinite(o))throw new Error(`gltf v1: failed to resolve ${r} with id ${e}`);return o}return e}_updateObjects(e){for(let r of this.json.buffers)delete r.type}_updateMaterial(e){for(let r of e.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let n=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,o=e.textures.findIndex(s=>s.id===n);o!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:o})}}};function h0(t,e={}){return new Wl().normalize(t,e)}async function p0(t,e,r=0,n,o){return n3(t,e,r,n),h0(t,{normalize:n?.gltf?.normalize}),a0(t,n,o),n?.gltf?.loadBuffers&&t.json.buffers&&await o3(t,n,o),n?.gltf?.loadImages&&await s3(t,n,o),await c0(t,n,o),t}function n3(t,e,r,n){if(n.core?.baseUrl&&(t.baseUri=n.core?.baseUrl),e instanceof ArrayBuffer&&!t0(e,r,n.glb)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=bc(e);else if(e instanceof ArrayBuffer){let i={};r=r0(i,e,r,n.glb),ue(i.type==="glTF",`Invalid GLB magic string ${i.type}`),t._glb=i,t.json=i.json}else ue(!1,"GLTF: must be ArrayBuffer or string");let o=t.json.buffers||[];if(t.buffers=new Array(o.length).fill(null),t._glb&&t._glb.header.hasBinChunk){let{binChunks:i}=t._glb;t.buffers[0]={arrayBuffer:i[0].arrayBuffer,byteOffset:i[0].byteOffset,byteLength:i[0].byteLength}}let s=t.json.images||[];t.images=new Array(s.length).fill({})}async function o3(t,e,r){let n=t.json.buffers||[];for(let o=0;o<n.length;++o){let s=n[o];if(s.uri){let{fetch:i}=r;ue(i);let a=Nl(s.uri,e,r),l=await(await r?.fetch?.(a))?.arrayBuffer?.();t.buffers[o]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete s.uri}else t.buffers[o]===null&&(t.buffers[o]={arrayBuffer:new ArrayBuffer(s.byteLength),byteOffset:0,byteLength:s.byteLength})}}async function s3(t,e,r){let n=i3(t),o=t.json.images||[],s=[];for(let i of n)s.push(a3(t,o[i],i,e,r));return await Promise.all(s)}function i3(t){let e=new Set,r=t.json.textures||[];for(let n of r)n.source!==void 0&&e.add(n.source);return Array.from(e).sort()}async function a3(t,e,r,n,o){let s;if(e.uri&&!e.hasOwnProperty("bufferView")){let l=Nl(e.uri,n,o),{fetch:f}=o;s=await(await f(l)).arrayBuffer(),e.bufferView={data:s}}if(Number.isFinite(e.bufferView)){let l=Wg(t.json,t.buffers,e.bufferView);s=ar(l.buffer,l.byteOffset,l.byteLength)}ue(s,"glTF image has no data");let i=n,a={...i,core:{...i?.core,mimeType:e.mimeType}},c=await Oe(s,[Kr,Zc],a,o);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),t.images=t.images||[],t.images[r]=c}var Er={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:$g,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:c3,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};async function c3(t,e={},r){let n={...Er.options,...e};n.gltf={...Er.options.gltf,...n.gltf};let o=e?.glb?.byteOffset||0;return await p0({},t,o,n,r)}var l3={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},f3={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},je={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},u3={magFilter:je.TEXTURE_MAG_FILTER,minFilter:je.TEXTURE_MIN_FILTER,wrapS:je.TEXTURE_WRAP_S,wrapT:je.TEXTURE_WRAP_T},h3={[je.TEXTURE_MAG_FILTER]:je.LINEAR,[je.TEXTURE_MIN_FILTER]:je.NEAREST_MIPMAP_LINEAR,[je.TEXTURE_WRAP_S]:je.REPEAT,[je.TEXTURE_WRAP_T]:je.REPEAT};function p3(){return{id:"default-sampler",parameters:h3}}function d3(t){return f3[t]}function m3(t){return l3[t]}var Xl=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,r={}){let{json:n,buffers:o=[],images:s=[]}=e,{baseUri:i=""}=e;return ue(n),this.baseUri=i,this.buffers=o,this.images=s,this.jsonUnprocessed=n,this.json=this._resolveTree(e.json,r),this.json}_resolveTree(e,r={}){let n={...e};return this.json=n,e.bufferViews&&(n.bufferViews=e.bufferViews.map((o,s)=>this._resolveBufferView(o,s))),e.images&&(n.images=e.images.map((o,s)=>this._resolveImage(o,s))),e.samplers&&(n.samplers=e.samplers.map((o,s)=>this._resolveSampler(o,s))),e.textures&&(n.textures=e.textures.map((o,s)=>this._resolveTexture(o,s))),e.accessors&&(n.accessors=e.accessors.map((o,s)=>this._resolveAccessor(o,s))),e.materials&&(n.materials=e.materials.map((o,s)=>this._resolveMaterial(o,s))),e.meshes&&(n.meshes=e.meshes.map((o,s)=>this._resolveMesh(o,s))),e.nodes&&(n.nodes=e.nodes.map((o,s)=>this._resolveNode(o,s)),n.nodes=n.nodes.map((o,s)=>this._resolveNodeChildren(o))),e.skins&&(n.skins=e.skins.map((o,s)=>this._resolveSkin(o,s))),e.scenes&&(n.scenes=e.scenes.map((o,s)=>this._resolveScene(o,s))),typeof this.json.scene=="number"&&n.scenes&&(n.scene=n.scenes[this.json.scene]),n}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,r){if(typeof r=="object")return r;let n=e&&e[r];return n||console.warn(`glTF file error: Could not find ${e}[${r}]`),n}_resolveScene(e,r){return{...e,id:e.id||`scene-${r}`,nodes:(e.nodes||[]).map(n=>this.getNode(n))}}_resolveNode(e,r){let n={...e,id:e?.id||`node-${r}`};return e.mesh!==void 0&&(n.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(n.camera=this.getCamera(e.camera)),e.skin!==void 0&&(n.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(n.mesh=e.meshes.reduce((o,s)=>{let i=this.getMesh(s);return o.id=i.id,o.primitives=o.primitives.concat(i.primitives),o},{primitives:[]})),n}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(r=>this.getNode(r))),e}_resolveSkin(e,r){let n=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${r}`,inverseBindMatrices:n}}_resolveMesh(e,r){let n={...e,id:e.id||`mesh-${r}`,primitives:[]};return e.primitives&&(n.primitives=e.primitives.map(o=>{let s={...o,attributes:{},indices:void 0,material:void 0},i=o.attributes;for(let a in i)s.attributes[a]=this.getAccessor(i[a]);return o.indices!==void 0&&(s.indices=this.getAccessor(o.indices)),o.material!==void 0&&(s.material=this.getMaterial(o.material)),s})),n}_resolveMaterial(e,r){let n={...e,id:e.id||`material-${r}`};if(n.normalTexture&&(n.normalTexture={...n.normalTexture},n.normalTexture.texture=this.getTexture(n.normalTexture.index)),n.occlusionTexture&&(n.occlusionTexture={...n.occlusionTexture},n.occlusionTexture.texture=this.getTexture(n.occlusionTexture.index)),n.emissiveTexture&&(n.emissiveTexture={...n.emissiveTexture},n.emissiveTexture.texture=this.getTexture(n.emissiveTexture.index)),n.emissiveFactor||(n.emissiveFactor=n.emissiveTexture?[1,1,1]:[0,0,0]),n.pbrMetallicRoughness){n.pbrMetallicRoughness={...n.pbrMetallicRoughness};let o=n.pbrMetallicRoughness;o.baseColorTexture&&(o.baseColorTexture={...o.baseColorTexture},o.baseColorTexture.texture=this.getTexture(o.baseColorTexture.index)),o.metallicRoughnessTexture&&(o.metallicRoughnessTexture={...o.metallicRoughnessTexture},o.metallicRoughnessTexture.texture=this.getTexture(o.metallicRoughnessTexture.index))}return n}_resolveAccessor(e,r){let n=d3(e.componentType),o=m3(e.type),s=n*o,i={...e,id:e.id||`accessor-${r}`,bytesPerComponent:n,components:o,bytesPerElement:s,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(i.bufferView=this.getBufferView(e.bufferView)),i.bufferView){let a=i.bufferView.buffer,{ArrayType:c,byteLength:l}=cn(i,i.bufferView),f=(i.bufferView.byteOffset||0)+(i.byteOffset||0)+a.byteOffset,u=Yn(a.arrayBuffer,f,l);i.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(a,f,i.bufferView.byteStride,i.bytesPerElement,i.count)),i.value=new c(u)}return i}_getValueFromInterleavedBuffer(e,r,n,o,s){let i=new Uint8Array(s*o);for(let a=0;a<s;a++){let c=r+a*n;i.set(new Uint8Array(e.arrayBuffer.slice(c,c+o)),a*o)}return i.buffer}_resolveTexture(e,r){return{...e,id:e.id||`texture-${r}`,sampler:typeof e.sampler=="number"?this.getSampler(e.sampler):p3(),source:typeof e.source=="number"?this.getImage(e.source):void 0}}_resolveSampler(e,r){let n={id:e.id||`sampler-${r}`,...e,parameters:{}};for(let o in n){let s=this._enumSamplerParameter(o);s!==void 0&&(n.parameters[s]=n[o])}return n}_enumSamplerParameter(e){return u3[e]}_resolveImage(e,r){let n={...e,id:e.id||`image-${r}`,image:null,bufferView:e.bufferView!==void 0?this.getBufferView(e.bufferView):void 0},o=this.images[r];return o&&(n.image=o),n}_resolveBufferView(e,r){let n=e.buffer,o=this.buffers[n].arrayBuffer,s=this.buffers[n].byteOffset||0;return e.byteOffset&&(s+=e.byteOffset),{id:`bufferView-${r}`,...e,buffer:this.buffers[n],data:new Uint8Array(o,s,e.byteLength)}}_resolveCamera(e,r){let n={...e,id:e.id||`camera-${r}`};return n.perspective,n.orthographic,n}};function Bo(t,e){return new Xl().postProcess(t,e)}var wi={URI:0,EMBEDDED:1};function Li(t,e,r,n){t.rotateYtoZ=!0;let o=(t.byteOffset||0)+(t.byteLength||0)-r;if(o===0)throw new Error("glTF byte length must be greater than 0.");return t.gltfUpAxis=n?.["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",t.gltfArrayBuffer=ar(e,r,o),t.gltfByteOffset=0,t.gltfByteLength=o,r%4===0||console.warn(`${t.type}: embedded glb is not aligned to a 4-byte boundary.`),(t.byteOffset||0)+(t.byteLength||0)}async function Fi(t,e,r,n){let o=r?.["3d-tiles"]||{};if(g3(t,e,r),o.loadGLTF){if(!n)return;if(t.gltfUrl){let{fetch:s}=n,i=await s(t.gltfUrl,r?.core);t.gltfArrayBuffer=await i.arrayBuffer(),t.gltfByteOffset=0}if(t.gltfArrayBuffer){let s=await Oe(t.gltfArrayBuffer,Er,r,n);t.gltf=Bo(s),t.gpuMemoryUsageInBytes=Eo(t.gltf),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength}}}function g3(t,e,r){switch(e){case wi.URI:if(t.gltfArrayBuffer){let n=new Uint8Array(t.gltfArrayBuffer,t.gltfByteOffset),s=new TextDecoder().decode(n);t.gltfUrl=s.replace(/[\s\0]+$/,"")}delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength;break;case wi.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function d0(t,e,r,n,o){r=A3(t,e,r,n,o),await Fi(t,wi.EMBEDDED,n,o);let s=t?.gltf?.extensions;return s&&s.CESIUM_RTC&&(t.rtcCenter=s.CESIUM_RTC.center),r}function A3(t,e,r,n,o){r=jt(t,e,r),r=sn(t,e,r),r=an(t,e,r,n),r=Li(t,e,r,n);let s=new Et(t.featureTableJson,t.featureTableBinary);return t.rtcCenter=s.getGlobalProperty("RTC_CENTER",O.FLOAT,3),r}async function m0(t,e,r,n,o){return r=x3(t,e,r,n,o),await Fi(t,t.gltfFormat||0,n,o),r}function x3(t,e,r,n,o){if(r=jt(t,e,r),t.version!==1)throw new Error(`Instanced 3D Model version ${t.version} is not supported`);r=sn(t,e,r);let s=new DataView(e);if(t.gltfFormat=s.getUint32(r,!0),r+=4,r=an(t,e,r,n),r=Li(t,e,r,n),!t?.header?.featureTableJsonByteLength||t.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let i=new Et(t.featureTableJson,t.featureTableBinary),a=i.getGlobalProperty("INSTANCES_LENGTH");if(i.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");t.eastNorthUp=i.getGlobalProperty("EAST_NORTH_UP"),t.rtcCenter=i.getGlobalProperty("RTC_CENTER",O.FLOAT,3);let c=new Tr(t.batchTableJson,t.batchTableBinary,a);return y3(t,i,c,a),r}function y3(t,e,r,n){let o=new Array(n),s=new y,i=new y,a=new y,c=new y,l=new k,f=new it,u=new y,h={},p=new N,d=[],m=[],g=[],x=[];for(let b=0;b<n;b++){let M;if(e.hasProperty("POSITION"))M=e.getProperty("POSITION",O.FLOAT,3,b,s);else if(e.hasProperty("POSITION_QUANTIZED")){M=e.getProperty("POSITION_QUANTIZED",O.UNSIGNED_SHORT,3,b,s);let A=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",O.FLOAT,3);if(!A)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let B=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",O.FLOAT,3);if(!B)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let L=65535;for(let F=0;F<3;F++)M[F]=M[F]/L*B[F]+A[F]}if(!M)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");s.copy(M),h.translation=s,t.normalUp=e.getProperty("NORMAL_UP",O.FLOAT,3,b,d),t.normalRight=e.getProperty("NORMAL_RIGHT",O.FLOAT,3,b,m);let E=!1;if(t.normalUp){if(!t.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");t.hasCustomOrientation=!0}else{if(t.octNormalUp=e.getProperty("NORMAL_UP_OCT32P",O.UNSIGNED_SHORT,2,b,d),t.octNormalRight=e.getProperty("NORMAL_RIGHT_OCT32P",O.UNSIGNED_SHORT,2,b,m),t.octNormalUp)throw t.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");t.eastNorthUp?(G.WGS84.eastNorthUpToFixedFrame(s,p),p.getRotationMatrix3(l)):l.identity()}E&&(c.copy(i).cross(a).normalize(),l.setColumn(0,i),l.setColumn(1,a),l.setColumn(2,c)),f.fromMatrix3(l),h.rotation=f,u.set(1,1,1);let C=e.getProperty("SCALE",O.FLOAT,1,b,g);Number.isFinite(C)&&u.multiplyByScalar(C);let _=e.getProperty("SCALE_NON_UNIFORM",O.FLOAT,3,b,d);_&&u.scale(_),h.scale=u;let R=e.getProperty("BATCH_ID",O.UNSIGNED_SHORT,1,b,x);R===void 0&&(R=b);let S=new N().fromQuaternion(h.rotation);p.identity(),p.translate(h.translation),p.multiplyRight(S),p.scale(h.scale);let T=p.clone();o[b]={modelMatrix:T,batchId:R}}t.instances=o}async function g0(t,e,r,n,o,s){r=jt(t,e,r);let i=new DataView(e);for(t.tilesLength=i.getUint32(r,!0),r+=4,t.tiles=[];t.tiles.length<t.tilesLength&&(t.byteLength||0)-r>12;){let a={shape:"tile3d"};t.tiles.push(a),r=await s(e,r,n,o,a)}return r}async function A0(t,e,r,n){if(t.rotateYtoZ=!0,t.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!n)return e.byteLength;let o=await Oe(e,Er,r,n);t.gltf=Bo(o),t.gpuMemoryUsageInBytes=Eo(t.gltf)}else t.gltfArrayBuffer=e;return e.byteLength}async function Yl(t,e=0,r,n,o={shape:"tile3d"}){switch(o.byteOffset=e,o.type=Eg(t,e),o.type){case yr.COMPOSITE:return await g0(o,t,e,r,n,Yl);case yr.BATCHED_3D_MODEL:return await d0(o,t,e,r,n);case yr.GLTF:return await A0(o,t,r,n);case yr.INSTANCED_3D_MODEL:return await m0(o,t,e,r,n);case yr.POINT_CLOUD:return await qg(o,t,e,r,n);default:throw new Error(`3DTileLoader: unknown type ${o.type}`)}}async function Kl(t,e,r){if(new Uint32Array(t.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let s=x0(t.slice(8,16)),i=new Uint8Array(t,24,s),c=new TextDecoder("utf8").decode(i),l=JSON.parse(c),f=x0(t.slice(16,24)),u=new ArrayBuffer(0);if(f&&(u=t.slice(24+s)),await Pi(l,l.tileAvailability,u,r),Array.isArray(l.contentAvailability))for(let h of l.contentAvailability)await Pi(l,h,u,r);else await Pi(l,l.contentAvailability,u,r);return await Pi(l,l.childSubtreeAvailability,u,r),l}async function Pi(t,e,r,n){let o=Number.isFinite(e.bitstream)?e.bitstream:e.bufferView;if(typeof o!="number")return;let s=t.bufferViews[o],i=t.buffers[s.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(i.uri){let c=`${n?.baseUrl||""}/${i.uri}`,f=await(await n.fetch(c)).arrayBuffer();e.explicitBitstream=new Uint8Array(f,s.byteOffset,s.byteLength);return}let a=t.buffers.slice(0,s.buffer).reduce((c,l)=>c+l.byteLength,0);e.explicitBitstream=new Uint8Array(r.slice(a,a+i.byteLength),s.byteOffset,s.byteLength)}function x0(t){let e=new DataView(t),r=e.getUint32(0,!0),n=e.getUint32(4,!0);return r+2**32*n}var Ni={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:Ai,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:Kl,options:{}};var V0=D(rr(),1);var O0=D(rr(),1);var qe=null;try{qe=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Z(t,e,r){this.low=t|0,this.high=e|0,this.unsigned=!!r}Z.prototype.__isLong__;Object.defineProperty(Z.prototype,"__isLong__",{value:!0});function Ee(t){return(t&&t.__isLong__)===!0}function y0(t){var e=Math.clz32(t&-t);return t?31-e:e}Z.isLong=Ee;var b0={},T0={};function Sr(t,e){var r,n,o;return e?(t>>>=0,(o=0<=t&&t<256)&&(n=T0[t],n)?n:(r=q(t,0,!0),o&&(T0[t]=r),r)):(t|=0,(o=-128<=t&&t<128)&&(n=b0[t],n)?n:(r=q(t,t<0?-1:0,!1),o&&(b0[t]=r),r))}Z.fromInt=Sr;function Je(t,e){if(isNaN(t))return e?St:tt;if(e){if(t<0)return St;if(t>=_0)return I0}else{if(t<=-E0)return Le;if(t+1>=E0)return B0}return t<0?Je(-t,e).neg():q(t%An|0,t/An|0,e)}Z.fromNumber=Je;function q(t,e,r){return new Z(t,e,r)}Z.fromBits=q;var Oi=Math.pow;function Zl(t,e,r){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(r=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?St:tt;if(r=r||10,r<2||36<r)throw RangeError("radix");var n;if((n=t.indexOf("-"))>0)throw Error("interior hyphen");if(n===0)return Zl(t.substring(1),e,r).neg();for(var o=Je(Oi(r,8)),s=tt,i=0;i<t.length;i+=8){var a=Math.min(8,t.length-i),c=parseInt(t.substring(i,i+a),r);if(a<8){var l=Je(Oi(r,a));s=s.mul(l).add(Je(c))}else s=s.mul(o),s=s.add(Je(c))}return s.unsigned=e,s}Z.fromString=Zl;function rt(t,e){return typeof t=="number"?Je(t,e):typeof t=="string"?Zl(t,e):q(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}Z.fromValue=rt;var M0=1<<16,b3=1<<24,An=M0*M0,_0=An*An,E0=_0/2,S0=Sr(b3),tt=Sr(0);Z.ZERO=tt;var St=Sr(0,!0);Z.UZERO=St;var gn=Sr(1);Z.ONE=gn;var C0=Sr(1,!0);Z.UONE=C0;var Ql=Sr(-1);Z.NEG_ONE=Ql;var B0=q(-1,2147483647,!1);Z.MAX_VALUE=B0;var I0=q(-1,-1,!0);Z.MAX_UNSIGNED_VALUE=I0;var Le=q(0,-2147483648,!1);Z.MIN_VALUE=Le;var I=Z.prototype;I.toInt=function(){return this.unsigned?this.low>>>0:this.low};I.toNumber=function(){return this.unsigned?(this.high>>>0)*An+(this.low>>>0):this.high*An+(this.low>>>0)};I.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Le)){var r=Je(e),n=this.div(r),o=n.mul(r).sub(this);return n.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var s=Je(Oi(e,6),this.unsigned),i=this,a="";;){var c=i.div(s),l=i.sub(c.mul(s)).toInt()>>>0,f=l.toString(e);if(i=c,i.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}};I.getHighBits=function(){return this.high};I.getHighBitsUnsigned=function(){return this.high>>>0};I.getLowBits=function(){return this.low};I.getLowBitsUnsigned=function(){return this.low>>>0};I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Le)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&!(e&1<<r);r--);return this.high!=0?r+33:r+1};I.isZero=function(){return this.high===0&&this.low===0};I.eqz=I.isZero;I.isNegative=function(){return!this.unsigned&&this.high<0};I.isPositive=function(){return this.unsigned||this.high>=0};I.isOdd=function(){return(this.low&1)===1};I.isEven=function(){return(this.low&1)===0};I.equals=function(e){return Ee(e)||(e=rt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};I.eq=I.equals;I.notEquals=function(e){return!this.eq(e)};I.neq=I.notEquals;I.ne=I.notEquals;I.lessThan=function(e){return this.comp(e)<0};I.lt=I.lessThan;I.lessThanOrEqual=function(e){return this.comp(e)<=0};I.lte=I.lessThanOrEqual;I.le=I.lessThanOrEqual;I.greaterThan=function(e){return this.comp(e)>0};I.gt=I.greaterThan;I.greaterThanOrEqual=function(e){return this.comp(e)>=0};I.gte=I.greaterThanOrEqual;I.ge=I.greaterThanOrEqual;I.compare=function(e){if(Ee(e)||(e=rt(e)),this.eq(e))return 0;var r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};I.comp=I.compare;I.negate=function(){return!this.unsigned&&this.eq(Le)?Le:this.not().add(gn)};I.neg=I.negate;I.add=function(e){Ee(e)||(e=rt(e));var r=this.high>>>16,n=this.high&65535,o=this.low>>>16,s=this.low&65535,i=e.high>>>16,a=e.high&65535,c=e.low>>>16,l=e.low&65535,f=0,u=0,h=0,p=0;return p+=s+l,h+=p>>>16,p&=65535,h+=o+c,u+=h>>>16,h&=65535,u+=n+a,f+=u>>>16,u&=65535,f+=r+i,f&=65535,q(h<<16|p,f<<16|u,this.unsigned)};I.subtract=function(e){return Ee(e)||(e=rt(e)),this.add(e.neg())};I.sub=I.subtract;I.multiply=function(e){if(this.isZero())return this;if(Ee(e)||(e=rt(e)),qe){var r=qe.mul(this.low,this.high,e.low,e.high);return q(r,qe.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?St:tt;if(this.eq(Le))return e.isOdd()?Le:tt;if(e.eq(Le))return this.isOdd()?Le:tt;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(S0)&&e.lt(S0))return Je(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,o=this.high&65535,s=this.low>>>16,i=this.low&65535,a=e.high>>>16,c=e.high&65535,l=e.low>>>16,f=e.low&65535,u=0,h=0,p=0,d=0;return d+=i*f,p+=d>>>16,d&=65535,p+=s*f,h+=p>>>16,p&=65535,p+=i*l,h+=p>>>16,p&=65535,h+=o*f,u+=h>>>16,h&=65535,h+=s*l,u+=h>>>16,h&=65535,h+=i*c,u+=h>>>16,h&=65535,u+=n*f+o*l+s*c+i*a,u&=65535,q(p<<16|d,u<<16|h,this.unsigned)};I.mul=I.multiply;I.divide=function(e){if(Ee(e)||(e=rt(e)),e.isZero())throw Error("division by zero");if(qe){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?qe.div_u:qe.div_s)(this.low,this.high,e.low,e.high);return q(r,qe.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?St:tt;var n,o,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return St;if(e.gt(this.shru(1)))return C0;s=St}else{if(this.eq(Le)){if(e.eq(gn)||e.eq(Ql))return Le;if(e.eq(Le))return gn;var i=this.shr(1);return n=i.div(e).shl(1),n.eq(tt)?e.isNegative()?gn:Ql:(o=this.sub(e.mul(n)),s=n.add(o.div(e)),s)}else if(e.eq(Le))return this.unsigned?St:tt;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=tt}for(o=this;o.gte(e);){n=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),c=a<=48?1:Oi(2,a-48),l=Je(n),f=l.mul(e);f.isNegative()||f.gt(o);)n-=c,l=Je(n,this.unsigned),f=l.mul(e);l.isZero()&&(l=gn),s=s.add(l),o=o.sub(f)}return s};I.div=I.divide;I.modulo=function(e){if(Ee(e)||(e=rt(e)),qe){var r=(this.unsigned?qe.rem_u:qe.rem_s)(this.low,this.high,e.low,e.high);return q(r,qe.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};I.mod=I.modulo;I.rem=I.modulo;I.not=function(){return q(~this.low,~this.high,this.unsigned)};I.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};I.clz=I.countLeadingZeros;I.countTrailingZeros=function(){return this.low?y0(this.low):y0(this.high)+32};I.ctz=I.countTrailingZeros;I.and=function(e){return Ee(e)||(e=rt(e)),q(this.low&e.low,this.high&e.high,this.unsigned)};I.or=function(e){return Ee(e)||(e=rt(e)),q(this.low|e.low,this.high|e.high,this.unsigned)};I.xor=function(e){return Ee(e)||(e=rt(e)),q(this.low^e.low,this.high^e.high,this.unsigned)};I.shiftLeft=function(e){return Ee(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):q(0,this.low<<e-32,this.unsigned)};I.shl=I.shiftLeft;I.shiftRight=function(e){return Ee(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):q(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};I.shr=I.shiftRight;I.shiftRightUnsigned=function(e){return Ee(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?q(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?q(this.high,0,this.unsigned):q(this.high>>>e-32,0,this.unsigned)};I.shru=I.shiftRightUnsigned;I.shr_u=I.shiftRightUnsigned;I.rotateLeft=function(e){var r;return Ee(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?q(this.high,this.low,this.unsigned):e<32?(r=32-e,q(this.low<<e|this.high>>>r,this.high<<e|this.low>>>r,this.unsigned)):(e-=32,r=32-e,q(this.high<<e|this.low>>>r,this.low<<e|this.high>>>r,this.unsigned))};I.rotl=I.rotateLeft;I.rotateRight=function(e){var r;return Ee(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?q(this.high,this.low,this.unsigned):e<32?(r=32-e,q(this.high<<r|this.low>>>e,this.low<<r|this.high>>>e,this.unsigned)):(e-=32,r=32-e,q(this.low<<r|this.high>>>e,this.high<<r|this.low>>>e,this.unsigned))};I.rotr=I.rotateRight;I.toSigned=function(){return this.unsigned?q(this.low,this.high,!1):this};I.toUnsigned=function(){return this.unsigned?this:q(this.low,this.high,!0)};I.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};I.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};I.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Z.fromBytes=function(e,r,n){return n?Z.fromBytesLE(e,r):Z.fromBytesBE(e,r)};Z.fromBytesLE=function(e,r){return new Z(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};Z.fromBytesBE=function(e,r){return new Z(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var xn=Z;var T3=16;function Io(t){t==="X"&&(t="");let e=t.padEnd(T3,"0");return xn.fromString(e,!0,16)}function $l(t){if(t.isZero())return"X";let e=t.countTrailingZeros(),r=e%4;e=(e-r)/4;let n=e;e*=4;let s=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-n-s.length).join("0")+s}function ef(t,e){let r=M3(t).shiftRightUnsigned(2);return t.add(xn.fromNumber(2*e+1-4).multiply(r))}function M3(t){return t.and(t.not().add(1))}var E3=3,S3=30,_3=2*S3+1,R0=180/Math.PI;function w0(t){if(t.length===0)throw new Error(`Invalid Hilbert quad key ${t}`);let e=t.split("/"),r=parseInt(e[0],10),n=e[1],o=n.length,s=0,i=[0,0];for(let a=o-1;a>=0;a--){s=o-a;let c=n[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,s-1);C3(u,i,l,f),i[0]+=u*l,i[1]+=u*f}if(r%2===1){let a=i[0];i[0]=i[1],i[1]=a}return{face:r,ij:i,level:s}}function L0(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length<E3+_3;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),o=e.substring(3,r),s=o.length/2,i=xn.fromString(n,!0,2).toString(10),a="";if(s!==0)for(a=xn.fromString(o,!0,2).toString(4);a.length<s;)a="0"+a;return`${i}/${a}`}function tf(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function v0(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function rf(t){return[v0(t[0]),v0(t[1])]}function nf(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function of([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*R0,n*R0]}function C3(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let o=e[0];e[0]=e[1],e[1]=o}}function F0(t){let e=tf(t.ij,t.level,[.5,.5]),r=rf(e),n=nf(t.face,r);return of(n)}var B3=100;function sf(t){let{face:e,ij:r,level:n}=t,o=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(B3*Math.pow(2,-n))),i=new Float64Array(4*s*2+2),a=0,c=0;for(let l=0;l<4;l++){let f=o[l].slice(0),u=o[l+1],h=(u[0]-f[0])/s,p=(u[1]-f[1])/s;for(let d=0;d<s;d++){f[0]+=h,f[1]+=p;let m=tf(r,n,f),g=rf(m),x=nf(e,g),b=of(x);Math.abs(b[1])>89.999&&(b[0]=c);let M=b[0]-c;b[0]+=M>180?-360:M<-180?360:0,i[a++]=b[0],i[a++]=b[1],c=b[0]}}return i[a++]=i[0],i[a++]=i[1],i}function yn(t){let e=I3(t);return w0(e)}function I3(t){if(t.indexOf("/")>0)return t;let e=Io(t);return L0(e)}function af(t){let e=yn(t);return F0(e)}function N0(t){let e;if(t.face===2||t.face===5){let r=null,n=0;for(let o=0;o<4;o++){let s=`${t.face}/${o}`,i=yn(s),a=sf(i);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,n),n+=a.length}e=P0(r)}else{let r=sf(t);e=P0(r)}return e}function P0(t){if(t.length%2!==0)throw new Error("Invalid corners");let e=[],r=[];for(let n=0;n<t.length;n+=2)e.push(t[n]),r.push(t[n+1]);return e.sort((n,o)=>n-o),r.sort((n,o)=>n-o),{west:e[0],east:e[e.length-1],north:r[r.length-1],south:r[0]}}function cf(t,e){let r=e?.minimumHeight||0,n=e?.maximumHeight||0,o=yn(t),s=N0(o),i=s.west,a=s.south,c=s.east,l=s.north,f=[];return f.push(new y(i,l,r)),f.push(new y(c,l,r)),f.push(new y(c,a,r)),f.push(new y(i,a,r)),f.push(new y(i,l,n)),f.push(new y(c,l,n)),f.push(new y(c,a,n)),f.push(new y(i,a,n)),f}function Ui(t){let e=t.token,r={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},n=cf(e,r),o=af(e),s=o[0],i=o[1],a=G.WGS84.cartographicToCartesian([s,i,r.maximumHeight]),c=new y(a[0],a[1],a[2]);n.push(c);let l=co(n);return[...l.center,...l.halfAxes]}var R3=4,v3=8,w3={QUADTREE:R3,OCTREE:v3};function L3(t,e,r){if(t?.box){let n=Io(t.s2VolumeInfo.token),o=ef(n,e),s=$l(o),i={...t.s2VolumeInfo};switch(i.token=s,r){case"OCTREE":let l=t.s2VolumeInfo,f=l.maximumHeight-l.minimumHeight,u=f/2,h=l.minimumHeight+f/2;l.minimumHeight=h-u,l.maximumHeight=h+u;break;default:break}return{box:Ui(i),s2VolumeInfo:i}}}async function ff(t){let{subtree:e,subtreeData:r={level:0,x:0,y:0,z:0},parentData:n={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:o=0,implicitOptions:s,loaderOptions:i,s2VolumeBox:a}=t,{subdivisionScheme:c,subtreeLevels:l,maximumLevel:f,contentUrlTemplate:u,subtreesUriTemplate:h,basePath:p}=s,d={children:[],lodMetricValue:0,contentUrl:""};if(!f)return dc.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${u} won't be loaded...`),d;let m=n.localLevel+1,g=r.level+m;if(g>f)return d;let x=w3[c],b=Math.log2(x),M=o&1,E=o>>1&1,C=o>>2&1,_=_r(n.localX,M,1),R=_r(n.localY,E,1),S=_r(n.localZ,C,1),T=_r(r.x,_,m),A=_r(r.y,R,m),B=_r(r.z,S,m),L=_r(n.mortonIndex,o,b),F=m===l&&lf(e.childSubtreeAvailability,L),w,U,W,z;if(F){let Y=`${p}/${h}`,ee=Di(Y,g,T,A,B);w=await(0,O0.load)(ee,Ni,i),z=0,U={level:g,x:T,y:A,z:B},W={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else w=e,z=(x**m-1)/(x-1)+L,U=r,W={mortonIndex:L,localLevel:m,localX:_,localY:R,localZ:S};if(!lf(w.tileAvailability,z))return d;lf(w.contentAvailability,z)&&(d.contentUrl=Di(u,g,T,A,B));for(let Y=0;Y<x;Y++){let ee=L3(a,Y,c),Ie=await ff({subtree:w,subtreeData:U,parentData:W,childIndex:Y,implicitOptions:s,loaderOptions:i,s2VolumeBox:ee});(Ie.contentUrl||Ie.children.length)&&d.children.push(Ie)}return d.contentUrl||d.children.length?F3(d,{level:g,x:T,y:A,z:B},s,a):d}function lf(t,e){let r;return Array.isArray(t)?(r=t[0],t.length>1&&dc.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=t,"constant"in r?Boolean(r.constant):r.explicitBitstream?O3(e,r.explicitBitstream):!1}function F3(t,e,r,n){let{basePath:o,refine:s,getRefine:i,lodMetricType:a,getTileType:c,rootLodMetricValue:l,rootBoundingVolume:f}=r,u=t.contentUrl&&t.contentUrl.replace(`${o}/`,""),h=l/2**e.level,p=n?.box?{box:n.box}:f,d=P3(p,e,r.subdivisionScheme);return{children:t.children,contentUrl:t.contentUrl,content:{uri:u},id:t.contentUrl,refine:i(s),type:c(t),lodMetricType:a,lodMetricValue:h,geometricError:h,transform:t.transform,boundingVolume:d}}function P3(t,e,r){if(t.region){let{level:n,x:o,y:s,z:i}=e,[a,c,l,f,u,h]=t.region,p=2**n,d=(l-a)/p,[m,g]=[a+d*o,a+d*(o+1)],x=(f-c)/p,[b,M]=[c+x*s,c+x*(s+1)],E,C;if(r==="OCTREE"){let _=(h-u)/p;[E,C]=[u+_*i,u+_*(i+1)]}else[E,C]=[u,h];return{region:[m,b,g,M,E,C]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function _r(t,e,r){return(t<<r)+e}function Di(t,e,r,n,o){let s=N3({level:e,x:r,y:n,z:o});return t.replace(/{level}|{x}|{y}|{z}/gi,i=>s[i])}function N3(t){let e={};for(let r in t)e[`{${r}}`]=t[r];return e}function O3(t,e){let r=Math.floor(t/8),n=t%8;return(e[r]>>n&1)===1}function hf(t,e=""){if(!e)return ke.EMPTY;let n=e.split("?")[0].split(".").pop();switch(n){case"pnts":return ke.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return ke.SCENEGRAPH;default:return n||ke.EMPTY}}function pf(t){switch(t){case"REPLACE":case"replace":return Te.REPLACE;case"ADD":case"add":return Te.ADD;default:return t}}function uf(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){let n=new URL(t,`${e}/`);return decodeURI(n.toString())}else if(t.startsWith("/"))return t;return Ot.resolve(e,t)}function U0(t,e){if(!t)return null;let r;if(t.content){let o=t.content.uri||t.content?.url;typeof o<"u"&&(r=uf(o,e))}return{...t,id:r,contentUrl:r,lodMetricType:Mt.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:hf(t,r),refine:pf(t.refine)}}async function H0(t,e,r){let n=null,o=G0(t.root);o&&t.root?n=await D0(t.root,t,e,o,r):n=U0(t.root,e);let s=[];for(s.push(n);s.length>0;){let i=s.pop()||{},a=i.children||[],c=[];for(let l of a){let f=G0(l),u;f?u=await D0(l,t,e,f,r):u=U0(l,e),u&&(c.push(u),s.push(u))}i.children=c}return n}async function D0(t,e,r,n,o){let{subdivisionScheme:s,maximumLevel:i,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=n,f=Di(l,0,0,0,0),u=uf(f,r),h=await(0,V0.load)(u,Ni,o),p=t.content?.uri,d=p?uf(p,r):"",m=e?.root?.refine,g=t.geometricError,x=t.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(x){let C={box:Ui(x),s2VolumeInfo:x};t.boundingVolume=C}let b=t.boundingVolume,M={contentUrlTemplate:d,subtreesUriTemplate:l,subdivisionScheme:s,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:i,refine:m,basePath:r,lodMetricType:Mt.GEOMETRIC_ERROR,rootLodMetricValue:g,rootBoundingVolume:b,getTileType:hf,getRefine:pf};return await U3(t,r,h,M,o)}async function U3(t,e,r,n,o){if(!t)return null;let{children:s,contentUrl:i}=await ff({subtree:r,implicitOptions:n,loaderOptions:o}),a,c=null;return i&&(a=i,c={uri:i.replace(`${e}/`,"")}),{...t,id:a,contentUrl:a,lodMetricType:Mt.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:hf(t,a),refine:pf(t.refine),content:c||t.content,children:s}}function G0(t){return t?.extensions?.["3DTILES_implicit_tiling"]||t?.implicitTiling}var Gi={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:Ai,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:D3,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function D3(t,e={},r){let n=e["3d-tiles"]||{},o;return n.isTileset==="auto"?o=r?.url&&r.url.indexOf(".json")!==-1:o=n.isTileset,o?G3(t,e,r):V3(t,e,r)}async function G3(t,e,r){let n=JSON.parse(new TextDecoder().decode(t)),o=r?.url||"",s=H3(o),i=await H0(n,s,e||{});return{...n,shape:"tileset3d",loader:Gi,url:o,queryString:r?.queryString||"",basePath:s,root:i||n.root,type:de.TILES3D,lodMetricType:Mt.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0}}async function V3(t,e,r){let n={content:{shape:"tile3d",featureIds:null}};return await Yl(t,0,e,r,n.content),n.content}function H3(t){return Ot.dirname(t)}var z0=[0],z3={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Gi,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,r)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}},Ro=class extends Wt.CompositeLayer{initializeState(){"onTileLoadFail"in this.props&&Wt.log.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:r,changeFlags:n}){if(e.data&&e.data!==r.data&&this._loadTileset(e.data),n.viewportChanged){let{activeViewports:o}=this.state;Object.keys(o).length&&(this._updateTileset(o),this.state.lastUpdatedViewports=o,this.state.activeViewports={})}if(n.propsChanged){let{layerMap:o}=this.state;for(let s in o)o[s].needsUpdate=!0}}finalizeState(e){this.state.tileset3d?.destroy(),this.state.tileset3d=null,this.state.layerMap={},this.state.activeViewports={},this.state.lastUpdatedViewports=null,super.finalizeState(e)}activateViewport(e){let{activeViewports:r,lastUpdatedViewports:n}=this.state;this.internalState.viewport=e,r[e.id]=e;let o=n?.[e.id];(!o||!e.equals(o))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:r}){let n=r&&r.props.tile;return e.picked&&(e.object=n),e.sourceTile=n,e}filterSubLayer({layer:e,viewport:r,cullRect:n,isPicking:o}){let{tile:s}=e.props,{id:i}=r;if(!s.selected||!s.viewportIds.includes(i))return!1;if(o&&n&&s.content?.cartographicOrigin){let[a,c]=r.project(s.content.cartographicOrigin),l=n.x+n.width/2,f=n.y+n.height/2,u=Math.max(r.width,r.height)/4,h=a-l,p=c-f;if(h*h+p*p>u*u)return!1}return!0}_updateAutoHighlight(e){let r=e.sourceTile,n=this.state.layerMap[r?.id];n&&n.layer&&n.layer.updateAutoHighlight(e)}async _loadTileset(e){let r=this.props.loadOptions||{},n=this.props.loaders?.length?this.props.loaders:this.props.loader,o=Array.isArray(n)?n[0]:n,{tileset:s,...i}=r,a={loadOptions:{...i},...s},c=e;if("preload"in o&&typeof o.preload=="function"){let u=await o.preload(e,r);u.url&&(c=u.url),u.headers&&(a.loadOptions.core={...a.loadOptions.core,fetch:{...a.loadOptions.core?.fetch,headers:u.headers}}),Object.assign(a,u)}let l=await(0,J0.load)(c,o,a.loadOptions),f=new yo(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...a});this.setState({tileset3d:f,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(f)}_onTileLoad(e){let{lastUpdatedViewports:r}=this.state;e.tileDrawn=!1,this.props.onTileLoad(e),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;let{tileset3d:r}=this.state,{timeline:n}=this.context,o=Object.keys(e).length;!n||!o||!r||r.selectTiles(Object.values(e)).then(s=>{this.state.frameNumber!==s&&this.setState({frameNumber:s})})}_getSubLayer(e,r){if(!e.content)return null;switch(e.type){case ke.POINTCLOUD:return this._makePointCloudLayer(e,r);case ke.SCENEGRAPH:return this._make3DModelLayer(e);case ke.MESH:return this._makeSimpleMeshLayer(e,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){let{attributes:n,pointCount:o,constantRGBA:s,cartographicOrigin:i,modelMatrix:a}=e.content,{positions:c,normals:l,colors:f}=n;if(!c)return null;let u=r&&r.props.data||{header:{vertexCount:o},attributes:{POSITION:c,NORMAL:l,COLOR_0:f}},{pointSize:h,getPointColor:p}=this.props,d=this.getSubLayerClass("pointcloud",j0.PointCloudLayer);return new d({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:u,coordinateSystem:Wt.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:i,modelMatrix:a,getColor:s||p,_offset:0})}_make3DModelLayer(e){let{gltf:r,instances:n,cartographicOrigin:o,modelMatrix:s}=e.content,i=this.getSubLayerClass("scenegraph",q0.ScenegraphLayer);return new i({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:n||z0,scenegraph:r,coordinateSystem:Wt.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:o,modelMatrix:s,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,r){let n=e.content,{attributes:o,indices:s,modelMatrix:i,cartographicOrigin:a,coordinateSystem:c=Wt.COORDINATE_SYSTEM.METER_OFFSETS,material:l,featureIds:f}=n,{_getMeshColor:u}=this.props,h=r&&r.props.mesh||new k0.Geometry({topology:"triangle-list",attributes:k3(o),indices:s}),p=this.getSubLayerClass("mesh",Dm);return new p(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:h,data:z0,getColor:u(e),pbrMaterial:l,modelMatrix:i,coordinateOrigin:a,coordinateSystem:c,featureIds:f,_offset:0})}renderLayers(){let{tileset3d:e,layerMap:r}=this.state;return e?e.tiles.map(n=>{let o=r[n.id]=r[n.id]||{tile:n},{layer:s}=o;return n.selected&&(s?o.needsUpdate&&(s=this._getSubLayer(n,s),o.needsUpdate=!1):s=this._getSubLayer(n)),o.layer=s,s}).filter(Boolean):null}};Ro.defaultProps=z3;Ro.layerName="Tile3DLayer";var W0=Ro;function k3(t){let e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}var dt=D(ot(),1),xf=D(Zs(),1);var j3=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function df(t){return t>>1^-(t&1)}function q3(t){let e=0,r={};for(let[n,o]of j3){let s=o===8?t.getFloat64:t.getFloat32;r[n]=s.call(t,e,!0),e+=o}return{header:r,headerEndPosition:e}}function J3(t,e){let r=e,n=3,o=t.getUint32(r,!0),s=new Uint16Array(o*n);r+=Uint32Array.BYTES_PER_ELEMENT;let i=Uint16Array.BYTES_PER_ELEMENT,a=o*i,c=r,l=c+a,f=l+a,u=0,h=0,p=0;for(let d=0;d<o;d++)u+=df(t.getUint16(c+i*d,!0)),h+=df(t.getUint16(l+i*d,!0)),p+=df(t.getUint16(f+i*d,!0)),s[d]=u,s[d+o]=h,s[d+o*2]=p;return r+=a*3,{vertexData:s,vertexDataEndPosition:r}}function vo(t,e,r,n,o=!0){let s;if(n===2?s=new Uint16Array(t,e,r):s=new Uint32Array(t,e,r),!o)return s;let i=0;for(let a=0;a<s.length;++a){let c=s[a];s[a]=i-c,c===0&&++i}return s}function W3(t,e,r){let n=r,o=3,i=e.length/o>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;n%i!==0&&(n+=i-n%i);let a=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=vo(t.buffer,n,c,i);return n+=c*i,{triangleIndicesEndPosition:n,triangleIndices:l}}function X3(t,e,r){let n=r,o=3,i=e.length/o>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=vo(t.buffer,n,a,i,!1);n+=a*i;let l=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let f=vo(t.buffer,n,l,i,!1);n+=l*i;let u=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let h=vo(t.buffer,n,u,i,!1);n+=u*i;let p=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let d=vo(t.buffer,n,p,i,!1);return n+=p*i,{edgeIndicesEndPosition:n,westIndices:c,southIndices:f,eastIndices:h,northIndices:d}}function Y3(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function K3(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function Q3(t,e){let r={};if(t.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let n=e;for(;n<t.byteLength;){let o=t.getUint8(n,!0);n+=Uint8Array.BYTES_PER_ELEMENT;let s=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let i=new DataView(t.buffer,n,s);switch(o){case 1:{r.vertexNormals=Y3(i);break}case 2:{r.waterMask=K3(i);break}default:}n+=s}return{extensions:r,extensionsEndPosition:n}}var Cr={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},Z3={maxDecodingStep:Cr.extensions};function mf(t,e){let r=Object.assign({},Z3,e),n=new DataView(t),{header:o,headerEndPosition:s}=q3(n);if(r.maxDecodingStep<Cr.vertices)return{header:o};let{vertexData:i,vertexDataEndPosition:a}=J3(n,s);if(r.maxDecodingStep<Cr.triangleIndices)return{header:o,vertexData:i};let{triangleIndices:c,triangleIndicesEndPosition:l}=W3(n,i,a);if(r.maxDecodingStep<Cr.edgeIndices)return{header:o,vertexData:i,triangleIndices:c};let{westIndices:f,southIndices:u,eastIndices:h,northIndices:p,edgeIndicesEndPosition:d}=X3(n,i,l);if(r.maxDecodingStep<Cr.extensions)return{header:o,vertexData:i,triangleIndices:c,westIndices:f,northIndices:p,eastIndices:h,southIndices:u};let{extensions:m}=Q3(n,d);return{header:o,vertexData:i,triangleIndices:c,westIndices:f,northIndices:p,eastIndices:h,southIndices:u,extensions:m}}function Vi(t,e,r,n){let o=n?eR(n,t.POSITION.value):$3(e),s=new t.POSITION.value.constructor(o.length*6),i=new t.TEXCOORD_0.value.constructor(o.length*4),a=new e.constructor(o.length*6);for(let l=0;l<o.length;l++){let f=o[l];tR({edge:f,edgeIndex:l,attributes:t,skirtHeight:r,newPosition:s,newTexcoord0:i,newTriangles:a})}t.POSITION.value=Wn(t.POSITION.value,s),t.TEXCOORD_0.value=Wn(t.TEXCOORD_0.value,i);let c=e instanceof Array?e.concat(a):Wn(e,a);return{attributes:t,triangles:c}}function $3(t){let e=[];for(let o=0;o<t.length;o+=3)e.push([t[o],t[o+1]]),e.push([t[o+1],t[o+2]]),e.push([t[o+2],t[o]]);e.sort((o,s)=>Math.min(...o)-Math.min(...s)||Math.max(...o)-Math.max(...s));let r=[],n=0;for(;n<e.length;)e[n][0]===e[n+1]?.[1]&&e[n][1]===e[n+1]?.[0]?n+=2:(r.push(e[n]),n++);return r}function eR(t,e){t.westIndices.sort((n,o)=>e[3*n+1]-e[3*o+1]),t.eastIndices.sort((n,o)=>e[3*o+1]-e[3*n+1]),t.southIndices.sort((n,o)=>e[3*o]-e[3*n]),t.northIndices.sort((n,o)=>e[3*n]-e[3*o]);let r=[];for(let n in t){let o=t[n];for(let s=0;s<o.length-1;s++)r.push([o[s],o[s+1]])}return r}function tR({edge:t,edgeIndex:e,attributes:r,skirtHeight:n,newPosition:o,newTexcoord0:s,newTriangles:i}){let a=r.POSITION.value.length,c=e*2,l=e*2+1;o.set(r.POSITION.value.subarray(t[0]*3,t[0]*3+3),c*3),o[c*3+2]=o[c*3+2]-n,o.set(r.POSITION.value.subarray(t[1]*3,t[1]*3+3),l*3),o[l*3+2]=o[l*3+2]-n,s.set(r.TEXCOORD_0.value.subarray(t[0]*2,t[0]*2+2),c*2),s.set(r.TEXCOORD_0.value.subarray(t[1]*2,t[1]*2+2),l*2);let f=e*2*3;i[f]=t[0],i[f+1]=a/3+l,i[f+2]=t[1],i[f+3]=a/3+l,i[f+4]=t[0],i[f+5]=a/3+c}function gf(t,e={}){let{bounds:r}=e,{header:n,vertexData:o,triangleIndices:s,westIndices:i,northIndices:a,eastIndices:c,southIndices:l}=mf(t,Cr.triangleIndices),f=s,u=rR(o,n,r),h=br(u);if(e?.skirtHeight){let{attributes:p,triangles:d}=Vi(u,f,e.skirtHeight,{westIndices:i,northIndices:a,eastIndices:c,southIndices:l});u=p,f=d}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:h},schema:void 0,topology:"triangle-list",mode:4,indices:{value:f,size:1},attributes:u}}function rR(t,e,r){let{minHeight:n,maxHeight:o}=e,[s,i,a,c]=r||[0,0,1,1],l=a-s,f=c-i,u=o-n,h=t.length/3,p=new Float32Array(h*3),d=new Float32Array(h*2);for(let m=0;m<h;m++){let g=t[m]/32767,x=t[m+h]/32767,b=t[m+h*2]/32767;p[3*m+0]=g*l+s,p[3*m+1]=x*f+i,p[3*m+2]=b*u+n,d[2*m+0]=g,d[2*m+1]=x}return{POSITION:{value:p,size:3},TEXCOORD_0:{value:d,size:2}}}var wo=class{constructor(e=257){this.gridSize=e;let r=e-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let o=n+2,s=0,i=0,a=0,c=0,l=0,f=0;for(o&1?a=c=l=r:s=i=f=r;(o>>=1)>1;){let h=s+a>>1,p=i+c>>1;o&1?(a=s,c=i,s=l,i=f):(s=a,i=c,a=l,c=f),l=h,f=p}let u=n*4;this.coords[u+0]=s,this.coords[u+1]=i,this.coords[u+2]=a,this.coords[u+3]=c}}createTile(e){return new Af(e,this)}},Af=class{constructor(e,r){let n=r.gridSize;if(e.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:n,gridSize:o}=this.martini,{terrain:s,errors:i}=this;for(let a=e-1;a>=0;a--){let c=a*4,l=n[c+0],f=n[c+1],u=n[c+2],h=n[c+3],p=l+u>>1,d=f+h>>1,m=p+d-f,g=d+l-p,x=(s[f*o+l]+s[h*o+u])/2,b=d*o+p,M=Math.abs(x-s[b]);if(i[b]=Math.max(i[b],M),a<r){let E=(f+g>>1)*o+(l+m>>1),C=(h+g>>1)*o+(u+m>>1);i[b]=Math.max(i[b],i[E],i[C])}}}getMesh(e=0){let{gridSize:r,indices:n}=this.martini,{errors:o}=this,s=0,i=0,a=r-1;n.fill(0);function c(p,d,m,g,x,b){let M=p+m>>1,E=d+g>>1;Math.abs(p-x)+Math.abs(d-b)>1&&o[E*r+M]>e?(c(x,b,p,d,M,E),c(m,g,x,b,M,E)):(n[d*r+p]=n[d*r+p]||++s,n[g*r+m]=n[g*r+m]||++s,n[b*r+x]=n[b*r+x]||++s,i++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);let l=new Uint16Array(s*2),f=new Uint32Array(i*3),u=0;function h(p,d,m,g,x,b){let M=p+m>>1,E=d+g>>1;if(Math.abs(p-x)+Math.abs(d-b)>1&&o[E*r+M]>e)h(x,b,p,d,M,E),h(m,g,x,b,M,E);else{let C=n[d*r+p]-1,_=n[g*r+m]-1,R=n[b*r+x]-1;l[2*C]=p,l[2*C+1]=d,l[2*_]=m,l[2*_+1]=g,l[2*R]=x,l[2*R+1]=b,f[u++]=C,f[u++]=_,f[u++]=R}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:l,triangles:f}}};var Lo=class{constructor(e,r,n=r){this.data=e,this.width=r,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let o=r-1,s=n-1,i=this._addPoint(0,0),a=this._addPoint(o,0),c=this._addPoint(0,s),l=this._addPoint(o,s),f=this._addTriangle(l,i,c,-1,-1,-1);this._addTriangle(i,l,a,f,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r<this._pendingLen;r++){let n=this._pending[r],o=2*this.triangles[n*3+0],s=2*this.triangles[n*3+1],i=2*this.triangles[n*3+2];this._findCandidate(e[o],e[o+1],e[s],e[s+1],e[i],e[i+1],n)}this._pendingLen=0}_findCandidate(e,r,n,o,s,i,a){let c=Math.min(e,n,s),l=Math.min(r,o,i),f=Math.max(e,n,s),u=Math.max(r,o,i),h=Br(n,o,s,i,c,l),p=Br(s,i,e,r,c,l),d=Br(e,r,n,o,c,l),m=o-r,g=e-n,x=i-o,b=n-s,M=r-i,E=s-e,C=Br(e,r,n,o,s,i),_=this.heightAt(e,r)/C,R=this.heightAt(n,o)/C,S=this.heightAt(s,i)/C,T=0,A=0,B=0,L=0;for(let F=l;F<=u;F++){let w=0;h<0&&x!==0&&(w=Math.max(w,Math.floor(-h/x))),p<0&&M!==0&&(w=Math.max(w,Math.floor(-p/M))),d<0&&m!==0&&(w=Math.max(w,Math.floor(-d/m)));let U=h+x*w,W=p+M*w,z=d+m*w,re=!1;for(let K=c+w;K<=f;K++){if(U>=0&&W>=0&&z>=0){re=!0;let Y=_*U+R*W+S*z,ee=Math.abs(Y-this.heightAt(K,F));L+=ee*ee,ee>T&&(T=ee,A=K,B=F)}else if(re)break;U+=x,W+=M,z+=m}h+=b,p+=E,d+=g}(A===e&&B===r||A===n&&B===o||A===s&&B===i)&&(T=0),this._candidates[2*a]=A,this._candidates[2*a+1]=B,this._rms[a]=L,this._queuePush(a,T,L)}_step(){let e=this._queuePop(),r=e*3+0,n=e*3+1,o=e*3+2,s=this.triangles[r],i=this.triangles[n],a=this.triangles[o],c=this.coords[2*s],l=this.coords[2*s+1],f=this.coords[2*i],u=this.coords[2*i+1],h=this.coords[2*a],p=this.coords[2*a+1],d=this._candidates[2*e],m=this._candidates[2*e+1],g=this._addPoint(d,m);if(Br(c,l,f,u,d,m)===0)this._handleCollinear(g,r);else if(Br(f,u,h,p,d,m)===0)this._handleCollinear(g,n);else if(Br(h,p,c,l,d,m)===0)this._handleCollinear(g,o);else{let x=this._halfedges[r],b=this._halfedges[n],M=this._halfedges[o],E=this._addTriangle(s,i,g,x,-1,-1,r),C=this._addTriangle(i,a,g,b,-1,E+1),_=this._addTriangle(a,s,g,M,E+2,C+1);this._legalize(E),this._legalize(C),this._legalize(_)}}_addPoint(e,r){let n=this.coords.length>>1;return this.coords.push(e,r),n}_addTriangle(e,r,n,o,s,i,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=n,this._halfedges[a+0]=o,this._halfedges[a+1]=s,this._halfedges[a+2]=i,o>=0&&(this._halfedges[o]=a+0),s>=0&&(this._halfedges[s]=a+1),i>=0&&(this._halfedges[i]=a+2),this._candidates[2*c+0]=0,this._candidates[2*c+1]=0,this._queueIndices[c]=-1,this._rms[c]=0,this._pending[this._pendingLen++]=c,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let n=e-e%3,o=r-r%3,s=n+(e+1)%3,i=n+(e+2)%3,a=o+(r+2)%3,c=o+(r+1)%3,l=this.triangles[i],f=this.triangles[e],u=this.triangles[s],h=this.triangles[a],p=this.coords;if(!nR(p[2*l],p[2*l+1],p[2*f],p[2*f+1],p[2*u],p[2*u+1],p[2*h],p[2*h+1]))return;let d=this._halfedges[s],m=this._halfedges[i],g=this._halfedges[a],x=this._halfedges[c];this._queueRemove(n/3),this._queueRemove(o/3);let b=this._addTriangle(l,h,u,-1,g,d,n),M=this._addTriangle(h,l,f,b,m,x,o);this._legalize(b+1),this._legalize(M+2)}_handleCollinear(e,r){let n=r-r%3,o=n+(r+1)%3,s=n+(r+2)%3,i=this.triangles[s],a=this.triangles[r],c=this.triangles[o],l=this._halfedges[o],f=this._halfedges[s],u=this._halfedges[r];if(u<0){let _=this._addTriangle(e,i,a,-1,f,-1,n),R=this._addTriangle(i,e,c,_,-1,l);this._legalize(_+1),this._legalize(R+2);return}let h=u-u%3,p=h+(u+2)%3,d=h+(u+1)%3,m=this.triangles[p],g=this._halfedges[p],x=this._halfedges[d];this._queueRemove(h/3);let b=this._addTriangle(i,a,e,f,-1,-1,n),M=this._addTriangle(a,m,e,x,-1,b+1,h),E=this._addTriangle(m,c,e,g,-1,M+1),C=this._addTriangle(c,i,e,l,b+2,E+1);this._legalize(b),this._legalize(M),this._legalize(E),this._legalize(C)}_queuePush(e,r,n){let o=this._queue.length;this._queueIndices[e]=o,this._queue.push(e),this._errors.push(r),this._rmsSum+=n,this._queueUp(o)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let o=this._pending.indexOf(e);if(o!==-1)this._pending[o]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let n=this._queue.length-1;n!==r&&(this._queueSwap(r,n),this._queueDown(r,n)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let n=this._queue[e],o=this._queue[r];this._queue[e]=o,this._queue[r]=n,this._queueIndices[n]=r,this._queueIndices[o]=e;let s=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=s}_queueUp(e){let r=e;for(;;){let n=r-1>>1;if(n===r||!this._queueLess(r,n))break;this._queueSwap(n,r),r=n}}_queueDown(e,r){let n=e;for(;;){let o=2*n+1;if(o>=r||o<0)break;let s=o+1,i=o;if(s<r&&this._queueLess(s,o)&&(i=s),!this._queueLess(i,n))break;this._queueSwap(n,i),n=i}return n>e}};function Br(t,e,r,n,o,s){return(r-o)*(e-s)-(n-s)*(t-o)}function nR(t,e,r,n,o,s,i,a){let c=t-i,l=e-a,f=r-i,u=n-a,h=o-i,p=s-a,d=c*c+l*l,m=f*f+u*u,g=h*h+p*p;return c*(u*g-m*p)-l*(f*g-m*h)+d*(f*p-u*h)<0}function K0(t,e){let{meshMaxError:r,bounds:n,elevationDecoder:o}=e,{data:s,width:i,height:a}=t,c,l;switch(e.tesselator){case"martini":c=Hi(s,i,a,o,e.tesselator),l=X0(r,i,c);break;case"delatin":c=Hi(s,i,a,o,e.tesselator),l=Y0(r,i,a,c);break;default:i===a&&!(a&i-1)?(c=Hi(s,i,a,o,"martini"),l=X0(r,i,c)):(c=Hi(s,i,a,o,"delatin"),l=Y0(r,i,a,c));break}let{vertices:f}=l,{triangles:u}=l,h=oR(f,c,i,a,n),p=br(h);if(e.skirtHeight){let{attributes:d,triangles:m}=Vi(h,u,e.skirtHeight);h=d,u=m}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:p},mode:4,indices:{value:Uint32Array.from(u),size:1},attributes:h}}function X0(t,e,r){let n=e+1,s=new wo(n).createTile(r),{vertices:i,triangles:a}=s.getMesh(t);return{vertices:i,triangles:a}}function Y0(t,e,r,n){let o=new Lo(n,e+1,r+1);o.run(t);let{coords:s,triangles:i}=o;return{vertices:s,triangles:i}}function Hi(t,e,r,n,o){let{rScaler:s,bScaler:i,gScaler:a,offset:c}=n,l=new Float32Array((e+1)*(r+1));for(let f=0,u=0;u<r;u++)for(let h=0;h<e;h++,f++){let p=f*4,d=t[p+0],m=t[p+1],g=t[p+2];l[f+u]=d*s+m*a+g*i+c}if(o==="martini"){for(let f=(e+1)*e,u=0;u<e;u++,f++)l[f]=l[f-e-1];for(let f=r,u=0;u<r+1;u++,f+=r+1)l[f]=l[f-1]}return l}function oR(t,e,r,n,o){let s=r+1,i=t.length/2,a=new Float32Array(i*3),c=new Float32Array(i*2),[l,f,u,h]=o||[0,0,r,n],p=(u-l)/r,d=(h-f)/n;for(let m=0;m<i;m++){let g=t[m*2],x=t[m*2+1],b=x*s+g;a[3*m+0]=g*p+l,a[3*m+1]=-x*d+h,a[3*m+2]=e[b],c[2*m+0]=g/r,c[2*m+1]=x/n}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:c,size:2}}}var zi="4.4.3";var ki={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:zi,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var Q0={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:zi,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var sR={...ki,parse:iR};async function iR(t,e,r){let n={...e,core:{...e?.core,mimeType:"application/x.image"},image:{...e?.image,type:"data"}},o=await Oe(t,[],n,r),s={...sR.options.terrain,...e?.terrain};return K0(o,s)}var f5={...Q0,parseSync:(t,e)=>gf(t,e?.["quantized-mesh"]),parse:async(t,e)=>gf(t,e?.["quantized-mesh"])};var Z0=[1],$0=1,e1=1,ji=90,qi=180,aR={...mr.defaultProps,elevationData:Ht,texture:{...Ht,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[ki]};function t1(t){return Array.isArray(t)?t.join(";"):t||""}function cR(t,e,r){let n=(t[2]-t[0])/e*$0,o=(t[3]-t[1])/e*$0,s=[t[0]-n,t[1]-o,t[2]+n,t[3]+o];return r?[Math.max(s[0],-qi),Math.max(s[1],-ji),Math.min(s[2],qi),Math.min(s[3],ji)]:s}function lR(t){return!Number.isFinite(t)||t<=0?e1:Math.max(t,e1)}var Fo=class extends dt.CompositeLayer{updateState({props:e,oldProps:r}){let n=e.elevationData!==r.elevationData;if(n){let{elevationData:s}=e,i=s&&(Array.isArray(s)||fR(s));this.setState({isTiled:i})}let o=n||e.meshMaxError!==r.meshMaxError||e.elevationDecoder!==r.elevationDecoder||e.bounds!==r.bounds;if(!this.state.isTiled&&o){let s=this.loadTerrain(e);this.setState({terrain:s})}e.workerUrl&&dt.log.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:r,elevationDecoder:n,meshMaxError:o,signal:s}){if(!e)return null;let i=lR(o),a=this.getLoadOptions();a={...a,terrain:{skirtHeight:this.state.isTiled?i*2:0,...a?.terrain,bounds:r,meshMaxError:i,elevationDecoder:n}};let{fetch:c}=this.props;return c(e,{propName:"elevationData",layer:this,loadOptions:a,signal:s})}getTiledTerrainData(e){let{elevationData:r,fetch:n,texture:o,elevationDecoder:s,meshMaxError:i}=this.props,{viewport:a}=this.context,c=ut(r,e),l=o&&ut(o,e),{signal:f}=e,u=[0,0],h=[0,0];if(a.isGeospatial){let x=e.bbox;u=a.projectFlat([x.west,x.south]),h=a.projectFlat([x.east,x.north])}else{let x=e.bbox;u=[x.left,x.bottom],h=[x.right,x.top]}let p=[u[0],u[1],h[0],h[1]],d=cR(p,this.props.tileSize,a instanceof dt._GlobeViewport),m=this.loadTerrain({elevationData:c,bounds:d,elevationDecoder:s,meshMaxError:i,signal:f}),g=l?n(l,{propName:"texture",layer:this,loaders:[],signal:f}).catch(x=>null):Promise.resolve(null);return Promise.all([m,g])}renderSubLayers(e){let r=this.getSubLayerClass("mesh",xf.SimpleMeshLayer),{color:n,wireframe:o,material:s}=this.props,{data:i}=e;if(!i)return null;let[a,c]=i,{viewport:l}=this.context,f=l instanceof dt._GlobeViewport,u=a?.header?.boundingBox,h=u&&u.every(([d,m])=>d>=-qi&&d<=qi&&m>=-ji&&m<=ji),p=f&&h?dt.COORDINATE_SYSTEM.LNGLAT:dt.COORDINATE_SYSTEM.CARTESIAN;return new r(e,{data:Z0,mesh:a,texture:c,_instanced:!1,coordinateSystem:p,getPosition:d=>[0,0,0],getColor:n,wireframe:o,material:s})}onViewportLoad(e){if(!e)return;let{zRange:r}=this.state,n=e.map(i=>i.content).filter(Boolean).map(i=>i[0].header.boundingBox.map(c=>c[2]));if(n.length===0)return;let o=Math.min(...n.map(i=>i[0])),s=Math.max(...n.map(i=>i[1]));(!r||o<r[0]||s>r[1])&&this.setState({zRange:[o,s]})}renderLayers(){let{color:e,material:r,elevationData:n,texture:o,wireframe:s,meshMaxError:i,elevationDecoder:a,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:h,onTileLoad:p,onTileUnload:d,onTileError:m,maxCacheSize:g,maxCacheByteSize:x,refinementStrategy:b,zoomOffset:M}=this.props;if(this.state.isTiled)return new mr(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:t1(n),texture:t1(o),meshMaxError:i,elevationDecoder:a,projectionMode:this.context.viewport.projectionMode,zoomOffset:M}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:h,onTileLoad:p,onTileUnload:d,onTileError:m,maxCacheSize:g,maxCacheByteSize:x,refinementStrategy:b,zoomOffset:M});if(!n)return null;let E=this.getSubLayerClass("mesh",xf.SimpleMeshLayer);return new E(this.getSubLayerProps({id:"mesh"}),{data:Z0,mesh:this.state.terrain,texture:o,_instanced:!1,getPosition:C=>[0,0,0],getColor:e,material:r,wireframe:s})}};Fo.defaultProps=aR;Fo.layerName="TerrainLayer";var r1=Fo,fR=t=>t.includes("{x}")&&(t.includes("{y}")||t.includes("{-y}"));var ra=D(ot(),1),Nf=D(Xe(),1),O1=D(o1(),1);function s1(t,e,r){switch(t.type){case"Point":return hR(t,e,r);case"LineString":return uR(t,e,r);case"Polygon":return i1(t,e,r);default:let n=t;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function i1(t,e=-1/0,r=1/0){let{positions:n}=t,o=t.polygonIndices.value.filter(c=>c>=e&&c<=r),s=t.primitivePolygonIndices.value.filter(c=>c>=e&&c<=r);if(!(o.length>2)){let c=[];for(let l=0;l<s.length-1;l++){let f=s[l],u=s[l+1],h=Ji(n,f,u);c.push(h)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<o.length-1;c++){let l=o[c],f=o[c+1],u=i1(t,l,f).coordinates;a.push(u)}return{type:"MultiPolygon",coordinates:a}}function uR(t,e=-1/0,r=1/0){let{positions:n}=t,o=t.pathIndices.value.filter(a=>a>=e&&a<=r);if(!(o.length>2))return{type:"LineString",coordinates:Ji(n,o[0],o[1])};let i=[];for(let a=0;a<o.length-1;a++){let c=Ji(n,o[a],o[a+1]);i.push(c)}return{type:"MultiLineString",coordinates:i}}function hR(t,e,r){let{positions:n}=t,o=Ji(n,e,r);return o.length>1?{type:"MultiPoint",coordinates:o}:{type:"Point",coordinates:o[0]}}function Ji(t,e,r){e=e||0,r=r||t.value.length/t.size;let n=[];for(let o=e;o<r;o++){let s=Array();for(let i=o*t.size;i<(o+1)*t.size;i++)s.push(Number(t.value[i]));n.push(s)}return n}var Po={x:0,y:1,z:2};function Ir(t,e={}){let{start:r=0,end:n=t.length,plane:o="xy"}=e,s=e.size||2,i=0,a=Po[o[0]],c=Po[o[1]];for(let l=r,f=n-s;l<n;l+=s)i+=(t[l+a]-t[f+a])*(t[l+c]+t[f+c]),f=l;return i/2}function bf(t,e,r=2,n,o="xy"){let s=e&&e.length,i=s?e[0]*r:t.length,a=c1(t,0,i,r,!0,n&&n[0],o),c=[];if(!a||a.next===a.prev)return c;let l,f,u,h,p,d,m;if(s&&(a=yR(t,e,a,r,n,o)),t.length>80*r){h=f=t[0],p=u=t[1];for(let g=r;g<i;g+=r)d=t[g],m=t[g+1],d<h&&(h=d),m<p&&(p=m),d>f&&(f=d),m>u&&(u=m);l=Math.max(f-h,u-p),l=l!==0?32767/l:0}return No(a,c,r,h,p,l,0),c}function c1(t,e,r,n,o,s,i){let a,c;s===void 0&&(s=Ir(t,{start:e,end:r,size:n,plane:i}));let l=Po[i[0]],f=Po[i[1]];if(o===s<0)for(a=e;a<r;a+=n)c=a1(a,t[a+l],t[a+f],c);else for(a=r-n;a>=e;a-=n)c=a1(a,t[a+l],t[a+f],c);return c&&Yi(c,c.next)&&(Uo(c),c=c.next),c}function Rr(t,e){if(!t)return t;e||(e=t);let r=t,n;do if(n=!1,!r.steiner&&(Yi(r,r.next)||ne(r.prev,r,r.next)===0)){if(Uo(r),r=e=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==e);return e}function No(t,e,r,n,o,s,i){if(!t)return;!i&&s&&SR(t,n,o,s);let a=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,s?gR(t,n,o,s):mR(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),Uo(t),t=l.next,a=l.next;continue}if(t=l,t===a){i?i===1?(t=AR(Rr(t),e,r),No(t,e,r,n,o,s,2)):i===2&&xR(t,e,r,n,o,s):No(Rr(t),e,r,n,o,s,1);break}}}function mR(t){let e=t.prev,r=t,n=t.next;if(ne(e,r,n)>=0)return!1;let o=e.x,s=r.x,i=n.x,a=e.y,c=r.y,l=n.y,f=o<s?o<i?o:i:s<i?s:i,u=a<c?a<l?a:l:c<l?c:l,h=o>s?o>i?o:i:s>i?s:i,p=a>c?a>l?a:l:c>l?c:l,d=n.next;for(;d!==e;){if(d.x>=f&&d.x<=h&&d.y>=u&&d.y<=p&&bn(o,a,s,c,i,l,d.x,d.y)&&ne(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function gR(t,e,r,n){let o=t.prev,s=t,i=t.next;if(ne(o,s,i)>=0)return!1;let a=o.x,c=s.x,l=i.x,f=o.y,u=s.y,h=i.y,p=a<c?a<l?a:l:c<l?c:l,d=f<u?f<h?f:h:u<h?u:h,m=a>c?a>l?a:l:c>l?c:l,g=f>u?f>h?f:h:u>h?u:h,x=yf(p,d,e,r,n),b=yf(m,g,e,r,n),M=t.prevZ,E=t.nextZ;for(;M&&M.z>=x&&E&&E.z<=b;){if(M.x>=p&&M.x<=m&&M.y>=d&&M.y<=g&&M!==o&&M!==i&&bn(a,f,c,u,l,h,M.x,M.y)&&ne(M.prev,M,M.next)>=0||(M=M.prevZ,E.x>=p&&E.x<=m&&E.y>=d&&E.y<=g&&E!==o&&E!==i&&bn(a,f,c,u,l,h,E.x,E.y)&&ne(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;M&&M.z>=x;){if(M.x>=p&&M.x<=m&&M.y>=d&&M.y<=g&&M!==o&&M!==i&&bn(a,f,c,u,l,h,M.x,M.y)&&ne(M.prev,M,M.next)>=0)return!1;M=M.prevZ}for(;E&&E.z<=b;){if(E.x>=p&&E.x<=m&&E.y>=d&&E.y<=g&&E!==o&&E!==i&&bn(a,f,c,u,l,h,E.x,E.y)&&ne(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function AR(t,e,r){let n=t;do{let o=n.prev,s=n.next.next;!Yi(o,s)&&l1(o,n,n.next,s)&&Oo(o,s)&&Oo(s,o)&&(e.push(o.i/r|0),e.push(n.i/r|0),e.push(s.i/r|0),Uo(n),Uo(n.next),n=t=s),n=n.next}while(n!==t);return Rr(n)}function xR(t,e,r,n,o,s){let i=t;do{let a=i.next.next;for(;a!==i.prev;){if(i.i!==a.i&&BR(i,a)){let c=f1(i,a);i=Rr(i,i.next),c=Rr(c,c.next),No(i,e,r,n,o,s,0),No(c,e,r,n,o,s,0);return}a=a.next}i=i.next}while(i!==t)}function yR(t,e,r,n,o,s){let i=[],a,c,l,f,u;for(a=0,c=e.length;a<c;a++)l=e[a]*n,f=a<c-1?e[a+1]*n:t.length,u=c1(t,l,f,n,!1,o&&o[a+1],s),u===u.next&&(u.steiner=!0),i.push(CR(u));for(i.sort(bR),a=0;a<i.length;a++)r=TR(i[a],r);return r}function bR(t,e){return t.x-e.x}function TR(t,e){let r=MR(t,e);if(!r)return e;let n=f1(r,t);return Rr(n,n.next),Rr(r,r.next)}function MR(t,e){let r=e,n=t.x,o=t.y,s=-1/0,i;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){let h=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=n&&h>s&&(s=h,i=r.x<r.next.x?r:r.next,h===n))return i}r=r.next}while(r!==e);if(!i)return null;let a=i,c=i.x,l=i.y,f=1/0,u;r=i;do n>=r.x&&r.x>=c&&n!==r.x&&bn(o<l?n:s,o,c,l,o<l?s:n,o,r.x,r.y)&&(u=Math.abs(o-r.y)/(n-r.x),Oo(r,t)&&(u<f||u===f&&(r.x>i.x||r.x===i.x&&ER(i,r)))&&(i=r,f=u)),r=r.next;while(r!==a);return i}function ER(t,e){return ne(t.prev,t,e.prev)<0&&ne(e.next,t,t.next)<0}function SR(t,e,r,n){let o=t;do o.z===0&&(o.z=yf(o.x,o.y,e,r,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,_R(o)}function _R(t){let e,r,n=1,o,s,i,a,c,l;do{for(s=t,t=null,l=null,o=0;s;){for(o++,a=s,i=0,r=0;r<n&&(i++,a=a.nextZ,!!a);r++);for(c=n;i>0||c>0&&a;)i!==0&&(c===0||!a||s.z<=a.z)?(e=s,s=s.nextZ,i--):(e=a,a=a.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;s=a}l.nextZ=null,n*=2}while(o>1);return t}function yf(t,e,r,n,o){return t=(t-r)*o|0,e=(e-n)*o|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function CR(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function bn(t,e,r,n,o,s,i,a){return(o-i)*(e-a)>=(t-i)*(s-a)&&(t-i)*(n-a)>=(r-i)*(e-a)&&(r-i)*(s-a)>=(o-i)*(n-a)}function BR(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!IR(t,e)&&(Oo(t,e)&&Oo(e,t)&&RR(t,e)&&(ne(t.prev,t,e.prev)||ne(t,e.prev,e))||Yi(t,e)&&ne(t.prev,t,t.next)>0&&ne(e.prev,e,e.next)>0)}function ne(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Yi(t,e){return t.x===e.x&&t.y===e.y}function l1(t,e,r,n){let o=Xi(ne(t,e,r)),s=Xi(ne(t,e,n)),i=Xi(ne(r,n,t)),a=Xi(ne(r,n,e));return!!(o!==s&&i!==a||o===0&&Wi(t,r,e)||s===0&&Wi(t,n,e)||i===0&&Wi(r,t,n)||a===0&&Wi(r,e,n))}function Wi(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Xi(t){return t>0?1:t<0?-1:0}function IR(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&l1(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function Oo(t,e){return ne(t.prev,t,t.next)<0?ne(t,e,t.next)>=0&&ne(t,t.prev,e)>=0:ne(t,e,t.prev)<0||ne(t,t.next,e)<0}function RR(t,e){let r=t,n=!1,o=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&r.next.y!==r.y&&o<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==t);return n}function f1(t,e){let r=new Do(t.i,t.x,t.y),n=new Do(e.i,e.x,e.y),o=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=o,o.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function a1(t,e,r,n){let o=new Do(t,e,r);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.next=o):(o.prev=o,o.next=o),o}function Uo(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)}var Do=class{constructor(e,r,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=n}};function Ki(t,e,r){let n=PR(t),o=Object.keys(n).filter(s=>n[s]!==Array);return NR(t,{propArrayTypes:n,...e},{numericPropKeys:r&&r.numericPropKeys||o,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function PR(t){let e={};for(let r of t)if(r.properties)for(let n in r.properties){let o=r.properties[n];e[n]=HR(o,e[n])}return e}function NR(t,e,r){let{pointPositionsCount:n,pointFeaturesCount:o,linePositionsCount:s,linePathsCount:i,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:h,coordLength:p}=e,{numericPropKeys:d=[],PositionDataType:m=Float32Array,triangulate:g=!0}=r,x=t[0]&&"id"in t[0],b=t.length>65535?Uint32Array:Uint16Array,M={type:"Point",positions:new m(n*p),globalFeatureIds:new b(n),featureIds:o>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},E={type:"LineString",pathIndices:s>65535?new Uint32Array(i+1):new Uint16Array(i+1),positions:new m(s*p),globalFeatureIds:new b(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},C={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new m(c*p),globalFeatureIds:new b(c),featureIds:u>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};g&&(C.triangles=[]);for(let R of[M,E,C])for(let S of d){let T=h[S];R.numericProps[S]=new T(R.positions.length/p)}E.pathIndices[i]=s,C.polygonIndices[l]=c,C.primitivePolygonIndices[f]=c;let _={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let R of t){let S=R.geometry,T=R.properties||{};switch(S.type){case"Point":OR(S,M,_,p,T),M.properties.push(Mf(T,d)),x&&M.fields.push({id:R.id}),_.pointFeature++;break;case"LineString":UR(S,E,_,p,T),E.properties.push(Mf(T,d)),x&&E.fields.push({id:R.id}),_.lineFeature++;break;case"Polygon":DR(S,C,_,p,T),C.properties.push(Mf(T,d)),x&&C.fields.push({id:R.id}),_.polygonFeature++;break;default:throw new Error("Invalid geometry type")}_.feature++}return VR(M,E,C,p)}function OR(t,e,r,n,o){e.positions.set(t.data,r.pointPosition*n);let s=t.data.length/n;Ef(e,o,r.pointPosition,s),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+s),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+s),r.pointPosition+=s}function UR(t,e,r,n,o){e.positions.set(t.data,r.linePosition*n);let s=t.data.length/n;Ef(e,o,r.linePosition,s),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+s),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+s);for(let i=0,a=t.indices.length;i<a;++i){let c=t.indices[i],l=i===a-1?t.data.length:t.indices[i+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/n}}function DR(t,e,r,n,o){e.positions.set(t.data,r.polygonPosition*n);let s=t.data.length/n;Ef(e,o,r.polygonPosition,s),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+s),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+s);for(let i=0,a=t.indices.length;i<a;++i){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[i],f=t.indices[i],u=t.indices[i+1];for(let p=0,d=f.length;p<d;++p){let m=f[p],g=p===d-1?u===void 0?t.data.length:u[0]:f[p+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(g-m)/n}let h=r.polygonPosition;GR(e,l,f,{startPosition:c,endPosition:h,coordLength:n})}}function GR(t,e,r,{startPosition:n,endPosition:o,coordLength:s}){if(!t.triangles)return;let i=n*s,a=o*s,c=t.positions.subarray(i,a),l=r[0],f=r.slice(1).map(h=>(h-l)/s),u=bf(c,f,s,e);for(let h=0,p=u.length;h<p;++h)t.triangles.push(n+u[h])}function Tf(t,e){let r={};for(let n in t)r[n]={value:t[n],size:e};return r}function VR(t,e,r,n){let o={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:n},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Tf(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:n},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Tf(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:n},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:Tf(r.numericProps,1)}};return o.polygons&&r.triangles&&(o.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),o}function Ef(t,e,r,n){for(let o in t.numericProps)if(o in e){let s=e[o];t.numericProps[o].fill(s,r,r+n)}}function Mf(t,e){let r={};for(let n in t)e.includes(n)||(r[n]=t[n]);return r}function HR(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function Go(t,e){let r=e?.globalFeatureId;return r!==void 0?zR(t,r):kR(t,e?.type)}function zR(t,e){let r=p1(t);for(let n of r){let o=0,s=n.featureIds.value[0];for(let i=0;i<n.featureIds.value.length;i++){let a=n.featureIds.value[i];if(a!==s){if(e===n.globalFeatureIds.value[o])return Qi(n,o,i);o=i,s=a}}if(e===n.globalFeatureIds.value[o])return Qi(n,o,n.featureIds.value.length)}throw new Error(`featureId:${e} not found`)}function kR(t,e){let r=p1(t,e);return jR(r)}function p1(t,e){let r=[];return t.points&&(t.points.type="Point",r.push(t.points)),t.lines&&(t.lines.type="LineString",r.push(t.lines)),t.polygons&&(t.polygons.type="Polygon",r.push(t.polygons)),r}function jR(t){let e=[];for(let r of t){if(r.featureIds.value.length===0)continue;let n=0,o=r.featureIds.value[0];for(let s=0;s<r.featureIds.value.length;s++){let i=r.featureIds.value[s];i!==o&&(e.push(Qi(r,n,s)),n=s,o=i)}e.push(Qi(r,n,r.featureIds.value.length))}return e}function Qi(t,e,r){let n=s1(t,e,r),o=JR(t,e,r),s=qR(t,e,r);return{type:"Feature",geometry:n,properties:o,...s}}function qR(t,e=0,r){return t.fields&&t.fields[t.featureIds.value[e]]}function JR(t,e=0,r){let n=Object.assign({},t.properties[t.featureIds.value[e]]);for(let o in t.numericProps)n[o]=t.numericProps[o].value[e];return n}var Rf=D(b1(),1);function fv(t){let e=0;for(let r=0,n=t.length-1,o,s;r<t.length;n=r++)o=t[r],s=t[n],e+=(s[0]-o[0])*(o[1]+s[1]);return e}function Cf(t,e){if(Array.isArray(t[0])){for(let n of t)Cf(n,e);return}let r=t;r[0]/=e,r[1]/=e}function T1(t,e){for(let r=0;r<t.length;++r)t[r]/=e}function Bf(t,e,r){if(typeof t[0][0]!="number"){for(let i of t)Bf(i,e,r);return}let n=r*Math.pow(2,e.z),o=r*e.x,s=r*e.y;for(let i=0;i<t.length;i++){let a=t[i];a[0]=(a[0]+o)*360/n-180;let c=180-(a[1]+s)*360/n;a[1]=360/Math.PI*Math.atan(Math.exp(c*Math.PI/180))-90}}function M1(t,e,r){let{x:n,y:o,z:s}=e,i=r*Math.pow(2,s),a=r*n,c=r*o;for(let l=0,f=t.length;l<f;l+=2){t[l]=(t[l]+a)*360/i-180;let u=180-(t[l+1]+c)*360/i;t[l+1]=360/Math.PI*Math.atan(Math.exp(u*Math.PI/180))-90}}function E1(t){let e=t.length;if(e<=1)return[t];let r=[],n,o;for(let s=0;s<e;s++){let i=fv(t[s]);i!==0&&(o===void 0&&(o=i<0),o===i<0?(n&&r.push(n),n=[t[s]]):n&&n.push(t[s]))}return n&&r.push(n),r}function S1(t){let e=t.indices.length,r="Polygon";if(e<=1)return{type:r,data:t.data,areas:[[Ir(t.data)]],indices:[t.indices]};let n=[],o=[],s=[],i=[],a,c=0;for(let l,f=0,u;f<e;f++){u=t.indices[f]-c,l=t.indices[f+1]-c||t.data.length;let h=t.data.slice(u,l),p=Ir(h);if(p===0){let d=t.data.slice(0,u),m=t.data.slice(l);t.data=d.concat(m),c+=l-u;continue}a===void 0&&(a=p<0),a===p<0?(i.length&&(n.push(s),o.push(i)),i=[u],s=[p]):(s.push(p),i.push(u))}return s&&n.push(s),i.length&&o.push(i),{type:r,areas:n,indices:o,data:t.data}}var vr=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(e,r,n,o,s,i){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=e,this._geometry=-1,this._keys=o,this._values=s,this._geometryInfo=i,e.readFields(uv,this,r)}toGeoJSONFeature(e,r){let n=this.loadGeometry();switch(e){case"wgs84":return _1(this,n,o=>Bf(o,r,this.extent));default:return _1(this,n,Cf)}}toBinaryFeature(e,r){let n=this.loadFlatGeometry();switch(e){case"wgs84":return this._toBinaryCoordinates(n,o=>M1(o,r,this.extent));default:return this._toBinaryCoordinates(n,T1)}}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o=0,s=0,i=0,a=1/0,c=-1/0,l=1/0,f=-1/0;for(;e.pos<r;){if(o<=0){let u=e.readVarint();n=u&7,o=u>>3}if(o--,n===1||n===2)s+=e.readSVarint(),i+=e.readSVarint(),s<a&&(a=s),s>c&&(c=s),i<l&&(l=i),i>f&&(f=i);else if(n!==7)throw new Error(`unknown command ${n}`)}return[a,l,c,f]}_toBinaryCoordinates(e,r){let n;r(e.data,this.extent);let o=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=e.indices.length,n={type:"Point",...e};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=e.indices.length,this._geometryInfo.linePositionsCount+=e.data.length/o,n={type:"LineString",...e};break;case 3:n=S1(e),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=n.indices.length;for(let i of n.indices)this._geometryInfo.polygonRingsCount+=i.length;this._geometryInfo.polygonPositionsCount+=n.data.length/o;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let s={type:"Feature",geometry:n,properties:this.properties};return this.id!==null&&(s.id=this.id),s}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o=0,s=0,i=0,a=[],c;for(;e.pos<r;){if(o<=0){let l=e.readVarint();n=l&7,o=l>>3}switch(o--,n){case 1:case 2:s+=e.readSVarint(),i+=e.readSVarint(),n===1&&(c&&a.push(c),c=[]),c&&c.push([s,i]);break;case 7:c&&c.push(c[0].slice());break;default:throw new Error(`unknown command ${n}`)}}return c&&a.push(c),a}loadFlatGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o,s=0,i=0,a=0,c=0,l=[],f=[];for(;e.pos<r;)if(s<=0&&(o=e.readVarint(),n=o&7,s=o>>3),s--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),n===1&&l.push(c),f.push(i,a),c+=2;else if(n===7){if(c>0){let u=l[l.length-1];f.push(f[u],f[u+1]),c+=2}}else throw new Error(`unknown command ${n}`);return{data:f,indices:l}}};Xt(vr,"types",["Unknown","Point","LineString","Polygon"]);function _1(t,e,r){let n=vr.types[t.type],o,s,i;switch(t.type){case 1:let c=[];for(o=0;o<e.length;o++)c[o]=e[o][0];i=c,r(i,t.extent);break;case 2:for(i=e,o=0;o<i.length;o++)r(i[o],t.extent);break;case 3:for(i=E1(e),o=0;o<i.length;o++)for(s=0;s<i[o].length;s++)r(i[o][s],t.extent);break;default:throw new Error("illegal vector tile type")}i.length===1?i=i[0]:n=`Multi${n}`;let a={type:"Feature",geometry:{type:n,coordinates:i},properties:t.properties};return t.id!==null&&(a.properties||={},a.properties.id=t.id),a}function uv(t,e,r){e&&r&&(t===1?e.id=r.readVarint():t===2?hv(r,e):t===3?e.type=r.readVarint():t===4&&(e._geometry=r.pos))}function hv(t,e){let r=t.readVarint()+t.pos;for(;t.pos<r;){let n=e._keys[t.readVarint()],o=e._values[t.readVarint()];e.properties[n]=o}}var ea=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(pv,this,r),this.length=this._features.length}getGeoJSONFeature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new vr(this._pbf,r,this.extent,this._keys,this._values)}getBinaryFeature(e,r){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let n=this._pbf.readVarint()+this._pbf.pos;return new vr(this._pbf,n,this.extent,this._keys,this._values,r)}};function pv(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(dv(r)))}function dv(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos<r;){let n=t.readVarint()>>3;e=n===1?t.readString():n===2?t.readFloat():n===3?t.readDouble():n===4?t.readVarint64():n===5?t.readVarint():n===6?t.readSVarint():n===7?t.readBoolean():null}return e}var Vo=class{layers;constructor(e,r){this.layers=e.readFields(mv,{},r)}};function mv(t,e,r){if(t===3&&r){let n=new ea(r,r.readVarint()+r.pos);n.length&&e&&(e[n.name]=n)}}function vf(t,e){let r=Av(e),n=e?.gis?.format||e?.mvt?.shape||e?.shape;switch(n){case"columnar-table":return{shape:"columnar-table",data:If(t,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:C1(t,r)};case"geojson":return C1(t,r);case"binary-geometry":return If(t,r);case"binary":return If(t,r);default:throw new Error(n||"undefined shape")}}function If(t,e){let[r,n]=gv(t,e),o=Ki(r,n);return o.byteLength=t.byteLength,o}function gv(t,e){let r=[],n={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength<=0)return[r,n];let o=new Vo(new Rf.default(t));return(e&&Array.isArray(e.layers)?e.layers:Object.keys(o.layers)).forEach(i=>{let a=o.layers[i];if(a)for(let c=0;c<a.length;c++){let l=a.getBinaryFeature(c,n),f=yv(l,e,i);r.push(f)}}),[r,n]}function C1(t,e){if(t.byteLength<=0)return[];let r=[],n=new Vo(new Rf.default(t));return(Array.isArray(e.layers)?e.layers:Object.keys(n.layers)).forEach(s=>{let i=n.layers[s];if(i)for(let a=0;a<i.length;a++){let c=i.getGeoJSONFeature(a),l=xv(c,e,s);r.push(l)}}),r}function Av(t){if(!t?.mvt)throw new Error("mvt options required");if(t.mvt?.coordinates==="wgs84"&&!t.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return t.gis&&gc.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),t.mvt}function xv(t,e,r){let n=t.toGeoJSONFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&(n.properties||={},n.properties[e.layerProperty]=r),n}function yv(t,e,r){let n=t.toBinaryFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&n.properties&&(n.properties[e.layerProperty]=r),n}var B1={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry"};var bv="4.4.3",ta={...B1,dataType:null,batchType:null,version:bv,worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},Tv={...ta,parse:async(t,e)=>vf(t,e),parseSync:vf,binary:!0};var Mv={Point:I1,MultiPoint:Ev,LineString:R1,MultiLineString:Sv,Polygon:v1,MultiPolygon:_v};function I1([t,e],[r,n],o){let s=It(r[0],n[0],t),i=It(r[1],n[1],e);return o.unprojectFlat([s,i])}function wf(t,e,r){return t.map(n=>I1(n,e,r))}function Ev(t,e,r){return wf(t,e,r)}function R1(t,e,r){return wf(t,e,r)}function Sv(t,e,r){return t.map(n=>R1(n,e,r))}function v1(t,e,r){return t.map(n=>wf(n,e,r))}function _v(t,e,r){return t.map(n=>v1(n,e,r))}function w1(t,e,r){let n=r.projectFlat([e.west,e.north]),o=r.projectFlat([e.east,e.south]),s=[n,o];return{...t,coordinates:Mv[t.type](t.coordinates,s,r)}}var Cv=["points","lines","polygons"];function Lf(t,e,r,n){for(let o of Cv){let s=t[o]&&Bv(t[o],e,r,n);if(s>=0)return s}return-1}function Bv(t,e,r,n){let o=t.featureIds.value;if(!o.length)return-1;let s=0,i=o[o.length-1]+1;if(n){let c=Iv(t,n);if(c)s=c[0],i=c[1]+1;else return-1}let a=-1;if(e in t.numericProps){let c=t.numericProps[e].value.findIndex((l,f)=>l===r&&o[f]>=s&&o[f]<i);return c>=0?t.globalFeatureIds.value[c]:-1}else e?a=L1(t.properties,c=>c[e]===r,s,i):t.fields&&(a=L1(t.fields,c=>c.id===r,s,i));return a>=0?Rv(t,a):-1}function Iv(t,e){if(!t.__layers){let r={},{properties:n}=t;for(let o=0;o<n.length;o++){let{layerName:s}=n[o];s&&(r[s]?r[s][1]=o:r[s]=[o,o])}t.__layers=r}return t.__layers[e]}function Rv(t,e){if(!t.__ids){let r=[],n=t.featureIds.value,o=t.globalFeatureIds.value;for(let s=0;s<n.length;s++)r[n[s]]=o[s];t.__ids=r}return t.__ids[e]}function L1(t,e,r,n){for(let o=r;o<n;o++)if(e(t[o],o))return o;return-1}var Ff=512,vv={...Nf.GeoJsonLayer.defaultProps,data:Ht,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[ta],binary:!0},Ho=class extends mr{initializeState(){super.initializeState();let e=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:e,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:e,oldProps:r,context:n,changeFlags:o}){o.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:r,context:n,changeFlags:o}),this._setWGS84PropertyForTiles());let{highlightColor:s}=e;s!==r.highlightColor&&Array.isArray(s)&&this.setState({highlightColor:s})}async _updateTileData(){let e=this.props.data,r=null;if(typeof e=="string"&&!jc(e)){let{onDataLoad:n,fetch:o}=this.props;this.setState({data:null,tileJSON:null});try{r=await o(e,{propName:"data",layer:this,loaders:[]})}catch(s){this.raiseError(s,"loading TileJSON"),e=null}n&&n(r,{propName:"data",layer:this})}else e&&typeof e=="object"&&"tilejson"in e&&(r=e);r&&(e=r.tiles),this.setState({data:e,tileJSON:r})}_getTilesetOptions(){let e=super._getTilesetOptions(),r=this.state.tileJSON,{minZoom:n,maxZoom:o}=this.props;return r&&(Number.isFinite(r.minzoom)&&r.minzoom>n&&(e.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(o)||r.maxzoom<o)&&(e.maxZoom=r.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){let{data:r,binary:n}=this.state,{index:o,signal:s}=e,i=ut(r,e);if(!i)return Promise.reject("Invalid URL");let a=this.getLoadOptions(),{fetch:c}=this.props;return a={...a,core:{...a?.core,mimeType:"application/x-protobuf"},mvt:{...a?.mvt,shape:n?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:o}},c(i,{propName:"data",layer:this,loadOptions:a,signal:s})}renderSubLayers(e){let{x:r,y:n,z:o}=e.tile.index,s=Math.pow(2,o),i=Ff/s,a=-i,c=Ff*r/s,l=Ff*(1-n/s),f=new N().scale([i,a,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=f,e.coordinateOrigin=[c,l,0],e.coordinateSystem=ra.COORDINATE_SYSTEM.CARTESIAN,e.extensions=[...e.extensions||[],new O1.ClipExtension]);let u=super.renderSubLayers(e);return this.state.binary&&!(u instanceof Nf.GeoJsonLayer)&&ra.log.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),u}_updateAutoHighlight(e){let{uniqueIdProperty:r}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:o}=this.state,s=e.object,i=null,a=null;s&&(i=Pf(s,r),a=F1(s));let{highlightColor:c}=this.props;typeof c=="function"&&(c=c(e)),(n!==i||o!==a)&&this.setState({highlightColor:c,hoveredFeatureId:i,hoveredFeatureLayerName:a})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(e){let r=super.getPickingInfo(e);if(this.state.binary&&r.index!==-1){let{data:n}=e.sourceLayer.props;r.object=Go(n,{globalFeatureId:r.index})}return r.object&&!this._isWGS84()&&(r.object=N1(r.object,r.tile.bbox,this.context.viewport)),r}getSubLayerPropsByTile(e){return{highlightedObjectIndex:this.getHighlightedObjectIndex(e),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(e){let{hoveredFeatureId:r,hoveredFeatureLayerName:n,binary:o}=this.state,{uniqueIdProperty:s,highlightedFeatureId:i}=this.props,a=e.content,c=P1(i);if(!(P1(r)||c))return-1;let f=c?i:r;return Array.isArray(a)?a.findIndex(u=>{let h=Pf(u,s)===f,p=c||F1(u)===n;return h&&p}):a&&o?Lf(a,s,f,c?"":n):-1}_pickObjects(e){let{deck:r,viewport:n}=this.context,o=n.width,s=n.height,i=n.x,a=n.y,c=[this.id];return r.pickObjects({x:i,y:a,width:o,height:s,layerIds:c,maxObjects:e})}getRenderedFeatures(e=null){let r=this._pickObjects(e),n=new Set,o=[];for(let s of r){let i=Pf(s.object,this.props.uniqueIdProperty);i===void 0?o.push(s.object):n.has(i)||(n.add(i),o.push(s.object))}return o}_setWGS84PropertyForTiles(){let e="dataInWGS84";this.state.tileset.selectedTiles.forEach(n=>{n.hasOwnProperty(e)||Object.defineProperty(n,e,{get:()=>{if(!n.content)return null;if(this.state.binary&&Array.isArray(n.content)&&!n.content.length)return[];let{bbox:o}=n;if(n._contentWGS84===void 0&&qc(o)){let s=this.state.binary?Go(n.content):n.content;n._contentWGS84=s.map(i=>N1(i,o,this.context.viewport))}return n._contentWGS84}})})}};Ho.layerName="MVTLayer";Ho.defaultProps=vv;var U1=Ho;function Pf(t,e){if(t.properties&&e)return t.properties[e];if("id"in t)return t.id}function F1(t){return t.properties?.layerName||null}function P1(t){return t!=null&&t!==""}function N1(t,e,r){let n={...t,geometry:{type:t.geometry.type}};return Object.defineProperty(n.geometry,"coordinates",{get:()=>w1(t.geometry,e,r).coordinates}),n}var D1="0123456789bcdefghjkmnpqrstuvwxyz",G1={};for(let t=0;t<D1.length;t++)G1[D1.charAt(t)]=t;var wv=-90,Lv=90,Fv=-180,Pv=180;function Nv(t){let e=!0,r=Lv,n=wv,o=Pv,s=Fv,i,a=0;for(let c=0,l=t.length;c<l;c++){let f=t[c].toLowerCase();a=G1[f];for(let u=4;u>=0;u--){let h=a>>u&1;e?(i=(o+s)/2,h===1?s=i:o=i):(i=(r+n)/2,h===1?n=i:r=i),e=!e}}return[n,s,r,o]}function V1(t){let[e,r,n,o]=Nv(t);return[o,n,o,e,r,e,r,n,o,n]}var Ov={getGeohash:{type:"accessor",value:t=>t.geohash}},zo=class extends De{indexToBounds(){let{data:e,getGeohash:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,o)=>V1(r(n,o))}}};zo.layerName="GeohashLayer";zo.defaultProps=Ov;var H1=zo;return X1(ko);})();
|
|
3723
|
+
`;var Bm=`struct VertexInputs {
|
|
3724
|
+
@location(0) positions: vec3<f32>,
|
|
3725
|
+
#ifdef HAS_NORMALS
|
|
3726
|
+
@location(1) normals: vec3<f32>,
|
|
3727
|
+
#endif
|
|
3728
|
+
@location(2) colors: vec4<f32>,
|
|
3729
|
+
#ifdef HAS_UV
|
|
3730
|
+
@location(3) texCoords: vec2<f32>,
|
|
3731
|
+
#endif
|
|
3732
|
+
#ifdef HAS_UV_REGIONS
|
|
3733
|
+
@location(4) uvRegions: vec4<f32>,
|
|
3734
|
+
#endif
|
|
3735
|
+
#ifdef HAS_FEATURE_IDS
|
|
3736
|
+
@location(5) rowIndexes: u32,
|
|
3737
|
+
#endif
|
|
3738
|
+
@location(6) instanceColors: vec4<f32>,
|
|
3739
|
+
@location(7) instanceModelMatrixCol0: vec3<f32>,
|
|
3740
|
+
@location(8) instanceModelMatrixCol1: vec3<f32>,
|
|
3741
|
+
@location(9) instanceModelMatrixCol2: vec3<f32>,
|
|
3742
|
+
};
|
|
3743
|
+
|
|
3744
|
+
struct FragmentInputs {
|
|
3745
|
+
@builtin(position) position: vec4<f32>,
|
|
3746
|
+
@location(0) color: vec4<f32>,
|
|
3747
|
+
@location(1) texCoord: vec2<f32>,
|
|
3748
|
+
@location(2) pbrPosition: vec3<f32>,
|
|
3749
|
+
@location(3) pbrNormal: vec3<f32>,
|
|
3750
|
+
@location(4) pickingColor: vec3<f32>,
|
|
3751
|
+
};
|
|
3752
|
+
|
|
3753
|
+
fn applyUVRegion(uv: vec2<f32>, uvRegion: vec4<f32>) -> vec2<f32> {
|
|
3754
|
+
#ifdef HAS_UV_REGIONS
|
|
3755
|
+
// https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md
|
|
3756
|
+
return fract(uv) * (uvRegion.zw - uvRegion.xy) + uvRegion.xy;
|
|
3757
|
+
#else
|
|
3758
|
+
return uv;
|
|
3759
|
+
#endif
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3762
|
+
@vertex
|
|
3763
|
+
fn vertexMain(
|
|
3764
|
+
inputs: VertexInputs,
|
|
3765
|
+
@builtin(instance_index) instanceIndex: u32
|
|
3766
|
+
) -> FragmentInputs {
|
|
3767
|
+
var outputs: FragmentInputs;
|
|
3768
|
+
var texCoord = vec2<f32>(0.0);
|
|
3769
|
+
var normal = vec3<f32>(0.0, 0.0, 1.0);
|
|
3770
|
+
var uvRegion = vec4<f32>(0.0);
|
|
3771
|
+
|
|
3772
|
+
#ifdef HAS_UV
|
|
3773
|
+
texCoord = inputs.texCoords;
|
|
3774
|
+
#endif
|
|
3775
|
+
#ifdef HAS_NORMALS
|
|
3776
|
+
normal = inputs.normals;
|
|
3777
|
+
#endif
|
|
3778
|
+
#ifdef HAS_UV_REGIONS
|
|
3779
|
+
uvRegion = inputs.uvRegions;
|
|
3780
|
+
#endif
|
|
3781
|
+
|
|
3782
|
+
texCoord = applyUVRegion(texCoord, uvRegion);
|
|
3783
|
+
geometry.uv = texCoord;
|
|
3784
|
+
#ifdef HAS_FEATURE_IDS
|
|
3785
|
+
geometry.pickingColor = picking_getPickingColorFromIndex(inputs.rowIndexes);
|
|
3786
|
+
#else
|
|
3787
|
+
geometry.pickingColor = picking_getPickingColorFromIndex(instanceIndex);
|
|
3788
|
+
#endif
|
|
3789
|
+
|
|
3790
|
+
let instanceModelMatrix = mat3x3<f32>(
|
|
3791
|
+
inputs.instanceModelMatrixCol0,
|
|
3792
|
+
inputs.instanceModelMatrixCol1,
|
|
3793
|
+
inputs.instanceModelMatrixCol2
|
|
3794
|
+
);
|
|
3795
|
+
let commonPosition = vec4<f32>(project_position_vec3_f32(inputs.positions), 1.0);
|
|
3796
|
+
|
|
3797
|
+
geometry.position = commonPosition;
|
|
3798
|
+
geometry.normal = project_normal(instanceModelMatrix * normal);
|
|
3799
|
+
|
|
3800
|
+
outputs.position = project_common_position_to_clipspace(commonPosition);
|
|
3801
|
+
outputs.color = vec4<f32>(
|
|
3802
|
+
inputs.colors.rgb * inputs.instanceColors.rgb,
|
|
3803
|
+
inputs.instanceColors.a
|
|
3804
|
+
);
|
|
3805
|
+
outputs.texCoord = texCoord;
|
|
3806
|
+
outputs.pbrPosition = commonPosition.xyz;
|
|
3807
|
+
outputs.pbrNormal = geometry.normal;
|
|
3808
|
+
outputs.pickingColor = geometry.pickingColor;
|
|
3809
|
+
return outputs;
|
|
3810
|
+
}
|
|
3811
|
+
|
|
3812
|
+
@fragment
|
|
3813
|
+
fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4<f32> {
|
|
3814
|
+
fragmentGeometry.uv = inputs.texCoord;
|
|
3815
|
+
|
|
3816
|
+
if (picking.isActive > 0.5) {
|
|
3817
|
+
if (!picking_isColorValid(inputs.pickingColor)) {
|
|
3818
|
+
discard;
|
|
3819
|
+
}
|
|
3820
|
+
return vec4<f32>(inputs.pickingColor, 1.0);
|
|
3821
|
+
}
|
|
3822
|
+
|
|
3823
|
+
fragmentInputs.pbr_vPosition = inputs.pbrPosition;
|
|
3824
|
+
fragmentInputs.pbr_vUV0 = inputs.texCoord;
|
|
3825
|
+
fragmentInputs.pbr_vUV1 = vec2<f32>(0.0);
|
|
3826
|
+
fragmentInputs.pbr_vNormal = inputs.pbrNormal;
|
|
3827
|
+
|
|
3828
|
+
var color = inputs.color * pbr_filterColor(vec4<f32>(0.0));
|
|
3829
|
+
color.a *= layer.opacity;
|
|
3830
|
+
|
|
3831
|
+
if (picking.isHighlightActive > 0.5) {
|
|
3832
|
+
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
3833
|
+
if (picking_isColorZero(abs(inputs.pickingColor - highlightedObjectColor))) {
|
|
3834
|
+
let highlightAlpha = picking.highlightColor.a;
|
|
3835
|
+
let blendedAlpha = highlightAlpha + color.a * (1.0 - highlightAlpha);
|
|
3836
|
+
if (blendedAlpha > 0.0) {
|
|
3837
|
+
color = vec4<f32>(
|
|
3838
|
+
mix(color.rgb, picking.highlightColor.rgb, highlightAlpha / blendedAlpha),
|
|
3839
|
+
blendedAlpha
|
|
3840
|
+
);
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
return deckgl_premultiplied_alpha(color);
|
|
3846
|
+
}
|
|
3847
|
+
`;function FC(t){let e=t.positions||t.POSITION,r=e.value.length/e.size;t.COLOR_0||t.colors||(t.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var PC={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},fo=class extends wm.SimpleMeshLayer{getShaders(){let e=super.getShaders();return{...e,vs:Im,fs:vm,source:Bm,modules:[...e.modules,Cm,Em]}}initializeState(){let{featureIds:e}=this.props;super.initializeState();let r=this.getAttributeManager();e&&r.add({rowIndexes:{type:"uint32",size:1,noAlloc:!0,update:this.calculateFeatureIdsPickingIndexes}})}updateState(e){super.updateState(e);let{props:r,oldProps:n}=e;r.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(e){let{featureIds:r}=this.props,{model:n}=this.state;if(!n)return;let o={pickFeatureIds:!!r},s={camera:this.context.viewport.cameraPosition};n.shaderInputs.setProps({pbrProjection:s,mesh:o}),super.draw(e)}getModel(e){let{id:r}=this.props,n=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:n});let o=this.getShaders();return FC(e.attributes),new Rm.Model(this.context.device,{...this.getShaders(),id:r,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...o.defines,...n?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0,HAS_FEATURE_IDS:this.props.featureIds?1:0},parameters:n?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){let{model:r}=this.state;if(r){let{mesh:n}=this.props,o=this.parseMaterial(e,n);this.setState({parsedPBRMaterial:o});let{pbr_baseColorSampler:s}=o.bindings,{emptyTexture:i}=this.state,a=s||i,c={...this.context.device.type==="webgpu"?{simpleMeshTexture:a}:{sampler:a},hasTexture:!!s},{camera:l,...f}={...o.bindings,...o.uniforms};r.shaderInputs.setProps({simpleMesh:c,pbrMaterial:f})}}parseMaterial(e,r){let n=!!(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return Qc(this.context.device,{unlit:n,...e},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingIndexes(e){let r=this.props.featureIds;e.value=new Uint32Array(r)}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}};fo.layerName="MeshLayer";fo.defaultProps=PC;var Lm=fo;var Z0=U(Yt(),1);var yt=6356752314245179e-9,NC={radii:[6378137,6378137,yt],radiiSquared:[6378137*6378137,6378137*6378137,yt*yt],oneOverRadii:[1/6378137,1/6378137,1/yt],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(yt*yt)],maximumRadius:Math.max(6378137,6378137,yt),centerToleranceSquared:.1};function ti(t){return t}var ZG=new x;function OC(t,e=[],r=ti){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Fm(t,e=[]){return OC(t,e,Z._cartographicRadians?ti:Ma)}function UC(t,e,r=ti){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Pm(t,e){return UC(t,e,Z._cartographicRadians?ti:_a)}var Nm=1e-14,DC=new x,Om={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Zc={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},uo={east:new x,north:new x,up:new x,west:new x,south:new x,down:new x},VC=new x,GC=new x,HC=new x;function $c(t,e,r,n,o,s){let i=Om[e]&&Om[e][r];he(i&&(!n||n===i));let a,c,l,f=DC.copy(o);if(Me(f.x,0,Nm)&&Me(f.y,0,Nm)){let h=Math.sign(f.z);a=VC.fromArray(Zc[e]),e!=="east"&&e!=="west"&&a.scale(h),c=GC.fromArray(Zc[r]),r!=="east"&&r!=="west"&&c.scale(h),l=HC.fromArray(Zc[n]),n!=="east"&&n!=="west"&&l.scale(h)}else{let{up:h,east:p,north:d}=uo;p.set(-f.y,f.x,0).normalize(),t.geodeticSurfaceNormal(f,h),d.copy(h).cross(p);let{down:m,west:g,south:b}=uo;m.copy(h).scale(-1),g.copy(p).scale(-1),b.copy(d).scale(-1),a=uo[e],c=uo[r],l=uo[n]}return s[0]=a.x,s[1]=a.y,s[2]=a.z,s[3]=0,s[4]=c.x,s[5]=c.y,s[6]=c.z,s[7]=0,s[8]=l.x,s[9]=l.y,s[10]=l.z,s[11]=0,s[12]=f.x,s[13]=f.y,s[14]=f.z,s[15]=1,s}var Kr=new x,kC=new x,zC=new x;function Um(t,e,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:o,centerToleranceSquared:s}=e;Kr.from(t);let i=Kr.x,a=Kr.y,c=Kr.z,l=n.x,f=n.y,u=n.z,h=i*i*l*l,p=a*a*f*f,d=c*c*u*u,m=h+p+d,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;let b=kC;if(b.copy(t).scale(g),m<s)return b.to(r);let T=o.x,S=o.y,M=o.z,C=zC;C.set(b.x*T*2,b.y*S*2,b.z*M*2);let E=(1-g)*Kr.len()/(.5*C.len()),B=0,_,y,A,I;do{E-=B,_=1/(1+E*T),y=1/(1+E*S),A=1/(1+E*M);let L=_*_,F=y*y,w=A*A,D=L*_,W=F*y,k=w*A;I=h*L+p*F+d*w-1;let Q=-2*(h*D*T+p*W*S+d*k*M);B=I/Q}while(Math.abs(I)>Ke.EPSILON12);return Kr.scale([_,y,A]).to(r)}var ri=new x,Dm=new x,JC=new x,$e=new x,WC=new x,ni=new x,V=class{constructor(e=0,r=0,n=0){this.centerToleranceSquared=Ke.EPSILON1,he(e>=0),he(r>=0),he(n>=0),this.radii=new x(e,r,n),this.radiiSquared=new x(e*e,r*r,n*n),this.radiiToTheFourth=new x(e*e*e*e,r*r*r*r,n*n*n*n),this.oneOverRadii=new x(e===0?0:1/e,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new x(e===0?0:1/(e*e),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(e,r,n),this.maximumRadius=Math.max(e,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||!!(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let n=Dm,o=JC,[,,s]=e;this.geodeticSurfaceNormalCartographic(e,n),o.copy(this.radiiSquared).scale(n);let i=Math.sqrt(n.dot(o));return o.scale(1/i),n.scale(s),o.add(n),o.to(r)}cartesianToCartographic(e,r=[0,0,0]){ni.from(e);let n=this.scaleToGeodeticSurface(ni,$e);if(!n)return;let o=this.geodeticSurfaceNormal(n,Dm),s=WC;s.copy(ni).subtract(n);let i=Math.atan2(o.y,o.x),a=Math.asin(o.z),c=Math.sign(wr.dot(s,ni))*wr.length(s);return Pm([i,a,c],r)}eastNorthUpToFixedFrame(e,r=new N){return $c(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,n,o,s=new N){return $c(this,e,r,n,o,s)}geocentricSurfaceNormal(e,r=[0,0,0]){return ri.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let n=Fm(e),o=n[0],s=n[1],i=Math.cos(s);return ri.set(i*Math.cos(o),i*Math.sin(o),Math.sin(s)).normalize(),ri.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return ri.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return Um(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){$e.from(e);let n=$e.x,o=$e.y,s=$e.z,i=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*i.x+o*o*i.y+s*s*i.z);return $e.multiplyScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return $e.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return $e.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,n=[0,0,0]){he(Me(this.radii.x,this.radii.y,Ke.EPSILON15)),he(this.radii.z>0),$e.from(e);let o=$e.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(o)>=this.radii.z-r))return $e.set(0,0,o).to(n)}};V.WGS84=new V(6378137,6378137,yt);var oi=class{item;previous;next;constructor(e,r,n){this.item=e,this.previous=r,this.next=n}};var si=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new oi(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let n=e.next;e.next=r,this.tail===e?this.tail=r:n.previous=r,r.next=n,r.previous=e,++this._length}};var ii=class{_list;_sentinel;_trimTiles;constructor(){this._list=new si,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(e,r))}unloadTile(e,r,n){let o=r._cacheNode;o&&(this._list.remove(o),r._cacheNode=null,n&&n(e,r))}unloadTiles(e,r){let n=this._trimTiles;this._trimTiles=!1;let o=this._list,s=e.maximumMemoryUsage*1024*1024,i=this._sentinel,a=o.head;for(;a!==i&&(e.gpuMemoryUsageInBytes>s||n);){let c=a.item;a=a.next,this.unloadTile(e,c,r)}}trim(){this._trimTiles=!0}};function Vm(t,e){H(t),H(e);let{rtcCenter:r,gltfUpAxis:n}=e,{computedTransform:o,boundingVolume:{center:s}}=t,i=new N(o);switch(r&&i.translate(r),n){case"Z":break;case"Y":let h=new N().rotateX(Math.PI/2);i=i.multiplyRight(h);break;case"X":let p=new N().rotateY(-Math.PI/2);i=i.multiplyRight(p);break;default:break}e.isQuantized&&i.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new x(s);e.cartesianModelMatrix=i,e.cartesianOrigin=a;let c=V.WGS84.cartesianToCartographic(a,new x),f=V.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=f.multiplyRight(i),e.cartographicOrigin=c;let u=KC(e);u&&(e.cartesianModelMatrix=new N(i).multiplyRight(u.matrix),e.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=N.IDENTITY),e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var XC=1e6**2;function KC(t){let e=t.gltf;if(!e)return null;let r=typeof e.scene=="number"?e.scene:0,o=e.scenes?.[r]?.nodes?.[0];if(!o?.matrix)return null;let s=o.matrix;return s[12]*s[12]+s[13]*s[13]+s[14]*s[14]<=XC?null:o}var Gm=new x,el=new x,tl=new Ee([new be,new be,new be,new be,new be,new be]);function km(t,e){let{cameraDirection:r,cameraUp:n,height:o}=t,{metersPerUnit:s}=t.distanceScales,i=ai(t,t.center),a=V.WGS84.eastNorthUpToFixedFrame(i),c=t.unprojectPosition(t.cameraPosition),l=V.WGS84.cartographicToCartesian(c,new x),f=new x(a.transformAsVector(new x(r).scale(s))).normalize(),u=new x(a.transformAsVector(new x(n).scale(s))).normalize();YC(t);let h=t.constructor,{longitude:p,latitude:d,width:m,bearing:g,zoom:b}=t,T=new h({longitude:p,latitude:d,height:o,width:m,bearing:g,zoom:b,pitch:0});return{camera:{position:l,direction:f,up:u},viewport:t,topDownViewport:T,height:o,cullingVolume:tl,frameNumber:e,sseDenominator:1.15}}function zm(t,e,r){if(r===0||t.length<=r)return[t,[]];let n=[],{longitude:o,latitude:s}=e.viewport;for(let[l,f]of t.entries()){let[u,h]=f.header.mbs,p=Math.abs(o-u),d=Math.abs(s-h),m=Math.sqrt(d*d+p*p);n.push([l,m])}let i=n.sort((l,f)=>l[1]-f[1]),a=[];for(let l=0;l<r;l++)a.push(t[i[l][0]]);let c=[];for(let l=r;l<i.length;l++)c.push(t[i[l][0]]);return[a,c]}function YC(t){let e=t.getFrustumPlanes(),r=Hm(e.near,t.cameraPosition),n=ai(t,r),o=ai(t,t.cameraPosition,el),s=0;tl.planes[s++].fromPointNormal(n,Gm.copy(n).subtract(o));for(let i in e){if(i==="near")continue;let a=e[i],c=Hm(a,r,el),l=ai(t,c,el);tl.planes[s++].fromPointNormal(l,Gm.copy(n).subtract(l))}}function Hm(t,e,r=new x){let n=t.normal.dot(e);return r.copy(t.normal).scale(t.distance-n).add(e),r}function ai(t,e,r=new x){let n=t.unprojectPosition(e);return V.WGS84.cartographicToCartesian(n,r)}var QC=6378137,ZC=6378137,rl=6356752314245179e-9,Yr=new x;function qm(t,e){if(t instanceof xt){let{halfAxes:r}=t,n=$C(r);return Math.log2(rl/(n+e[2]))}else if(t instanceof ct){let{radius:r}=t;return Math.log2(rl/(r+e[2]))}else if(t.width&&t.height){let{width:r,height:n}=t,o=Math.log2(QC/r),s=Math.log2(ZC/n);return(o+s)/2}return 1}function nl(t,e,r){V.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],Yr);let n=Math.sqrt(Math.pow(Yr[0]-r[0],2)+Math.pow(Yr[1]-r[1],2)+Math.pow(Yr[2]-r[2],2));return Math.log2(rl/(n+e[2]))}function jm(t,e,r){let[n,o,s,i]=t;return nl({xmin:n,xmax:s,ymin:o,ymax:i,zmin:0,zmax:0},e,r)}function $C(t){t.getColumn(0,Yr);let e=t.getColumn(1),r=t.getColumn(2);return Yr.add(e).add(r).len()}var cg=U(Yt(),1);var Ce={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},xe;(function(t){t[t.ADD=1]="ADD",t[t.REPLACE=2]="REPLACE"})(xe||(xe={}));var He;(function(t){t.EMPTY="empty",t.SCENEGRAPH="scenegraph",t.POINTCLOUD="pointcloud",t.MESH="mesh"})(He||(He={}));var pe;(function(t){t.I3S="I3S",t.TILES3D="TILES3D"})(pe||(pe={}));var St;(function(t){t.GEOMETRIC_ERROR="geometricError",t.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(St||(St={}));var Jm={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function Ym(t){return t!=null}var Te=new x,ci=new x,eI=new x,tI=new x,ur=new x,Wm=new x,Xm=new x,Km=new x;function li(t,e,r){if(H(t,"3D Tile: boundingVolume must be defined"),t.box)return Zm(t.box,e,r);if(t.region)return nI(t.region);if(t.sphere)return rI(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Qm(t,e){if(t.box)return oI(e);if(t.region){let[r,n,o,s,i,a]=t.region;return[[Ne(r),Ne(n),i],[Ne(o),Ne(s),a]]}if(t.sphere)return sI(e);throw new Error("Unkown boundingVolume type")}function Zm(t,e,r){let n=new x(t[0],t[1],t[2]);e.transform(n,n);let o=[];if(t.length===10){let l=t.slice(3,6),f=new ot;f.fromArray(t,6);let u=new x([1,0,0]),h=new x([0,1,0]),p=new x([0,0,1]);u.transformByQuaternion(f),u.scale(l[0]),h.transformByQuaternion(f),h.scale(l[1]),p.transformByQuaternion(f),p.scale(l[2]),o=[...u.toArray(),...h.toArray(),...p.toArray()]}else o=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];let s=e.transformAsVector(o.slice(0,3)),i=e.transformAsVector(o.slice(3,6)),a=e.transformAsVector(o.slice(6,9)),c=new z([s[0],s[1],s[2],i[0],i[1],i[2],a[0],a[1],a[2]]);return Ym(r)?(r.center=n,r.halfAxes=c,r):new xt(n,c)}function rI(t,e,r){let n=new x(t[0],t[1],t[2]);e.transform(n,n);let o=e.getScale(ci),s=Math.max(Math.max(o[0],o[1]),o[2]),i=t[3]*s;return Ym(r)?(r.center=n,r.radius=i,r):new ct(n,i)}function nI(t){let[e,r,n,o,s,i]=t,a=V.WGS84.cartographicToCartesian([Ne(e),Ne(o),s],eI),c=V.WGS84.cartographicToCartesian([Ne(n),Ne(r),i],tI),l=new x().addVectors(a,c).multiplyByScalar(.5);return V.WGS84.cartesianToCartographic(l,ur),V.WGS84.cartographicToCartesian([Ne(n),ur[1],ur[2]],Wm),V.WGS84.cartographicToCartesian([ur[0],Ne(o),ur[2]],Xm),V.WGS84.cartographicToCartesian([ur[0],ur[1],i],Km),Zm([...l,...Wm.subtract(l),...Xm.subtract(l),...Km.subtract(l)],new N)}function oI(t){let e=$m(),{halfAxes:r}=t,n=new x(r.getColumn(0)),o=new x(r.getColumn(1)),s=new x(r.getColumn(2));for(let i=0;i<2;i++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)Te.copy(t.center),Te.add(n),Te.add(o),Te.add(s),eg(e,Te),s.negate();o.negate()}n.negate()}return e}function sI(t){let e=$m(),{center:r,radius:n}=t,o=V.WGS84.scaleToGeodeticSurface(r,Te),s;o?s=V.WGS84.geodeticSurfaceNormal(o):s=new x(0,0,1);let i=new x(s[2],-s[1],0);i.len()>0?i.normalize():i=new x(0,1,0);let a=i.clone().cross(s);for(let c of[i,a,s]){ci.copy(c).scale(n);for(let l=0;l<2;l++)Te.copy(r),Te.add(ci),eg(e,Te),ci.negate()}return e}function $m(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function eg(t,e){V.WGS84.cartesianToCartographic(e,Te),t[0][0]=Math.min(t[0][0],Te[0]),t[0][1]=Math.min(t[0][1],Te[1]),t[0][2]=Math.min(t[0][2],Te[2]),t[1][0]=Math.max(t[1][0],Te[0]),t[1][1]=Math.max(t[1][1],Te[1]),t[1][2]=Math.max(t[1][2],Te[2])}var D4=new x,V4=new x,G4=new N,H4=new x,k4=new x,z4=new x;function iI(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function aI(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){let r=t.dynamicScreenSpaceErrorComputedDensity,n=t.dynamicScreenSpaceErrorFactor;return iI(e,r)*n}return 0}function tg(t,e,r){let n=t.tileset,o=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,s=r?o:t.lodMetricValue;if(s===0)return 0;let i=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:c}=e,{viewDistanceScale:l}=n.options,f=s*a*(l||1)/(i*c);return f-=aI(n,i),f}var ol=new x,rg=new x,Vt=new x,ng=new x,cI=new x,sl=new N,og=new N;function sg(t,e){if(t.lodMetricValue===0||isNaN(t.lodMetricValue))return"DIG";let r=2*il(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function il(t,e){let{topDownViewport:r}=e,n=t.header.mbs[1],o=t.header.mbs[0],s=t.header.mbs[2],i=t.header.mbs[3],a=[...t.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);V.WGS84.cartographicToCartesian(c,ol),rg.copy(ol).subtract(a).normalize(),V.WGS84.eastNorthUpToFixedFrame(a,sl),og.copy(sl).invert(),Vt.copy(ol).transform(og);let l=Math.sqrt(Vt[0]*Vt[0]+Vt[1]*Vt[1]),f=l*l/Vt[2];ng.copy([Vt[0],Vt[1],f]);let h=ng.transform(sl).subtract(a).normalize(),d=rg.cross(h).normalize().scale(i).add(a),m=V.WGS84.cartesianToCartographic(d),g=r.project([o,n,s]),b=r.project(m);return cI.copy(g).subtract(b).magnitude()}function ig(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}var ho=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return H(e<this._array.length),this._array[e]}set(e,r){H(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){H(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){H(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var lI={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},ut=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new ho;_emptyTraversalStack=new ho;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...lI,...e}}traverse(e,r,n){this.root=e,this.options={...this.options,...n},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let n=this._traversalStack;for(e._selectionDepth=1,n.push(e);n.length>0;){let s=n.pop(),i=!1;this.canTraverse(s,r)&&(this.updateChildTiles(s,r),i=this.updateAndPushChildren(s,r,n,s.hasRenderContent?s._selectionDepth+1:s._selectionDepth));let a=s.parent,c=!!(!a||a._shouldRefine),l=!i;s.hasRenderContent?s.refine===xe.ADD?(this.loadTile(s,r),this.selectTile(s,r)):s.refine===xe.REPLACE&&(this.loadTile(s,r),l&&this.selectTile(s,r)):(this.emptyTiles[s.id]=s,this.loadTile(s,r),l&&this.selectTile(s,r)),this.touchTile(s,r),s._shouldRefine=i&&c}let o=new Date().getTime();(this.traversalFinished(r)||o-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=o,this.options.onTraversalEnd(r))}updateChildTiles(e,r){let n=e.children;for(let o of n)this.updateTile(o,r)}updateAndPushChildren(e,r,n,o){let{loadSiblings:s,skipLevelOfDetail:i}=this.options,a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===xe.REPLACE&&e.hasRenderContent&&!i,l=!1,f=!0;for(let u of a)if(u._selectionDepth=o,u.isVisibleAndInRequestVolume?(n.find(u)&&n.delete(u),n.push(u),l=!0):(c||s)&&(this.loadTile(u,r),this.touchTile(u,r)),c){let h;if(u._inRequestVolume?u.hasRenderContent?h=u.contentAvailable:h=this.executeEmptyTraversal(u,r):h=!1,f=f&&h,!f)return!1}return l||(f=!1),f}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){this.shouldLoadTile(e)&&(e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,r):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,r,n=!1){let o=e._screenSpaceError;return n&&(o=e.getScreenSpaceError(r,!0)),o>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let n=[];if(this.options.viewportTraversersMap)for(let o in this.options.viewportTraversersMap)this.options.viewportTraversersMap[o]===r.viewport.id&&n.push(o);else n.push(r.viewport.id);e.updateVisibility(r,n)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let n=!1;for(let o of e.children)o.updateVisibility(r),n=n||o.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,r){let n=!0,o=this._emptyTraversalStack;for(o.push(e);o.length>0;){let s=o.pop(),i=!s.hasRenderContent&&this.canTraverse(s,r),a=!s.hasRenderContent&&s.children.length===0;if(!i&&!s.contentAvailable&&!a&&(n=!1),this.updateTile(s,r),s.isVisibleAndInRequestVolume||(this.loadTile(s,r),this.touchTile(s,r)),i){let c=s.children;for(let l of c)o.push(l)}}return e.hasEmptyContent||n}};var ag=new x;function fI(t){return t!=null}var hr=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Ce.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new N;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new ut({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new N;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(e,r,n,o=""){this.header=r,this.tileset=e,this.id=o||r.id,this.url=r.url,this.parent=n,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Ce.READY||this.hasEmptyContent}get contentAvailable(){return!!(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Ce.UNLOADED}get contentExpired(){return this.contentState===Ce.EXPIRED}get contentFailed(){return this.contentState===Ce.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Qm(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,r){switch(this.tileset.type){case pe.I3S:return il(this,e);case pe.TILES3D:return tg(this,e,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let e=this.tileset._traverser,{skipLevelOfDetail:r}=e.options,n=this.refine===xe.ADD||r;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Ce.UNLOADED)return-1;let o=this.parent,i=o&&(!n||this._screenSpaceError===0||o.hasTilesetContent)?o._screenSpaceError:this._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-i,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Ce.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Ce.UNLOADED,!1;try{let n=this.tileset.getTileUrl(this.contentUrl),o=this.tileset.loader,s=this.tileset.loadOptions[o.id]||{},i={...this.tileset.loadOptions,[o.id]:{...s,isTileset:this.type==="json",...this._getLoaderSpecificOptions(o.id)}};return this.content=await(0,cg.load)(n,o,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Ce.READY,this._onContentLoaded(),!0}catch(n){throw this.contentState=Ce.FAILED,n}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Ce.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let n=this.parent,o=n?n._visibilityPlaneMask:Ee.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let s=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(s)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,o),this._visible=this._visibilityPlaneMask!==Ee.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}visibility(e,r){let{cullingVolume:n}=e,{boundingVolume:o}=this;return n.computeVisibilityWithPlaneMask(o,r)}contentVisibility(){return!0}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return ag.subVectors(r.center,e.position),e.direction.dot(ag)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(fI(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=Ce.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new N(e.transform):new N;let r=this.parent,n=this.tileset,o=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new N(o).multiplyRight(this.transform);let s=r&&r._initialTransform?r._initialTransform.clone():new N;this._initialTransform=new N(s).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Ce.UNLOADED,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=Ee.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||xe.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=li(e.boundingVolume,this.computedTransform,this.boundingVolume);let r=e.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=li(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=li(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new N){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){return e==="i3s"?{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1}:ig(this.tileset.tileset)}};var fi=class extends ut{compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let n=e.children.length>0;if(e.hasTilesetContent&&n){let i=e.children[0];this.updateTileVisibility(i,r),e._visible=i._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let o=e.refine===xe.REPLACE,s=e._optimChildrenWithinParent===Jm.USE_OPTIMIZATION;if(o&&s&&n&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:n}=e;return!n||n.hasTilesetContent||n.refine!==xe.ADD?!1:!this.shouldRefine(e,r,!0)}};var lg=U(Yt(),1);var ui=class{frameNumberMap=new Map;register(e,r){let n=this.frameNumberMap.get(e)||new Map,o=n.get(r)||0;n.set(r,o+1),this.frameNumberMap.set(e,n)}deregister(e,r){let n=this.frameNumberMap.get(e);if(!n)return;let o=n.get(r)||1;n.set(r,o-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var al={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},hi=class{_statusMap;pendingTilesRegister=new ui;constructor(){this._statusMap={}}add(e,r,n,o){if(!this._statusMap[r]){let{frameNumber:s,viewport:{id:i}}=o;this._statusMap[r]={request:e,callback:n,key:r,frameState:o,status:al.REQUESTED},this.pendingTilesRegister.register(i,s),e().then(a=>{this._statusMap[r].status=al.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,o)}).catch(a=>{this._statusMap[r].status=al.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),n(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:n,viewport:{id:o}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(o,n);let{frameNumber:s,viewport:{id:i}}=r;this.pendingTilesRegister.register(i,s),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var pi=class extends ut{_tileManager;constructor(e){super(e),this._tileManager=new hi}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=sg(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let n=e.header.children||[],o=e.children,s=e.tileset;for(let i of n){let a=`${i.id}-${r.viewport.id}`,c=o&&o.find(l=>l.id===a);if(c)c&&this.updateTile(c,r);else{let l=()=>this._loadTile(i.id,s);this._tileManager.find(a)?this._tileManager.update(a,r):(s.tileset.nodePages&&(l=()=>s.tileset.nodePagesTile.formTileFromNodePages(i.id)),this._tileManager.add(l,a,u=>this._onTileLoad(u,e,a),r))}}return!1}async _loadTile(e,r){let{loader:n}=r,o=r.getTileUrl(`${r.url}/nodes/${e}`),s={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await(0,lg.load)(o,n,s)}_onTileLoad(e,r,n){let o=new hr(r.tileset,e,r,n);r.children.push(o);let s=this._tileManager.find(o.id).frameState;this.updateTile(o,s),this._frameNumber===s.frameNumber&&(this.traversalFinished(s)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(o,s)}};var uI={description:"",ellipsoid:V.WGS84,modelMatrix:new N,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},di="Tiles In Tileset(s)",cl="Tiles In Memory",fg="Tiles In View",ug="Tiles To Render",hg="Tiles Loaded",ll="Tiles Loading",pg="Tiles Unloaded",dg="Failed Tile Loads",mg="Points/Vertices",fl="Tile Memory Use",gg="Maximum Screen Space Error",po=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new ii;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,r){this.options={...uI,...r},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||Ot.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new Pt({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new Ft({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let n=e;return this.queryParams.length&&(n=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),n}hasExtension(e){return this._extensionsUsed.indexOf(e)>-1}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let n=[];for(let o of r){let s=o.id;this._needTraverse(s)?n.push(s):this.traverseCounter--}for(let o of r){let s=o.id;if(this.roots[s]||(this.roots[s]=this._initializeTileHeaders(this.tileset,null)),!n.includes(s))continue;let i=km(o,this._frameNumber);this._traverser.traverse(this.roots[s],i,this.options)}}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],o=Object.values(this._traverser.selectedTiles),[s,i]=zm(o,e,this.options.maximumTilesSelected);n.selectedTiles=s;for(let a of i)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let s in this.frameStateData){let i=this.frameStateData[s];this.selectedTiles=this.selectedTiles.concat(i.selectedTiles),this._requestedTiles=this._requestedTiles.concat(i._requestedTiles),this._emptyTiles=this._emptyTiles.concat(i._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles.map(s=>s.id)),n=this.selectedTiles.some(s=>!s.tileDrawn),o=0;if(n){for(let s of r)this._heldTiles.add(s);for(let s of this._heldTiles){if(r.has(s))continue;let i=this._tiles[s];i&&i.contentAvailable?(i._selectedFrame=this._frameNumber,this.selectedTiles.push(i),o++):this._heldTiles.delete(s)}}else this._heldTiles=r;o>0&&setTimeout(()=>{this.selectTiles()},0);for(let s of this.selectedTiles)this._tiles[s.id]=s;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let n=new Set(e.map(i=>i.id)),o=new Set(r.map(i=>i.id)),s=e.filter(i=>!o.has(i.id)).length>0;return s=s||r.filter(i=>!n.has(i.id)).length>0,s}_loadTiles(){this._requestedTiles.sort((e,r)=>e._priority-r._priority);for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r))}_updateStats(){let e=0,r=0;for(let n of this.selectedTiles)n.contentAvailable&&n.content&&(e++,n.content.pointCount?r+=n.content.pointCount:r+=n.content.vertexCount);this.stats.get(fg).count=this.selectedTiles.length,this.stats.get(ug).count=e,this.stats.get(mg).count=r,this.stats.get(gg).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===pe.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===pe.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===pe.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let e=this.tileset.fullExtent;if(e){let{xmin:n,xmax:o,ymin:s,ymax:i,zmin:a,zmax:c}=e;this.cartographicCenter=new x(n+(o-n)/2,s+(i-s)/2,a+(c-a)/2),this.cartesianCenter=new x,V.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=nl(e,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[n,o,s,i]=r;this.cartographicCenter=new x(n+(s-n)/2,o+(i-o)/2,0),this.cartesianCenter=new x,V.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=jm(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new x,this.zoom=1}calculateViewPropsTiles3D(){let e=this.root,{center:r}=e.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new x,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new x,V.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new x(0,0,-V.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=qm(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(di),this.stats.get(ll),this.stats.get(cl),this.stats.get(fg),this.stats.get(ug),this.stats.get(hg),this.stats.get(pg),this.stats.get(dg),this.stats.get(mg),this.stats.get(fl,"memory"),this.stats.get(gg)}_initializeTileHeaders(e,r){let n=new hr(this,e.root,r);if(r&&(r.children.push(n),n.depth=r.depth+1),this.type===pe.TILES3D){let o=[];for(o.push(n);o.length>0;){let s=o.pop();this.stats.get(di).incrementCount();let i=s.header.children||[];for(let a of i){let c=new hr(this,a,s);if(c.contentUrl?.includes("?session=")){let f=new URL(c.contentUrl).searchParams.get("session");f&&(this._queryParams.session=f)}s.children.push(c),c.depth=s.depth+1,o.push(c)}}}return n}_initializeTraverser(){let e;switch(this.type){case pe.TILES3D:e=fi;break;case pe.I3S:e=pi;break;default:e=ut}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r;try{this._onStartTileLoading(),r=await e.loadContent()}catch(n){this._onTileLoadError(e,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}_onTileLoadError(e,r){this.stats.get(dg).incrementCount();let n=r.message||r.toString(),o=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,o)}_onTileLoad(e,r){if(r){if(this.type===pe.I3S){let n=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(di).reset(),this.stats.get(di).addCount(n)}e&&e.content&&Vm(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===pe.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===pe.TILES3D){let{extensionsRemoved:r=[]}=e.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(ll).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(ll).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(hg).incrementCount(),this.stats.get(cl).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(fl).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(cl).decrementCount(),this.stats.get(pg).incrementCount(),this.stats.get(fl).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let n of r.children)e.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,n=[];for(n.push(r);n.length>0;){e=n.pop();for(let o of e.children)n.push(o);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){let r=new URLSearchParams(e.queryString),n=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){let e=this.loadOptions.i3s;e&&typeof e=="object"&&"token"in e&&(this._queryParams.token=e.token)}};var mi="4.4.3";var pr={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},DH=Object.keys(pr);function ul(t,e,r){H(t instanceof ArrayBuffer);let n=new TextDecoder("utf8"),o=new Uint8Array(t,e,r);return n.decode(o)}function Ag(t,e=0){let r=new DataView(t);return`${String.fromCharCode(r.getUint8(e+0))}${String.fromCharCode(r.getUint8(e+1))}${String.fromCharCode(r.getUint8(e+2))}${String.fromCharCode(r.getUint8(e+3))}`}var hI="1.5.6",pI="1.4.1",hl=`https://www.gstatic.com/draco/versioned/decoders/${hI}`,de={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},mo={[de.DECODER]:`${hl}/${de.DECODER}`,[de.DECODER_WASM]:`${hl}/${de.DECODER_WASM}`,[de.FALLBACK_DECODER]:`${hl}/${de.FALLBACK_DECODER}`,[de.ENCODER]:`https://raw.githubusercontent.com/google/draco/${pI}/javascript/${de.ENCODER}`},pl;async function xg(t={},e){let r=t.modules||{};return r.draco3d?pl||=r.draco3d.createDecoderModule({}).then(n=>({draco:n})):pl||=dI(t,e),await pl}function bg(t,e){if(t&&typeof t=="object"){if(t.default)return t.default;if(t[e])return t[e]}return t}async function dI(t,e){let r,n;switch(e){case"js":r=await Ve(mo[de.FALLBACK_DECODER],"draco",t,de.FALLBACK_DECODER);break;default:try{[r,n]=await Promise.all([await Ve(mo[de.DECODER],"draco",t,de.DECODER),await Ve(mo[de.DECODER_WASM],"draco",t,de.DECODER_WASM)])}catch{r=null,n=null}}return r=bg(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,!r&&!mt&&([r,n]=await Promise.all([await Ve(mo[de.DECODER],"draco",{...t,useLocalLibraries:!0},de.DECODER),await Ve(mo[de.DECODER_WASM],"draco",{...t,useLocalLibraries:!0},de.DECODER_WASM)]),r=bg(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule),await mI(r,n)}function mI(t,e){if(typeof t!="function")throw new Error("DracoDecoderModule could not be loaded");let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t({...r,onModuleLoaded:o=>n({draco:o})})})}var Tg="4.4.3";function yg(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function dr(t){let e=1/0,r=1/0,n=1/0,o=-1/0,s=-1/0,i=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],u=a[l+1],h=a[l+2];e=f<e?f:e,r=u<r?u:r,n=h<n?h:n,o=f>o?f:o,s=u>s?u:s,i=h>i?h:i}return[[e,r,n],[o,s,i]]}function dl(t,e,r){let n=yg(e.value),o=r||Sg(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:n}]},nullable:!1,metadata:o}}function Sg(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}function _g(t,e,r){let n=Eg(e.metadata),o=[],s=gI(e.attributes);for(let i in t){let a=t[i],c=Mg(i,a,s[i]);o.push(c)}if(r){let i=Mg("indices",r);o.push(i)}return{fields:o,metadata:n}}function gI(t){let e={};for(let r in t){let n=t[r];e[n.name||"undefined"]=n}return e}function Mg(t,e,r){let n=r?Eg(r.metadata):void 0;return dl(t,e,n)}function Eg(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var Cg={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},AI={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},bI=4,go=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let o=this.decoder.GetEncodedGeometryType(n),s=o===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(o){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(n,s);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(n,s);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!s.ptr){let h=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(h)}let a=this._getDracoLoaderData(s,o,r),c=this._getMeshData(s,a,r),l=dr(c.attributes),f=_g(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:s.num_points(),boundingBox:l},...c,schema:f}}finally{this.draco.destroy(n),s&&this.draco.destroy(s)}}_getDracoLoaderData(e,r,n){let o=this._getTopLevelMetadata(e),s=this._getDracoAttributes(e,n);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:o,attributes:s}}_getDracoAttributes(e,r){let n={};for(let o=0;o<e.num_attributes();o++){let s=this.decoder.GetAttribute(e,o),i=this._getAttributeMetadata(e,o);n[s.unique_id()]={unique_id:s.unique_id(),attribute_type:s.attribute_type(),data_type:s.data_type(),num_components:s.num_components(),byte_offset:s.byte_offset(),byte_stride:s.byte_stride(),normalized:s.normalized(),attribute_index:o,metadata:i};let a=this._getQuantizationTransform(s,r);a&&(n[s.unique_id()].quantization_transform=a);let c=this._getOctahedronTransform(s,r);c&&(n[s.unique_id()].octahedron_transform=c)}return n}_getMeshData(e,r,n){let o=this._getMeshAttributes(r,e,n);if(!o.POSITION)throw new Error("DRACO: No position attribute found.");return e instanceof this.draco.Mesh?n.topology==="triangle-strip"?{topology:"triangle-strip",mode:4,attributes:o,indices:{value:this._getTriangleStripIndices(e),size:1}}:{topology:"triangle-list",mode:5,attributes:o,indices:{value:this._getTriangleListIndices(e),size:1}}:{topology:"point-list",mode:0,attributes:o}}_getMeshAttributes(e,r,n){let o={};for(let s of Object.values(e.attributes)){let i=this._deduceAttributeName(s,n);s.name=i;let a=this._getAttributeValues(r,s);if(a){let{value:c,size:l}=a;o[i]={value:c,size:l,byteOffset:s.byte_offset,byteStride:s.byte_stride,normalized:s.normalized}}}return o}_getTriangleListIndices(e){let n=e.num_faces()*3,o=n*bI,s=this.draco._malloc(o);try{return this.decoder.GetTrianglesUInt32Array(e,o,s),new Uint32Array(this.draco.HEAPF32.buffer,s,n).slice()}finally{this.draco._free(s)}}_getTriangleStripIndices(e){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),yI(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){let n=AI[r.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;let o=r.num_components,i=e.num_points()*o,a=i*n.BYTES_PER_ELEMENT,c=xI(this.draco,n),l,f=this.draco._malloc(a);try{let u=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,u,c,a,f),l=new n(this.draco.HEAPF32.buffer,f,i).slice()}finally{this.draco._free(f)}return{value:l,size:o}}_deduceAttributeName(e,r){let n=e.unique_id;for(let[i,a]of Object.entries(r.extraAttributes||{}))if(a===n)return i;let o=e.attribute_type;for(let i in Cg)if(this.draco[i]===o)return Cg[i];let s=r.attributeNameEntry||"name";return e.metadata[s]?e.metadata[s].string:`CUSTOM_ATTRIBUTE_${n}`}_getTopLevelMetadata(e){let r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){let n=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};let r={},n=this.metadataQuerier.NumEntries(e);for(let o=0;o<n;o++){let s=this.metadataQuerier.GetEntryName(e,o);r[s]=this._getDracoMetadataField(e,s)}return r}_getDracoMetadataField(e,r){let n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,n);let o=TI(n);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:o}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){let{quantizedAttributes:r=[],octahedronAttributes:n=[]}=e,o=[...r,...n];for(let s of o)this.decoder.SkipAttributeTransform(this.draco[s])}_getQuantizationTransform(e,r){let{quantizedAttributes:n=[]}=r,o=e.attribute_type();if(n.map(i=>this.decoder[i]).includes(o)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(a=>i.min_value(a))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:n=[]}=r,o=e.attribute_type();if(n.map(i=>this.decoder[i]).includes(o)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function xI(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function TI(t){let e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}function yI(t){let e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}var Ig={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:Tg,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},Ao={...Ig,parse:SI};async function SI(t,e){let{draco:r}=await xg(Gn(e),e?.draco?.decoderType||"wasm"),n=new go(r);try{return n.parseSync(t,e?.draco)}finally{n.destroy()}}var MI={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},fe={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},O={...MI,...fe};var ml={[fe.DOUBLE]:Float64Array,[fe.FLOAT]:Float32Array,[fe.UNSIGNED_SHORT]:Uint16Array,[fe.UNSIGNED_INT]:Uint32Array,[fe.UNSIGNED_BYTE]:Uint8Array,[fe.BYTE]:Int8Array,[fe.SHORT]:Int16Array,[fe.INT]:Int32Array},_I={DOUBLE:fe.DOUBLE,FLOAT:fe.FLOAT,UNSIGNED_SHORT:fe.UNSIGNED_SHORT,UNSIGNED_INT:fe.UNSIGNED_INT,UNSIGNED_BYTE:fe.UNSIGNED_BYTE,BYTE:fe.BYTE,SHORT:fe.SHORT,INT:fe.INT},gl="Failed to convert GL type",Re=class t{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(let r in ml)if(ml[r]===e)return r;throw new Error(gl)}static fromName(e){let r=_I[e];if(!r)throw new Error(gl);return r}static getArrayType(e){switch(e){case fe.UNSIGNED_SHORT_5_6_5:case fe.UNSIGNED_SHORT_4_4_4_4:case fe.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=ml[e];if(!r)throw new Error(gl);return r}}static getByteSize(e){return t.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return!!t.getArrayType(e)}static createTypedArray(e,r,n=0,o){o===void 0&&(o=(r.byteLength-n)/t.getByteSize(e));let s=ArrayBuffer.isView(r)?r.buffer:r,i=t.getArrayType(e);return new i(s,n,o)}};function vg(t,e){if(!t)throw new Error(`math.gl assertion failed. ${e}`)}function Al(t,e=[0,0,0]){let r=t>>11&31,n=t>>5&63,o=t&31;return e[0]=r<<3,e[1]=n<<2,e[2]=o<<3,e}var x9=1/256;var T9=new Wt,y9=new x,S9=new Wt,M9=new Wt,_9=new Uint8Array(1);function Bg(t,e=255){return is(t,0,e)/e*2-1}function Rg(t){return t<0?-1:1}function wg(t,e,r,n){if(vg(n),t<0||t>r||e<0||e>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(n.x=Bg(t,r),n.y=Bg(e,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){let o=n.x;n.x=(1-Math.abs(n.y))*Rg(o),n.y=(1-Math.abs(o))*Rg(n.y)}return n.normalize()}function bl(t,e,r){return wg(t,e,255,r)}var Mt=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,r){this.json=e,this.buffer=r}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return!!this.json[e]}getGlobalProperty(e,r=O.UNSIGNED_INT,n=1){let o=this.json[e];return o&&Number.isFinite(o.byteOffset)?this._getTypedArrayFromBinary(e,r,n,1,o.byteOffset):o}getPropertyArray(e,r,n){let o=this.json[e];return o&&Number.isFinite(o.byteOffset)?("componentType"in o&&(r=Re.fromName(o.componentType)),this._getTypedArrayFromBinary(e,r,n,this.featuresLength,o.byteOffset)):this._getTypedArrayFromArray(e,r,o)}getProperty(e,r,n,o,s){let i=this.json[e];if(!i)return i;let a=this.getPropertyArray(e,r,n);if(n===1)return a[o];for(let c=0;c<n;++c)s[c]=a[n*o+c];return s}_getTypedArrayFromBinary(e,r,n,o,s){let i=this._cachedTypedArrays,a=i[e];return a||(a=Re.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+s,o*n),i[e]=a),a}_getTypedArrayFromArray(e,r,n){let o=this._cachedTypedArrays,s=o[e];if(!s){if(ArrayBuffer.isView(n)){let i=n.byteOffset,c=n.byteLength/Re.getByteSize(r);s=Re.createTypedArray(r,n.buffer,i,c)}else if(n instanceof ArrayBuffer)s=Re.createTypedArray(r,n);else{let i=Re.getArrayType(r);s=new i(n)}o[e]=s}return s}};var EI={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},CI={SCALAR:(t,e)=>t[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},II={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};function Lg(t,e,r,n){let{componentType:o}=t;H(t.componentType);let s=typeof o=="string"?Re.fromName(o):o,i=EI[t.type],a=CI[t.type],c=II[t.type];return r+=t.byteOffset,{values:Re.createTypedArray(s,e,r,i*n),type:s,size:i,unpacker:a,packer:c}}var ht=t=>t!==void 0;function Fg(t,e,r){if(!e)return null;let n=t.getExtension("3DTILES_batch_table_hierarchy"),o=e.HIERARCHY;return o&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=o,n=o),n?vI(n,r):null}function vI(t,e){let r,n,o,s=t.instancesLength,i=t.classes,a=t.classIds,c=t.parentCounts,l=t.parentIds,f=s;ht(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,o=getBinaryAccessor(a),a=o.createArrayBufferView(e.buffer,e.byteOffset+a.byteOffset,s));let u;if(ht(c))for(ht(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,o=getBinaryAccessor(c),c=o.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,s)),u=new Uint16Array(s),f=0,r=0;r<s;++r)u[r]=f,f+=c[r];ht(l)&&ht(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,o=getBinaryAccessor(l),l=o.createArrayBufferView(e.buffer,e.byteOffset+l.byteOffset,f));let h=i.length;for(r=0;r<h;++r){let g=i[r].length,b=i[r].instances,T=getBinaryProperties(g,b,e);i[r].instances=combine(T,b)}let p=new Array(h).fill(0),d=new Uint16Array(s);for(r=0;r<s;++r)n=a[r],d[r]=p[n],++p[n];let m={classes:i,classIds:a,classIndexes:d,parentCounts:c,parentIndexes:u,parentIds:l};return wI(m),m}function Qr(t,e,r){if(!t)return;let n=t.parentCounts;return t.parentIds?r(t,e):n>0?BI(t,e,r):RI(t,e,r)}function BI(t,e,r){let n=t.classIds,o=t.parentCounts,s=t.parentIds,i=t.parentIndexes,a=n.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,f=scratchStack;for(f.length=0,f.push(e);f.length>0;){if(e=f.pop(),c[e]===l)continue;c[e]=l;let u=r(t,e);if(ht(u))return u;let h=o[e],p=i[e];for(let d=0;d<h;++d){let m=s[p+d];m!==e&&f.push(m)}}return null}function RI(t,e,r){let n=!0;for(;n;){let o=r(t,e);if(ht(o))return o;let s=t.parentIds[e];n=s!==e,e=s}throw new Error("traverseHierarchySingleParent")}function wI(t){let e=[],n=t.classIds.length;for(let o=0;o<n;++o)Pg(t,o,stack)}function Pg(t,e,r){let n=t.parentCounts,o=t.parentIds,s=t.parentIndexes,a=t.classIds.length;if(!ht(o))return;assert(e<a,`Parent index ${e} exceeds the total number of instances: ${a}`),assert(r.indexOf(e)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(e);let c=ht(n)?n[e]:1,l=ht(n)?s[e]:e;for(let f=0;f<c;++f){let u=o[l+f];u!==e&&Pg(t,u,r)}r.pop(e)}function we(t){return t!=null}var gi=(t,e)=>t,LI={HIERARCHY:!0,extensions:!0,extras:!0},mr=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,r,n,o={}){H(n>=0),this.json=e||{},this.binary=r,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(let s in this.json)LI[s]||(this._properties[s]=this.json[s]);this._binaryProperties=this._initializeBinaryProperties(),o["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Fg(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,r){if(this._checkBatchId(e),H(typeof r=="string",r),this._hierarchy){let n=Qr(this._hierarchy,e,(o,s)=>{let i=o.classIds[s];return o.classes[i].name===r});return we(n)}return!1}isExactClass(e,r){return H(typeof r=="string",r),this.getExactClassName(e)===r}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){let r=this._hierarchy.classIds[e];return this._hierarchy.classes[r].name}}hasProperty(e,r){return this._checkBatchId(e),H(typeof r=="string",r),we(this._properties[r])||this._hasPropertyInHierarchy(e,r)}getPropertyNames(e,r){this._checkBatchId(e),r=we(r)?r:[],r.length=0;let n=Object.keys(this._properties);return r.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(e,r),r}getProperty(e,r){if(this._checkBatchId(e),H(typeof r=="string",r),this._binaryProperties){let o=this._binaryProperties[r];if(we(o))return this._getBinaryProperty(o,e)}let n=this._properties[r];if(we(n))return gi(n[e],!0);if(this._hierarchy){let o=this._getHierarchyProperty(e,r);if(we(o))return o}}setProperty(e,r,n){let o=this.featureCount;if(this._checkBatchId(e),H(typeof r=="string",r),this._binaryProperties){let i=this._binaryProperties[r];if(i){this._setBinaryProperty(i,e,n);return}}if(this._hierarchy&&this._setHierarchyProperty(this,e,r,n))return;let s=this._properties[r];we(s)||(this._properties[r]=new Array(o),s=this._properties[r]),s[e]=gi(n,!0)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,r){return e.unpack(e.typedArray,r)}_setBinaryProperty(e,r,n){e.pack(n,e.typedArray,r)}_initializeBinaryProperties(){let e=null;for(let r in this._properties){let n=this._properties[r],o=this._initializeBinaryProperty(r,n);o&&(e=e||{},e[r]=o)}return e}_initializeBinaryProperty(e,r){if("byteOffset"in r){let n=r;H(this.binary,`Property ${e} requires a batch table binary.`),H(n.type,`Property ${e} requires a type.`);let o=Lg(n,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:o.values,componentCount:o.size,unpack:o.unpacker,pack:o.packer}}return null}_hasPropertyInHierarchy(e,r){if(!this._hierarchy)return!1;let n=Qr(this._hierarchy,e,(o,s)=>{let i=o.classIds[s],a=o.classes[i].instances;return we(a[r])});return we(n)}_getPropertyNamesInHierarchy(e,r){Qr(this._hierarchy,e,(n,o)=>{let s=n.classIds[o],i=n.classes[s].instances;for(let a in i)i.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(e,r){return Qr(this._hierarchy,e,(n,o)=>{let s=n.classIds[o],i=n.classes[s],a=n.classIndexes[o],c=i.instances[r];return we(c)?we(c.typedArray)?this._getBinaryProperty(c,a):gi(c[a],!0):null})}_setHierarchyProperty(e,r,n,o){let s=Qr(this._hierarchy,r,(i,a)=>{let c=i.classIds[a],l=i.classes[c],f=i.classIndexes[a],u=l.instances[n];return we(u)?(H(a===r,`Inherited property "${n}" is read-only.`),we(u.typedArray)?this._setBinaryProperty(u,f,o):u[f]=gi(o,!0),!0):!1});return we(s)}};function Gt(t,e,r=0){let n=new DataView(e);if(t.magic=n.getUint32(r,!0),r+=4,t.version=n.getUint32(r,!0),r+=4,t.byteLength=n.getUint32(r,!0),r+=4,t.version!==1)throw new Error(`3D Tile Version ${t.version} not supported`);return r}var Zr=4,Ng="b3dm tile in legacy format.";function $r(t,e,r){let n=new DataView(e),o;t.header=t.header||{};let s=n.getUint32(r,!0);r+=Zr;let i=n.getUint32(r,!0);r+=Zr;let a=n.getUint32(r,!0);r+=Zr;let c=n.getUint32(r,!0);return r+=Zr,a>=570425344?(r-=Zr*2,o=s,a=i,c=0,s=0,i=0,console.warn(Ng)):c>=570425344&&(r-=Zr,o=a,a=s,c=i,s=0,i=0,console.warn(Ng)),t.header.featureTableJsonByteLength=s,t.header.featureTableBinaryByteLength=i,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=c,t.header.batchLength=o,r}function en(t,e,r,n){return r=FI(t,e,r,n),r=PI(t,e,r,n),r}function FI(t,e,r,n){let{featureTableJsonByteLength:o,featureTableBinaryByteLength:s,batchLength:i}=t.header||{};if(t.featureTableJson={BATCH_LENGTH:i||0},o&&o>0){let a=ul(e,r,o);t.featureTableJson=JSON.parse(a)}return r+=o||0,t.featureTableBinary=new Uint8Array(e,r,s),r+=s||0,r}function PI(t,e,r,n){let{batchTableJsonByteLength:o,batchTableBinaryByteLength:s}=t.header||{};if(o&&o>0){let i=ul(e,r,o);t.batchTableJson=JSON.parse(i),r+=o,s&&s>0&&(t.batchTableBinary=new Uint8Array(e,r,s),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=s)}return r}function xl(t,e,r){if(!e&&(!t||!t.batchIds||!r))return null;let{batchIds:n,isRGB565:o,pointCount:s=0}=t;if(n&&r){let i=new Uint8ClampedArray(s*3);for(let a=0;a<s;a++){let c=n[a],f=r.getProperty(c,"dimensions").map(u=>u*255);i[a*3]=f[0],i[a*3+1]=f[1],i[a*3+2]=f[2]}return{type:O.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}if(e&&o){let i=new Uint8ClampedArray(s*3);for(let a=0;a<s;a++){let c=Al(e[a]);i[a*3]=c[0],i[a*3+1]=c[1],i[a*3+2]=c[2]}return{type:O.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}return e&&e.length===s*3?{type:O.UNSIGNED_BYTE,value:e,size:3,normalized:!0}:{type:O.UNSIGNED_BYTE,value:e||new Uint8ClampedArray,size:4,normalized:!0}}var Og=new x;function Ug(t,e){if(!e)return null;if(t.isOctEncoded16P){let r=new Float32Array((t.pointsLength||0)*3);for(let n=0;n<(t.pointsLength||0);n++)bl(e[n*2],e[n*2+1],Og),Og.toArray(r,n*3);return{type:O.FLOAT,size:2,value:r}}return{type:O.FLOAT,size:2,value:e}}function Dg(t,e,r){return t.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(t.isQuantized=!1,NI(t,e)):{type:O.UNSIGNED_SHORT,value:e,size:3,normalized:!0}:e}function NI(t,e){let r=new x,n=new Float32Array(t.pointCount*3);for(let o=0;o<t.pointCount;o++)r.set(e[o*3],e[o*3+1],e[o*3+2]).scale(1/t.quantizedRange).multiply(t.quantizedVolumeScale).add(t.quantizedVolumeOffset).toArray(n,o*3);return n}async function Vg(t,e,r,n,o){r=Gt(t,e,r),r=$r(t,e,r),r=en(t,e,r,n),OI(t);let{featureTable:s,batchTable:i}=UI(t);return await kI(t,s,i,n,o),DI(t,s,n),VI(t,s,i),GI(t,s),r}function OI(t){t.attributes={positions:null,colors:null,normals:null,batchIds:null},t.isQuantized=!1,t.isTranslucent=!1,t.isRGB565=!1,t.isOctEncoded16P=!1}function UI(t){let e=new Mt(t.featureTableJson,t.featureTableBinary),r=e.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");e.featuresLength=r,t.featuresLength=r,t.pointsLength=r,t.pointCount=r,t.rtcCenter=e.getGlobalProperty("RTC_CENTER",O.FLOAT,3);let n=HI(t,e);return{featureTable:e,batchTable:n}}function DI(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.positions){if(e.hasProperty("POSITION"))t.attributes.positions=e.getPropertyArray("POSITION",O.FLOAT,3);else if(e.hasProperty("POSITION_QUANTIZED")){let n=e.getPropertyArray("POSITION_QUANTIZED",O.UNSIGNED_SHORT,3);if(t.isQuantized=!0,t.quantizedRange=65535,t.quantizedVolumeScale=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",O.FLOAT,3),!t.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(t.quantizedVolumeOffset=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",O.FLOAT,3),!t.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");t.attributes.positions=Dg(t,n,r)}}if(!t.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function VI(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.colors){let n=null;e.hasProperty("RGBA")?(n=e.getPropertyArray("RGBA",O.UNSIGNED_BYTE,4),t.isTranslucent=!0):e.hasProperty("RGB")?n=e.getPropertyArray("RGB",O.UNSIGNED_BYTE,3):e.hasProperty("RGB565")&&(n=e.getPropertyArray("RGB565",O.UNSIGNED_SHORT,1),t.isRGB565=!0),t.attributes.colors=xl(t,n,r)}e.hasProperty("CONSTANT_RGBA")&&(t.constantRGBA=e.getGlobalProperty("CONSTANT_RGBA",O.UNSIGNED_BYTE,4))}function GI(t,e){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.normals){let r=null;e.hasProperty("NORMAL")?r=e.getPropertyArray("NORMAL",O.FLOAT,3):e.hasProperty("NORMAL_OCT16P")&&(r=e.getPropertyArray("NORMAL_OCT16P",O.UNSIGNED_BYTE,2),t.isOctEncoded16P=!0),t.attributes.normals=Ug(t,r)}}function HI(t,e){let r=null;if(!t.batchIds&&e.hasProperty("BATCH_ID")&&(t.batchIds=e.getPropertyArray("BATCH_ID",O.UNSIGNED_SHORT,1),t.batchIds)){let n=e.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:o,batchTableBinary:s}=t;r=new mr(o,s,n)}return r}async function kI(t,e,r,n,o){let s,i,a,c=t.batchTableJson&&t.batchTableJson.extensions&&t.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);let l=e.getExtension("3DTILES_draco_point_compression");if(l){i=l.properties;let u=l.byteOffset,h=l.byteLength;if(!i||!Number.isFinite(u)||!h)throw new Error("Draco properties, byteOffset, and byteLength must be defined");s=(t.featureTableBinary||[]).slice(u,u+h),t.hasPositions=Number.isFinite(i.POSITION),t.hasColors=Number.isFinite(i.RGB)||Number.isFinite(i.RGBA),t.hasNormals=Number.isFinite(i.NORMAL),t.hasBatchIds=Number.isFinite(i.BATCH_ID),t.isTranslucent=Number.isFinite(i.RGBA)}if(!s)return!0;let f={buffer:s,properties:{...i,...a},featureTableProperties:i,batchTableProperties:a,dequantizeInShader:!1};return await zI(t,f,n,o)}async function zI(t,e,r,n){if(!n)return;let o={...r,draco:{...r?.draco,extraAttributes:e.batchTableProperties||{}}};delete o["3d-tiles"];let s=await Oe(e.buffer,Ao,o,n),i=s.attributes.POSITION&&s.attributes.POSITION.value,a=s.attributes.COLOR_0&&s.attributes.COLOR_0.value,c=s.attributes.NORMAL&&s.attributes.NORMAL.value,l=s.attributes.BATCH_ID&&s.attributes.BATCH_ID.value,f=i&&s.attributes.POSITION.value.quantization,u=c&&s.attributes.NORMAL.value.quantization;if(f){let p=s.POSITION.data.quantization,d=p.range;t.quantizedVolumeScale=new x(d,d,d),t.quantizedVolumeOffset=new x(p.minValues),t.quantizedRange=(1<<p.quantizationBits)-1,t.isQuantizedDraco=!0}u&&(t.octEncodedRange=(1<<s.NORMAL.data.quantization.quantizationBits)-1,t.isOctEncodedDraco=!0);let h={};if(e.batchTableProperties)for(let p of Object.keys(e.batchTableProperties))s.attributes[p]&&s.attributes[p].value&&(h[p.toLowerCase()]=s.attributes[p].value);t.attributes={positions:i,colors:xl(t,a,void 0),normals:c,batchIds:l,...h}}var Tl={};Ae(Tl,{createExtMeshFeatures:()=>iv,decode:()=>tv,encode:()=>rv,name:()=>ev});function ue(t,e){if(!t)throw new Error(e||"assert failed: gltf")}var Ai={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bi={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var qI=1.33,Gg=["SCALAR","VEC2","VEC3","VEC4"],jI=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],JI=new Map(jI),WI={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},XI={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},KI={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function xi(t){return Gg[t-1]||Gg[0]}function Ht(t){let e=JI.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function tn(t,e){let r=KI[t.componentType],n=WI[t.type],o=XI[t.componentType],s=t.count*n,i=t.count*n*o;ue(i>=0&&i<=e.byteLength);let a=bi[t.componentType],c=Ai[t.type];return{ArrayType:r,length:s,byteLength:i,componentByteSize:a,numberOfComponentsInElement:c}}function bo(t){let{images:e,bufferViews:r}=t;e=e||[],r=r||[];let n=e.map(i=>i.bufferView);r=r.filter(i=>!n.includes(i));let o=r.reduce((i,a)=>i+a.byteLength,0),s=e.reduce((i,a)=>{let{width:c,height:l}=a.image;return i+c*l},0);return o+Math.ceil(4*s*qI)}function Hg(t,e,r){let n=t.bufferViews[r];ue(n);let o=n.buffer,s=e[o];ue(s);let i=(n.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,i,n.byteLength)}function kg(t,e,r){let n=typeof r=="number"?t.accessors?.[r]:r;if(!n)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let o=t.bufferViews?.[n.bufferView||0];if(!o)throw new Error(`No gltf buffer view for accessor ${o}`);let{arrayBuffer:s,byteOffset:i}=e[o.buffer],a=(i||0)+(n.byteOffset||0)+(o.byteOffset||0),{ArrayType:c,length:l,componentByteSize:f,numberOfComponentsInElement:u}=tn(n,o),h=f*u,p=o.byteStride||h;if(typeof o.byteStride>"u"||o.byteStride===h)return new c(s,a,l);let d=new c(l);for(let m=0;m<n.count;m++){let g=new c(s,a+m*p,u);d.set(g,m*u)}return d}function YI(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var q=class{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||YI(),buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){let r=this.getUsedExtensions().find(o=>o===e),n=this.getRequiredExtensions().find(o=>o===e);return typeof r=="string"||typeof n=="string"}getExtension(e){let r=this.getUsedExtensions().find(o=>o===e),n=this.json.extensions||{};return r?n[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(n=>n===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;let n=this.json[e]&&this.json[e][r];if(!n)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return n}getTypedArrayForBufferView(e){e=this.getBufferView(e);let r=e.buffer,n=this.gltf.buffers[r];ue(n);let o=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,o,e.byteLength)}getTypedArrayForAccessor(e){let r=this.getAccessor(e);return kg(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);let r=this.getBufferView(e.bufferView),o=this.getBuffer(r.buffer).data,s=r.byteOffset||0;return new Uint8Array(o,s,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,n){return e.extensions=e.extensions||{},e.extensions[r]=n,this.registerUsedExtension(r),this}setObjectExtension(e,r,n){let o=e.extensions||{};o[r]=n}removeObjectExtension(e,r){let n=e?.extensions||{};if(n[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let o=this.json.extensionsRemoved;o.includes(r)||o.push(r)}delete n[r]}addExtension(e,r={}){return ue(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return ue(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(e)||r.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){let{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){let{meshIndex:r,matrix:n}=e;this.json.nodes=this.json.nodes||[];let o={mesh:r};return n&&(o.matrix=n),this.json.nodes.push(o),this.json.nodes.length-1}addMesh(e){let{attributes:r,indices:n,material:o,mode:s=4}=e,a={primitives:[{attributes:this._addAttributes(r),mode:s}]};if(n){let c=this._addIndices(n);a.primitives[0].indices=c}return Number.isFinite(o)&&(a.primitives[0].material=o),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){let n={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(n),this.json.meshes.length-1}addImage(e,r){let n=sr(e),o=r||n?.mimeType,i={bufferView:this.addBufferView(e),mimeType:o};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(e,r=0,n=this.byteLength){let o=e.byteLength;ue(Number.isFinite(o)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);let s={buffer:r,byteOffset:n,byteLength:o};return this.byteLength+=Lt(o,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(s),this.json.bufferViews.length-1}addAccessor(e,r){let n={bufferView:e,type:xi(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){let n=this.addBufferView(e),o={min:r.min,max:r.max};(!o.min||!o.max)&&(o=this._getAccessorMinMax(e,r.size));let s={size:r.size,componentType:Ht(e),count:Math.round(e.length/r.size),min:o.min,max:o.max};return this.addAccessor(n,Object.assign(s,r))}addTexture(e){let{imageIndex:r}=e,n={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){let e=this.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r),o=0;for(let s of this.sourceBuffers||[])o=yc(s,n,o);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r],this.gltf.buffers=[{arrayBuffer:r,byteOffset:0,byteLength:r.byteLength}]}_removeStringFromArray(e,r){let n=!0;for(;n;){let o=e.indexOf(r);o>-1?e.splice(o,1):n=!1}}_addAttributes(e={}){let r={};for(let n in e){let o=e[n],s=this._getGltfAttributeName(n),i=this.addBinaryBuffer(o.value,o);r[s]=i}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){let n={min:null,max:null};if(e.length<r)return n;n.min=[],n.max=[];let o=e.subarray(0,r);for(let s of o)n.min.push(s),n.max.push(s);for(let s=r;s<e.length;s+=r)for(let i=0;i<r;i++)n.min[0+i]=Math.min(n.min[0+i],e[s+i]),n.max[0+i]=Math.max(n.max[0+i],e[s+i]);return n}};function zg(t){return(t%1+1)%1}var qg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},QI={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},jg={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function xo(t,e){return jg[e]*qg[t]}function rn(t,e,r,n){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;let o=t.getTypedArrayForBufferView(e),s=nn(o,"SCALAR",r,n+1);return s instanceof BigInt64Array||s instanceof BigUint64Array?null:s}function nn(t,e,r,n=1){let o=qg[e],s=QI[r],i=jg[r],a=n*o,c=a*i,l=t.buffer,f=t.byteOffset;return f%i!==0&&(l=new Uint8Array(l).slice(f,f+c).buffer,f=0),new s(Nt(l),f,a)}function on(t,e,r){let n=`TEXCOORD_${e.texCoord||0}`,o=r.attributes[n],s=t.getTypedArrayForAccessor(o),i=t.gltf.json,a=e.index,c=i.textures?.[a]?.source;if(typeof c<"u"){let l=i.images?.[c]?.mimeType,f=t.gltf.images?.[c];if(f&&typeof f.width<"u"){let u=[];for(let h=0;h<s.length;h+=2){let p=ZI(f,l,s,h,e.channels);u.push(p)}return u}}return[]}function Ti(t,e,r,n,o){if(!r?.length)return;let s=[];for(let f of r){let u=n.findIndex(h=>h===f);u===-1&&(u=n.push(f)-1),s.push(u)}let i=new Uint32Array(s),a=t.gltf.buffers.push({arrayBuffer:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength})-1,c=t.addBufferView(i,a,0),l=t.addAccessor(c,{size:1,componentType:Ht(i),count:i.length});o.attributes[e]=l}function ZI(t,e,r,n,o=[0]){let s={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},i=r[n],a=r[n+1],c=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(c=4);let l=$I(i,a,t,c),f=0;for(let u of o){let h=typeof u=="number"?Object.values(s)[u]:s[u],p=l+h.offset,d=Kn(t);if(d.data.length<=p)throw new Error(`${d.data.length} <= ${p}`);let m=d.data[p];f|=m<<h.shift}return f}function $I(t,e,r,n=1){let o=r.width,s=zg(t)*(o-1),i=Math.round(s),a=r.height,c=zg(e)*(a-1),l=Math.round(c),f=r.components?r.components:n;return(l*o+i)*f}function yi(t,e,r,n,o){let s=[];for(let i=0;i<e;i++){let a=r[i],c=r[i+1]-r[i];if(c+a>n)break;let l=a/o,f=c/o;s.push(t.slice(l,l+f))}return s}function Si(t,e,r){let n=[];for(let o=0;o<e;o++){let s=o*r;n.push(t.slice(s,s+r))}return n}function Mi(t,e,r,n){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(n){let o=[],s=new TextDecoder("utf8"),i=0;for(let a=0;a<t;a++){let c=n[a+1]-n[a];if(c+i<=e.length){let l=e.subarray(i,c+i),f=s.decode(l);o.push(f),i+=c}}return o}return[]}var sn="EXT_mesh_features",ev=sn;async function tv(t,e){let r=new q(t);nv(r,e)}function rv(t,e){let r=new q(t);return sv(r,e),r.createBinaryChunk(),r.gltf}function nv(t,e){let r=t.gltf.json;if(r.meshes)for(let n of r.meshes)for(let o of n.primitives)ov(t,o,e)}function ov(t,e,r){if(!r?.gltf?.loadBuffers)return;let o=e.extensions?.[sn]?.featureIds;if(o)for(let s of o){let i;if(typeof s.attribute<"u"){let a=`_FEATURE_ID_${s.attribute}`,c=e.attributes[a];i=t.getTypedArrayForAccessor(c)}else typeof s.texture<"u"&&r?.gltf?.loadImages?i=on(t,s.texture,e):i=[];s.data=i}}function sv(t,e){let r=t.gltf.json.meshes;if(r)for(let n of r)for(let o of n.primitives)av(t,o)}function iv(t,e,r,n){e.extensions||(e.extensions={});let o=e.extensions[sn];o||(o={featureIds:[]},e.extensions[sn]=o);let{featureIds:s}=o,i={featureCount:r.length,propertyTable:n,data:r};s.push(i),t.addObjectExtension(e,sn,o)}function av(t,e){let r=e.extensions?.[sn];if(!r)return;let n=r.featureIds;n.forEach((o,s)=>{if(o.data){let{accessorKey:i,index:a}=cv(e.attributes),c=new Uint32Array(o.data);n[s]={featureCount:c.length,propertyTable:o.propertyTable,attribute:a},t.gltf.buffers.push({arrayBuffer:c.buffer,byteOffset:c.byteOffset,byteLength:c.byteLength});let l=t.addBufferView(c),f=t.addAccessor(l,{size:1,componentType:Ht(c),count:c.length});e.attributes[i]=f}})}function cv(t){let e="_FEATURE_ID_",r=Object.keys(t).filter(s=>s.indexOf(e)===0),n=-1;for(let s of r){let i=Number(s.substring(e.length));i>n&&(n=i)}return n++,{accessorKey:`${e}${n}`,index:n}}var Ml={};Ae(Ml,{createExtStructuralMetadata:()=>Rv,decode:()=>fv,encode:()=>uv,name:()=>lv});var an="EXT_structural_metadata",lv=an;async function fv(t,e){let r=new q(t);hv(r,e)}function uv(t,e){let r=new q(t);return vv(r,e),r.createBinaryChunk(),r.gltf}function hv(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(an);r&&(e.gltf?.loadImages&&pv(t,r),dv(t,r))}function pv(t,e){let r=e.propertyTextures,n=t.gltf.json;if(r&&n.meshes)for(let o of n.meshes)for(let s of o.primitives)gv(t,r,s,e)}function dv(t,e){let r=e.schema;if(!r)return;let n=r.classes,o=e.propertyTables;if(n&&o)for(let s in n){let i=mv(o,s);i&&bv(t,r,i)}}function mv(t,e){for(let r of t)if(r.class===e)return r;return null}function gv(t,e,r,n){if(!e)return;let s=r.extensions?.[an]?.propertyTextures;if(s)for(let i of s){let a=e[i];Av(t,a,r,n)}}function Av(t,e,r,n){if(!e.properties)return;n.dataAttributeNames||(n.dataAttributeNames=[]);let o=e.class;for(let s in e.properties){let i=`${o}_${s}`,a=e.properties?.[s];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=on(t,a,r);l!==null&&(Ti(t,i,l,c,r),a.data=c,n.dataAttributeNames.push(i))}}function bv(t,e,r){let n=e.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let o=r.count;for(let s in n.properties){let i=n.properties[s],a=r.properties?.[s];if(a){let c=xv(t,e,i,o,a);a.data=c}}}function xv(t,e,r,n,o){let s=[],i=o.values,a=t.getTypedArrayForBufferView(i),c=Tv(t,r,o,n),l=yv(t,o,n);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{s=Sv(r,n,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{s=Mi(n,a,c,l);break}case"ENUM":{s=Mv(e,r,n,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return s}function Tv(t,e,r,n){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?rn(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",n):null}function yv(t,e,r){return typeof e.stringOffsets<"u"?rn(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function Sv(t,e,r,n){let o=t.array,s=t.count,i=xo(t.type,t.componentType),a=r.byteLength/i,c;return t.componentType?c=nn(r,t.type,t.componentType,a):c=r,o?n?yi(c,e,n,r.length,i):s?Si(c,e,s):[]:c}function Mv(t,e,r,n,o){let s=e.enumType;if(!s)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let i=t.enums?.[s];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${s}`);let a=i.valueType||"UINT16",c=xo(e.type,a),l=n.byteLength/c,f=nn(n,e.type,a,l);if(f||(f=n),e.array){if(o)return _v({valuesData:f,numberOfElements:r,arrayOffsets:o,valuesDataBytesLength:n.length,elementSize:c,enumEntry:i});let u=e.count;return u?Ev(f,r,u,i):[]}return Sl(f,0,r,i)}function _v(t){let{valuesData:e,numberOfElements:r,arrayOffsets:n,valuesDataBytesLength:o,elementSize:s,enumEntry:i}=t,a=[];for(let c=0;c<r;c++){let l=n[c],f=n[c+1]-n[c];if(f+l>o)break;let u=l/s,h=f/s,p=Sl(e,u,h,i);a.push(p)}return a}function Ev(t,e,r,n){let o=[];for(let s=0;s<e;s++){let i=r*s,a=Sl(t,i,r,n);o.push(a)}return o}function Sl(t,e,r,n){let o=[];for(let s=0;s<r;s++)if(t instanceof BigInt64Array||t instanceof BigUint64Array)o.push("");else{let i=t[e+s],a=Cv(n,i);a?o.push(a.name):o.push("")}return o}function Cv(t,e){for(let r of t.values)if(r.value===e)return r;return null}var Iv="schemaClassId";function vv(t,e){let r=t.getExtension(an);if(r&&r.propertyTables)for(let n of r.propertyTables){let o=n.class,s=r.schema?.classes?.[o];n.properties&&s&&Bv(n,s,t)}}function Bv(t,e,r){for(let n in t.properties){let o=t.properties[n].data;if(o){let s=e.properties[n];if(s){let i=Fv(o,s,r);t.properties[n]=i}}}}function Rv(t,e,r=Iv){let n=t.getExtension(an);n||(n=t.addExtension(an)),n.schema=wv(e,r,n.schema);let o=Lv(e,r,n.schema);return n.propertyTables||(n.propertyTables=[]),n.propertyTables.push(o)-1}function wv(t,e,r){let n=r??{id:"schema_id"},o={properties:{}};for(let s of t){let i={type:s.elementType,componentType:s.componentType};o.properties[s.name]=i}return n.classes={},n.classes[e]=o,n}function Lv(t,e,r){let n={class:e,count:0},o=0,s=r.classes?.[e];for(let i of t){if(o===0&&(o=i.values.length),o!==i.values.length&&i.values.length)throw new Error("Illegal values in attributes");s?.properties[i.name]&&(n.properties||(n.properties={}),n.properties[i.name]={values:0,data:i.values})}return n.count=o,n}function Fv(t,e,r){let n={values:0};if(e.type==="STRING"){let{stringData:o,stringOffsets:s}=Ov(t);n.stringOffsets=yl(s,r),n.values=yl(o,r)}else if(e.type==="SCALAR"&&e.componentType){let o=Nv(t,e.componentType);n.values=yl(o,r)}return n}var Pv={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function Nv(t,e){let r=[];for(let o of t)r.push(Number(o));let n=Pv[e];if(!n)throw new Error("Illegal component type");return new n(r)}function Ov(t){let e=new TextEncoder,r=[],n=0;for(let c of t){let l=e.encode(c);n+=l.length,r.push(l)}let o=new Uint8Array(n),s=[],i=0;for(let c of r)o.set(c,i),s.push(i),i+=c.length;s.push(i);let a=new Uint32Array(s);return{stringData:o,stringOffsets:a}}function yl(t,e){return e.gltf.buffers.push({arrayBuffer:Nt(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength}),e.addBufferView(t)}var _l={};Ae(_l,{decode:()=>Dv,name:()=>Uv});var Jg="EXT_feature_metadata",Uv=Jg;async function Dv(t,e){let r=new q(t);Vv(r,e)}function Vv(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(Jg);r&&(e.gltf?.loadImages&&Gv(t,r),Hv(t,r))}function Gv(t,e){let r=e.schema;if(!r)return;let n=r.classes,{featureTextures:o}=e;if(n&&o)for(let s in n){let i=n[s],a=zv(o,s);a&&jv(t,a,i)}}function Hv(t,e){let r=e.schema;if(!r)return;let n=r.classes,o=e.featureTables;if(n&&o)for(let s in n){let i=kv(o,s);i&&qv(t,r,i)}}function kv(t,e){for(let r in t){let n=t[r];if(n.class===e)return n}return null}function zv(t,e){for(let r in t){let n=t[r];if(n.class===e)return n}return null}function qv(t,e,r){if(!r.class)return;let n=e.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let o=r.count;for(let s in n.properties){let i=n.properties[s],a=r.properties?.[s];if(a){let c=Jv(t,e,i,o,a);a.data=c}}}function jv(t,e,r){let n=e.class;for(let o in r.properties){let s=e?.properties?.[o];if(s){let i=Qv(t,s,n);s.data=i}}}function Jv(t,e,r,n,o){let s=[],i=o.bufferView,a=t.getTypedArrayForBufferView(i),c=Wv(t,r,o,n),l=Xv(t,r,o,n);return r.type==="STRING"||r.componentType==="STRING"?s=Mi(n,a,c,l):Kv(r)&&(s=Yv(r,n,a,c)),s}function Wv(t,e,r,n){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?rn(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",n):null}function Xv(t,e,r,n){return typeof r.stringOffsetBufferView<"u"?rn(t,r.stringOffsetBufferView,r.offsetType||"UINT32",n):null}function Kv(t){let e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function Yv(t,e,r,n){let o=t.type==="ARRAY",s=t.componentCount,i="SCALAR",a=t.componentType||t.type,c=xo(i,a),l=r.byteLength/c,f=nn(r,i,a,l);return o?n?yi(f,e,n,r.length,c):s?Si(f,e,s):[]:f}function Qv(t,e,r){let n=t.gltf.json;if(!n.meshes)return[];let o=[];for(let s of n.meshes)for(let i of s.primitives)Zv(t,r,e,o,i);return o}function Zv(t,e,r,n,o){let s={channels:r.channels,...r.texture},i=on(t,s,o);i&&Ti(t,e,i,n,o)}var Wg="4.4.3";var Xg="4.4.3";var _i={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},Kg;async function Cl(t){Ac(t.modules);let e=bc("basis");return e||(Kg||=$v(t),await Kg)}async function $v(t){let e=null,r=null;return[e,r]=await Promise.all([await Ve(_i.TRANSCODER,"textures",t),await Ve(_i.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await eB(e,r)}function eB(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t(r).then(o=>{let{BasisFile:s,initializeBasis:i}=o;i(),n({BasisFile:s})})})}var El;async function Il(t){let e=t.modules||{};return e.basisEncoder?e.basisEncoder:(El=El||tB(t),await El)}async function tB(t){let e=null,r=null;return[e,r]=await Promise.all([await Ve(_i.ENCODER,"textures",t),await Ve(_i.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await rB(e,r)}function rB(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(n=>{t(r).then(o=>{let{BasisFile:s,KTX2File:i,initializeBasis:a,BasisEncoder:c}=o;a(),n({BasisFile:s,KTX2File:i,BasisEncoder:c})})})}var nB=["","WEBKIT_","MOZ_"],Yg={WEBGL_compressed_texture_s3tc:["bc1-rgb-unorm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rgb-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};var Ei=null;function Qg(t){if(!Ei){t=t||oB()||void 0,Ei=new Set;for(let e of nB)for(let r in Yg)if(t&&t.getExtension(`${e}${r}`))for(let n of Yg[r])Ei.add(n)}return Ei}function oB(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var Ue=[171,75,84,88,32,50,48,187,13,10,26,10];function Zg(t){let e=new Uint8Array(t);return!(e.byteLength<Ue.length||e[0]!==Ue[0]||e[1]!==Ue[1]||e[2]!==Ue[2]||e[3]!==Ue[3]||e[4]!==Ue[4]||e[5]!==Ue[5]||e[6]!==Ue[6]||e[7]!==Ue[7]||e[8]!==Ue[8]||e[9]!==Ue[9]||e[10]!==Ue[10]||e[11]!==Ue[11])}var $g=Promise.resolve(),r0={etc1:{basisFormat:0,compressed:!0,format:36196,textureFormat:"etc1-rgb-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:37493,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:33776,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:33779,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:36283,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:36285,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:37808,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:35986,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:34798,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:32856,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:32854,textureFormat:"rgba4unorm-webgl"}},xk=Object.freeze(Object.keys(r0));async function aB(t){let e=$g,r;$g=new Promise(n=>{r=n}),await e;try{return await t()}finally{r()}}async function n0(t,e={}){let r=Gn(e);return await aB(async()=>{if(!e.basis?.containerFormat||e.basis.containerFormat==="auto"){if(Zg(t)){let o=await Il(r);return e0(o.KTX2File,t,e)}let{BasisFile:n}=await Cl(r);return vl(n,t,e)}if(e.basis.module==="encoder"){let n=await Il(r);return e.basis.containerFormat==="ktx2"?e0(n.KTX2File,t,e):vl(n.BasisFile,t,e)}else{let{BasisFile:o}=await Cl(r);return vl(o,t,e)}})}function vl(t,e,r){let n=new t(new Uint8Array(e));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");let o=n.getNumImages(),s=[];for(let i=0;i<o;i++){let a=n.getNumLevels(i),c=[];for(let l=0;l<a;l++)c.push(cB(n,i,l,r));s.push(c)}return s}finally{n.close(),n.delete()}}function cB(t,e,r,n){let o=t.getImageWidth(e,r),s=t.getImageHeight(e,r),i=t.getHasAlpha(),{compressed:a,format:c,basisFormat:l,textureFormat:f}=o0(n,i),u=t.getImageTranscodedSizeInBytes(e,r,l),h=new Uint8Array(u);if(!t.transcodeImage(h,e,r,l,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:o,height:s,data:h,compressed:a,...c!==void 0?{format:c}:{},...f!==void 0?{textureFormat:f}:{},hasAlpha:i}}function e0(t,e,r){let n=new t(new Uint8Array(e));try{if(!n.startTranscoding())throw new Error("failed to start KTX2 transcoding");let o=n.getLevels(),s=[];for(let i=0;i<o;i++)s.push(lB(n,i,r));return[s]}finally{n.close(),n.delete()}}function lB(t,e,r){let{alphaFlag:n,height:o,width:s}=t.getImageLevelInfo(e,0,0),{compressed:i,format:a,basisFormat:c,textureFormat:l}=o0(r,n),f=t.getImageTranscodedSizeInBytes(e,0,0,c),u=new Uint8Array(f);if(!t.transcodeImage(u,e,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:s,height:o,data:u,compressed:i,...a!==void 0?{format:a}:{},...l!==void 0?{textureFormat:l}:{},levelSize:f,hasAlpha:n}}function o0(t,e){let r=t.basis?.format||"auto";r==="auto"&&(r=t.basis?.supportedTextureFormats?t0(t.basis.supportedTextureFormats):t0()),typeof r=="object"&&(r=e?r.alpha:r.noAlpha);let n=r.toLowerCase(),o=r0[n];if(!o)throw new Error(`Unknown Basis format ${r}`);return o}function t0(t=Qg()){let e=new Set(t);return cn(e,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":cn(e,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:cn(e,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:cn(e,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:cn(e,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":e.has("etc1-rgb-unorm-webgl")?"etc1":cn(e,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function cn(t,e){return e.some(r=>t.has(r))}var s0={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:Xg,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}}},Bl={...s0,parse:n0};var ln=!0,i0=1735152710,Ll=12,Ci=8,fB=1313821514,uB=5130562,hB=0,pB=0,dB=1;function mB(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function a0(t,e=0,r={}){let n=new DataView(t),{magic:o=i0}=r,s=n.getUint32(e,!1);return s===o||s===i0}function c0(t,e,r=0,n={}){let o=new DataView(e),s=mB(o,r+0),i=o.getUint32(r+4,ln),a=o.getUint32(r+8,ln);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:s,version:i,json:{},binChunks:[]}),r+=Ll,t.version){case 1:return gB(t,o,r);case 2:return AB(t,o,r,n={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function gB(t,e,r){H(t.header.byteLength>Ll+Ci);let n=e.getUint32(r+0,ln),o=e.getUint32(r+4,ln);return r+=Ci,H(o===hB),Rl(t,e,r,n),r+=n,r+=wl(t,e,r,t.header.byteLength),r}function AB(t,e,r,n){return H(t.header.byteLength>Ll+Ci),bB(t,e,r,n),r+t.header.byteLength}function bB(t,e,r,n){for(;r+8<=t.header.byteLength;){let o=e.getUint32(r+0,ln),s=e.getUint32(r+4,ln);switch(r+=Ci,s){case fB:Rl(t,e,r,o);break;case uB:wl(t,e,r,o);break;case pB:n.strict||Rl(t,e,r,o);break;case dB:n.strict||wl(t,e,r,o);break;default:break}r+=Lt(o,4)}return r}function Rl(t,e,r,n){let o=new Uint8Array(e.buffer,r,n),i=new TextDecoder("utf8").decode(o);return t.json=JSON.parse(i),Lt(n,4)}function wl(t,e,r,n){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:n,arrayBuffer:e.buffer}),Lt(n,4)}function Fl(t,e,r){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;let o=r?.baseUrl||xB(e?.core?.baseUrl);if(!o)throw new Error(`'baseUrl' must be provided to resolve relative url ${t}`);return o.endsWith("/")?`${o}${t}`:`${o}/${t}`}function xB(t){if(!t)return;if(t.endsWith("/"))return t;let e=t.lastIndexOf("/");return e>=0?t.slice(0,e+1):""}var Nl={};Ae(Nl,{decode:()=>wB,name:()=>RB});var TB="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",yB="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",SB=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),MB=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),_B={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},EB={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function l0(t,e,r,n,o,s="NONE"){let i=await CB();BB(i,i.exports[EB[o]],t,e,r,n,i.exports[_B[s||"NONE"]])}var Pl;async function CB(){return Pl||(Pl=IB()),Pl}async function IB(){let t=TB;WebAssembly.validate(SB)&&(t=yB,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let e=await WebAssembly.instantiate(vB(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function vB(t){let e=new Uint8Array(t.length);for(let n=0;n<t.length;++n){let o=t.charCodeAt(n);e[n]=o>96?o-71:o>64?o-65:o>47?o+4:o>46?63:62}let r=0;for(let n=0;n<t.length;++n)e[r++]=e[n]<60?MB[e[n]]:(e[n]-60)*64+e[++n];return e.buffer.slice(0,r)}function BB(t,e,r,n,o,s,i){let a=t.exports.sbrk,c=n+3&-4,l=a(c*o),f=a(s.length),u=new Uint8Array(t.exports.memory.buffer);u.set(s,f);let h=e(l,n,o,f,s.length);if(h===0&&i&&i(l,c,o),r.set(u.subarray(l,l+n*o)),a(l-a(0)),h!==0)throw new Error(`Malformed buffer data: ${h}`)}var Ii="EXT_meshopt_compression",RB=Ii;async function wB(t,e){let r=new q(t);if(!e?.gltf?.decompressMeshes||!e.gltf?.loadBuffers)return;let n=[];for(let o of t.json.bufferViews||[])n.push(LB(r,o));await Promise.all(n),r.removeExtension(Ii)}async function LB(t,e){let r=t.getObjectExtension(e,Ii);if(r){let{byteOffset:n=0,byteLength:o=0,byteStride:s,count:i,mode:a,filter:c="NONE",buffer:l}=r,f=t.gltf.buffers[l],u=new Uint8Array(f.arrayBuffer,f.byteOffset+n,o),h=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);await l0(h,i,s,u,a,c),t.removeObjectExtension(e,Ii)}}var Ol={};Ae(Ol,{name:()=>FB,preprocess:()=>PB});var fn="EXT_texture_webp",FB=fn;function PB(t,e){let r=new q(t);if(!Lc("image/webp")){if(r.getRequiredExtensions().includes(fn))throw new Error(`gltf: Required extension ${fn} not supported by browser`);return}let{json:n}=r;for(let o of n.textures||[]){let s=r.getObjectExtension(o,fn);s&&(o.source=s.source),r.removeObjectExtension(o,fn)}r.removeExtension(fn)}var Ul={};Ae(Ul,{name:()=>NB,preprocess:()=>OB});var vi="KHR_texture_basisu",NB=vi;function OB(t,e){let r=new q(t),{json:n}=r;for(let o of n.textures||[]){let s=r.getObjectExtension(o,vi);s&&(o.source=s.source,r.removeObjectExtension(o,vi))}r.removeExtension(vi)}var Vl={};Ae(Vl,{decode:()=>HB,encode:()=>kB,name:()=>VB,preprocess:()=>GB});function f0(t){let e={};for(let r in t){let n=t[r];if(r!=="indices"){let o=Dl(n);e[r]=o}}return e}function Dl(t){let{buffer:e,size:r,count:n}=UB(t);return{value:e,size:r,byteOffset:0,count:n,type:xi(r),componentType:Ht(e)}}function UB(t){let e=t,r=1,n=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=DB(e,Float32Array)),n=e.length/r),{buffer:e,size:r,count:n}}function DB(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}var kt="KHR_draco_mesh_compression",VB=kt;function GB(t,e,r){let n=new q(t);for(let o of u0(n))n.getObjectExtension(o,kt)}async function HB(t,e,r){if(!e?.gltf?.decompressMeshes)return;let n=new q(t),o=[];for(let s of u0(n))n.getObjectExtension(s,kt)&&o.push(zB(n,s,e,r));await Promise.all(o),n.removeExtension(kt)}function kB(t,e={}){let r=new q(t);for(let n of r.json.meshes||[])qB(n,e),r.addRequiredExtension(kt)}async function zB(t,e,r,n){let o=t.getObjectExtension(e,kt);if(!o)return;let s=t.getTypedArrayForBufferView(o.bufferView),i=tr(s.buffer,s.byteOffset),a={...r};delete a["3d-tiles"];let c=await Oe(i,Ao,a,n),l=f0(c.attributes);for(let[f,u]of Object.entries(l))if(f in e.attributes){let h=e.attributes[f],p=t.getAccessor(h);p?.min&&p?.max&&(u.min=p.min,u.max=p.max)}e.attributes=l,c.indices&&(e.indices=Dl(c.indices)),t.removeObjectExtension(e,kt),jB(e)}function qB(t,e,r=4,n,o){if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let s=n.DracoWriter.encodeSync({attributes:t}),i=o?.parseSync?.({attributes:t}),a=n._addFauxAttributes(i.attributes),c=n.addBufferView(s);return{primitives:[{attributes:a,mode:r,extensions:{[kt]:{bufferView:c,attributes:a}}}]}}function jB(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*u0(t){for(let e of t.json.meshes||[])for(let r of e.primitives)yield r}var Gl={};Ae(Gl,{decode:()=>KB,name:()=>JB});var Ri="KHR_texture_transform",JB=Ri,Bi=new x,WB=new z,XB=new z;async function KB(t,e){if(!new q(t).hasExtension(Ri)||!e.gltf?.loadBuffers)return;let o=t.json.materials||[];for(let s=0;s<o.length;s++)YB(s,t)}function YB(t,e){let r=e.json.materials?.[t],n=[r?.pbrMetallicRoughness?.baseColorTexture,r?.emissiveTexture,r?.normalTexture,r?.occlusionTexture,r?.pbrMetallicRoughness?.metallicRoughnessTexture],o=[];for(let s of n)s&&s?.extensions?.[Ri]&&QB(e,t,s,o)}function QB(t,e,r,n){let o=ZB(r,n);if(!o)return;let s=t.json.meshes||[];for(let i of s)for(let a of i.primitives){let c=a.material;Number.isFinite(c)&&e===c&&$B(t,a,o)}}function ZB(t,e){let r=t.extensions?.[Ri],{texCoord:n=0}=t,{texCoord:o=n}=r;if(!(e.findIndex(([i,a])=>i===n&&a===o)!==-1)){let i=r3(r);return n!==o&&(t.texCoord=o),e.push([n,o]),{originalTexCoord:n,texCoord:o,matrix:i}}return null}function $B(t,e,r){let{originalTexCoord:n,texCoord:o,matrix:s}=r,i=e.attributes[`TEXCOORD_${n}`];if(Number.isFinite(i)){let a=t.json.accessors?.[i];if(a&&a.bufferView!==void 0){let c=t.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:f}=t.buffers[c.buffer],u=(f||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:h,length:p}=tn(a,c),d=bi[a.componentType],m=Ai[a.type],g=c.byteStride||d*m,b=new Float32Array(p);for(let T=0;T<a.count;T++){let S=new h(l,u+T*g,2);Bi.set(S[0],S[1],1),Bi.transformByMatrix3(s),b.set([Bi[0],Bi[1]],T*m)}n===o?e3(a,t,b,a.bufferView):t3(o,a,e,t,b)}}}}function e3(t,e,r,n){t.componentType=5126,t.byteOffset=0;let i=(e.json.accessors||[]).reduce((l,f)=>f.bufferView===n?l+1:l,0)>1;e.buffers.push({arrayBuffer:Nt(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength});let a=e.buffers.length-1;if(e.json.bufferViews=e.json.bufferViews||[],i){e.json.bufferViews.push({buffer:a,byteLength:r.buffer.byteLength,byteOffset:0}),t.bufferView=e.json.bufferViews.length-1;return}let c=e.json.bufferViews[n];c&&(c.buffer=a,c.byteOffset=0,c.byteLength=r.buffer.byteLength,c.byteStride!==void 0&&delete c.byteStride)}function t3(t,e,r,n,o){n.buffers.push({arrayBuffer:Nt(o.buffer),byteOffset:0,byteLength:o.buffer.byteLength}),n.json.bufferViews=n.json.bufferViews||[];let s=n.json.bufferViews;s.push({buffer:n.buffers.length-1,byteLength:o.buffer.byteLength,byteOffset:0});let i=n.json.accessors;i&&(i.push({bufferView:s?.length-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),r.attributes[`TEXCOORD_${t}`]=i.length-1)}function r3(t){let{offset:e=[0,0],rotation:r=0,scale:n=[1,1]}=t,o=new z().set(1,0,0,0,1,0,e[0],e[1],1),s=WB.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),i=XB.set(n[0],0,0,0,n[1],0,0,0,1);return o.multiplyRight(s).multiplyRight(i)}var Hl={};Ae(Hl,{decode:()=>o3,encode:()=>s3,name:()=>n3});var gr="KHR_lights_punctual",n3=gr;async function o3(t){let e=new q(t),{json:r}=e,n=e.getExtension(gr);n&&(e.json.lights=n.lights,e.removeExtension(gr));for(let o of r.nodes||[]){let s=e.getObjectExtension(o,gr);s&&(o.light=s.light),e.removeObjectExtension(o,gr)}}async function s3(t){let e=new q(t),{json:r}=e;if(r.lights){let n=e.addExtension(gr);ue(!n.lights),n.lights=r.lights,delete r.lights}if(e.json.lights){for(let n of e.json.lights){let o=n.node;e.addObjectExtension(o,gr,n)}delete e.json.lights}}var kl={};Ae(kl,{decode:()=>a3,encode:()=>c3,name:()=>i3});var To="KHR_materials_unlit",i3=To;async function a3(t){let e=new q(t),{json:r}=e;for(let n of r.materials||[])n.extensions&&n.extensions.KHR_materials_unlit&&(n.unlit=!0),e.removeObjectExtension(n,To);e.removeExtension(To)}function c3(t){let e=new q(t),{json:r}=e;if(e.materials)for(let n of r.materials||[])n.unlit&&(delete n.unlit,e.addObjectExtension(n,To,{}),e.addExtension(To))}var zl={};Ae(zl,{decode:()=>f3,encode:()=>u3,name:()=>l3});var yo="KHR_techniques_webgl",l3=yo;async function f3(t){let e=new q(t),{json:r}=e,n=e.getExtension(yo);if(n){let o=h3(n,e);for(let s of r.materials||[]){let i=e.getObjectExtension(s,yo);i&&(s.technique=Object.assign({},i,o[i.technique]),s.technique.values=p3(s.technique,e)),e.removeObjectExtension(s,yo)}e.removeExtension(yo)}}async function u3(t,e){}function h3(t,e){let{programs:r=[],shaders:n=[],techniques:o=[]}=t,s=new TextDecoder;return n.forEach(i=>{if(Number.isFinite(i.bufferView))i.code=s.decode(e.getTypedArrayForBufferView(i.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(i=>{i.fragmentShader=n[i.fragmentShader],i.vertexShader=n[i.vertexShader]}),o.forEach(i=>{i.program=r[i.program]}),o}function p3(t,e){let r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(n=>{t.uniforms[n].value&&!(n in r)&&(r[n]=t.uniforms[n].value)}),Object.keys(r).forEach(n=>{typeof r[n]=="object"&&r[n].index!==void 0&&(r[n].texture=e.getTexture(r[n].index))}),r}var h0=[Ml,Tl,Nl,Ol,Ul,Vl,Hl,kl,zl,Gl,_l];function p0(t,e={},r){let n=h0.filter(o=>m0(o.name,e));for(let o of n)o.preprocess?.(t,e,r)}async function d0(t,e={},r){let n=h0.filter(o=>m0(o.name,e));for(let o of n)await o.decode?.(t,e,r)}function m0(t,e){let r=e?.gltf?.excludeExtensions||{};return!(t in r&&!r[t])}var ql="KHR_binary_glTF";function g0(t){let e=new q(t),{json:r}=e;for(let n of r.images||[]){let o=e.getObjectExtension(n,ql);o&&Object.assign(n,o),e.removeObjectExtension(n,ql)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(ql)}var A0={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},m3={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},jl=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,r){this.json=e.json;let n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${n.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),g0(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(let r in A0)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){let n=e[r];if(!(!n||Array.isArray(n))){e[r]=[];for(let o in n){let s=n[o];s.id=s.id||o;let i=e[r].length;e[r].push(s),this.idToIndexMap[r][o]=i}}}_convertObjectIdsToArrayIndices(e){for(let r in A0)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(let r of e.textures)this._convertTextureIds(r);for(let r of e.meshes)this._convertMeshIds(r);for(let r of e.nodes)this._convertNodeIds(r);for(let r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(let r of e.primitives){let{attributes:n,indices:o,material:s}=r;for(let i in n)n[i]=this._convertIdToIndex(n[i],"accessor");o&&(r.indices=this._convertIdToIndex(o,"accessor")),s&&(r.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(let n of e[r])for(let o in n){let s=n[o],i=this._convertIdToIndex(s,o);n[o]=i}}_convertIdToIndex(e,r){let n=m3[r];if(n in this.idToIndexMap){let o=this.idToIndexMap[n][e];if(!Number.isFinite(o))throw new Error(`gltf v1: failed to resolve ${r} with id ${e}`);return o}return e}_updateObjects(e){for(let r of this.json.buffers)delete r.type}_updateMaterial(e){for(let r of e.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let n=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,o=e.textures.findIndex(s=>s.id===n);o!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:o})}}};function b0(t,e={}){return new jl().normalize(t,e)}async function x0(t,e,r=0,n,o){return g3(t,e,r,n),b0(t,{normalize:n?.gltf?.normalize}),p0(t,n,o),n?.gltf?.loadBuffers&&t.json.buffers&&await A3(t,n,o),n?.gltf?.loadImages&&await b3(t,n,o),await d0(t,n,o),t}function g3(t,e,r,n){if(n.core?.baseUrl&&(t.baseUri=n.core?.baseUrl),e instanceof ArrayBuffer&&!a0(e,r,n.glb)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=Tc(e);else if(e instanceof ArrayBuffer){let i={};r=c0(i,e,r,n.glb),ue(i.type==="glTF",`Invalid GLB magic string ${i.type}`),t._glb=i,t.json=i.json}else ue(!1,"GLTF: must be ArrayBuffer or string");let o=t.json.buffers||[];if(t.buffers=new Array(o.length).fill(null),t._glb&&t._glb.header.hasBinChunk){let{binChunks:i}=t._glb;t.buffers[0]={arrayBuffer:i[0].arrayBuffer,byteOffset:i[0].byteOffset,byteLength:i[0].byteLength}}let s=t.json.images||[];t.images=new Array(s.length).fill({})}async function A3(t,e,r){let n=t.json.buffers||[];for(let o=0;o<n.length;++o){let s=n[o];if(s.uri){let{fetch:i}=r;ue(i);let a=Fl(s.uri,e,r),l=await(await r?.fetch?.(a))?.arrayBuffer?.();t.buffers[o]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete s.uri}else t.buffers[o]===null&&(t.buffers[o]={arrayBuffer:new ArrayBuffer(s.byteLength),byteOffset:0,byteLength:s.byteLength})}}async function b3(t,e,r){let n=x3(t),o=t.json.images||[],s=[];for(let i of n)s.push(T3(t,o[i],i,e,r));return await Promise.all(s)}function x3(t){let e=new Set,r=t.json.textures||[];for(let n of r)n.source!==void 0&&e.add(n.source);return Array.from(e).sort()}async function T3(t,e,r,n,o){let s;if(e.uri&&!e.hasOwnProperty("bufferView")){let l=Fl(e.uri,n,o),{fetch:f}=o;s=await(await f(l)).arrayBuffer(),e.bufferView={data:s}}if(Number.isFinite(e.bufferView)){let l=Hg(t.json,t.buffers,e.bufferView);s=tr(l.buffer,l.byteOffset,l.byteLength)}ue(s,"glTF image has no data");let i=n,a={...i,core:{...i?.core,mimeType:e.mimeType}},c=await Oe(s,[zr,Bl],a,o);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),t.images=t.images||[],t.images[r]=c}var Ar={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:Wg,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:y3,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};async function y3(t,e={},r){let n={...Ar.options,...e};n.gltf={...Ar.options.gltf,...n.gltf};let o=e?.glb?.byteOffset||0;return await x0({},t,o,n,r)}var S3={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},M3={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ke={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},_3={magFilter:ke.TEXTURE_MAG_FILTER,minFilter:ke.TEXTURE_MIN_FILTER,wrapS:ke.TEXTURE_WRAP_S,wrapT:ke.TEXTURE_WRAP_T},E3={[ke.TEXTURE_MAG_FILTER]:ke.LINEAR,[ke.TEXTURE_MIN_FILTER]:ke.NEAREST_MIPMAP_LINEAR,[ke.TEXTURE_WRAP_S]:ke.REPEAT,[ke.TEXTURE_WRAP_T]:ke.REPEAT};function C3(){return{id:"default-sampler",parameters:E3}}function I3(t){return M3[t]}function v3(t){return S3[t]}var Jl=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,r={}){let{json:n,buffers:o=[],images:s=[]}=e,{baseUri:i=""}=e;return ue(n),this.baseUri=i,this.buffers=o,this.images=s,this.jsonUnprocessed=n,this.json=this._resolveTree(e.json,r),this.json}_resolveTree(e,r={}){let n={...e};return this.json=n,e.bufferViews&&(n.bufferViews=e.bufferViews.map((o,s)=>this._resolveBufferView(o,s))),e.images&&(n.images=e.images.map((o,s)=>this._resolveImage(o,s))),e.samplers&&(n.samplers=e.samplers.map((o,s)=>this._resolveSampler(o,s))),e.textures&&(n.textures=e.textures.map((o,s)=>this._resolveTexture(o,s))),e.accessors&&(n.accessors=e.accessors.map((o,s)=>this._resolveAccessor(o,s))),e.materials&&(n.materials=e.materials.map((o,s)=>this._resolveMaterial(o,s))),e.meshes&&(n.meshes=e.meshes.map((o,s)=>this._resolveMesh(o,s))),e.nodes&&(n.nodes=e.nodes.map((o,s)=>this._resolveNode(o,s)),n.nodes=n.nodes.map((o,s)=>this._resolveNodeChildren(o))),e.skins&&(n.skins=e.skins.map((o,s)=>this._resolveSkin(o,s))),e.scenes&&(n.scenes=e.scenes.map((o,s)=>this._resolveScene(o,s))),typeof this.json.scene=="number"&&n.scenes&&(n.scene=n.scenes[this.json.scene]),n}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,r){if(typeof r=="object")return r;let n=e&&e[r];return n||console.warn(`glTF file error: Could not find ${e}[${r}]`),n}_resolveScene(e,r){return{...e,id:e.id||`scene-${r}`,nodes:(e.nodes||[]).map(n=>this.getNode(n))}}_resolveNode(e,r){let n={...e,id:e?.id||`node-${r}`};return e.mesh!==void 0&&(n.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(n.camera=this.getCamera(e.camera)),e.skin!==void 0&&(n.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(n.mesh=e.meshes.reduce((o,s)=>{let i=this.getMesh(s);return o.id=i.id,o.primitives=o.primitives.concat(i.primitives),o},{primitives:[]})),n}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(r=>this.getNode(r))),e}_resolveSkin(e,r){let n=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${r}`,inverseBindMatrices:n}}_resolveMesh(e,r){let n={...e,id:e.id||`mesh-${r}`,primitives:[]};return e.primitives&&(n.primitives=e.primitives.map(o=>{let s={...o,attributes:{},indices:void 0,material:void 0},i=o.attributes;for(let a in i)s.attributes[a]=this.getAccessor(i[a]);return o.indices!==void 0&&(s.indices=this.getAccessor(o.indices)),o.material!==void 0&&(s.material=this.getMaterial(o.material)),s})),n}_resolveMaterial(e,r){let n={...e,id:e.id||`material-${r}`};if(n.normalTexture&&(n.normalTexture={...n.normalTexture},n.normalTexture.texture=this.getTexture(n.normalTexture.index)),n.occlusionTexture&&(n.occlusionTexture={...n.occlusionTexture},n.occlusionTexture.texture=this.getTexture(n.occlusionTexture.index)),n.emissiveTexture&&(n.emissiveTexture={...n.emissiveTexture},n.emissiveTexture.texture=this.getTexture(n.emissiveTexture.index)),n.emissiveFactor||(n.emissiveFactor=n.emissiveTexture?[1,1,1]:[0,0,0]),n.pbrMetallicRoughness){n.pbrMetallicRoughness={...n.pbrMetallicRoughness};let o=n.pbrMetallicRoughness;o.baseColorTexture&&(o.baseColorTexture={...o.baseColorTexture},o.baseColorTexture.texture=this.getTexture(o.baseColorTexture.index)),o.metallicRoughnessTexture&&(o.metallicRoughnessTexture={...o.metallicRoughnessTexture},o.metallicRoughnessTexture.texture=this.getTexture(o.metallicRoughnessTexture.index))}return n}_resolveAccessor(e,r){let n=I3(e.componentType),o=v3(e.type),s=n*o,i={...e,id:e.id||`accessor-${r}`,bytesPerComponent:n,components:o,bytesPerElement:s,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(i.bufferView=this.getBufferView(e.bufferView)),i.bufferView){let a=i.bufferView.buffer,{ArrayType:c,byteLength:l}=tn(i,i.bufferView),f=(i.bufferView.byteOffset||0)+(i.byteOffset||0)+a.byteOffset,u=zn(a.arrayBuffer,f,l);i.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(a,f,i.bufferView.byteStride,i.bytesPerElement,i.count)),i.value=new c(u)}return i}_getValueFromInterleavedBuffer(e,r,n,o,s){let i=new Uint8Array(s*o);for(let a=0;a<s;a++){let c=r+a*n;i.set(new Uint8Array(e.arrayBuffer.slice(c,c+o)),a*o)}return i.buffer}_resolveTexture(e,r){return{...e,id:e.id||`texture-${r}`,sampler:typeof e.sampler=="number"?this.getSampler(e.sampler):C3(),source:typeof e.source=="number"?this.getImage(e.source):void 0}}_resolveSampler(e,r){let n={id:e.id||`sampler-${r}`,...e,parameters:{}};for(let o in n){let s=this._enumSamplerParameter(o);s!==void 0&&(n.parameters[s]=n[o])}return n}_enumSamplerParameter(e){return _3[e]}_resolveImage(e,r){let n={...e,id:e.id||`image-${r}`,image:null,bufferView:e.bufferView!==void 0?this.getBufferView(e.bufferView):void 0},o=this.images[r];return o&&(n.image=o),n}_resolveBufferView(e,r){let n=e.buffer,o=this.buffers[n].arrayBuffer,s=this.buffers[n].byteOffset||0;return e.byteOffset&&(s+=e.byteOffset),{id:`bufferView-${r}`,...e,buffer:this.buffers[n],data:new Uint8Array(o,s,e.byteLength)}}_resolveCamera(e,r){let n={...e,id:e.id||`camera-${r}`};return n.perspective,n.orthographic,n}};function So(t,e){return new Jl().postProcess(t,e)}var wi={URI:0,EMBEDDED:1};function Li(t,e,r,n){t.rotateYtoZ=!0;let o=(t.byteOffset||0)+(t.byteLength||0)-r;if(o===0)throw new Error("glTF byte length must be greater than 0.");return t.gltfUpAxis=n?.["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",t.gltfArrayBuffer=tr(e,r,o),t.gltfByteOffset=0,t.gltfByteLength=o,r%4===0||console.warn(`${t.type}: embedded glb is not aligned to a 4-byte boundary.`),(t.byteOffset||0)+(t.byteLength||0)}async function Fi(t,e,r,n){let o=r?.["3d-tiles"]||{};if(B3(t,e,r),o.loadGLTF){if(!n)return;if(t.gltfUrl){let{fetch:s}=n,i=await s(t.gltfUrl,r?.core);t.gltfArrayBuffer=await i.arrayBuffer(),t.gltfByteOffset=0}if(t.gltfArrayBuffer){let s=await Oe(t.gltfArrayBuffer,Ar,r,n);t.gltf=So(s),t.gpuMemoryUsageInBytes=bo(t.gltf),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength}}}function B3(t,e,r){switch(e){case wi.URI:if(t.gltfArrayBuffer){let n=new Uint8Array(t.gltfArrayBuffer,t.gltfByteOffset),s=new TextDecoder().decode(n);t.gltfUrl=s.replace(/[\s\0]+$/,"")}delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength;break;case wi.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function T0(t,e,r,n,o){r=R3(t,e,r,n,o),await Fi(t,wi.EMBEDDED,n,o);let s=t?.gltf?.extensions;return s&&s.CESIUM_RTC&&(t.rtcCenter=s.CESIUM_RTC.center),r}function R3(t,e,r,n,o){r=Gt(t,e,r),r=$r(t,e,r),r=en(t,e,r,n),r=Li(t,e,r,n);let s=new Mt(t.featureTableJson,t.featureTableBinary);return t.rtcCenter=s.getGlobalProperty("RTC_CENTER",O.FLOAT,3),r}async function y0(t,e,r,n,o){return r=w3(t,e,r,n,o),await Fi(t,t.gltfFormat||0,n,o),r}function w3(t,e,r,n,o){if(r=Gt(t,e,r),t.version!==1)throw new Error(`Instanced 3D Model version ${t.version} is not supported`);r=$r(t,e,r);let s=new DataView(e);if(t.gltfFormat=s.getUint32(r,!0),r+=4,r=en(t,e,r,n),r=Li(t,e,r,n),!t?.header?.featureTableJsonByteLength||t.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let i=new Mt(t.featureTableJson,t.featureTableBinary),a=i.getGlobalProperty("INSTANCES_LENGTH");if(i.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");t.eastNorthUp=i.getGlobalProperty("EAST_NORTH_UP"),t.rtcCenter=i.getGlobalProperty("RTC_CENTER",O.FLOAT,3);let c=new mr(t.batchTableJson,t.batchTableBinary,a);return L3(t,i,c,a),r}function L3(t,e,r,n){let o=new Array(n),s=new x,i=new x,a=new x,c=new x,l=new z,f=new ot,u=new x,h={},p=new N,d=[],m=[],g=[],b=[];for(let T=0;T<n;T++){let S;if(e.hasProperty("POSITION"))S=e.getProperty("POSITION",O.FLOAT,3,T,s);else if(e.hasProperty("POSITION_QUANTIZED")){S=e.getProperty("POSITION_QUANTIZED",O.UNSIGNED_SHORT,3,T,s);let A=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",O.FLOAT,3);if(!A)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let I=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",O.FLOAT,3);if(!I)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let L=65535;for(let F=0;F<3;F++)S[F]=S[F]/L*I[F]+A[F]}if(!S)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");s.copy(S),h.translation=s,t.normalUp=e.getProperty("NORMAL_UP",O.FLOAT,3,T,d),t.normalRight=e.getProperty("NORMAL_RIGHT",O.FLOAT,3,T,m);let M=!1;if(t.normalUp){if(!t.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");t.hasCustomOrientation=!0}else{if(t.octNormalUp=e.getProperty("NORMAL_UP_OCT32P",O.UNSIGNED_SHORT,2,T,d),t.octNormalRight=e.getProperty("NORMAL_RIGHT_OCT32P",O.UNSIGNED_SHORT,2,T,m),t.octNormalUp)throw t.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");t.eastNorthUp?(V.WGS84.eastNorthUpToFixedFrame(s,p),p.getRotationMatrix3(l)):l.identity()}M&&(c.copy(i).cross(a).normalize(),l.setColumn(0,i),l.setColumn(1,a),l.setColumn(2,c)),f.fromMatrix3(l),h.rotation=f,u.set(1,1,1);let C=e.getProperty("SCALE",O.FLOAT,1,T,g);Number.isFinite(C)&&u.multiplyByScalar(C);let E=e.getProperty("SCALE_NON_UNIFORM",O.FLOAT,3,T,d);E&&u.scale(E),h.scale=u;let B=e.getProperty("BATCH_ID",O.UNSIGNED_SHORT,1,T,b);B===void 0&&(B=T);let _=new N().fromQuaternion(h.rotation);p.identity(),p.translate(h.translation),p.multiplyRight(_),p.scale(h.scale);let y=p.clone();o[T]={modelMatrix:y,batchId:B}}t.instances=o}async function S0(t,e,r,n,o,s){r=Gt(t,e,r);let i=new DataView(e);for(t.tilesLength=i.getUint32(r,!0),r+=4,t.tiles=[];t.tiles.length<t.tilesLength&&(t.byteLength||0)-r>12;){let a={shape:"tile3d"};t.tiles.push(a),r=await s(e,r,n,o,a)}return r}async function M0(t,e,r,n){if(t.rotateYtoZ=!0,t.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!n)return e.byteLength;let o=await Oe(e,Ar,r,n);t.gltf=So(o),t.gpuMemoryUsageInBytes=bo(t.gltf)}else t.gltfArrayBuffer=e;return e.byteLength}async function Wl(t,e=0,r,n,o={shape:"tile3d"}){switch(o.byteOffset=e,o.type=Ag(t,e),o.type){case pr.COMPOSITE:return await S0(o,t,e,r,n,Wl);case pr.BATCHED_3D_MODEL:return await T0(o,t,e,r,n);case pr.GLTF:return await M0(o,t,r,n);case pr.INSTANCED_3D_MODEL:return await y0(o,t,e,r,n);case pr.POINT_CLOUD:return await Vg(o,t,e,r,n);default:throw new Error(`3DTileLoader: unknown type ${o.type}`)}}async function Xl(t,e,r){if(new Uint32Array(t.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let s=_0(t.slice(8,16)),i=new Uint8Array(t,24,s),c=new TextDecoder("utf8").decode(i),l=JSON.parse(c),f=_0(t.slice(16,24)),u=new ArrayBuffer(0);if(f&&(u=t.slice(24+s)),await Pi(l,l.tileAvailability,u,r),Array.isArray(l.contentAvailability))for(let h of l.contentAvailability)await Pi(l,h,u,r);else await Pi(l,l.contentAvailability,u,r);return await Pi(l,l.childSubtreeAvailability,u,r),l}async function Pi(t,e,r,n){let o=Number.isFinite(e.bitstream)?e.bitstream:e.bufferView;if(typeof o!="number")return;let s=t.bufferViews[o],i=t.buffers[s.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(i.uri){let c=`${n?.baseUrl||""}/${i.uri}`,f=await(await n.fetch(c)).arrayBuffer();e.explicitBitstream=new Uint8Array(f,s.byteOffset,s.byteLength);return}let a=t.buffers.slice(0,s.buffer).reduce((c,l)=>c+l.byteLength,0);e.explicitBitstream=new Uint8Array(r.slice(a,a+i.byteLength),s.byteOffset,s.byteLength)}function _0(t){let e=new DataView(t),r=e.getUint32(0,!0),n=e.getUint32(4,!0);return r+2**32*n}var Ni={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:mi,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:Xl,options:{}};var J0=U(Yt(),1);var k0=U(Yt(),1);var ze=null;try{ze=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function $(t,e,r){this.low=t|0,this.high=e|0,this.unsigned=!!r}$.prototype.__isLong__;Object.defineProperty($.prototype,"__isLong__",{value:!0});function ye(t){return(t&&t.__isLong__)===!0}function E0(t){var e=Math.clz32(t&-t);return t?31-e:e}$.isLong=ye;var C0={},I0={};function br(t,e){var r,n,o;return e?(t>>>=0,(o=0<=t&&t<256)&&(n=I0[t],n)?n:(r=j(t,0,!0),o&&(I0[t]=r),r)):(t|=0,(o=-128<=t&&t<128)&&(n=C0[t],n)?n:(r=j(t,t<0?-1:0,!1),o&&(C0[t]=r),r))}$.fromInt=br;function qe(t,e){if(isNaN(t))return e?_t:et;if(e){if(t<0)return _t;if(t>=w0)return P0}else{if(t<=-B0)return Le;if(t+1>=B0)return F0}return t<0?qe(-t,e).neg():j(t%hn|0,t/hn|0,e)}$.fromNumber=qe;function j(t,e,r){return new $(t,e,r)}$.fromBits=j;var Oi=Math.pow;function Yl(t,e,r){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(r=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?_t:et;if(r=r||10,r<2||36<r)throw RangeError("radix");var n;if((n=t.indexOf("-"))>0)throw Error("interior hyphen");if(n===0)return Yl(t.substring(1),e,r).neg();for(var o=qe(Oi(r,8)),s=et,i=0;i<t.length;i+=8){var a=Math.min(8,t.length-i),c=parseInt(t.substring(i,i+a),r);if(a<8){var l=qe(Oi(r,a));s=s.mul(l).add(qe(c))}else s=s.mul(o),s=s.add(qe(c))}return s.unsigned=e,s}$.fromString=Yl;function tt(t,e){return typeof t=="number"?qe(t,e):typeof t=="string"?Yl(t,e):j(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}$.fromValue=tt;var v0=65536,F3=1<<24,hn=v0*v0,w0=hn*hn,B0=w0/2,R0=br(F3),et=br(0);$.ZERO=et;var _t=br(0,!0);$.UZERO=_t;var un=br(1);$.ONE=un;var L0=br(1,!0);$.UONE=L0;var Kl=br(-1);$.NEG_ONE=Kl;var F0=j(-1,2147483647,!1);$.MAX_VALUE=F0;var P0=j(-1,-1,!0);$.MAX_UNSIGNED_VALUE=P0;var Le=j(0,-2147483648,!1);$.MIN_VALUE=Le;var v=$.prototype;v.toInt=function(){return this.unsigned?this.low>>>0:this.low};v.toNumber=function(){return this.unsigned?(this.high>>>0)*hn+(this.low>>>0):this.high*hn+(this.low>>>0)};v.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Le)){var r=qe(e),n=this.div(r),o=n.mul(r).sub(this);return n.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var s=qe(Oi(e,6),this.unsigned),i=this,a="";;){var c=i.div(s),l=i.sub(c.mul(s)).toInt()>>>0,f=l.toString(e);if(i=c,i.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}};v.getHighBits=function(){return this.high};v.getHighBitsUnsigned=function(){return this.high>>>0};v.getLowBits=function(){return this.low};v.getLowBitsUnsigned=function(){return this.low>>>0};v.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Le)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&(e&1<<r)==0;r--);return this.high!=0?r+33:r+1};v.isZero=function(){return this.high===0&&this.low===0};v.eqz=v.isZero;v.isNegative=function(){return!this.unsigned&&this.high<0};v.isPositive=function(){return this.unsigned||this.high>=0};v.isOdd=function(){return(this.low&1)===1};v.isEven=function(){return(this.low&1)===0};v.equals=function(e){return ye(e)||(e=tt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};v.eq=v.equals;v.notEquals=function(e){return!this.eq(e)};v.neq=v.notEquals;v.ne=v.notEquals;v.lessThan=function(e){return this.comp(e)<0};v.lt=v.lessThan;v.lessThanOrEqual=function(e){return this.comp(e)<=0};v.lte=v.lessThanOrEqual;v.le=v.lessThanOrEqual;v.greaterThan=function(e){return this.comp(e)>0};v.gt=v.greaterThan;v.greaterThanOrEqual=function(e){return this.comp(e)>=0};v.gte=v.greaterThanOrEqual;v.ge=v.greaterThanOrEqual;v.compare=function(e){if(ye(e)||(e=tt(e)),this.eq(e))return 0;var r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};v.comp=v.compare;v.negate=function(){return!this.unsigned&&this.eq(Le)?Le:this.not().add(un)};v.neg=v.negate;v.add=function(e){ye(e)||(e=tt(e));var r=this.high>>>16,n=this.high&65535,o=this.low>>>16,s=this.low&65535,i=e.high>>>16,a=e.high&65535,c=e.low>>>16,l=e.low&65535,f=0,u=0,h=0,p=0;return p+=s+l,h+=p>>>16,p&=65535,h+=o+c,u+=h>>>16,h&=65535,u+=n+a,f+=u>>>16,u&=65535,f+=r+i,f&=65535,j(h<<16|p,f<<16|u,this.unsigned)};v.subtract=function(e){return ye(e)||(e=tt(e)),this.add(e.neg())};v.sub=v.subtract;v.multiply=function(e){if(this.isZero())return this;if(ye(e)||(e=tt(e)),ze){var r=ze.mul(this.low,this.high,e.low,e.high);return j(r,ze.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?_t:et;if(this.eq(Le))return e.isOdd()?Le:et;if(e.eq(Le))return this.isOdd()?Le:et;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(R0)&&e.lt(R0))return qe(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,o=this.high&65535,s=this.low>>>16,i=this.low&65535,a=e.high>>>16,c=e.high&65535,l=e.low>>>16,f=e.low&65535,u=0,h=0,p=0,d=0;return d+=i*f,p+=d>>>16,d&=65535,p+=s*f,h+=p>>>16,p&=65535,p+=i*l,h+=p>>>16,p&=65535,h+=o*f,u+=h>>>16,h&=65535,h+=s*l,u+=h>>>16,h&=65535,h+=i*c,u+=h>>>16,h&=65535,u+=n*f+o*l+s*c+i*a,u&=65535,j(p<<16|d,u<<16|h,this.unsigned)};v.mul=v.multiply;v.divide=function(e){if(ye(e)||(e=tt(e)),e.isZero())throw Error("division by zero");if(ze){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?ze.div_u:ze.div_s)(this.low,this.high,e.low,e.high);return j(r,ze.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?_t:et;var n,o,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return _t;if(e.gt(this.shru(1)))return L0;s=_t}else{if(this.eq(Le)){if(e.eq(un)||e.eq(Kl))return Le;if(e.eq(Le))return un;var i=this.shr(1);return n=i.div(e).shl(1),n.eq(et)?e.isNegative()?un:Kl:(o=this.sub(e.mul(n)),s=n.add(o.div(e)),s)}else if(e.eq(Le))return this.unsigned?_t:et;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=et}for(o=this;o.gte(e);){n=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),c=a<=48?1:Oi(2,a-48),l=qe(n),f=l.mul(e);f.isNegative()||f.gt(o);)n-=c,l=qe(n,this.unsigned),f=l.mul(e);l.isZero()&&(l=un),s=s.add(l),o=o.sub(f)}return s};v.div=v.divide;v.modulo=function(e){if(ye(e)||(e=tt(e)),ze){var r=(this.unsigned?ze.rem_u:ze.rem_s)(this.low,this.high,e.low,e.high);return j(r,ze.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};v.mod=v.modulo;v.rem=v.modulo;v.not=function(){return j(~this.low,~this.high,this.unsigned)};v.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};v.clz=v.countLeadingZeros;v.countTrailingZeros=function(){return this.low?E0(this.low):E0(this.high)+32};v.ctz=v.countTrailingZeros;v.and=function(e){return ye(e)||(e=tt(e)),j(this.low&e.low,this.high&e.high,this.unsigned)};v.or=function(e){return ye(e)||(e=tt(e)),j(this.low|e.low,this.high|e.high,this.unsigned)};v.xor=function(e){return ye(e)||(e=tt(e)),j(this.low^e.low,this.high^e.high,this.unsigned)};v.shiftLeft=function(e){return ye(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?j(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):j(0,this.low<<e-32,this.unsigned)};v.shl=v.shiftLeft;v.shiftRight=function(e){return ye(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?j(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):j(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};v.shr=v.shiftRight;v.shiftRightUnsigned=function(e){return ye(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?j(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?j(this.high,0,this.unsigned):j(this.high>>>e-32,0,this.unsigned)};v.shru=v.shiftRightUnsigned;v.shr_u=v.shiftRightUnsigned;v.rotateLeft=function(e){var r;return ye(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?j(this.high,this.low,this.unsigned):e<32?(r=32-e,j(this.low<<e|this.high>>>r,this.high<<e|this.low>>>r,this.unsigned)):(e-=32,r=32-e,j(this.high<<e|this.low>>>r,this.low<<e|this.high>>>r,this.unsigned))};v.rotl=v.rotateLeft;v.rotateRight=function(e){var r;return ye(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?j(this.high,this.low,this.unsigned):e<32?(r=32-e,j(this.high<<r|this.low>>>e,this.low<<r|this.high>>>e,this.unsigned)):(e-=32,r=32-e,j(this.low<<r|this.high>>>e,this.high<<r|this.low>>>e,this.unsigned))};v.rotr=v.rotateRight;v.toSigned=function(){return this.unsigned?j(this.low,this.high,!1):this};v.toUnsigned=function(){return this.unsigned?this:j(this.low,this.high,!0)};v.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};v.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};v.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};$.fromBytes=function(e,r,n){return n?$.fromBytesLE(e,r):$.fromBytesBE(e,r)};$.fromBytesLE=function(e,r){return new $(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};$.fromBytesBE=function(e,r){return new $(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var pn=$;var P3=16;function Mo(t){t==="X"&&(t="");let e=t.padEnd(P3,"0");return pn.fromString(e,!0,16)}function Ql(t){if(t.isZero())return"X";let e=t.countTrailingZeros(),r=e%4;e=(e-r)/4;let n=e;e*=4;let s=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-n-s.length).join("0")+s}function Zl(t,e){let r=N3(t).shiftRightUnsigned(2);return t.add(pn.fromNumber(2*e+1-4).multiply(r))}function N3(t){return t.and(t.not().add(1))}var O3=3,U3=30,D3=2*U3+1,N0=180/Math.PI;function U0(t){if(t.length===0)throw new Error(`Invalid Hilbert quad key ${t}`);let e=t.split("/"),r=parseInt(e[0],10),n=e[1],o=n.length,s=0,i=[0,0];for(let a=o-1;a>=0;a--){s=o-a;let c=n[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,s-1);V3(u,i,l,f),i[0]+=u*l,i[1]+=u*f}if(r%2===1){let a=i[0];i[0]=i[1],i[1]=a}return{face:r,ij:i,level:s}}function D0(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length<O3+D3;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),o=e.substring(3,r),s=o.length/2,i=pn.fromString(n,!0,2).toString(10),a="";if(s!==0)for(a=pn.fromString(o,!0,2).toString(4);a.length<s;)a="0"+a;return`${i}/${a}`}function $l(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function O0(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function ef(t){return[O0(t[0]),O0(t[1])]}function tf(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function rf([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*N0,n*N0]}function V3(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let o=e[0];e[0]=e[1],e[1]=o}}function V0(t){let e=$l(t.ij,t.level,[.5,.5]),r=ef(e),n=tf(t.face,r);return rf(n)}var G3=100;function nf(t){let{face:e,ij:r,level:n}=t,o=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(G3*Math.pow(2,-n))),i=new Float64Array(4*s*2+2),a=0,c=0;for(let l=0;l<4;l++){let f=o[l].slice(0),u=o[l+1],h=(u[0]-f[0])/s,p=(u[1]-f[1])/s;for(let d=0;d<s;d++){f[0]+=h,f[1]+=p;let m=$l(r,n,f),g=ef(m),b=tf(e,g),T=rf(b);Math.abs(T[1])>89.999&&(T[0]=c);let S=T[0]-c;T[0]+=S>180?-360:S<-180?360:0,i[a++]=T[0],i[a++]=T[1],c=T[0]}}return i[a++]=i[0],i[a++]=i[1],i}function dn(t){let e=H3(t);return U0(e)}function H3(t){if(t.indexOf("/")>0)return t;let e=Mo(t);return D0(e)}function of(t){let e=dn(t);return V0(e)}function H0(t){let e;if(t.face===2||t.face===5){let r=null,n=0;for(let o=0;o<4;o++){let s=`${t.face}/${o}`,i=dn(s),a=nf(i);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,n),n+=a.length}e=G0(r)}else{let r=nf(t);e=G0(r)}return e}function G0(t){if(t.length%2!==0)throw new Error("Invalid corners");let e=[],r=[];for(let n=0;n<t.length;n+=2)e.push(t[n]),r.push(t[n+1]);return e.sort((n,o)=>n-o),r.sort((n,o)=>n-o),{west:e[0],east:e[e.length-1],north:r[r.length-1],south:r[0]}}function sf(t,e){let r=e?.minimumHeight||0,n=e?.maximumHeight||0,o=dn(t),s=H0(o),i=s.west,a=s.south,c=s.east,l=s.north,f=[];return f.push(new x(i,l,r)),f.push(new x(c,l,r)),f.push(new x(c,a,r)),f.push(new x(i,a,r)),f.push(new x(i,l,n)),f.push(new x(c,l,n)),f.push(new x(c,a,n)),f.push(new x(i,a,n)),f}function Ui(t){let e=t.token,r={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},n=sf(e,r),o=of(e),s=o[0],i=o[1],a=V.WGS84.cartographicToCartesian([s,i,r.maximumHeight]),c=new x(a[0],a[1],a[2]);n.push(c);let l=no(n);return[...l.center,...l.halfAxes]}var k3=4,z3=8,q3={QUADTREE:k3,OCTREE:z3};function j3(t,e,r){if(t?.box){let n=Mo(t.s2VolumeInfo.token),o=Zl(n,e),s=Ql(o),i={...t.s2VolumeInfo};if(i.token=s,r==="OCTREE"){let l=t.s2VolumeInfo,f=l.maximumHeight-l.minimumHeight,u=f/2,h=l.minimumHeight+f/2;l.minimumHeight=h-u,l.maximumHeight=h+u}return{box:Ui(i),s2VolumeInfo:i}}}async function cf(t){let{subtree:e,subtreeData:r={level:0,x:0,y:0,z:0},parentData:n={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:o=0,implicitOptions:s,loaderOptions:i,s2VolumeBox:a}=t,{subdivisionScheme:c,subtreeLevels:l,maximumLevel:f,contentUrlTemplate:u,subtreesUriTemplate:h,basePath:p}=s,d={children:[],lodMetricValue:0,contentUrl:""};if(!f)return dc.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${u} won't be loaded...`),d;let m=n.localLevel+1,g=r.level+m;if(g>f)return d;let b=q3[c],T=Math.log2(b),S=o&1,M=o>>1&1,C=o>>2&1,E=xr(n.localX,S,1),B=xr(n.localY,M,1),_=xr(n.localZ,C,1),y=xr(r.x,E,m),A=xr(r.y,B,m),I=xr(r.z,_,m),L=xr(n.mortonIndex,o,T),F=m===l&&af(e.childSubtreeAvailability,L),w,D,W,k;if(F){let K=`${p}/${h}`,te=Di(K,g,y,A,I);w=await(0,k0.load)(te,Ni,i),k=0,D={level:g,x:y,y:A,z:I},W={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else w=e,k=(b**m-1)/(b-1)+L,D=r,W={mortonIndex:L,localLevel:m,localX:E,localY:B,localZ:_};if(!af(w.tileAvailability,k))return d;af(w.contentAvailability,k)&&(d.contentUrl=Di(u,g,y,A,I));for(let K=0;K<b;K++){let te=j3(a,K,c),Ie=await cf({subtree:w,subtreeData:D,parentData:W,childIndex:K,implicitOptions:s,loaderOptions:i,s2VolumeBox:te});(Ie.contentUrl||Ie.children.length)&&d.children.push(Ie)}return d.contentUrl||d.children.length?J3(d,{level:g,x:y,y:A,z:I},s,a):d}function af(t,e){let r;return Array.isArray(t)?(r=t[0],t.length>1&&dc.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=t,"constant"in r?!!r.constant:r.explicitBitstream?K3(e,r.explicitBitstream):!1}function J3(t,e,r,n){let{basePath:o,refine:s,getRefine:i,lodMetricType:a,getTileType:c,rootLodMetricValue:l,rootBoundingVolume:f}=r,u=t.contentUrl&&t.contentUrl.replace(`${o}/`,""),h=l/2**e.level,p=n?.box?{box:n.box}:f,d=W3(p,e,r.subdivisionScheme);return{children:t.children,contentUrl:t.contentUrl,content:{uri:u},id:t.contentUrl,refine:i(s),type:c(t),lodMetricType:a,lodMetricValue:h,geometricError:h,transform:t.transform,boundingVolume:d}}function W3(t,e,r){if(t.region){let{level:n,x:o,y:s,z:i}=e,[a,c,l,f,u,h]=t.region,p=2**n,d=(l-a)/p,[m,g]=[a+d*o,a+d*(o+1)],b=(f-c)/p,[T,S]=[c+b*s,c+b*(s+1)],M,C;if(r==="OCTREE"){let E=(h-u)/p;[M,C]=[u+E*i,u+E*(i+1)]}else[M,C]=[u,h];return{region:[m,T,g,S,M,C]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function xr(t,e,r){return(t<<r)+e}function Di(t,e,r,n,o){let s=X3({level:e,x:r,y:n,z:o});return t.replace(/{level}|{x}|{y}|{z}/gi,i=>s[i])}function X3(t){let e={};for(let r in t)e[`{${r}}`]=t[r];return e}function K3(t,e){let r=Math.floor(t/8),n=t%8;return(e[r]>>n&1)===1}function ff(t,e=""){if(!e)return He.EMPTY;let n=e.split("?")[0].split(".").pop();switch(n){case"pnts":return He.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return He.SCENEGRAPH;default:return n||He.EMPTY}}function uf(t){switch(t){case"REPLACE":case"replace":return xe.REPLACE;case"ADD":case"add":return xe.ADD;default:return t}}function lf(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){let n=new URL(t,`${e}/`);return decodeURI(n.toString())}else if(t.startsWith("/"))return t;return Ot.resolve(e,t)}function z0(t,e){if(!t)return null;let r;if(t.content){let o=t.content.uri||t.content?.url;typeof o<"u"&&(r=lf(o,e))}return{...t,id:r,contentUrl:r,lodMetricType:St.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:ff(t,r),refine:uf(t.refine)}}async function W0(t,e,r){let n=null,o=j0(t.root);o&&t.root?n=await q0(t.root,t,e,o,r):n=z0(t.root,e);let s=[];for(s.push(n);s.length>0;){let i=s.pop()||{},a=i.children||[],c=[];for(let l of a){let f=j0(l),u;f?u=await q0(l,t,e,f,r):u=z0(l,e),u&&(c.push(u),s.push(u))}i.children=c}return n}async function q0(t,e,r,n,o){let{subdivisionScheme:s,maximumLevel:i,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=n,f=Di(l,0,0,0,0),u=lf(f,r),h=await(0,J0.load)(u,Ni,o),p=t.content?.uri,d=p?lf(p,r):"",m=e?.root?.refine,g=t.geometricError,b=t.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(b){let C={box:Ui(b),s2VolumeInfo:b};t.boundingVolume=C}let T=t.boundingVolume,S={contentUrlTemplate:d,subtreesUriTemplate:l,subdivisionScheme:s,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:i,refine:m,basePath:r,lodMetricType:St.GEOMETRIC_ERROR,rootLodMetricValue:g,rootBoundingVolume:T,getTileType:ff,getRefine:uf};return await Y3(t,r,h,S,o)}async function Y3(t,e,r,n,o){if(!t)return null;let{children:s,contentUrl:i}=await cf({subtree:r,implicitOptions:n,loaderOptions:o}),a,c=null;return i&&(a=i,c={uri:i.replace(`${e}/`,"")}),{...t,id:a,contentUrl:a,lodMetricType:St.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:ff(t,a),refine:uf(t.refine),content:c||t.content,children:s}}function j0(t){return t?.extensions?.["3DTILES_implicit_tiling"]||t?.implicitTiling}var Vi={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:mi,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:Q3,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function Q3(t,e={},r){let n=e["3d-tiles"]||{},o;return n.isTileset==="auto"?o=r?.url&&r.url.indexOf(".json")!==-1:o=n.isTileset,o?Z3(t,e,r):$3(t,e,r)}async function Z3(t,e,r){let n=JSON.parse(new TextDecoder().decode(t)),o=r?.url||"",s=e2(o),i=await W0(n,s,e||{});return{...n,shape:"tileset3d",loader:Vi,url:o,queryString:r?.queryString||"",basePath:s,root:i||n.root,type:pe.TILES3D,lodMetricType:St.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0}}async function $3(t,e,r){let n={content:{shape:"tile3d",featureIds:null}};return await Wl(t,0,e,r,n.content),n.content}function e2(t){return Ot.dirname(t)}var X0=[0],t2={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Vi,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,r)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}},_o=class extends zt.CompositeLayer{initializeState(){"onTileLoadFail"in this.props&&zt.log.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return!!(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:r,changeFlags:n}){if(e.data&&e.data!==r.data&&this._loadTileset(e.data),n.viewportChanged){let{activeViewports:o}=this.state;Object.keys(o).length&&(this._updateTileset(o),this.state.lastUpdatedViewports=o,this.state.activeViewports={})}if(n.propsChanged){let{layerMap:o}=this.state;for(let s in o)o[s].needsUpdate=!0}}finalizeState(e){this.state.tileset3d?.destroy(),this.state.tileset3d=null,this.state.layerMap={},this.state.activeViewports={},this.state.lastUpdatedViewports=null,super.finalizeState(e)}activateViewport(e){let{activeViewports:r,lastUpdatedViewports:n}=this.state;this.internalState.viewport=e,r[e.id]=e;let o=n?.[e.id];(!o||!e.equals(o))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:r}){let n=r&&r.props.tile;return e.picked&&(e.object=n),e.sourceTile=n,e}filterSubLayer({layer:e,viewport:r,cullRect:n,isPicking:o}){let{tile:s}=e.props,{id:i}=r;if(!s.selected||!s.viewportIds.includes(i))return!1;if(o&&n&&s.content?.cartographicOrigin){let[a,c]=r.project(s.content.cartographicOrigin),l=n.x+n.width/2,f=n.y+n.height/2,u=Math.max(r.width,r.height)/4,h=a-l,p=c-f;if(h*h+p*p>u*u)return!1}return!0}_updateAutoHighlight(e){let r=e.sourceTile,n=this.state.layerMap[r?.id];n&&n.layer&&n.layer.updateAutoHighlight(e)}async _loadTileset(e){let r=this.props.loadOptions||{},n=this.props.loaders?.length?this.props.loaders:this.props.loader,o=Array.isArray(n)?n[0]:n,{tileset:s,...i}=r,a={loadOptions:{...i},...s},c=e;if("preload"in o&&typeof o.preload=="function"){let u=await o.preload(e,r);u.url&&(c=u.url),u.headers&&(a.loadOptions.core={...a.loadOptions.core,fetch:{...a.loadOptions.core?.fetch,headers:u.headers}}),Object.assign(a,u)}let l=await(0,Z0.load)(c,o,a.loadOptions),f=new po(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...a});this.setState({tileset3d:f,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(f)}_onTileLoad(e){let{lastUpdatedViewports:r}=this.state;e.tileDrawn=!1,this.props.onTileLoad(e),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;let{tileset3d:r}=this.state,{timeline:n}=this.context,o=Object.keys(e).length;!n||!o||!r||r.selectTiles(Object.values(e)).then(s=>{this.state.frameNumber!==s&&this.setState({frameNumber:s})})}_getSubLayer(e,r){if(!e.content)return null;switch(e.type){case He.POINTCLOUD:return this._makePointCloudLayer(e,r);case He.SCENEGRAPH:return this._make3DModelLayer(e);case He.MESH:return this._makeSimpleMeshLayer(e,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){let{attributes:n,pointCount:o,constantRGBA:s,cartographicOrigin:i,modelMatrix:a}=e.content,{positions:c,normals:l,colors:f}=n;if(!c)return null;let u=r&&r.props.data||{header:{vertexCount:o},attributes:{POSITION:c,NORMAL:l,COLOR_0:f}},{pointSize:h,getPointColor:p}=this.props,d=this.getSubLayerClass("pointcloud",Y0.PointCloudLayer);return new d({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:u,coordinateSystem:zt.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:i,modelMatrix:a,getColor:s||p,_offset:0})}_make3DModelLayer(e){let{gltf:r,instances:n,cartographicOrigin:o,modelMatrix:s}=e.content,i=this.getSubLayerClass("scenegraph",Q0.ScenegraphLayer);return new i({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:n||X0,scenegraph:r,coordinateSystem:zt.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:o,modelMatrix:s,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,r){let n=e.content,{attributes:o,indices:s,modelMatrix:i,cartographicOrigin:a,coordinateSystem:c=zt.COORDINATE_SYSTEM.METER_OFFSETS,material:l,featureIds:f}=n,{_getMeshColor:u}=this.props,h=r&&r.props.mesh||new K0.Geometry({topology:"triangle-list",attributes:r2(o),indices:s}),p=this.getSubLayerClass("mesh",Lm);return new p(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:h,data:X0,getColor:u(e),pbrMaterial:l,modelMatrix:i,coordinateOrigin:a,coordinateSystem:c,featureIds:f,_offset:0})}renderLayers(){let{tileset3d:e,layerMap:r}=this.state;return e?e.tiles.map(n=>{let o=r[n.id]=r[n.id]||{tile:n},{layer:s}=o;return n.selected&&(s?o.needsUpdate&&(s=this._getSubLayer(n,s),o.needsUpdate=!1):s=this._getSubLayer(n)),o.layer=s,s}).filter(Boolean):null}};_o.defaultProps=t2;_o.layerName="Tile3DLayer";var $0=_o;function r2(t){let e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}var pt=U(We(),1),gf=U(Ys(),1);var n2=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function hf(t){return t>>1^-(t&1)}function o2(t){let e=0,r={};for(let[n,o]of n2){let s=o===8?t.getFloat64:t.getFloat32;r[n]=s.call(t,e,!0),e+=o}return{header:r,headerEndPosition:e}}function s2(t,e){let r=e,n=3,o=t.getUint32(r,!0),s=new Uint16Array(o*n);r+=Uint32Array.BYTES_PER_ELEMENT;let i=Uint16Array.BYTES_PER_ELEMENT,a=o*i,c=r,l=c+a,f=l+a,u=0,h=0,p=0;for(let d=0;d<o;d++)u+=hf(t.getUint16(c+i*d,!0)),h+=hf(t.getUint16(l+i*d,!0)),p+=hf(t.getUint16(f+i*d,!0)),s[d]=u,s[d+o]=h,s[d+o*2]=p;return r+=a*3,{vertexData:s,vertexDataEndPosition:r}}function Eo(t,e,r,n,o=!0){let s;if(n===2?s=new Uint16Array(t,e,r):s=new Uint32Array(t,e,r),!o)return s;let i=0;for(let a=0;a<s.length;++a){let c=s[a];s[a]=i-c,c===0&&++i}return s}function i2(t,e,r){let n=r,i=e.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;n%i!==0&&(n+=i-n%i);let a=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=Eo(t.buffer,n,c,i);return n+=c*i,{triangleIndicesEndPosition:n,triangleIndices:l}}function a2(t,e,r){let n=r,i=e.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=Eo(t.buffer,n,a,i,!1);n+=a*i;let l=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let f=Eo(t.buffer,n,l,i,!1);n+=l*i;let u=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let h=Eo(t.buffer,n,u,i,!1);n+=u*i;let p=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let d=Eo(t.buffer,n,p,i,!1);return n+=p*i,{edgeIndicesEndPosition:n,westIndices:c,southIndices:f,eastIndices:h,northIndices:d}}function c2(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function l2(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function f2(t,e){let r={};if(t.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let n=e;for(;n<t.byteLength;){let o=t.getUint8(n,!0);n+=Uint8Array.BYTES_PER_ELEMENT;let s=t.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let i=new DataView(t.buffer,n,s);switch(o){case 1:{r.vertexNormals=c2(i);break}case 2:{r.waterMask=l2(i);break}default:}n+=s}return{extensions:r,extensionsEndPosition:n}}var Tr={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},u2={maxDecodingStep:Tr.extensions};function pf(t,e){let r=Object.assign({},u2,e),n=new DataView(t),{header:o,headerEndPosition:s}=o2(n);if(r.maxDecodingStep<Tr.vertices)return{header:o};let{vertexData:i,vertexDataEndPosition:a}=s2(n,s);if(r.maxDecodingStep<Tr.triangleIndices)return{header:o,vertexData:i};let{triangleIndices:c,triangleIndicesEndPosition:l}=i2(n,i,a);if(r.maxDecodingStep<Tr.edgeIndices)return{header:o,vertexData:i,triangleIndices:c};let{westIndices:f,southIndices:u,eastIndices:h,northIndices:p,edgeIndicesEndPosition:d}=a2(n,i,l);if(r.maxDecodingStep<Tr.extensions)return{header:o,vertexData:i,triangleIndices:c,westIndices:f,northIndices:p,eastIndices:h,southIndices:u};let{extensions:m}=f2(n,d);return{header:o,vertexData:i,triangleIndices:c,westIndices:f,northIndices:p,eastIndices:h,southIndices:u,extensions:m}}function Gi(t,e,r,n){let o=n?p2(n,t.POSITION.value):h2(e),s=new t.POSITION.value.constructor(o.length*6),i=new t.TEXCOORD_0.value.constructor(o.length*4),a=new e.constructor(o.length*6);for(let l=0;l<o.length;l++){let f=o[l];d2({edge:f,edgeIndex:l,attributes:t,skirtHeight:r,newPosition:s,newTexcoord0:i,newTriangles:a})}t.POSITION.value=Hn(t.POSITION.value,s),t.TEXCOORD_0.value=Hn(t.TEXCOORD_0.value,i);let c=e instanceof Array?e.concat(a):Hn(e,a);return{attributes:t,triangles:c}}function h2(t){let e=[];for(let o=0;o<t.length;o+=3)e.push([t[o],t[o+1]]),e.push([t[o+1],t[o+2]]),e.push([t[o+2],t[o]]);e.sort((o,s)=>Math.min(...o)-Math.min(...s)||Math.max(...o)-Math.max(...s));let r=[],n=0;for(;n<e.length;)e[n][0]===e[n+1]?.[1]&&e[n][1]===e[n+1]?.[0]?n+=2:(r.push(e[n]),n++);return r}function p2(t,e){t.westIndices.sort((n,o)=>e[3*n+1]-e[3*o+1]),t.eastIndices.sort((n,o)=>e[3*o+1]-e[3*n+1]),t.southIndices.sort((n,o)=>e[3*o]-e[3*n]),t.northIndices.sort((n,o)=>e[3*n]-e[3*o]);let r=[];for(let n in t){let o=t[n];for(let s=0;s<o.length-1;s++)r.push([o[s],o[s+1]])}return r}function d2({edge:t,edgeIndex:e,attributes:r,skirtHeight:n,newPosition:o,newTexcoord0:s,newTriangles:i}){let a=r.POSITION.value.length,c=e*2,l=e*2+1;o.set(r.POSITION.value.subarray(t[0]*3,t[0]*3+3),c*3),o[c*3+2]=o[c*3+2]-n,o.set(r.POSITION.value.subarray(t[1]*3,t[1]*3+3),l*3),o[l*3+2]=o[l*3+2]-n,s.set(r.TEXCOORD_0.value.subarray(t[0]*2,t[0]*2+2),c*2),s.set(r.TEXCOORD_0.value.subarray(t[1]*2,t[1]*2+2),l*2);let f=e*2*3;i[f]=t[0],i[f+1]=a/3+l,i[f+2]=t[1],i[f+3]=a/3+l,i[f+4]=t[0],i[f+5]=a/3+c}function df(t,e={}){let{bounds:r}=e,{header:n,vertexData:o,triangleIndices:s,westIndices:i,northIndices:a,eastIndices:c,southIndices:l}=pf(t,Tr.triangleIndices),f=s,u=m2(o,n,r),h=dr(u);if(e?.skirtHeight){let{attributes:p,triangles:d}=Gi(u,f,e.skirtHeight,{westIndices:i,northIndices:a,eastIndices:c,southIndices:l});u=p,f=d}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:h},schema:void 0,topology:"triangle-list",mode:4,indices:{value:f,size:1},attributes:u}}function m2(t,e,r){let{minHeight:n,maxHeight:o}=e,[s,i,a,c]=r||[0,0,1,1],l=a-s,f=c-i,u=o-n,h=t.length/3,p=new Float32Array(h*3),d=new Float32Array(h*2);for(let m=0;m<h;m++){let g=t[m]/32767,b=t[m+h]/32767,T=t[m+h*2]/32767;p[3*m+0]=g*l+s,p[3*m+1]=b*f+i,p[3*m+2]=T*u+n,d[2*m+0]=g,d[2*m+1]=b}return{POSITION:{value:p,size:3},TEXCOORD_0:{value:d,size:2}}}var Co=class{constructor(e=257){this.gridSize=e;let r=e-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let o=n+2,s=0,i=0,a=0,c=0,l=0,f=0;for(o&1?a=c=l=r:s=i=f=r;(o>>=1)>1;){let h=s+a>>1,p=i+c>>1;o&1?(a=s,c=i,s=l,i=f):(s=a,i=c,a=l,c=f),l=h,f=p}let u=n*4;this.coords[u+0]=s,this.coords[u+1]=i,this.coords[u+2]=a,this.coords[u+3]=c}}createTile(e){return new mf(e,this)}},mf=class{constructor(e,r){let n=r.gridSize;if(e.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:n,gridSize:o}=this.martini,{terrain:s,errors:i}=this;for(let a=e-1;a>=0;a--){let c=a*4,l=n[c+0],f=n[c+1],u=n[c+2],h=n[c+3],p=l+u>>1,d=f+h>>1,m=p+d-f,g=d+l-p,b=(s[f*o+l]+s[h*o+u])/2,T=d*o+p,S=Math.abs(b-s[T]);if(i[T]=Math.max(i[T],S),a<r){let M=(f+g>>1)*o+(l+m>>1),C=(h+g>>1)*o+(u+m>>1);i[T]=Math.max(i[T],i[M],i[C])}}}getMesh(e=0){let{gridSize:r,indices:n}=this.martini,{errors:o}=this,s=0,i=0,a=r-1;n.fill(0);function c(p,d,m,g,b,T){let S=p+m>>1,M=d+g>>1;Math.abs(p-b)+Math.abs(d-T)>1&&o[M*r+S]>e?(c(b,T,p,d,S,M),c(m,g,b,T,S,M)):(n[d*r+p]=n[d*r+p]||++s,n[g*r+m]=n[g*r+m]||++s,n[T*r+b]=n[T*r+b]||++s,i++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);let l=new Uint16Array(s*2),f=new Uint32Array(i*3),u=0;function h(p,d,m,g,b,T){let S=p+m>>1,M=d+g>>1;if(Math.abs(p-b)+Math.abs(d-T)>1&&o[M*r+S]>e)h(b,T,p,d,S,M),h(m,g,b,T,S,M);else{let C=n[d*r+p]-1,E=n[g*r+m]-1,B=n[T*r+b]-1;l[2*C]=p,l[2*C+1]=d,l[2*E]=m,l[2*E+1]=g,l[2*B]=b,l[2*B+1]=T,f[u++]=C,f[u++]=E,f[u++]=B}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:l,triangles:f}}};var Io=class{constructor(e,r,n=r){this.data=e,this.width=r,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let o=r-1,s=n-1,i=this._addPoint(0,0),a=this._addPoint(o,0),c=this._addPoint(0,s),l=this._addPoint(o,s),f=this._addTriangle(l,i,c,-1,-1,-1);this._addTriangle(i,l,a,f,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r<this._pendingLen;r++){let n=this._pending[r],o=2*this.triangles[n*3+0],s=2*this.triangles[n*3+1],i=2*this.triangles[n*3+2];this._findCandidate(e[o],e[o+1],e[s],e[s+1],e[i],e[i+1],n)}this._pendingLen=0}_findCandidate(e,r,n,o,s,i,a){let c=Math.min(e,n,s),l=Math.min(r,o,i),f=Math.max(e,n,s),u=Math.max(r,o,i),h=yr(n,o,s,i,c,l),p=yr(s,i,e,r,c,l),d=yr(e,r,n,o,c,l),m=o-r,g=e-n,b=i-o,T=n-s,S=r-i,M=s-e,C=yr(e,r,n,o,s,i),E=this.heightAt(e,r)/C,B=this.heightAt(n,o)/C,_=this.heightAt(s,i)/C,y=0,A=0,I=0,L=0;for(let F=l;F<=u;F++){let w=0;h<0&&b!==0&&(w=Math.max(w,Math.floor(-h/b))),p<0&&S!==0&&(w=Math.max(w,Math.floor(-p/S))),d<0&&m!==0&&(w=Math.max(w,Math.floor(-d/m)));let D=h+b*w,W=p+S*w,k=d+m*w,ne=!1;for(let Q=c+w;Q<=f;Q++){if(D>=0&&W>=0&&k>=0){ne=!0;let K=E*D+B*W+_*k,te=Math.abs(K-this.heightAt(Q,F));L+=te*te,te>y&&(y=te,A=Q,I=F)}else if(ne)break;D+=b,W+=S,k+=m}h+=T,p+=M,d+=g}(A===e&&I===r||A===n&&I===o||A===s&&I===i)&&(y=0),this._candidates[2*a]=A,this._candidates[2*a+1]=I,this._rms[a]=L,this._queuePush(a,y,L)}_step(){let e=this._queuePop(),r=e*3+0,n=e*3+1,o=e*3+2,s=this.triangles[r],i=this.triangles[n],a=this.triangles[o],c=this.coords[2*s],l=this.coords[2*s+1],f=this.coords[2*i],u=this.coords[2*i+1],h=this.coords[2*a],p=this.coords[2*a+1],d=this._candidates[2*e],m=this._candidates[2*e+1],g=this._addPoint(d,m);if(yr(c,l,f,u,d,m)===0)this._handleCollinear(g,r);else if(yr(f,u,h,p,d,m)===0)this._handleCollinear(g,n);else if(yr(h,p,c,l,d,m)===0)this._handleCollinear(g,o);else{let b=this._halfedges[r],T=this._halfedges[n],S=this._halfedges[o],M=this._addTriangle(s,i,g,b,-1,-1,r),C=this._addTriangle(i,a,g,T,-1,M+1),E=this._addTriangle(a,s,g,S,M+2,C+1);this._legalize(M),this._legalize(C),this._legalize(E)}}_addPoint(e,r){let n=this.coords.length>>1;return this.coords.push(e,r),n}_addTriangle(e,r,n,o,s,i,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=n,this._halfedges[a+0]=o,this._halfedges[a+1]=s,this._halfedges[a+2]=i,o>=0&&(this._halfedges[o]=a+0),s>=0&&(this._halfedges[s]=a+1),i>=0&&(this._halfedges[i]=a+2),this._candidates[2*c+0]=0,this._candidates[2*c+1]=0,this._queueIndices[c]=-1,this._rms[c]=0,this._pending[this._pendingLen++]=c,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let n=e-e%3,o=r-r%3,s=n+(e+1)%3,i=n+(e+2)%3,a=o+(r+2)%3,c=o+(r+1)%3,l=this.triangles[i],f=this.triangles[e],u=this.triangles[s],h=this.triangles[a],p=this.coords;if(!g2(p[2*l],p[2*l+1],p[2*f],p[2*f+1],p[2*u],p[2*u+1],p[2*h],p[2*h+1]))return;let d=this._halfedges[s],m=this._halfedges[i],g=this._halfedges[a],b=this._halfedges[c];this._queueRemove(n/3),this._queueRemove(o/3);let T=this._addTriangle(l,h,u,-1,g,d,n),S=this._addTriangle(h,l,f,T,m,b,o);this._legalize(T+1),this._legalize(S+2)}_handleCollinear(e,r){let n=r-r%3,o=n+(r+1)%3,s=n+(r+2)%3,i=this.triangles[s],a=this.triangles[r],c=this.triangles[o],l=this._halfedges[o],f=this._halfedges[s],u=this._halfedges[r];if(u<0){let E=this._addTriangle(e,i,a,-1,f,-1,n),B=this._addTriangle(i,e,c,E,-1,l);this._legalize(E+1),this._legalize(B+2);return}let h=u-u%3,p=h+(u+2)%3,d=h+(u+1)%3,m=this.triangles[p],g=this._halfedges[p],b=this._halfedges[d];this._queueRemove(h/3);let T=this._addTriangle(i,a,e,f,-1,-1,n),S=this._addTriangle(a,m,e,b,-1,T+1,h),M=this._addTriangle(m,c,e,g,-1,S+1),C=this._addTriangle(c,i,e,l,T+2,M+1);this._legalize(T),this._legalize(S),this._legalize(M),this._legalize(C)}_queuePush(e,r,n){let o=this._queue.length;this._queueIndices[e]=o,this._queue.push(e),this._errors.push(r),this._rmsSum+=n,this._queueUp(o)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let o=this._pending.indexOf(e);if(o!==-1)this._pending[o]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let n=this._queue.length-1;n!==r&&(this._queueSwap(r,n),this._queueDown(r,n)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let n=this._queue[e],o=this._queue[r];this._queue[e]=o,this._queue[r]=n,this._queueIndices[n]=r,this._queueIndices[o]=e;let s=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=s}_queueUp(e){let r=e;for(;;){let n=r-1>>1;if(n===r||!this._queueLess(r,n))break;this._queueSwap(n,r),r=n}}_queueDown(e,r){let n=e;for(;;){let o=2*n+1;if(o>=r||o<0)break;let s=o+1,i=o;if(s<r&&this._queueLess(s,o)&&(i=s),!this._queueLess(i,n))break;this._queueSwap(n,i),n=i}return n>e}};function yr(t,e,r,n,o,s){return(r-o)*(e-s)-(n-s)*(t-o)}function g2(t,e,r,n,o,s,i,a){let c=t-i,l=e-a,f=r-i,u=n-a,h=o-i,p=s-a,d=c*c+l*l,m=f*f+u*u,g=h*h+p*p;return c*(u*g-m*p)-l*(f*g-m*h)+d*(f*p-u*h)<0}function r1(t,e){let{meshMaxError:r,bounds:n,elevationDecoder:o}=e,{data:s,width:i,height:a}=t,c,l;switch(e.tesselator){case"martini":c=Hi(s,i,a,o,e.tesselator),l=e1(r,i,c);break;case"delatin":c=Hi(s,i,a,o,e.tesselator),l=t1(r,i,a,c);break;default:i===a&&!(a&i-1)?(c=Hi(s,i,a,o,"martini"),l=e1(r,i,c)):(c=Hi(s,i,a,o,"delatin"),l=t1(r,i,a,c));break}let{vertices:f}=l,{triangles:u}=l,h=A2(f,c,i,a,n),p=dr(h);if(e.skirtHeight){let{attributes:d,triangles:m}=Gi(h,u,e.skirtHeight);h=d,u=m}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:p},mode:4,indices:{value:Uint32Array.from(u),size:1},attributes:h}}function e1(t,e,r){let n=e+1,s=new Co(n).createTile(r),{vertices:i,triangles:a}=s.getMesh(t);return{vertices:i,triangles:a}}function t1(t,e,r,n){let o=new Io(n,e+1,r+1);o.run(t);let{coords:s,triangles:i}=o;return{vertices:s,triangles:i}}function Hi(t,e,r,n,o){let{rScaler:s,bScaler:i,gScaler:a,offset:c}=n,l=new Float32Array((e+1)*(r+1));for(let f=0,u=0;u<r;u++)for(let h=0;h<e;h++,f++){let p=f*4,d=t[p+0],m=t[p+1],g=t[p+2];l[f+u]=d*s+m*a+g*i+c}if(o==="martini"){for(let f=(e+1)*e,u=0;u<e;u++,f++)l[f]=l[f-e-1];for(let f=r,u=0;u<r+1;u++,f+=r+1)l[f]=l[f-1]}return l}function A2(t,e,r,n,o){let s=r+1,i=t.length/2,a=new Float32Array(i*3),c=new Float32Array(i*2),[l,f,u,h]=o||[0,0,r,n],p=(u-l)/r,d=(h-f)/n;for(let m=0;m<i;m++){let g=t[m*2],b=t[m*2+1],T=b*s+g;a[3*m+0]=g*p+l,a[3*m+1]=-b*d+h,a[3*m+2]=e[T],c[2*m+0]=g/r,c[2*m+1]=b/n}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:c,size:2}}}var ki="4.4.3";var zi={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:ki,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var n1={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:ki,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var b2={...zi,parse:x2};async function x2(t,e,r){let n={...e,core:{...e?.core,mimeType:"application/x.image"},image:{...e?.image,type:"data"}},o=await Oe(t,[],n,r),s={...b2.options.terrain,...e?.terrain};return r1(o,s)}var E5={...n1,parseSync:(t,e)=>df(t,e?.["quantized-mesh"]),parse:async(t,e)=>df(t,e?.["quantized-mesh"])};var o1=[1],s1=1,i1=1,qi=90,ji=180,T2={...lr.defaultProps,elevationData:Dt,texture:{...Dt,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[zi]};function a1(t){return Array.isArray(t)?t.join(";"):t||""}function y2(t,e,r){let n=(t[2]-t[0])/e*s1,o=(t[3]-t[1])/e*s1,s=[t[0]-n,t[1]-o,t[2]+n,t[3]+o];return r?[Math.max(s[0],-ji),Math.max(s[1],-qi),Math.min(s[2],ji),Math.min(s[3],qi)]:s}function S2(t){return!Number.isFinite(t)||t<=0?i1:Math.max(t,i1)}var vo=class extends pt.CompositeLayer{updateState({props:e,oldProps:r}){let n=e.elevationData!==r.elevationData;if(n){let{elevationData:s}=e,i=s&&(Array.isArray(s)||M2(s));this.setState({isTiled:i})}let o=n||e.meshMaxError!==r.meshMaxError||e.elevationDecoder!==r.elevationDecoder||e.bounds!==r.bounds;if(!this.state.isTiled&&o){let s=this.loadTerrain(e);this.setState({terrain:s})}e.workerUrl&&pt.log.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:r,elevationDecoder:n,meshMaxError:o,signal:s}){if(!e)return null;let i=S2(o),a=this.getLoadOptions();a={...a,terrain:{skirtHeight:this.state.isTiled?i*2:0,...a?.terrain,bounds:r,meshMaxError:i,elevationDecoder:n}};let{fetch:c}=this.props;return c(e,{propName:"elevationData",layer:this,loadOptions:a,signal:s})}getTiledTerrainData(e){let{elevationData:r,fetch:n,texture:o,elevationDecoder:s,meshMaxError:i}=this.props,{viewport:a}=this.context,c=ft(r,e),l=o&&ft(o,e),{signal:f}=e,u=[0,0],h=[0,0];if(a.isGeospatial){let b=e.bbox;u=a.projectFlat([b.west,b.south]),h=a.projectFlat([b.east,b.north])}else{let b=e.bbox;u=[b.left,b.bottom],h=[b.right,b.top]}let p=[u[0],u[1],h[0],h[1]],d=y2(p,this.props.tileSize,a instanceof pt._GlobeViewport),m=this.loadTerrain({elevationData:c,bounds:d,elevationDecoder:s,meshMaxError:i,signal:f}),g=l?n(l,{propName:"texture",layer:this,loaders:[],signal:f}).catch(b=>null):Promise.resolve(null);return Promise.all([m,g])}renderSubLayers(e){let r=this.getSubLayerClass("mesh",gf.SimpleMeshLayer),{color:n,wireframe:o,material:s}=this.props,{data:i}=e;if(!i)return null;let[a,c]=i,{viewport:l}=this.context,f=l instanceof pt._GlobeViewport,u=a?.header?.boundingBox,h=u&&u.every(([d,m])=>d>=-ji&&d<=ji&&m>=-qi&&m<=qi),p=f&&h?pt.COORDINATE_SYSTEM.LNGLAT:pt.COORDINATE_SYSTEM.CARTESIAN;return new r(e,{data:o1,mesh:a,texture:c,_instanced:!1,coordinateSystem:p,getPosition:d=>[0,0,0],getColor:n,wireframe:o,material:s})}onViewportLoad(e){if(!e)return;let{zRange:r}=this.state,n=e.map(i=>i.content).filter(Boolean).map(i=>i[0].header.boundingBox.map(c=>c[2]));if(n.length===0)return;let o=Math.min(...n.map(i=>i[0])),s=Math.max(...n.map(i=>i[1]));(!r||o<r[0]||s>r[1])&&this.setState({zRange:[o,s]})}renderLayers(){let{color:e,material:r,elevationData:n,texture:o,wireframe:s,meshMaxError:i,elevationDecoder:a,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:h,onTileLoad:p,onTileUnload:d,onTileError:m,maxCacheSize:g,maxCacheByteSize:b,refinementStrategy:T,zoomOffset:S}=this.props;if(this.state.isTiled)return new lr(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:a1(n),texture:a1(o),meshMaxError:i,elevationDecoder:a,projectionMode:this.context.viewport.projectionMode,zoomOffset:S}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:h,onTileLoad:p,onTileUnload:d,onTileError:m,maxCacheSize:g,maxCacheByteSize:b,refinementStrategy:T,zoomOffset:S});if(!n)return null;let M=this.getSubLayerClass("mesh",gf.SimpleMeshLayer);return new M(this.getSubLayerProps({id:"mesh"}),{data:o1,mesh:this.state.terrain,texture:o,_instanced:!1,getPosition:C=>[0,0,0],getColor:e,material:r,wireframe:s})}};vo.defaultProps=T2;vo.layerName="TerrainLayer";var c1=vo,M2=t=>t.includes("{x}")&&(t.includes("{y}")||t.includes("{-y}"));var ra=U(We(),1),Ff=U(Je(),1),k1=U(f1(),1);function u1(t,e,r){switch(t.type){case"Point":return E2(t,e,r);case"LineString":return _2(t,e,r);case"Polygon":return h1(t,e,r);default:let n=t;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function h1(t,e=-1/0,r=1/0){let{positions:n}=t,o=t.polygonIndices.value.filter(c=>c>=e&&c<=r),s=t.primitivePolygonIndices.value.filter(c=>c>=e&&c<=r);if(!(o.length>2)){let c=[];for(let l=0;l<s.length-1;l++){let f=s[l],u=s[l+1],h=Ji(n,f,u);c.push(h)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<o.length-1;c++){let l=o[c],f=o[c+1],u=h1(t,l,f).coordinates;a.push(u)}return{type:"MultiPolygon",coordinates:a}}function _2(t,e=-1/0,r=1/0){let{positions:n}=t,o=t.pathIndices.value.filter(a=>a>=e&&a<=r);if(!(o.length>2))return{type:"LineString",coordinates:Ji(n,o[0],o[1])};let i=[];for(let a=0;a<o.length-1;a++){let c=Ji(n,o[a],o[a+1]);i.push(c)}return{type:"MultiLineString",coordinates:i}}function E2(t,e,r){let{positions:n}=t,o=Ji(n,e,r);return o.length>1?{type:"MultiPoint",coordinates:o}:{type:"Point",coordinates:o[0]}}function Ji(t,e,r){e=e||0,r=r||t.value.length/t.size;let n=[];for(let o=e;o<r;o++){let s=Array();for(let i=o*t.size;i<(o+1)*t.size;i++)s.push(Number(t.value[i]));n.push(s)}return n}var Bo={x:0,y:1,z:2};function Sr(t,e={}){let{start:r=0,end:n=t.length,plane:o="xy"}=e,s=e.size||2,i=0,a=Bo[o[0]],c=Bo[o[1]];for(let l=r,f=n-s;l<n;l+=s)i+=(t[l+a]-t[f+a])*(t[l+c]+t[f+c]),f=l;return i/2}function bf(t,e,r=2,n,o="xy"){let s=e&&e.length,i=s?e[0]*r:t.length,a=d1(t,0,i,r,!0,n&&n[0],o),c=[];if(!a||a.next===a.prev)return c;let l,f,u,h,p,d,m;if(s&&(a=L2(t,e,a,r,n,o)),t.length>80*r){h=f=t[0],p=u=t[1];for(let g=r;g<i;g+=r)d=t[g],m=t[g+1],d<h&&(h=d),m<p&&(p=m),d>f&&(f=d),m>u&&(u=m);l=Math.max(f-h,u-p),l=l!==0?32767/l:0}return Ro(a,c,r,h,p,l,0),c}function d1(t,e,r,n,o,s,i){let a,c;s===void 0&&(s=Sr(t,{start:e,end:r,size:n,plane:i}));let l=Bo[i[0]],f=Bo[i[1]];if(o===s<0)for(a=e;a<r;a+=n)c=p1(a,t[a+l],t[a+f],c);else for(a=r-n;a>=e;a-=n)c=p1(a,t[a+l],t[a+f],c);return c&&Ki(c,c.next)&&(Lo(c),c=c.next),c}function Mr(t,e){if(!t)return t;e||(e=t);let r=t,n;do if(n=!1,!r.steiner&&(Ki(r,r.next)||oe(r.prev,r,r.next)===0)){if(Lo(r),r=e=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==e);return e}function Ro(t,e,r,n,o,s,i){if(!t)return;!i&&s&&U2(t,n,o,s);let a=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,s?B2(t,n,o,s):v2(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),Lo(t),t=l.next,a=l.next;continue}if(t=l,t===a){i?i===1?(t=R2(Mr(t),e,r),Ro(t,e,r,n,o,s,2)):i===2&&w2(t,e,r,n,o,s):Ro(Mr(t),e,r,n,o,s,1);break}}}function v2(t){let e=t.prev,r=t,n=t.next;if(oe(e,r,n)>=0)return!1;let o=e.x,s=r.x,i=n.x,a=e.y,c=r.y,l=n.y,f=o<s?o<i?o:i:s<i?s:i,u=a<c?a<l?a:l:c<l?c:l,h=o>s?o>i?o:i:s>i?s:i,p=a>c?a>l?a:l:c>l?c:l,d=n.next;for(;d!==e;){if(d.x>=f&&d.x<=h&&d.y>=u&&d.y<=p&&mn(o,a,s,c,i,l,d.x,d.y)&&oe(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function B2(t,e,r,n){let o=t.prev,s=t,i=t.next;if(oe(o,s,i)>=0)return!1;let a=o.x,c=s.x,l=i.x,f=o.y,u=s.y,h=i.y,p=a<c?a<l?a:l:c<l?c:l,d=f<u?f<h?f:h:u<h?u:h,m=a>c?a>l?a:l:c>l?c:l,g=f>u?f>h?f:h:u>h?u:h,b=Af(p,d,e,r,n),T=Af(m,g,e,r,n),S=t.prevZ,M=t.nextZ;for(;S&&S.z>=b&&M&&M.z<=T;){if(S.x>=p&&S.x<=m&&S.y>=d&&S.y<=g&&S!==o&&S!==i&&mn(a,f,c,u,l,h,S.x,S.y)&&oe(S.prev,S,S.next)>=0||(S=S.prevZ,M.x>=p&&M.x<=m&&M.y>=d&&M.y<=g&&M!==o&&M!==i&&mn(a,f,c,u,l,h,M.x,M.y)&&oe(M.prev,M,M.next)>=0))return!1;M=M.nextZ}for(;S&&S.z>=b;){if(S.x>=p&&S.x<=m&&S.y>=d&&S.y<=g&&S!==o&&S!==i&&mn(a,f,c,u,l,h,S.x,S.y)&&oe(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;M&&M.z<=T;){if(M.x>=p&&M.x<=m&&M.y>=d&&M.y<=g&&M!==o&&M!==i&&mn(a,f,c,u,l,h,M.x,M.y)&&oe(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function R2(t,e,r){let n=t;do{let o=n.prev,s=n.next.next;!Ki(o,s)&&m1(o,n,n.next,s)&&wo(o,s)&&wo(s,o)&&(e.push(o.i/r|0),e.push(n.i/r|0),e.push(s.i/r|0),Lo(n),Lo(n.next),n=t=s),n=n.next}while(n!==t);return Mr(n)}function w2(t,e,r,n,o,s){let i=t;do{let a=i.next.next;for(;a!==i.prev;){if(i.i!==a.i&&G2(i,a)){let c=g1(i,a);i=Mr(i,i.next),c=Mr(c,c.next),Ro(i,e,r,n,o,s,0),Ro(c,e,r,n,o,s,0);return}a=a.next}i=i.next}while(i!==t)}function L2(t,e,r,n,o,s){let i=[],a,c,l,f,u;for(a=0,c=e.length;a<c;a++)l=e[a]*n,f=a<c-1?e[a+1]*n:t.length,u=d1(t,l,f,n,!1,o&&o[a+1],s),u===u.next&&(u.steiner=!0),i.push(V2(u));for(i.sort(F2),a=0;a<i.length;a++)r=P2(i[a],r);return r}function F2(t,e){return t.x-e.x}function P2(t,e){let r=N2(t,e);if(!r)return e;let n=g1(r,t);return Mr(n,n.next),Mr(r,r.next)}function N2(t,e){let r=e,n=t.x,o=t.y,s=-1/0,i;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){let h=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=n&&h>s&&(s=h,i=r.x<r.next.x?r:r.next,h===n))return i}r=r.next}while(r!==e);if(!i)return null;let a=i,c=i.x,l=i.y,f=1/0,u;r=i;do n>=r.x&&r.x>=c&&n!==r.x&&mn(o<l?n:s,o,c,l,o<l?s:n,o,r.x,r.y)&&(u=Math.abs(o-r.y)/(n-r.x),wo(r,t)&&(u<f||u===f&&(r.x>i.x||r.x===i.x&&O2(i,r)))&&(i=r,f=u)),r=r.next;while(r!==a);return i}function O2(t,e){return oe(t.prev,t,e.prev)<0&&oe(e.next,t,t.next)<0}function U2(t,e,r,n){let o=t;do o.z===0&&(o.z=Af(o.x,o.y,e,r,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,D2(o)}function D2(t){let e,r,n=1,o,s,i,a,c,l;do{for(s=t,t=null,l=null,o=0;s;){for(o++,a=s,i=0,r=0;r<n&&(i++,a=a.nextZ,!!a);r++);for(c=n;i>0||c>0&&a;)i!==0&&(c===0||!a||s.z<=a.z)?(e=s,s=s.nextZ,i--):(e=a,a=a.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;s=a}l.nextZ=null,n*=2}while(o>1);return t}function Af(t,e,r,n,o){return t=(t-r)*o|0,e=(e-n)*o|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function V2(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function mn(t,e,r,n,o,s,i,a){return(o-i)*(e-a)>=(t-i)*(s-a)&&(t-i)*(n-a)>=(r-i)*(e-a)&&(r-i)*(s-a)>=(o-i)*(n-a)}function G2(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!H2(t,e)&&(wo(t,e)&&wo(e,t)&&k2(t,e)&&(oe(t.prev,t,e.prev)||oe(t,e.prev,e))||Ki(t,e)&&oe(t.prev,t,t.next)>0&&oe(e.prev,e,e.next)>0)}function oe(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Ki(t,e){return t.x===e.x&&t.y===e.y}function m1(t,e,r,n){let o=Xi(oe(t,e,r)),s=Xi(oe(t,e,n)),i=Xi(oe(r,n,t)),a=Xi(oe(r,n,e));return!!(o!==s&&i!==a||o===0&&Wi(t,r,e)||s===0&&Wi(t,n,e)||i===0&&Wi(r,t,n)||a===0&&Wi(r,e,n))}function Wi(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Xi(t){return t>0?1:t<0?-1:0}function H2(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&m1(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function wo(t,e){return oe(t.prev,t,t.next)<0?oe(t,e,t.next)>=0&&oe(t,t.prev,e)>=0:oe(t,e,t.prev)<0||oe(t,t.next,e)<0}function k2(t,e){let r=t,n=!1,o=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&r.next.y!==r.y&&o<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==t);return n}function g1(t,e){let r=new Fo(t.i,t.x,t.y),n=new Fo(e.i,e.x,e.y),o=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=o,o.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function p1(t,e,r,n){let o=new Fo(t,e,r);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.next=o):(o.prev=o,o.next=o),o}function Lo(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)}var Fo=class{constructor(e,r,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=n}};function Yi(t,e,r){let n=W2(t),o=Object.keys(n).filter(s=>n[s]!==Array);return X2(t,{propArrayTypes:n,...e},{numericPropKeys:r&&r.numericPropKeys||o,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function W2(t){let e={};for(let r of t)if(r.properties)for(let n in r.properties){let o=r.properties[n];e[n]=eR(o,e[n])}return e}function X2(t,e,r){let{pointPositionsCount:n,pointFeaturesCount:o,linePositionsCount:s,linePathsCount:i,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:h,coordLength:p}=e,{numericPropKeys:d=[],PositionDataType:m=Float32Array,triangulate:g=!0}=r,b=t[0]&&"id"in t[0],T=t.length>65535?Uint32Array:Uint16Array,S={type:"Point",positions:new m(n*p),globalFeatureIds:new T(n),featureIds:o>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},M={type:"LineString",pathIndices:s>65535?new Uint32Array(i+1):new Uint16Array(i+1),positions:new m(s*p),globalFeatureIds:new T(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},C={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new m(c*p),globalFeatureIds:new T(c),featureIds:u>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};g&&(C.triangles=[]);for(let B of[S,M,C])for(let _ of d){let y=h[_];B.numericProps[_]=new y(B.positions.length/p)}M.pathIndices[i]=s,C.polygonIndices[l]=c,C.primitivePolygonIndices[f]=c;let E={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let B of t){let _=B.geometry,y=B.properties||{};switch(_.type){case"Point":K2(_,S,E,p,y),S.properties.push(Tf(y,d)),b&&S.fields.push({id:B.id}),E.pointFeature++;break;case"LineString":Y2(_,M,E,p,y),M.properties.push(Tf(y,d)),b&&M.fields.push({id:B.id}),E.lineFeature++;break;case"Polygon":Q2(_,C,E,p,y),C.properties.push(Tf(y,d)),b&&C.fields.push({id:B.id}),E.polygonFeature++;break;default:throw new Error("Invalid geometry type")}E.feature++}return $2(S,M,C,p)}function K2(t,e,r,n,o){e.positions.set(t.data,r.pointPosition*n);let s=t.data.length/n;yf(e,o,r.pointPosition,s),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+s),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+s),r.pointPosition+=s}function Y2(t,e,r,n,o){e.positions.set(t.data,r.linePosition*n);let s=t.data.length/n;yf(e,o,r.linePosition,s),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+s),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+s);for(let i=0,a=t.indices.length;i<a;++i){let c=t.indices[i],l=i===a-1?t.data.length:t.indices[i+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/n}}function Q2(t,e,r,n,o){e.positions.set(t.data,r.polygonPosition*n);let s=t.data.length/n;yf(e,o,r.polygonPosition,s),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+s),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+s);for(let i=0,a=t.indices.length;i<a;++i){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[i],f=t.indices[i],u=t.indices[i+1];for(let p=0,d=f.length;p<d;++p){let m=f[p],g=p===d-1?u===void 0?t.data.length:u[0]:f[p+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(g-m)/n}let h=r.polygonPosition;Z2(e,l,f,{startPosition:c,endPosition:h,coordLength:n})}}function Z2(t,e,r,{startPosition:n,endPosition:o,coordLength:s}){if(!t.triangles)return;let i=n*s,a=o*s,c=t.positions.subarray(i,a),l=r[0],f=r.slice(1).map(h=>(h-l)/s),u=bf(c,f,s,e);for(let h=0,p=u.length;h<p;++h)t.triangles.push(n+u[h])}function xf(t,e){let r={};for(let n in t)r[n]={value:t[n],size:e};return r}function $2(t,e,r,n){let o={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:n},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:xf(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:n},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:xf(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:n},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:xf(r.numericProps,1)}};return o.polygons&&r.triangles&&(o.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),o}function yf(t,e,r,n){for(let o in t.numericProps)if(o in e){let s=e[o];t.numericProps[o].fill(s,r,r+n)}}function Tf(t,e){let r={};for(let n in t)e.includes(n)||(r[n]=t[n]);return r}function eR(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function Po(t,e){let r=e?.globalFeatureId;return r!==void 0?tR(t,r):rR(t,e?.type)}function tR(t,e){let r=x1(t);for(let n of r){let o=0,s=n.featureIds.value[0];for(let i=0;i<n.featureIds.value.length;i++){let a=n.featureIds.value[i];if(a!==s){if(e===n.globalFeatureIds.value[o])return Qi(n,o,i);o=i,s=a}}if(e===n.globalFeatureIds.value[o])return Qi(n,o,n.featureIds.value.length)}throw new Error(`featureId:${e} not found`)}function rR(t,e){let r=x1(t,e);return nR(r)}function x1(t,e){let r=[];return t.points&&(t.points.type="Point",r.push(t.points)),t.lines&&(t.lines.type="LineString",r.push(t.lines)),t.polygons&&(t.polygons.type="Polygon",r.push(t.polygons)),r}function nR(t){let e=[];for(let r of t){if(r.featureIds.value.length===0)continue;let n=0,o=r.featureIds.value[0];for(let s=0;s<r.featureIds.value.length;s++){let i=r.featureIds.value[s];i!==o&&(e.push(Qi(r,n,s)),n=s,o=i)}e.push(Qi(r,n,r.featureIds.value.length))}return e}function Qi(t,e,r){let n=u1(t,e,r),o=sR(t,e,r),s=oR(t,e,r);return{type:"Feature",geometry:n,properties:o,...s}}function oR(t,e=0,r){return t.fields&&t.fields[t.featureIds.value[e]]}function sR(t,e=0,r){let n=Object.assign({},t.properties[t.featureIds.value[e]]);for(let o in t.numericProps)n[o]=t.numericProps[o].value[e];return n}var If=U(C1(),1);function MR(t){let e=0;for(let r=0,n=t.length-1,o,s;r<t.length;n=r++)o=t[r],s=t[n],e+=(s[0]-o[0])*(o[1]+s[1]);return e}function _f(t,e){if(Array.isArray(t[0])){for(let n of t)_f(n,e);return}let r=t;r[0]/=e,r[1]/=e}function I1(t,e){for(let r=0;r<t.length;++r)t[r]/=e}function Ef(t,e,r){if(typeof t[0][0]!="number"){for(let i of t)Ef(i,e,r);return}let n=r*Math.pow(2,e.z),o=r*e.x,s=r*e.y;for(let i=0;i<t.length;i++){let a=t[i];a[0]=(a[0]+o)*360/n-180;let c=180-(a[1]+s)*360/n;a[1]=360/Math.PI*Math.atan(Math.exp(c*Math.PI/180))-90}}function v1(t,e,r){let{x:n,y:o,z:s}=e,i=r*Math.pow(2,s),a=r*n,c=r*o;for(let l=0,f=t.length;l<f;l+=2){t[l]=(t[l]+a)*360/i-180;let u=180-(t[l+1]+c)*360/i;t[l+1]=360/Math.PI*Math.atan(Math.exp(u*Math.PI/180))-90}}function B1(t){let e=t.length;if(e<=1)return[t];let r=[],n,o;for(let s=0;s<e;s++){let i=MR(t[s]);i!==0&&(o===void 0&&(o=i<0),o===i<0?(n&&r.push(n),n=[t[s]]):n&&n.push(t[s]))}return n&&r.push(n),r}function R1(t){let e=t.indices.length,r="Polygon";if(e<=1)return{type:r,data:t.data,areas:[[Sr(t.data)]],indices:[t.indices]};let n=[],o=[],s=[],i=[],a,c=0;for(let l,f=0,u;f<e;f++){u=t.indices[f]-c,l=t.indices[f+1]-c||t.data.length;let h=t.data.slice(u,l),p=Sr(h);if(p===0){let d=t.data.slice(0,u),m=t.data.slice(l);t.data=d.concat(m),c+=l-u;continue}a===void 0&&(a=p<0),a===p<0?(i.length&&(n.push(s),o.push(i)),i=[u],s=[p]):(s.push(p),i.push(u))}return s&&n.push(s),i.length&&o.push(i),{type:r,areas:n,indices:o,data:t.data}}var bn=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;static types=["Unknown","Point","LineString","Polygon"];constructor(e,r,n,o,s,i){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=e,this._geometry=-1,this._keys=o,this._values=s,this._geometryInfo=i,e.readFields(_R,this,r)}toGeoJSONFeature(e,r){let n=this.loadGeometry();return e==="wgs84"?w1(this,n,o=>Ef(o,r,this.extent)):w1(this,n,_f)}toBinaryFeature(e,r){let n=this.loadFlatGeometry();return e==="wgs84"?this._toBinaryCoordinates(n,o=>v1(o,r,this.extent)):this._toBinaryCoordinates(n,I1)}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o=0,s=0,i=0,a=1/0,c=-1/0,l=1/0,f=-1/0;for(;e.pos<r;){if(o<=0){let u=e.readVarint();n=u&7,o=u>>3}if(o--,n===1||n===2)s+=e.readSVarint(),i+=e.readSVarint(),s<a&&(a=s),s>c&&(c=s),i<l&&(l=i),i>f&&(f=i);else if(n!==7)throw new Error(`unknown command ${n}`)}return[a,l,c,f]}_toBinaryCoordinates(e,r){let n;r(e.data,this.extent);let o=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=e.indices.length,n={type:"Point",...e};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=e.indices.length,this._geometryInfo.linePositionsCount+=e.data.length/o,n={type:"LineString",...e};break;case 3:n=R1(e),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=n.indices.length;for(let i of n.indices)this._geometryInfo.polygonRingsCount+=i.length;this._geometryInfo.polygonPositionsCount+=n.data.length/o;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let s={type:"Feature",geometry:n,properties:this.properties};return this.id!==null&&(s.id=this.id),s}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o=0,s=0,i=0,a=[],c;for(;e.pos<r;){if(o<=0){let l=e.readVarint();n=l&7,o=l>>3}switch(o--,n){case 1:case 2:s+=e.readSVarint(),i+=e.readSVarint(),n===1&&(c&&a.push(c),c=[]),c&&c.push([s,i]);break;case 7:c&&c.push(c[0].slice());break;default:throw new Error(`unknown command ${n}`)}}return c&&a.push(c),a}loadFlatGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,n=1,o,s=0,i=0,a=0,c=0,l=[],f=[];for(;e.pos<r;)if(s<=0&&(o=e.readVarint(),n=o&7,s=o>>3),s--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),n===1&&l.push(c),f.push(i,a),c+=2;else if(n===7){if(c>0){let u=l[l.length-1];f.push(f[u],f[u+1]),c+=2}}else throw new Error(`unknown command ${n}`);return{data:f,indices:l}}};function w1(t,e,r){let n=bn.types[t.type],o,s,i;switch(t.type){case 1:let c=[];for(o=0;o<e.length;o++)c[o]=e[o][0];i=c,r(i,t.extent);break;case 2:for(i=e,o=0;o<i.length;o++)r(i[o],t.extent);break;case 3:for(i=B1(e),o=0;o<i.length;o++)for(s=0;s<i[o].length;s++)r(i[o][s],t.extent);break;default:throw new Error("illegal vector tile type")}i.length===1?i=i[0]:n=`Multi${n}`;let a={type:"Feature",geometry:{type:n,coordinates:i},properties:t.properties};return t.id!==null&&(a.properties||={},a.properties.id=t.id),a}function _R(t,e,r){e&&r&&(t===1?e.id=r.readVarint():t===2?ER(r,e):t===3?e.type=r.readVarint():t===4&&(e._geometry=r.pos))}function ER(t,e){let r=t.readVarint()+t.pos;for(;t.pos<r;){let n=e._keys[t.readVarint()],o=e._values[t.readVarint()];e.properties[n]=o}}var ea=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(CR,this,r),this.length=this._features.length}getGeoJSONFeature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new bn(this._pbf,r,this.extent,this._keys,this._values)}getBinaryFeature(e,r){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let n=this._pbf.readVarint()+this._pbf.pos;return new bn(this._pbf,n,this.extent,this._keys,this._values,r)}};function CR(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(IR(r)))}function IR(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos<r;){let n=t.readVarint()>>3;e=n===1?t.readString():n===2?t.readFloat():n===3?t.readDouble():n===4?t.readVarint64():n===5?t.readVarint():n===6?t.readSVarint():n===7?t.readBoolean():null}return e}var No=class{layers;constructor(e,r){this.layers=e.readFields(vR,{},r)}};function vR(t,e,r){if(t===3&&r){let n=new ea(r,r.readVarint()+r.pos);n.length&&e&&(e[n.name]=n)}}function vf(t,e){let r=RR(e),n=e?.gis?.format||e?.mvt?.shape||e?.shape;switch(n){case"columnar-table":return{shape:"columnar-table",data:Cf(t,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:L1(t,r)};case"geojson":return L1(t,r);case"binary-geometry":return Cf(t,r);case"binary":return Cf(t,r);default:throw new Error(n||"undefined shape")}}function Cf(t,e){let[r,n]=BR(t,e),o=Yi(r,n);return o.byteLength=t.byteLength,o}function BR(t,e){let r=[],n={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength<=0)return[r,n];let o=new No(new If.default(t));return(e&&Array.isArray(e.layers)?e.layers:Object.keys(o.layers)).forEach(i=>{let a=o.layers[i];if(a)for(let c=0;c<a.length;c++){let l=a.getBinaryFeature(c,n),f=LR(l,e,i);r.push(f)}}),[r,n]}function L1(t,e){if(t.byteLength<=0)return[];let r=[],n=new No(new If.default(t));return(Array.isArray(e.layers)?e.layers:Object.keys(n.layers)).forEach(s=>{let i=n.layers[s];if(i)for(let a=0;a<i.length;a++){let c=i.getGeoJSONFeature(a),l=wR(c,e,s);r.push(l)}}),r}function RR(t){if(!t?.mvt)throw new Error("mvt options required");if(t.mvt?.coordinates==="wgs84"&&!t.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return t.gis&&gc.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),t.mvt}function wR(t,e,r){let n=t.toGeoJSONFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&(n.properties||={},n.properties[e.layerProperty]=r),n}function LR(t,e,r){let n=t.toBinaryFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&n.properties&&(n.properties[e.layerProperty]=r),n}var F1={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry"};var FR="4.4.3",ta={...F1,dataType:null,batchType:null,version:FR,worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},PR={...ta,parse:async(t,e)=>vf(t,e),parseSync:vf,binary:!0};var NR={Point:P1,MultiPoint:OR,LineString:N1,MultiLineString:UR,Polygon:O1,MultiPolygon:DR};function P1([t,e],[r,n],o){let s=vt(r[0],n[0],t),i=vt(r[1],n[1],e);return o.unprojectFlat([s,i])}function Bf(t,e,r){return t.map(n=>P1(n,e,r))}function OR(t,e,r){return Bf(t,e,r)}function N1(t,e,r){return Bf(t,e,r)}function UR(t,e,r){return t.map(n=>N1(n,e,r))}function O1(t,e,r){return t.map(n=>Bf(n,e,r))}function DR(t,e,r){return t.map(n=>O1(n,e,r))}function U1(t,e,r){let n=r.projectFlat([e.west,e.north]),o=r.projectFlat([e.east,e.south]),s=[n,o];return{...t,coordinates:NR[t.type](t.coordinates,s,r)}}var VR=["points","lines","polygons"];function Rf(t,e,r,n){for(let o of VR){let s=t[o]&&GR(t[o],e,r,n);if(s>=0)return s}return-1}function GR(t,e,r,n){let o=t.featureIds.value;if(!o.length)return-1;let s=0,i=o[o.length-1]+1;if(n){let c=HR(t,n);if(c)s=c[0],i=c[1]+1;else return-1}let a=-1;if(e in t.numericProps){let c=t.numericProps[e].value.findIndex((l,f)=>l===r&&o[f]>=s&&o[f]<i);return c>=0?t.globalFeatureIds.value[c]:-1}else e?a=D1(t.properties,c=>c[e]===r,s,i):t.fields&&(a=D1(t.fields,c=>c.id===r,s,i));return a>=0?kR(t,a):-1}function HR(t,e){if(!t.__layers){let r={},{properties:n}=t;for(let o=0;o<n.length;o++){let{layerName:s}=n[o];s&&(r[s]?r[s][1]=o:r[s]=[o,o])}t.__layers=r}return t.__layers[e]}function kR(t,e){if(!t.__ids){let r=[],n=t.featureIds.value,o=t.globalFeatureIds.value;for(let s=0;s<n.length;s++)r[n[s]]=o[s];t.__ids=r}return t.__ids[e]}function D1(t,e,r,n){for(let o=r;o<n;o++)if(e(t[o],o))return o;return-1}var wf=512,zR={...Ff.GeoJsonLayer.defaultProps,data:Dt,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[ta],binary:!0},Oo=class extends lr{initializeState(){super.initializeState();let e=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:e,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return!!(this.state?.data&&super.isLoaded)}updateState({props:e,oldProps:r,context:n,changeFlags:o}){o.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:r,context:n,changeFlags:o}),this._setWGS84PropertyForTiles());let{highlightColor:s}=e;s!==r.highlightColor&&Array.isArray(s)&&this.setState({highlightColor:s})}async _updateTileData(){let e=this.props.data,r=null;if(typeof e=="string"&&!qc(e)){let{onDataLoad:n,fetch:o}=this.props;this.setState({data:null,tileJSON:null});try{r=await o(e,{propName:"data",layer:this,loaders:[]})}catch(s){this.raiseError(s,"loading TileJSON"),e=null}n&&n(r,{propName:"data",layer:this})}else e&&typeof e=="object"&&"tilejson"in e&&(r=e);r&&(e=r.tiles),this.setState({data:e,tileJSON:r})}_getTilesetOptions(){let e=super._getTilesetOptions(),r=this.state.tileJSON,{minZoom:n,maxZoom:o}=this.props;return r&&(Number.isFinite(r.minzoom)&&r.minzoom>n&&(e.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(o)||r.maxzoom<o)&&(e.maxZoom=r.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){let{data:r,binary:n}=this.state,{index:o,signal:s}=e,i=ft(r,e);if(!i)return Promise.reject("Invalid URL");let a=this.getLoadOptions(),{fetch:c}=this.props;return a={...a,core:{...a?.core,mimeType:"application/x-protobuf"},mvt:{...a?.mvt,shape:n?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:o}},c(i,{propName:"data",layer:this,loadOptions:a,signal:s})}renderSubLayers(e){let{x:r,y:n,z:o}=e.tile.index,s=Math.pow(2,o),i=wf/s,a=-i,c=wf*r/s,l=wf*(1-n/s),f=new N().scale([i,a,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=f,e.coordinateOrigin=[c,l,0],e.coordinateSystem=ra.COORDINATE_SYSTEM.CARTESIAN,e.extensions=[...e.extensions||[],new k1.ClipExtension]);let u=super.renderSubLayers(e);return this.state.binary&&!(u instanceof Ff.GeoJsonLayer)&&ra.log.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),u}_updateAutoHighlight(e){let{uniqueIdProperty:r}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:o}=this.state,s=e.object,i=null,a=null;s&&(i=Lf(s,r),a=V1(s));let{highlightColor:c}=this.props;typeof c=="function"&&(c=c(e)),(n!==i||o!==a)&&this.setState({highlightColor:c,hoveredFeatureId:i,hoveredFeatureLayerName:a})}_isWGS84(){return!!this.context.viewport.resolution}getPickingInfo(e){let r=super.getPickingInfo(e);if(this.state.binary&&r.index!==-1){let{data:n}=e.sourceLayer.props;r.object=Po(n,{globalFeatureId:r.index})}return r.object&&!this._isWGS84()&&(r.object=H1(r.object,r.tile.bbox,this.context.viewport)),r}getSubLayerPropsByTile(e){return{highlightedObjectIndex:this.getHighlightedObjectIndex(e),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(e){let{hoveredFeatureId:r,hoveredFeatureLayerName:n,binary:o}=this.state,{uniqueIdProperty:s,highlightedFeatureId:i}=this.props,a=e.content,c=G1(i);if(!(G1(r)||c))return-1;let f=c?i:r;return Array.isArray(a)?a.findIndex(u=>{let h=Lf(u,s)===f,p=c||V1(u)===n;return h&&p}):a&&o?Rf(a,s,f,c?"":n):-1}_pickObjects(e){let{deck:r,viewport:n}=this.context,o=n.width,s=n.height,i=n.x,a=n.y,c=[this.id];return r.pickObjects({x:i,y:a,width:o,height:s,layerIds:c,maxObjects:e})}getRenderedFeatures(e=null){let r=this._pickObjects(e),n=new Set,o=[];for(let s of r){let i=Lf(s.object,this.props.uniqueIdProperty);i===void 0?o.push(s.object):n.has(i)||(n.add(i),o.push(s.object))}return o}_setWGS84PropertyForTiles(){let e="dataInWGS84";this.state.tileset.selectedTiles.forEach(n=>{n.hasOwnProperty(e)||Object.defineProperty(n,e,{get:()=>{if(!n.content)return null;if(this.state.binary&&Array.isArray(n.content)&&!n.content.length)return[];let{bbox:o}=n;if(n._contentWGS84===void 0&&jc(o)){let s=this.state.binary?Po(n.content):n.content;n._contentWGS84=s.map(i=>H1(i,o,this.context.viewport))}return n._contentWGS84}})})}};Oo.layerName="MVTLayer";Oo.defaultProps=zR;var z1=Oo;function Lf(t,e){if(t.properties&&e)return t.properties[e];if("id"in t)return t.id}function V1(t){return t.properties?.layerName||null}function G1(t){return t!=null&&t!==""}function H1(t,e,r){let n={...t,geometry:{type:t.geometry.type}};return Object.defineProperty(n.geometry,"coordinates",{get:()=>U1(t.geometry,e,r).coordinates}),n}var q1="0123456789bcdefghjkmnpqrstuvwxyz",j1={};for(let t=0;t<q1.length;t++)j1[q1.charAt(t)]=t;var qR=-90,jR=90,JR=-180,WR=180;function XR(t){let e=!0,r=jR,n=qR,o=WR,s=JR,i,a=0;for(let c=0,l=t.length;c<l;c++){let f=t[c].toLowerCase();a=j1[f];for(let u=4;u>=0;u--){let h=a>>u&1;e?(i=(o+s)/2,h===1?s=i:o=i):(i=(r+n)/2,h===1?n=i:r=i),e=!e}}return[n,s,r,o]}function J1(t){let[e,r,n,o]=XR(t);return[o,n,o,e,r,e,r,n,o,n]}var KR={getGeohash:{type:"accessor",value:t=>t.geohash}},Uo=class extends De{indexToBounds(){let{data:e,getGeohash:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,o)=>J1(r(n,o))}}};Uo.layerName="GeohashLayer";Uo.defaultProps=KR;var W1=Uo;return $1(Do);})();
|
|
2582
3848
|
/*! Bundled license information:
|
|
2583
3849
|
|
|
2584
3850
|
long/dist/long.js:
|