olamaps-web-sdk 1.3.0 → 1.4.0

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.
@@ -33028,7 +33028,7 @@ class Yx {
33028
33028
  l.id = a, l.href = "https://www.openstreetmap.org/copyright", l.target = "_blank", l.textContent = "| © OpenStreetMap contributors", r.appendChild(l);
33029
33029
  }
33030
33030
  const c = "copernicus-attrib";
33031
- if (n.includes("default_dark_standard_satellite") && !r.querySelector(`#${c}`)) {
33031
+ if (n.includes("default-dark-standard-satellite") && !r.querySelector(`#${c}`)) {
33032
33032
  const l = document.createElement("span");
33033
33033
  l.id = c, l.textContent = " | Contains modified Copernicus Sentinel-2 data 2024", r.appendChild(l);
33034
33034
  }
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ class r {
12
12
  if (typeof window > "u")
13
13
  throw new Error("OlaMaps can only be initialized in a browser environment");
14
14
  const [{ OlaMaps: o }, i] = await Promise.all([
15
- import("./OlaMaps-BGIwlyn5.js"),
15
+ import("./OlaMaps-C83wz36C.js"),
16
16
  import("./maplibre-gl-BIFSxk4Y.js").then((a) => a.O)
17
17
  ]);
18
18
  return r.initializeStaticProperties(i), await new o({
@@ -2401,4 +2401,4 @@ fragColor = vec4(lightColor, color.a * opacity);
2401
2401
  #endif
2402
2402
  DECKGL_FILTER_COLOR(fragColor, geometry);
2403
2403
  }
2404
- `;function b6(e){const t=e.positions||e.POSITION,r=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}const v6={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};class by extends ty{getShaders(){const t=super.getShaders();return t.modules.push(Qg),{...t,vs:m6,fs:y6}}initializeState(){const{featureIds:t}=this.props;super.initializeState();const r=this.getAttributeManager();t&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(t){super.updateState(t);const{props:r,oldProps:n}=t;r.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(t){const{featureIds:r}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.uniforms.project_uCameraPosition,pickFeatureIds:!!r}),super.draw(t))}getModel(t){const{id:r,pbrMaterial:n}=this.props,a=this.parseMaterial(n,t);this.setState({parsedPBRMaterial:a});const d=this.getShaders();return b6(t.attributes),new ea(this.context.device,{...this.getShaders(),id:r,geometry:t,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...d.defines,...a?.defines,HAS_UV_REGIONS:t.attributes.uvRegions?1:0},parameters:a?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(t){const{model:r}=this.state;if(r){const{mesh:n}=this.props,a=this.parseMaterial(t,n);this.setState({parsedPBRMaterial:a}),r.setBindings(a.bindings),r.setUniforms(a.uniforms)}}parseMaterial(t,r){const n=!!(t.pbrMetallicRoughness&&t.pbrMetallicRoughness.baseColorTexture);return qw(this.context.device,{unlit:n,...t},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(t){const r=this.props.featureIds,n=new Uint8ClampedArray(r.length*t.size),a=[];for(let d=0;d<r.length;d++)this.encodePickingColor(r[d],a),n[d*3]=a[0],n[d*3+1]=a[1],n[d*3+2]=a[2];t.value=n}finalizeState(t){super.finalizeState(t),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}}by.layerName="MeshLayer",by.defaultProps=v6;const x6=6378137,w6=6378137,T6=6356752314245179e-9;function hp(e){return e}new Bt;function A6(e,t=[],r=hp){return"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):"x"in e?(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function E6(e,t=[]){return A6(e,t,yi._cartographicRadians?hp:fP)}function S6(e,t,r=hp){return"longitude"in t?(t.longitude=r(e[0]),t.latitude=r(e[1]),t.height=e[2]):"x"in t?(t.x=r(e[0]),t.y=r(e[1]),t.z=e[2]):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function C6(e,t){return S6(e,t,yi._cartographicRadians?hp:pP)}const MT=1e-14,I6=new Bt,RT={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"}},vy={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},kh={east:new Bt,north:new Bt,up:new Bt,west:new Bt,south:new Bt,down:new Bt},M6=new Bt,R6=new Bt,P6=new Bt;function PT(e,t,r,n,a,d){const f=RT[t]&&RT[t][r];Tn(f&&(!n||n===f));let c,T,C;const R=I6.copy(a);if(wn(R.x,0,MT)&&wn(R.y,0,MT)){const V=Math.sign(R.z);c=M6.fromArray(vy[t]),t!=="east"&&t!=="west"&&c.scale(V),T=R6.fromArray(vy[r]),r!=="east"&&r!=="west"&&T.scale(V),C=P6.fromArray(vy[n]),n!=="east"&&n!=="west"&&C.scale(V)}else{const{up:V,east:X,north:at}=kh;X.set(-R.y,R.x,0).normalize(),e.geodeticSurfaceNormal(R,V),at.copy(V).cross(X);const{down:nt,west:K,south:It}=kh;nt.copy(V).scale(-1),K.copy(X).scale(-1),It.copy(at).scale(-1),c=kh[t],T=kh[r],C=kh[n]}return d[0]=c.x,d[1]=c.y,d[2]=c.z,d[3]=0,d[4]=T.x,d[5]=T.y,d[6]=T.z,d[7]=0,d[8]=C.x,d[9]=C.y,d[10]=C.z,d[11]=0,d[12]=R.x,d[13]=R.y,d[14]=R.z,d[15]=1,d}const Fc=new Bt,B6=new Bt,D6=new Bt;function F6(e,t,r=[]){const{oneOverRadii:n,oneOverRadiiSquared:a,centerToleranceSquared:d}=t;Fc.from(e);const f=Fc.x,c=Fc.y,T=Fc.z,C=n.x,R=n.y,L=n.z,V=f*f*C*C,X=c*c*R*R,at=T*T*L*L,nt=V+X+at,K=Math.sqrt(1/nt);if(!Number.isFinite(K))return;const It=B6;if(It.copy(e).scale(K),nt<d)return It.to(r);const St=a.x,Ct=a.y,Ht=a.z,Qt=D6;Qt.set(It.x*St*2,It.y*Ct*2,It.z*Ht*2);let ee=(1-K)*Fc.len()/(.5*Qt.len()),ae=0,be,ie,le,Ae;do{ee-=ae,be=1/(1+ee*St),ie=1/(1+ee*Ct),le=1/(1+ee*Ht);const Fe=be*be,ze=ie*ie,Ce=le*le,zr=Fe*be,ns=ze*ie,Hr=Ce*le;Ae=V*Fe+X*ze+at*Ce-1;const Le=-2*(V*zr*St+X*ns*Ct+at*Hr*Ht);ae=Ae/Le}while(Math.abs(Ae)>D3);return Fc.scale([be,ie,le]).to(r)}const dp=new Bt,BT=new Bt,O6=new Bt,Mn=new Bt,k6=new Bt,fp=new Bt;class Er{constructor(t=0,r=0,n=0){this.centerToleranceSquared=B3,Tn(t>=0),Tn(r>=0),Tn(n>=0),this.radii=new Bt(t,r,n),this.radiiSquared=new Bt(t*t,r*r,n*n),this.radiiToTheFourth=new Bt(t*t*t*t,r*r*r*r,n*n*n*n),this.oneOverRadii=new Bt(t===0?0:1/t,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new Bt(t===0?0:1/(t*t),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(t,r,n),this.maximumRadius=Math.max(t,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||!!(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,r=[0,0,0]){const n=BT,a=O6,[,,d]=t;this.geodeticSurfaceNormalCartographic(t,n),a.copy(this.radiiSquared).scale(n);const f=Math.sqrt(n.dot(a));return a.scale(1/f),n.scale(d),a.add(n),a.to(r)}cartesianToCartographic(t,r=[0,0,0]){fp.from(t);const n=this.scaleToGeodeticSurface(fp,Mn);if(!n)return;const a=this.geodeticSurfaceNormal(n,BT),d=k6;d.copy(fp).subtract(n);const f=Math.atan2(a.y,a.x),c=Math.asin(a.z),T=Math.sign(Vg(d,fp))*yx(d);return C6([f,c,T],r)}eastNorthUpToFixedFrame(t,r=new He){return PT(this,"east","north","up",t,r)}localFrameToFixedFrame(t,r,n,a,d=new He){return PT(this,t,r,n,a,d)}geocentricSurfaceNormal(t,r=[0,0,0]){return dp.from(t).normalize().to(r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){const n=E6(t),a=n[0],d=n[1],f=Math.cos(d);return dp.set(f*Math.cos(a),f*Math.sin(a),Math.sin(d)).normalize(),dp.to(r)}geodeticSurfaceNormal(t,r=[0,0,0]){return dp.from(t).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(t,r){return F6(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){Mn.from(t);const n=Mn.x,a=Mn.y,d=Mn.z,f=this.oneOverRadiiSquared,c=1/Math.sqrt(n*n*f.x+a*a*f.y+d*d*f.z);return Mn.multiplyScalar(c).to(r)}transformPositionToScaledSpace(t,r=[0,0,0]){return Mn.from(t).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(t,r=[0,0,0]){return Mn.from(t).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(t,r=0,n=[0,0,0]){Tn(wn(this.radii.x,this.radii.y,Fx)),Tn(this.radii.z>0),Mn.from(t);const a=Mn.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(a)>=this.radii.z-r))return Mn.set(0,0,a).to(n)}}Er.WGS84=new Er(x6,w6,T6);class N6{item;previous;next;constructor(t,r,n){this.item=t,this.previous=r,this.next=n}}class L6{head=null;tail=null;_length=0;get length(){return this._length}add(t){const r=new N6(t,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,r){t!==r&&(this.remove(r),this._insert(t,r))}_insert(t,r){const n=t.next;t.next=r,this.tail===t?this.tail=r:n.previous=r,r.next=n,r.previous=t,++this._length}}class U6{_list;_sentinel;_trimTiles;constructor(){this._list=new L6,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){const r=t._cacheNode;r&&this._list.splice(this._sentinel,r)}add(t,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(t,r))}unloadTile(t,r,n){const a=r._cacheNode;a&&(this._list.remove(a),r._cacheNode=null,n&&n(t,r))}unloadTiles(t,r){const n=this._trimTiles;this._trimTiles=!1;const a=this._list,d=t.maximumMemoryUsage*1024*1024,f=this._sentinel;let c=a.head;for(;c!==f&&(t.gpuMemoryUsageInBytes>d||n);){const T=c.item;c=c.next,this.unloadTile(t,T,r)}}trim(){this._trimTiles=!0}}function z6(e,t){Ar(e),Ar(t);const{rtcCenter:r,gltfUpAxis:n}=t,{computedTransform:a,boundingVolume:{center:d}}=e;let f=new He(a);switch(r&&f.translate(r),n){case"Z":break;case"Y":const L=new He().rotateX(Math.PI/2);f=f.multiplyRight(L);break;case"X":const V=new He().rotateY(-Math.PI/2);f=f.multiplyRight(V);break}t.isQuantized&&f.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const c=new Bt(d);t.cartesianModelMatrix=f,t.cartesianOrigin=c;const T=Er.WGS84.cartesianToCartographic(c,new Bt),R=Er.WGS84.eastNorthUpToFixedFrame(c).invert();t.cartographicModelMatrix=R.multiplyRight(f),t.cartographicOrigin=T,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}const DT=new Bt,xy=new Bt,wy=new an([new so,new so,new so,new so,new so,new so]);function V6(e,t){const{cameraDirection:r,cameraUp:n,height:a}=e,{metersPerUnit:d}=e.distanceScales,f=pp(e,e.center),c=Er.WGS84.eastNorthUpToFixedFrame(f),T=e.unprojectPosition(e.cameraPosition),C=Er.WGS84.cartographicToCartesian(T,new Bt),R=new Bt(c.transformAsVector(new Bt(r).scale(d))).normalize(),L=new Bt(c.transformAsVector(new Bt(n).scale(d))).normalize();H6(e);const V=e.constructor,{longitude:X,latitude:at,width:nt,bearing:K,zoom:It}=e,St=new V({longitude:X,latitude:at,height:a,width:nt,bearing:K,zoom:It,pitch:0});return{camera:{position:C,direction:R,up:L},viewport:e,topDownViewport:St,height:a,cullingVolume:wy,frameNumber:t,sseDenominator:1.15}}function j6(e,t,r){if(r===0||e.length<=r)return[e,[]];const n=[],{longitude:a,latitude:d}=t.viewport;for(const[C,R]of e.entries()){const[L,V]=R.header.mbs,X=Math.abs(a-L),at=Math.abs(d-V),nt=Math.sqrt(at*at+X*X);n.push([C,nt])}const f=n.sort((C,R)=>C[1]-R[1]),c=[];for(let C=0;C<r;C++)c.push(e[f[C][0]]);const T=[];for(let C=r;C<f.length;C++)T.push(e[f[C][0]]);return[c,T]}function H6(e){const t=e.getFrustumPlanes(),r=FT(t.near,e.cameraPosition),n=pp(e,r),a=pp(e,e.cameraPosition,xy);let d=0;wy.planes[d++].fromPointNormal(n,DT.copy(n).subtract(a));for(const f in t){if(f==="near")continue;const c=t[f],T=FT(c,r,xy),C=pp(e,T,xy);wy.planes[d++].fromPointNormal(C,DT.copy(n).subtract(C))}}function FT(e,t,r=new Bt){const n=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-n).add(t),r}function pp(e,t,r=new Bt){const n=e.unprojectPosition(t);return Er.WGS84.cartographicToCartesian(n,r)}const G6=6378137,$6=6378137,Ty=6356752314245179e-9,Oc=new Bt;function W6(e,t){if(e instanceof Ph){const{halfAxes:r}=e,n=q6(r);return Math.log2(Ty/(n+t[2]))}else if(e instanceof Rh){const{radius:r}=e;return Math.log2(Ty/(r+t[2]))}else if(e.width&&e.height){const{width:r,height:n}=e,a=Math.log2(G6/r),d=Math.log2($6/n);return(a+d)/2}return 1}function OT(e,t,r){Er.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],Oc);const n=Math.sqrt(Math.pow(Oc[0]-r[0],2)+Math.pow(Oc[1]-r[1],2)+Math.pow(Oc[2]-r[2],2));return Math.log2(Ty/(n+t[2]))}function X6(e,t,r){const[n,a,d,f]=e;return OT({xmax:d,ymax:f,zmax:0},t,r)}function q6(e){e.getColumn(0,Oc);const t=e.getColumn(1),r=e.getColumn(2);return Oc.add(t).add(r).len()}const Ds={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5};var Rn;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(Rn||(Rn={}));var Mo;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(Mo||(Mo={}));var ms;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(ms||(ms={}));var kc;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(kc||(kc={}));const Z6={USE_OPTIMIZATION:1};function kT(e){return e!=null}const Ji=new Bt,_p=new Bt,Y6=new Bt,K6=new Bt,al=new Bt,NT=new Bt,LT=new Bt,UT=new Bt;function Ay(e,t,r){if(Ar(e,"3D Tile: boundingVolume must be defined"),e.box)return zT(e.box,t,r);if(e.region)return t5(e.region);if(e.sphere)return Q6(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function J6(e,t){if(e.box)return e5(t);if(e.region){const[r,n,a,d,f,c]=e.region;return[[xn(r),xn(n),f],[xn(a),xn(d),c]]}if(e.sphere)return r5(t);throw new Error("Unkown boundingVolume type")}function zT(e,t,r){const n=new Bt(e[0],e[1],e[2]);t.transform(n,n);let a=[];if(e.length===10){const C=e.slice(3,6),R=new ch;R.fromArray(e,6);const L=new Bt([1,0,0]),V=new Bt([0,1,0]),X=new Bt([0,0,1]);L.transformByQuaternion(R),L.scale(C[0]),V.transformByQuaternion(R),V.scale(C[1]),X.transformByQuaternion(R),X.scale(C[2]),a=[...L.toArray(),...V.toArray(),...X.toArray()]}else a=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const d=t.transformAsVector(a.slice(0,3)),f=t.transformAsVector(a.slice(3,6)),c=t.transformAsVector(a.slice(6,9)),T=new Xr([d[0],d[1],d[2],f[0],f[1],f[2],c[0],c[1],c[2]]);return kT(r)?(r.center=n,r.halfAxes=T,r):new Ph(n,T)}function Q6(e,t,r){const n=new Bt(e[0],e[1],e[2]);t.transform(n,n);const a=t.getScale(_p),d=Math.max(Math.max(a[0],a[1]),a[2]),f=e[3]*d;return kT(r)?(r.center=n,r.radius=f,r):new Rh(n,f)}function t5(e){const[t,r,n,a,d,f]=e,c=Er.WGS84.cartographicToCartesian([xn(t),xn(a),d],Y6),T=Er.WGS84.cartographicToCartesian([xn(n),xn(r),f],K6),C=new Bt().addVectors(c,T).multiplyByScalar(.5);return Er.WGS84.cartesianToCartographic(C,al),Er.WGS84.cartographicToCartesian([xn(n),al[1],al[2]],NT),Er.WGS84.cartographicToCartesian([al[0],xn(a),al[2]],LT),Er.WGS84.cartographicToCartesian([al[0],al[1],f],UT),zT([...C,...NT.subtract(C),...LT.subtract(C),...UT.subtract(C)],new He)}function e5(e){const t=VT(),{halfAxes:r}=e,n=new Bt(r.getColumn(0)),a=new Bt(r.getColumn(1)),d=new Bt(r.getColumn(2));for(let f=0;f<2;f++){for(let c=0;c<2;c++){for(let T=0;T<2;T++)Ji.copy(e.center),Ji.add(n),Ji.add(a),Ji.add(d),jT(t,Ji),d.negate();a.negate()}n.negate()}return t}function r5(e){const t=VT(),{center:r,radius:n}=e,a=Er.WGS84.scaleToGeodeticSurface(r,Ji);let d;a?d=Er.WGS84.geodeticSurfaceNormal(a):d=new Bt(0,0,1);let f=new Bt(d[2],-d[1],0);f.len()>0?f.normalize():f=new Bt(0,1,0);const c=f.clone().cross(d);for(const T of[f,c,d]){_p.copy(T).scale(n);for(let C=0;C<2;C++)Ji.copy(r),Ji.add(_p),jT(t,Ji),_p.negate()}return t}function VT(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function jT(e,t){Er.WGS84.cartesianToCartographic(t,Ji),e[0][0]=Math.min(e[0][0],Ji[0]),e[0][1]=Math.min(e[0][1],Ji[1]),e[0][2]=Math.min(e[0][2],Ji[2]),e[1][0]=Math.max(e[1][0],Ji[0]),e[1][1]=Math.max(e[1][1],Ji[1]),e[1][2]=Math.max(e[1][2],Ji[2])}new Bt,new Bt,new He,new Bt,new Bt,new Bt;function i5(e,t){const r=e*t;return 1-Math.exp(-(r*r))}function s5(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const r=e.dynamicScreenSpaceErrorComputedDensity,n=e.dynamicScreenSpaceErrorFactor;return i5(t,r)*n}return 0}function n5(e,t,r){const n=e.tileset,a=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,d=r?a:e.lodMetricValue;if(d===0)return 0;const f=Math.max(e._distanceToCamera,1e-7),{height:c,sseDenominator:T}=t,{viewDistanceScale:C}=n.options;let R=d*c*(C||1)/(f*T);return R-=s5(n,f),R}const Ey=new Bt,HT=new Bt,pa=new Bt,GT=new Bt,o5=new Bt,Sy=new He,$T=new He;function a5(e,t){if(e.lodMetricValue===0||isNaN(e.lodMetricValue))return"DIG";const r=2*WT(e,t);return r<2?"OUT":!e.header.children||r<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}function WT(e,t){const{topDownViewport:r}=t,n=e.header.mbs[1],a=e.header.mbs[0],d=e.header.mbs[2],f=e.header.mbs[3],c=[...e.boundingVolume.center],T=r.unprojectPosition(r.cameraPosition);Er.WGS84.cartographicToCartesian(T,Ey),HT.copy(Ey).subtract(c).normalize(),Er.WGS84.eastNorthUpToFixedFrame(c,Sy),$T.copy(Sy).invert(),pa.copy(Ey).transform($T);const C=Math.sqrt(pa[0]*pa[0]+pa[1]*pa[1]),R=C*C/pa[2];GT.copy([pa[0],pa[1],R]);const V=GT.transform(Sy).subtract(c).normalize(),at=HT.cross(V).normalize().scale(f).add(c),nt=Er.WGS84.cartesianToCartographic(at),K=r.project([a,n,d]),It=r.project(nt);return o5.copy(K).subtract(It).magnitude()}function l5(e){return{assetGltfUpAxis:e.asset&&e.asset.gltfUpAxis||"Y"}}class XT{_map=new Map;_array;_length;constructor(t=0){this._array=new Array(t),this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return Ar(t<this._array.length),this._array[t]}set(t,r){Ar(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=r,this._map.set(r,t)}delete(t){const r=this._map.get(t);r>=0&&(this._array.splice(r,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){const r=this.length++;this._array[r]=t,this._map.set(t,r)}}pop(){const t=this._array[--this.length];return this._map.delete(t),t}reserve(t){Ar(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){Ar(t>=0),this.length=t}trim(t){t==null&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}}const c5={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class gp{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new XT;_emptyTraversalStack=new XT;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...c5,...t}}traverse(t,r,n){this.root=t,this.options={...this.options,...n},this.reset(),this.updateTile(t,r),this._frameNumber=r.frameNumber,this.executeTraversal(t,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,r){const n=this._traversalStack;for(t._selectionDepth=1,n.push(t);n.length>0;){const d=n.pop();let f=!1;this.canTraverse(d,r)&&(this.updateChildTiles(d,r),f=this.updateAndPushChildren(d,r,n,d.hasRenderContent?d._selectionDepth+1:d._selectionDepth));const c=d.parent,T=!!(!c||c._shouldRefine),C=!f;d.hasRenderContent?d.refine===Rn.ADD?(this.loadTile(d,r),this.selectTile(d,r)):d.refine===Rn.REPLACE&&(this.loadTile(d,r),C&&this.selectTile(d,r)):(this.emptyTiles[d.id]=d,this.loadTile(d,r),C&&this.selectTile(d,r)),this.touchTile(d,r),d._shouldRefine=f&&T}const a=new Date().getTime();(this.traversalFinished(r)||a-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=a,this.options.onTraversalEnd(r))}updateChildTiles(t,r){const n=t.children;for(const a of n)this.updateTile(a,r)}updateAndPushChildren(t,r,n,a){const{loadSiblings:d,skipLevelOfDetail:f}=this.options,c=t.children;c.sort(this.compareDistanceToCamera.bind(this));const T=t.refine===Rn.REPLACE&&t.hasRenderContent&&!f;let C=!1,R=!0;for(const L of c)if(L._selectionDepth=a,L.isVisibleAndInRequestVolume?(n.find(L)&&n.delete(L),n.push(L),C=!0):(T||d)&&(this.loadTile(L,r),this.touchTile(L,r)),T){let V;if(L._inRequestVolume?L.hasRenderContent?V=L.contentAvailable:V=this.executeEmptyTraversal(L,r):V=!1,R=R&&V,!R)return!1}return C||(R=!1),R}updateTile(t,r){this.updateTileVisibility(t,r)}selectTile(t,r){this.shouldSelectTile(t)&&(t._selectedFrame=r.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,r){this.shouldLoadTile(t)&&(t._requestedFrame=r.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,r){t.tileset._cache.touch(t),t._touchedFrame=r.frameNumber}canTraverse(t,r){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:this.shouldRefine(t,r):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,r,n=!1){let a=t._screenSpaceError;return n&&(a=t.getScreenSpaceError(r,!0)),a>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,r){const n=[];if(this.options.viewportTraversersMap)for(const a in this.options.viewportTraversersMap)this.options.viewportTraversersMap[a]===r.viewport.id&&n.push(a);else n.push(r.viewport.id);t.updateVisibility(r,n)}compareDistanceToCamera(t,r){return t._distanceToCamera-r._distanceToCamera}anyChildrenVisible(t,r){let n=!1;for(const a of t.children)a.updateVisibility(r),n=n||a.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(t,r){let n=!0;const a=this._emptyTraversalStack;for(a.push(t);a.length>0;){const d=a.pop(),f=!d.hasRenderContent&&this.canTraverse(d,r),c=!d.hasRenderContent&&d.children.length===0;if(!f&&!d.contentAvailable&&!c&&(n=!1),this.updateTile(d,r),d.isVisibleAndInRequestVolume||(this.loadTile(d,r),this.touchTile(d,r)),f){const T=d.children;for(const C of T)a.push(C)}}return n}}const qT=new Bt;function u5(e){return e!=null}class Cy{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Ds.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new He;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new gp({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new He;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(t,r,n,a=""){this.header=r,this.tileset=t,this.id=a||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===Ds.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===Ds.UNLOADED}get contentExpired(){return this.contentState===Ds.EXPIRED}get contentFailed(){return this.contentState===Ds.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=J6(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,r){switch(this.tileset.type){case ms.I3S:return WT(this,t);case ms.TILES3D:return n5(this,t,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){const t=this.tileset._traverser,{skipLevelOfDetail:r}=t.options,n=this.refine===Rn.ADD||r;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Ds.UNLOADED)return-1;const a=this.parent,f=a&&(!n||this._screenSpaceError===0||a.hasTilesetContent)?a._screenSpaceError:this._screenSpaceError,c=t.root?t.root._screenSpaceError:0;return Math.max(c-f,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Ds.LOADING;const r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Ds.UNLOADED,!1;try{const n=this.tileset.getTileUrl(this.contentUrl),a=this.tileset.loader,d={...this.tileset.loadOptions,[a.id]:{...this.tileset.loadOptions[a.id],isTileset:this.type==="json",...this._getLoaderSpecificOptions(a.id)}};return this.content=await Ko(n,a,d),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Ds.READY,this._onContentLoaded(),!0}catch(n){throw this.contentState=Ds.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=Ds.UNLOADED,!0}updateVisibility(t,r){if(this._frameNumber===t.frameNumber)return;const n=this.parent,a=n?n._visibilityPlaneMask:an.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const d=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(d)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,a),this._visible=this._visibilityPlaneMask!==an.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=r}visibility(t,r){const{cullingVolume:n}=t,{boundingVolume:a}=this;return n.computeVisibilityWithPlaneMask(a,r)}contentVisibility(){return!0}distanceToTile(t){const r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){const r=this.boundingVolume;return qT.subVectors(r.center,t.position),t.direction.dot(qT)}insideViewerRequestVolume(t){const r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(u5(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){const t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=Ds.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){"lodMetricType"in t?this.lodMetricType=t.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 t?this.lodMetricValue=t.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(t){this.transform=t.transform?new He(t.transform):new He;const r=this.parent,n=this.tileset,a=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new He(a).multiplyRight(this.transform);const d=r&&r._initialTransform?r._initialTransform.clone():new He;this._initialTransform=new He(d).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Ds.UNLOADED,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=an.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(t){return t||this.parent&&this.parent.refine||Rn.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}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(t){this.boundingVolume=Ay(t.boundingVolume,this.computedTransform,this.boundingVolume);const r=t.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=Ay(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=Ay(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(t=new He){const r=t.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){switch(t){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 l5(this.tileset.tileset)}}}class h5 extends gp{compareDistanceToCamera(t,r){return r._distanceToCamera===0&&t._distanceToCamera===0?r._centerZDepth-t._centerZDepth:r._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,r){if(super.updateTileVisibility(t,r),!t.isVisibleAndInRequestVolume)return;const n=t.children.length>0;if(t.hasTilesetContent&&n){const f=t.children[0];this.updateTileVisibility(f,r),t._visible=f._visible;return}if(this.meetsScreenSpaceErrorEarly(t,r)){t._visible=!1;return}const a=t.refine===Rn.REPLACE,d=t._optimChildrenWithinParent===Z6.USE_OPTIMIZATION;if(a&&d&&n&&!this.anyChildrenVisible(t,r)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,r){const{parent:n}=t;return!n||n.hasTilesetContent||n.refine!==Rn.ADD?!1:!this.shouldRefine(t,r,!0)}}class d5{frameNumberMap=new Map;register(t,r){const n=this.frameNumberMap.get(t)||new Map,a=n.get(r)||0;n.set(r,a+1),this.frameNumberMap.set(t,n)}deregister(t,r){const n=this.frameNumberMap.get(t);if(!n)return;const a=n.get(r)||1;n.set(r,a-1)}isZero(t,r){return(this.frameNumberMap.get(t)?.get(r)||0)===0}}const Iy={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"};class f5{_statusMap;pendingTilesRegister=new d5;constructor(){this._statusMap={}}add(t,r,n,a){if(!this._statusMap[r]){const{frameNumber:d,viewport:{id:f}}=a;this._statusMap[r]={request:t,callback:n,key:r,frameState:a,status:Iy.REQUESTED},this.pendingTilesRegister.register(f,d),t().then(c=>{this._statusMap[r].status=Iy.COMPLETED;const{frameNumber:T,viewport:{id:C}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(C,T),this._statusMap[r].callback(c,a)}).catch(c=>{this._statusMap[r].status=Iy.ERROR;const{frameNumber:T,viewport:{id:C}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(C,T),n(c)})}}update(t,r){if(this._statusMap[t]){const{frameNumber:n,viewport:{id:a}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(a,n);const{frameNumber:d,viewport:{id:f}}=r;this.pendingTilesRegister.register(f,d),this._statusMap[t].frameState=r}}find(t){return this._statusMap[t]}hasPendingTiles(t,r){return!this.pendingTilesRegister.isZero(t,r)}}class p5 extends gp{_tileManager;constructor(t){super(t),this._tileManager=new f5}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,r){return t._lodJudge=a5(t,r),t._lodJudge==="DIG"}updateChildTiles(t,r){const n=t.header.children||[],a=t.children,d=t.tileset;for(const f of n){const c=`${f.id}-${r.viewport.id}`,T=a&&a.find(C=>C.id===c);if(T)T&&this.updateTile(T,r);else{let C=()=>this._loadTile(f.id,d);this._tileManager.find(c)?this._tileManager.update(c,r):(d.tileset.nodePages&&(C=()=>d.tileset.nodePagesTile.formTileFromNodePages(f.id)),this._tileManager.add(C,c,L=>this._onTileLoad(L,t,c),r))}}return!1}async _loadTile(t,r){const{loader:n}=r,a=r.getTileUrl(`${r.url}/nodes/${t}`),d={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await Ko(a,n,d)}_onTileLoad(t,r,n){const a=new Cy(r.tileset,t,r,n);r.children.push(a);const d=this._tileManager.find(a.id).frameState;this.updateTile(a,d),this._frameNumber===d.frameNumber&&(this.traversalFinished(d)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(a,d)}}const _5={description:"",ellipsoid:Er.WGS84,modelMatrix:new He,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},mp="Tiles In Tileset(s)",My="Tiles In Memory",ZT="Tiles In View",YT="Tiles To Render",KT="Tiles Loaded",Ry="Tiles Loading",JT="Tiles Unloaded",QT="Failed Tile Loads",tA="Points/Vertices",Py="Tile Memory Use",eA="Maximum Screen Space Error";class g5{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 U6;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(t,r){this.options={..._5,...r},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||ig(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new YC({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 sc({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(t)}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(t){this.options={...this.options,...t}}getTileUrl(t){if(t.startsWith("data:"))return t;let n=t;return this.queryParams.length&&(n=`${t}${t.includes("?")?"&":"?"}${this.queryParams}`),n}hasExtension(t){return this._extensionsUsed.indexOf(t)>-1}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),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(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;const r=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;const n=[];for(const a of r){const d=a.id;this._needTraverse(d)?n.push(d):this.traverseCounter--}for(const a of r){const d=a.id;if(this.roots[d]||(this.roots[d]=this._initializeTileHeaders(this.tileset,null)),!n.includes(d))continue;const f=V6(a,this._frameNumber);this._traverser.traverse(this.roots[d],f,this.options)}}_needTraverse(t){let r=t;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[t]),r===t}_onTraversalEnd(t){const r=t.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const n=this.frameStateData[r],a=Object.values(this._traverser.selectedTiles),[d,f]=j6(a,t,this.options.maximumTilesSelected);n.selectedTiles=d;for(const c of f)c.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const t in this.frameStateData){const r=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(r.selectedTiles),this._requestedTiles=this._requestedTiles.concat(r._requestedTiles),this._emptyTiles=this._emptyTiles.concat(r._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,r){if(t.length!==r.length)return!0;const n=new Set(t.map(f=>f.id)),a=new Set(r.map(f=>f.id));let d=t.filter(f=>!a.has(f.id)).length>0;return d=d||r.filter(f=>!n.has(f.id)).length>0,d}_loadTiles(){for(const t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,r)=>t._unloadTile(r))}_updateStats(){let t=0,r=0;for(const n of this.selectedTiles)n.contentAvailable&&n.content&&(t++,n.content.pointCount?r+=n.content.pointCount:r+=n.content.vertexCount);this.stats.get(ZT).count=this.selectedTiles.length,this.stats.get(YT).count=t,this.stats.get(tA).count=r,this.stats.get(eA).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(t){this.type===ms.I3S&&(this.calculateViewPropsI3S(),t.root=await t.root),this.root=this._initializeTileHeaders(t,null),this.type===ms.TILES3D&&(this._initializeTiles3DTileset(t),this.calculateViewPropsTiles3D()),this.type===ms.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){const t=this.tileset.fullExtent;if(t){const{xmin:n,xmax:a,ymin:d,ymax:f,zmin:c,zmax:T}=t;this.cartographicCenter=new Bt(n+(a-n)/2,d+(f-d)/2,c+(T-c)/2),this.cartesianCenter=new Bt,Er.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=OT(t,this.cartographicCenter,this.cartesianCenter);return}const r=this.tileset.store?.extent;if(r){const[n,a,d,f]=r;this.cartographicCenter=new Bt(n+(d-n)/2,a+(f-a)/2,0),this.cartesianCenter=new Bt,Er.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=X6(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new Bt,this.zoom=1}calculateViewPropsTiles3D(){const t=this.root,{center:r}=t.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new Bt,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new Bt,Er.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new Bt(0,0,-Er.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=W6(t.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(mp),this.stats.get(Ry),this.stats.get(My),this.stats.get(ZT),this.stats.get(YT),this.stats.get(KT),this.stats.get(JT),this.stats.get(QT),this.stats.get(tA),this.stats.get(Py,"memory"),this.stats.get(eA)}_initializeTileHeaders(t,r){const n=new Cy(this,t.root,r);if(r&&(r.children.push(n),n.depth=r.depth+1),this.type===ms.TILES3D){const a=[];for(a.push(n);a.length>0;){const d=a.pop();this.stats.get(mp).incrementCount();const f=d.header.children||[];for(const c of f){const T=new Cy(this,c,d);if(T.contentUrl?.includes("?session=")){const R=new URL(T.contentUrl).searchParams.get("session");R&&(this._queryParams.session=R)}d.children.push(T),T.depth=d.depth+1,a.push(T)}}}return n}_initializeTraverser(){let t;switch(this.type){case ms.TILES3D:t=h5;break;case ms.I3S:t=p5;break;default:t=gp}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let r;try{this._onStartTileLoading(),r=await t.loadContent()}catch(n){this._onTileLoadError(t,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}_onTileLoadError(t,r){this.stats.get(QT).incrementCount();const n=r.message||r.toString(),a=t.url;console.error(`A 3D tile failed to load: ${t.url} ${n}`),this.options.onTileError(t,n,a)}_onTileLoad(t,r){if(r){if(this.type===ms.I3S){const n=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(mp).reset(),this.stats.get(mp).addCount(n)}t&&t.content&&z6(t,t.content),this.updateContentTypes(t),this._addTileToCache(t),this.options.onTileLoad(t)}}updateContentTypes(t){if(this.type===ms.I3S)switch(t.header.isDracoGeometry&&(this.contentFormats.draco=!0),t.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break}else if(this.type===ms.TILES3D){const{extensionsRemoved:r=[]}=t.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(Ry).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Ry).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(KT).incrementCount(),this.stats.get(My).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(Py).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(My).decrementCount(),this.stats.get(JT).incrementCount(),this.stats.get(Py).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){const t=[];for(this.root&&t.push(this.root);t.length>0;){const r=t.pop();for(const n of r.children)t.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(t){const r=t,n=[];for(n.push(r);n.length>0;){t=n.pop();for(const a of t.children)n.push(a);t!==r&&this._destroyTile(t)}r.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeTiles3DTileset(t){if(t.queryString){const r=new URLSearchParams(t.queryString),n=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=t.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=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed||[],this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const rA="4.3.1",Nh={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GLTF:"glTF"};function iA(e,t,r){Ar(e instanceof ArrayBuffer);const n=new TextDecoder("utf8"),a=new Uint8Array(e,t,r);return n.decode(a)}function m5(e,t=0){const r=new DataView(e);return`${String.fromCharCode(r.getUint8(t+0))}${String.fromCharCode(r.getUint8(t+1))}${String.fromCharCode(r.getUint8(t+2))}${String.fromCharCode(r.getUint8(t+3))}`}const y5={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ai={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Ze={...y5,...ai},By={[ai.DOUBLE]:Float64Array,[ai.FLOAT]:Float32Array,[ai.UNSIGNED_SHORT]:Uint16Array,[ai.UNSIGNED_INT]:Uint32Array,[ai.UNSIGNED_BYTE]:Uint8Array,[ai.BYTE]:Int8Array,[ai.SHORT]:Int16Array,[ai.INT]:Int32Array},b5={DOUBLE:ai.DOUBLE,FLOAT:ai.FLOAT,UNSIGNED_SHORT:ai.UNSIGNED_SHORT,UNSIGNED_INT:ai.UNSIGNED_INT,UNSIGNED_BYTE:ai.UNSIGNED_BYTE,BYTE:ai.BYTE,SHORT:ai.SHORT,INT:ai.INT},Dy="Failed to convert GL type";class oo{static fromTypedArray(t){t=ArrayBuffer.isView(t)?t.constructor:t;for(const r in By)if(By[r]===t)return r;throw new Error(Dy)}static fromName(t){const r=b5[t];if(!r)throw new Error(Dy);return r}static getArrayType(t){switch(t){case ai.UNSIGNED_SHORT_5_6_5:case ai.UNSIGNED_SHORT_4_4_4_4:case ai.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const r=By[t];if(!r)throw new Error(Dy);return r}}static getByteSize(t){return oo.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return!!oo.getArrayType(t)}static createTypedArray(t,r,n=0,a){a===void 0&&(a=(r.byteLength-n)/oo.getByteSize(t));const d=oo.getArrayType(t);return new d(r,n,a)}}function v5(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}function x5(e,t=[0,0,0]){const r=e>>11&31,n=e>>5&63,a=e&31;return t[0]=r<<3,t[1]=n<<2,t[2]=a<<3,t}new zg,new Bt,new zg,new zg;function sA(e,t=255){return Eo(e,0,t)/t*2-1}function nA(e){return e<0?-1:1}function w5(e,t,r,n){if(v5(n),e<0||e>r||t<0||t>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(n.x=sA(e,r),n.y=sA(t,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){const a=n.x;n.x=(1-Math.abs(n.y))*nA(a),n.y=(1-Math.abs(a))*nA(n.y)}return n.normalize()}function T5(e,t,r){return w5(e,t,255,r)}class Fy{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(t,r){this.json=t,this.buffer=r}getExtension(t){return this.json.extensions&&this.json.extensions[t]}hasProperty(t){return!!this.json[t]}getGlobalProperty(t,r=Ze.UNSIGNED_INT,n=1){const a=this.json[t];return a&&Number.isFinite(a.byteOffset)?this._getTypedArrayFromBinary(t,r,n,1,a.byteOffset):a}getPropertyArray(t,r,n){const a=this.json[t];return a&&Number.isFinite(a.byteOffset)?("componentType"in a&&(r=oo.fromName(a.componentType)),this._getTypedArrayFromBinary(t,r,n,this.featuresLength,a.byteOffset)):this._getTypedArrayFromArray(t,r,a)}getProperty(t,r,n,a,d){const f=this.json[t];if(!f)return f;const c=this.getPropertyArray(t,r,n);if(n===1)return c[a];for(let T=0;T<n;++T)d[T]=c[n*a+T];return d}_getTypedArrayFromBinary(t,r,n,a,d){const f=this._cachedTypedArrays;let c=f[t];return c||(c=oo.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+d,a*n),f[t]=c),c}_getTypedArrayFromArray(t,r,n){const a=this._cachedTypedArrays;let d=a[t];return d||(d=oo.createTypedArray(r,n),a[t]=d),d}}const A5={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},E5={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},S5={SCALAR:(e,t,r)=>{t[r]=e},VEC2:(e,t,r)=>{t[2*r+0]=e[0],t[2*r+1]=e[1]},VEC3:(e,t,r)=>{t[3*r+0]=e[0],t[3*r+1]=e[1],t[3*r+2]=e[2]},VEC4:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT2:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT3:(e,t,r)=>{t[9*r+0]=e[0],t[9*r+1]=e[1],t[9*r+2]=e[2],t[9*r+3]=e[3],t[9*r+4]=e[4],t[9*r+5]=e[5],t[9*r+6]=e[6],t[9*r+7]=e[7],t[9*r+8]=e[8],t[9*r+9]=e[9]},MAT4:(e,t,r)=>{t[16*r+0]=e[0],t[16*r+1]=e[1],t[16*r+2]=e[2],t[16*r+3]=e[3],t[16*r+4]=e[4],t[16*r+5]=e[5],t[16*r+6]=e[6],t[16*r+7]=e[7],t[16*r+8]=e[8],t[16*r+9]=e[9],t[16*r+10]=e[10],t[16*r+11]=e[11],t[16*r+12]=e[12],t[16*r+13]=e[13],t[16*r+14]=e[14],t[16*r+15]=e[15]}};function C5(e,t,r,n){const{componentType:a}=e;Ar(e.componentType);const d=typeof a=="string"?oo.fromName(a):a,f=A5[e.type],c=E5[e.type],T=S5[e.type];return r+=e.byteOffset,{values:oo.createTypedArray(d,t,r,f*n),type:d,size:f,unpacker:c,packer:T}}const ao=e=>e!==void 0;function I5(e,t,r){if(!t)return null;let n=e.getExtension("3DTILES_batch_table_hierarchy");const a=t.HIERARCHY;return a&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=a,n=a),n?M5(n,r):null}function M5(e,t){let r,n,a;const d=e.instancesLength,f=e.classes;let c=e.classIds,T=e.parentCounts,C=e.parentIds,R=d;ao(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,a=getBinaryAccessor(c),c=a.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,d));let L;if(ao(T))for(ao(T.byteOffset)&&(T.componentType=defaultValue(T.componentType,GL.UNSIGNED_SHORT),T.type=AttributeType.SCALAR,a=getBinaryAccessor(T),T=a.createArrayBufferView(t.buffer,t.byteOffset+T.byteOffset,d)),L=new Uint16Array(d),R=0,r=0;r<d;++r)L[r]=R,R+=T[r];ao(C)&&ao(C.byteOffset)&&(C.componentType=defaultValue(C.componentType,GL.UNSIGNED_SHORT),C.type=AttributeType.SCALAR,a=getBinaryAccessor(C),C=a.createArrayBufferView(t.buffer,t.byteOffset+C.byteOffset,R));const V=f.length;for(r=0;r<V;++r){const K=f[r].length,It=f[r].instances,St=getBinaryProperties(K,It,t);f[r].instances=combine(St,It)}const X=new Array(V).fill(0),at=new Uint16Array(d);for(r=0;r<d;++r)n=c[r],at[r]=X[n],++X[n];const nt={classes:f,classIds:c,classIndexes:at,parentCounts:T,parentIndexes:L,parentIds:C};return B5(nt),nt}function Lh(e,t,r){if(!e)return;const n=e.parentCounts;return e.parentIds?r(e,t):n>0?R5(e,t,r):P5(e,t,r)}function R5(e,t,r){const n=e.classIds,a=e.parentCounts,d=e.parentIds,f=e.parentIndexes,c=n.length,T=scratchVisited;T.length=Math.max(T.length,c);const C=++marker,R=scratchStack;for(R.length=0,R.push(t);R.length>0;){if(t=R.pop(),T[t]===C)continue;T[t]=C;const L=r(e,t);if(ao(L))return L;const V=a[t],X=f[t];for(let at=0;at<V;++at){const nt=d[X+at];nt!==t&&R.push(nt)}}return null}function P5(e,t,r){let n=!0;for(;n;){const a=r(e,t);if(ao(a))return a;const d=e.parentIds[t];n=d!==t,t=d}throw new Error("traverseHierarchySingleParent")}function B5(e){const r=e.classIds.length;for(let n=0;n<r;++n)oA(e,n,stack)}function oA(e,t,r){const n=e.parentCounts,a=e.parentIds,d=e.parentIndexes,c=e.classIds.length;if(!ao(a))return;assert(t<c,`Parent index ${t} exceeds the total number of instances: ${c}`),assert(r.indexOf(t)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(t);const T=ao(n)?n[t]:1,C=ao(n)?d[t]:t;for(let R=0;R<T;++R){const L=a[C+R];L!==t&&oA(e,L,r)}r.pop(t)}function ys(e){return e!=null}const yp=(e,t)=>e,D5={HIERARCHY:!0,extensions:!0,extras:!0};class aA{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(t,r,n,a={}){Ar(n>=0),this.json=t||{},this.binary=r,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(const d in this.json)D5[d]||(this._properties[d]=this.json[d]);this._binaryProperties=this._initializeBinaryProperties(),a["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=I5(this,this.json,this.binary))}getExtension(t){return this.json&&this.json.extensions&&this.json.extensions[t]}memorySizeInBytes(){return 0}isClass(t,r){if(this._checkBatchId(t),Ar(typeof r=="string",r),this._hierarchy){const n=Lh(this._hierarchy,t,(a,d)=>{const f=a.classIds[d];return a.classes[f].name===r});return ys(n)}return!1}isExactClass(t,r){return Ar(typeof r=="string",r),this.getExactClassName(t)===r}getExactClassName(t){if(this._checkBatchId(t),this._hierarchy){const r=this._hierarchy.classIds[t];return this._hierarchy.classes[r].name}}hasProperty(t,r){return this._checkBatchId(t),Ar(typeof r=="string",r),ys(this._properties[r])||this._hasPropertyInHierarchy(t,r)}getPropertyNames(t,r){this._checkBatchId(t),r=ys(r)?r:[],r.length=0;const n=Object.keys(this._properties);return r.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(t,r),r}getProperty(t,r){if(this._checkBatchId(t),Ar(typeof r=="string",r),this._binaryProperties){const a=this._binaryProperties[r];if(ys(a))return this._getBinaryProperty(a,t)}const n=this._properties[r];if(ys(n))return yp(n[t]);if(this._hierarchy){const a=this._getHierarchyProperty(t,r);if(ys(a))return a}}setProperty(t,r,n){const a=this.featureCount;if(this._checkBatchId(t),Ar(typeof r=="string",r),this._binaryProperties){const f=this._binaryProperties[r];if(f){this._setBinaryProperty(f,t,n);return}}if(this._hierarchy&&this._setHierarchyProperty(this,t,r,n))return;let d=this._properties[r];ys(d)||(this._properties[r]=new Array(a),d=this._properties[r]),d[t]=yp(n)}_checkBatchId(t){if(!(t>=0&&t<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(t,r){return t.unpack(t.typedArray,r)}_setBinaryProperty(t,r,n){t.pack(n,t.typedArray,r)}_initializeBinaryProperties(){let t=null;for(const r in this._properties){const n=this._properties[r],a=this._initializeBinaryProperty(r,n);a&&(t=t||{},t[r]=a)}return t}_initializeBinaryProperty(t,r){if("byteOffset"in r){const n=r;Ar(this.binary,`Property ${t} requires a batch table binary.`),Ar(n.type,`Property ${t} requires a type.`);const a=C5(n,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:a.values,componentCount:a.size,unpack:a.unpacker,pack:a.packer}}return null}_hasPropertyInHierarchy(t,r){if(!this._hierarchy)return!1;const n=Lh(this._hierarchy,t,(a,d)=>{const f=a.classIds[d],c=a.classes[f].instances;return ys(c[r])});return ys(n)}_getPropertyNamesInHierarchy(t,r){Lh(this._hierarchy,t,(n,a)=>{const d=n.classIds[a],f=n.classes[d].instances;for(const c in f)f.hasOwnProperty(c)&&r.indexOf(c)===-1&&r.push(c)})}_getHierarchyProperty(t,r){return Lh(this._hierarchy,t,(n,a)=>{const d=n.classIds[a],f=n.classes[d],c=n.classIndexes[a],T=f.instances[r];return ys(T)?ys(T.typedArray)?this._getBinaryProperty(T,c):yp(T[c]):null})}_setHierarchyProperty(t,r,n,a){const d=Lh(this._hierarchy,r,(f,c)=>{const T=f.classIds[c],C=f.classes[T],R=f.classIndexes[c],L=C.instances[n];return ys(L)?(Ar(c===r,`Inherited property "${n}" is read-only.`),ys(L.typedArray)?this._setBinaryProperty(L,R,a):L[R]=yp(a),!0):!1});return ys(d)}}const Oy=4;function bp(e,t,r=0){const n=new DataView(t);if(e.magic=n.getUint32(r,!0),r+=Oy,e.version=n.getUint32(r,!0),r+=Oy,e.byteLength=n.getUint32(r,!0),r+=Oy,e.version!==1)throw new Error(`3D Tile Version ${e.version} not supported`);return r}const Nc=4,lA="b3dm tile in legacy format.";function ky(e,t,r){const n=new DataView(t);let a;e.header=e.header||{};let d=n.getUint32(r,!0);r+=Nc;let f=n.getUint32(r,!0);r+=Nc;let c=n.getUint32(r,!0);r+=Nc;let T=n.getUint32(r,!0);return r+=Nc,c>=570425344?(r-=Nc*2,a=d,c=f,T=0,d=0,f=0,console.warn(lA)):T>=570425344&&(r-=Nc,a=c,c=d,T=f,d=0,f=0,console.warn(lA)),e.header.featureTableJsonByteLength=d,e.header.featureTableBinaryByteLength=f,e.header.batchTableJsonByteLength=c,e.header.batchTableBinaryByteLength=T,e.header.batchLength=a,r}function Ny(e,t,r,n){return r=F5(e,t,r),r=O5(e,t,r),r}function F5(e,t,r,n){const{featureTableJsonByteLength:a,featureTableBinaryByteLength:d,batchLength:f}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:f||0},a&&a>0){const c=iA(t,r,a);e.featureTableJson=JSON.parse(c)}return r+=a||0,e.featureTableBinary=new Uint8Array(t,r,d),r+=d||0,r}function O5(e,t,r,n){const{batchTableJsonByteLength:a,batchTableBinaryByteLength:d}=e.header||{};if(a&&a>0){const f=iA(t,r,a);e.batchTableJson=JSON.parse(f),r+=a,d&&d>0&&(e.batchTableBinary=new Uint8Array(t,r,d),e.batchTableBinary=new Uint8Array(e.batchTableBinary),r+=d)}return r}function cA(e,t,r){if(!t&&(!e||!e.batchIds||!r))return null;const{batchIds:n,isRGB565:a,pointCount:d=0}=e;if(n&&r){const f=new Uint8ClampedArray(d*3);for(let c=0;c<d;c++){const T=n[c],R=r.getProperty(T,"dimensions").map(L=>L*255);f[c*3]=R[0],f[c*3+1]=R[1],f[c*3+2]=R[2]}return{type:Ze.UNSIGNED_BYTE,value:f,size:3,normalized:!0}}if(t&&a){const f=new Uint8ClampedArray(d*3);for(let c=0;c<d;c++){const T=x5(t[c]);f[c*3]=T[0],f[c*3+1]=T[1],f[c*3+2]=T[2]}return{type:Ze.UNSIGNED_BYTE,value:f,size:3,normalized:!0}}return t&&t.length===d*3?{type:Ze.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:Ze.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}const uA=new Bt;function k5(e,t){if(!t)return null;if(e.isOctEncoded16P){const r=new Float32Array((e.pointsLength||0)*3);for(let n=0;n<(e.pointsLength||0);n++)T5(t[n*2],t[n*2+1],uA),uA.toArray(r,n*3);return{type:Ze.FLOAT,size:2,value:r}}return{type:Ze.FLOAT,size:2,value:t}}function N5(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,L5(e,t)):{type:Ze.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}function L5(e,t){const r=new Bt,n=new Float32Array(e.pointCount*3);for(let a=0;a<e.pointCount;a++)r.set(t[a*3],t[a*3+1],t[a*3+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(n,a*3);return n}async function U5(e,t,r,n,a){r=bp(e,t,r),r=ky(e,t,r),r=Ny(e,t,r),z5(e);const{featureTable:d,batchTable:f}=V5(e);return await W5(e,d,f,n,a),j5(e,d,n),H5(e,d,f),G5(e,d),r}function z5(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}function V5(e){const t=new Fy(e.featureTableJson,e.featureTableBinary),r=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=r,e.featuresLength=r,e.pointsLength=r,e.pointCount=r,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",Ze.FLOAT,3);const n=$5(e,t);return{featureTable:t,batchTable:n}}function j5(e,t,r){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.positions){if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",Ze.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const n=t.getPropertyArray("POSITION_QUANTIZED",Ze.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Ze.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Ze.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=N5(e,n,r)}}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function H5(e,t,r){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.colors){let n=null;t.hasProperty("RGBA")?(n=t.getPropertyArray("RGBA",Ze.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?n=t.getPropertyArray("RGB",Ze.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(n=t.getPropertyArray("RGB565",Ze.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=cA(e,n,r)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",Ze.UNSIGNED_BYTE,4))}function G5(e,t){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.normals){let r=null;t.hasProperty("NORMAL")?r=t.getPropertyArray("NORMAL",Ze.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(r=t.getPropertyArray("NORMAL_OCT16P",Ze.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=k5(e,r)}}function $5(e,t){let r=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",Ze.UNSIGNED_SHORT,1),e.batchIds)){const n=t.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:a,batchTableBinary:d}=e;r=new aA(a,d,n)}return r}async function W5(e,t,r,n,a){let d,f,c;const T=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];T&&(c=T.properties);const C=t.getExtension("3DTILES_draco_point_compression");if(C){f=C.properties;const L=C.byteOffset,V=C.byteLength;if(!f||!Number.isFinite(L)||!V)throw new Error("Draco properties, byteOffset, and byteLength must be defined");d=(e.featureTableBinary||[]).slice(L,L+V),e.hasPositions=Number.isFinite(f.POSITION),e.hasColors=Number.isFinite(f.RGB)||Number.isFinite(f.RGBA),e.hasNormals=Number.isFinite(f.NORMAL),e.hasBatchIds=Number.isFinite(f.BATCH_ID),e.isTranslucent=Number.isFinite(f.RGBA)}if(!d)return!0;const R={buffer:d,properties:{...f,...c},batchTableProperties:c};return await X5(e,R,n,a)}async function X5(e,t,r,n){if(!n)return;const a={...r,draco:{...r?.draco,extraAttributes:t.batchTableProperties||{}}};delete a["3d-tiles"];const d=await Zu(t.buffer,wT,a,n),f=d.attributes.POSITION&&d.attributes.POSITION.value,c=d.attributes.COLOR_0&&d.attributes.COLOR_0.value,T=d.attributes.NORMAL&&d.attributes.NORMAL.value,C=d.attributes.BATCH_ID&&d.attributes.BATCH_ID.value,R=f&&d.attributes.POSITION.value.quantization,L=T&&d.attributes.NORMAL.value.quantization;if(R){const X=d.POSITION.data.quantization,at=X.range;e.quantizedVolumeScale=new Bt(at,at,at),e.quantizedVolumeOffset=new Bt(X.minValues),e.quantizedRange=(1<<X.quantizationBits)-1,e.isQuantizedDraco=!0}L&&(e.octEncodedRange=(1<<d.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const V={};if(t.batchTableProperties)for(const X of Object.keys(t.batchTableProperties))d.attributes[X]&&d.attributes[X].value&&(V[X.toLowerCase()]=d.attributes[X].value);e.attributes={positions:f,colors:cA(e,c,void 0),normals:T,batchIds:C,...V}}const Ly={URI:0,EMBEDDED:1};function hA(e,t,r,n){e.rotateYtoZ=!0;const a=(e.byteOffset||0)+(e.byteLength||0)-r;if(a===0)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=n?.["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=rg(t,r,a),e.gltfByteOffset=0,e.gltfByteLength=a,r%4===0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),(e.byteOffset||0)+(e.byteLength||0)}async function dA(e,t,r,n){const a=r?.["3d-tiles"]||{};if(q5(e,t),a.loadGLTF){if(!n)return;if(e.gltfUrl){const{fetch:d}=n,f=await d(e.gltfUrl,r);e.gltfArrayBuffer=await f.arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){const d=await Zu(e.gltfArrayBuffer,Oh,r,n);e.gltf=my(d),e.gpuMemoryUsageInBytes=lT(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}function q5(e,t,r){switch(t){case Ly.URI:if(e.gltfArrayBuffer){const n=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),d=new TextDecoder().decode(n);e.gltfUrl=d.replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case Ly.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function Z5(e,t,r,n,a){r=Y5(e,t,r,n),await dA(e,Ly.EMBEDDED,n,a);const d=e?.gltf?.extensions;return d&&d.CESIUM_RTC&&(e.rtcCenter=d.CESIUM_RTC.center),r}function Y5(e,t,r,n,a){r=bp(e,t,r),r=ky(e,t,r),r=Ny(e,t,r),r=hA(e,t,r,n);const d=new Fy(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=d.getGlobalProperty("RTC_CENTER",Ze.FLOAT,3),r}async function K5(e,t,r,n,a){return r=J5(e,t,r,n),await dA(e,e.gltfFormat||0,n,a),r}function J5(e,t,r,n,a){if(r=bp(e,t,r),e.version!==1)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);r=ky(e,t,r);const d=new DataView(t);if(e.gltfFormat=d.getUint32(r,!0),r+=4,r=Ny(e,t,r),r=hA(e,t,r,n),!e?.header?.featureTableJsonByteLength||e.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const f=new Fy(e.featureTableJson,e.featureTableBinary),c=f.getGlobalProperty("INSTANCES_LENGTH");if(f.featuresLength=c,!Number.isFinite(c))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=f.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=f.getGlobalProperty("RTC_CENTER",Ze.FLOAT,3);const T=new aA(e.batchTableJson,e.batchTableBinary,c);return Q5(e,f,T,c),r}function Q5(e,t,r,n){const a=new Array(n),d=new Bt;new Bt,new Bt,new Bt;const f=new Xr,c=new ch,T=new Bt,C={},R=new He,L=[],V=[],X=[],at=[];for(let nt=0;nt<n;nt++){let K;if(t.hasProperty("POSITION"))K=t.getProperty("POSITION",Ze.FLOAT,3,nt,d);else if(t.hasProperty("POSITION_QUANTIZED")){K=t.getProperty("POSITION_QUANTIZED",Ze.UNSIGNED_SHORT,3,nt,d);const ee=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Ze.FLOAT,3);if(!ee)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const ae=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Ze.FLOAT,3);if(!ae)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const be=65535;for(let ie=0;ie<3;ie++)K[ie]=K[ie]/be*ae[ie]+ee[ie]}if(!K)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(d.copy(K),C.translation=d,e.normalUp=t.getProperty("NORMAL_UP",Ze.FLOAT,3,nt,L),e.normalRight=t.getProperty("NORMAL_RIGHT",Ze.FLOAT,3,nt,V),e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",Ze.UNSIGNED_SHORT,2,nt,L),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",Ze.UNSIGNED_SHORT,2,nt,V),e.octNormalUp)throw e.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");e.eastNorthUp?(Er.WGS84.eastNorthUpToFixedFrame(d,R),R.getRotationMatrix3(f)):f.identity()}c.fromMatrix3(f),C.rotation=c,T.set(1,1,1);const It=t.getProperty("SCALE",Ze.FLOAT,1,nt,X);Number.isFinite(It)&&T.multiplyByScalar(It);const St=t.getProperty("SCALE_NON_UNIFORM",Ze.FLOAT,3,nt,L);St&&T.scale(St),C.scale=T;let Ct=t.getProperty("BATCH_ID",Ze.UNSIGNED_SHORT,1,nt,at);Ct===void 0&&(Ct=nt);const Ht=new He().fromQuaternion(C.rotation);R.identity(),R.translate(C.translation),R.multiplyRight(Ht),R.scale(C.scale);const Qt=R.clone();a[nt]={modelMatrix:Qt,batchId:Ct}}e.instances=a}async function t8(e,t,r,n,a,d){r=bp(e,t,r);const f=new DataView(t);for(e.tilesLength=f.getUint32(r,!0),r+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-r>12;){const c={shape:"tile3d"};e.tiles.push(c),r=await d(t,r,n,a,c)}return r}async function e8(e,t,r,n){if(e.rotateYtoZ=!0,e.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!n)return t.byteLength;const a=await Zu(t,Oh,r,n);e.gltf=my(a),e.gpuMemoryUsageInBytes=lT(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}async function fA(e,t=0,r,n,a={shape:"tile3d"}){switch(a.byteOffset=t,a.type=m5(e,t),a.type){case Nh.COMPOSITE:return await t8(a,e,t,r,n,fA);case Nh.BATCHED_3D_MODEL:return await Z5(a,e,t,r,n);case Nh.GLTF:return await e8(a,e,r,n);case Nh.INSTANCED_3D_MODEL:return await K5(a,e,t,r,n);case Nh.POINT_CLOUD:return await U5(a,e,t,r,n);default:throw new Error(`3DTileLoader: unknown type ${a.type}`)}}const r8=1952609651,i8=1;async function s8(e,t,r){if(new Uint32Array(e.slice(0,4))[0]!==r8)throw new Error("Wrong subtree file magic number");if(new Uint32Array(e.slice(4,8))[0]!==i8)throw new Error("Wrong subtree file verson, must be 1");const d=pA(e.slice(8,16)),f=new Uint8Array(e,24,d),T=new TextDecoder("utf8").decode(f),C=JSON.parse(T),R=pA(e.slice(16,24));let L=new ArrayBuffer(0);if(R&&(L=e.slice(24+d)),await vp(C,C.tileAvailability,L,r),Array.isArray(C.contentAvailability))for(const V of C.contentAvailability)await vp(C,V,L,r);else await vp(C,C.contentAvailability,L,r);return await vp(C,C.childSubtreeAvailability,L,r),C}async function vp(e,t,r,n){const a=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if(typeof a!="number")return;const d=e.bufferViews[a],f=e.buffers[d.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(f.uri){const T=`${n?.baseUrl||""}/${f.uri}`,R=await(await n.fetch(T)).arrayBuffer();t.explicitBitstream=new Uint8Array(R,d.byteOffset,d.byteLength);return}const c=e.buffers.slice(0,d.buffer).reduce((T,C)=>T+C.byteLength,0);t.explicitBitstream=new Uint8Array(r.slice(c,c+f.byteLength),d.byteOffset,d.byteLength)}function pA(e){const t=new DataView(e),r=t.getUint32(0,!0),n=t.getUint32(4,!0);return r+2**32*n}const _A={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:rA,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:s8,options:{}};var cn=null;try{cn=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 cr(e,t,r){this.low=e|0,this.high=t|0,this.unsigned=!!r}cr.prototype.__isLong__,Object.defineProperty(cr.prototype,"__isLong__",{value:!0});function Qi(e){return(e&&e.__isLong__)===!0}function gA(e){var t=Math.clz32(e&-e);return e?31-t:t}cr.isLong=Qi;var mA={},yA={};function ll(e,t){var r,n,a;return t?(e>>>=0,(a=0<=e&&e<256)&&(n=yA[e],n)?n:(r=Ke(e,0,!0),a&&(yA[e]=r),r)):(e|=0,(a=-128<=e&&e<128)&&(n=mA[e],n)?n:(r=Ke(e,e<0?-1:0,!1),a&&(mA[e]=r),r))}cr.fromInt=ll;function un(e,t){if(isNaN(e))return t?Ro:Bn;if(t){if(e<0)return Ro;if(e>=vA)return EA}else{if(e<=-xA)return bs;if(e+1>=xA)return AA}return e<0?un(-e,t).neg():Ke(e%Lc|0,e/Lc|0,t)}cr.fromNumber=un;function Ke(e,t,r){return new cr(e,t,r)}cr.fromBits=Ke;var xp=Math.pow;function Uy(e,t,r){if(e.length===0)throw Error("empty string");if(typeof t=="number"?(r=t,t=!1):t=!!t,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return t?Ro:Bn;if(r=r||10,r<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(n===0)return Uy(e.substring(1),t,r).neg();for(var a=un(xp(r,8)),d=Bn,f=0;f<e.length;f+=8){var c=Math.min(8,e.length-f),T=parseInt(e.substring(f,f+c),r);if(c<8){var C=un(xp(r,c));d=d.mul(C).add(un(T))}else d=d.mul(a),d=d.add(un(T))}return d.unsigned=t,d}cr.fromString=Uy;function Pn(e,t){return typeof e=="number"?un(e,t):typeof e=="string"?Uy(e,t):Ke(e.low,e.high,typeof t=="boolean"?t:e.unsigned)}cr.fromValue=Pn;var bA=65536,n8=1<<24,Lc=bA*bA,vA=Lc*Lc,xA=vA/2,wA=ll(n8),Bn=ll(0);cr.ZERO=Bn;var Ro=ll(0,!0);cr.UZERO=Ro;var Uc=ll(1);cr.ONE=Uc;var TA=ll(1,!0);cr.UONE=TA;var zy=ll(-1);cr.NEG_ONE=zy;var AA=Ke(-1,2147483647,!1);cr.MAX_VALUE=AA;var EA=Ke(-1,-1,!0);cr.MAX_UNSIGNED_VALUE=EA;var bs=Ke(0,-2147483648,!1);cr.MIN_VALUE=bs;var re=cr.prototype;re.toInt=function(){return this.unsigned?this.low>>>0:this.low},re.toNumber=function(){return this.unsigned?(this.high>>>0)*Lc+(this.low>>>0):this.high*Lc+(this.low>>>0)},re.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(bs)){var r=un(t),n=this.div(r),a=n.mul(r).sub(this);return n.toString(t)+a.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var d=un(xp(t,6),this.unsigned),f=this,c="";;){var T=f.div(d),C=f.sub(T.mul(d)).toInt()>>>0,R=C.toString(t);if(f=T,f.isZero())return R+c;for(;R.length<6;)R="0"+R;c=""+R+c}},re.getHighBits=function(){return this.high},re.getHighBitsUnsigned=function(){return this.high>>>0},re.getLowBits=function(){return this.low},re.getLowBitsUnsigned=function(){return this.low>>>0},re.getNumBitsAbs=function(){if(this.isNegative())return this.eq(bs)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,r=31;r>0&&(t&1<<r)==0;r--);return this.high!=0?r+33:r+1},re.isZero=function(){return this.high===0&&this.low===0},re.eqz=re.isZero,re.isNegative=function(){return!this.unsigned&&this.high<0},re.isPositive=function(){return this.unsigned||this.high>=0},re.isOdd=function(){return(this.low&1)===1},re.isEven=function(){return(this.low&1)===0},re.equals=function(t){return Qi(t)||(t=Pn(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low},re.eq=re.equals,re.notEquals=function(t){return!this.eq(t)},re.neq=re.notEquals,re.ne=re.notEquals,re.lessThan=function(t){return this.comp(t)<0},re.lt=re.lessThan,re.lessThanOrEqual=function(t){return this.comp(t)<=0},re.lte=re.lessThanOrEqual,re.le=re.lessThanOrEqual,re.greaterThan=function(t){return this.comp(t)>0},re.gt=re.greaterThan,re.greaterThanOrEqual=function(t){return this.comp(t)>=0},re.gte=re.greaterThanOrEqual,re.ge=re.greaterThanOrEqual,re.compare=function(t){if(Qi(t)||(t=Pn(t)),this.eq(t))return 0;var r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},re.comp=re.compare,re.negate=function(){return!this.unsigned&&this.eq(bs)?bs:this.not().add(Uc)},re.neg=re.negate,re.add=function(t){Qi(t)||(t=Pn(t));var r=this.high>>>16,n=this.high&65535,a=this.low>>>16,d=this.low&65535,f=t.high>>>16,c=t.high&65535,T=t.low>>>16,C=t.low&65535,R=0,L=0,V=0,X=0;return X+=d+C,V+=X>>>16,X&=65535,V+=a+T,L+=V>>>16,V&=65535,L+=n+c,R+=L>>>16,L&=65535,R+=r+f,R&=65535,Ke(V<<16|X,R<<16|L,this.unsigned)},re.subtract=function(t){return Qi(t)||(t=Pn(t)),this.add(t.neg())},re.sub=re.subtract,re.multiply=function(t){if(this.isZero())return this;if(Qi(t)||(t=Pn(t)),cn){var r=cn.mul(this.low,this.high,t.low,t.high);return Ke(r,cn.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Ro:Bn;if(this.eq(bs))return t.isOdd()?bs:Bn;if(t.eq(bs))return this.isOdd()?bs:Bn;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(wA)&&t.lt(wA))return un(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,a=this.high&65535,d=this.low>>>16,f=this.low&65535,c=t.high>>>16,T=t.high&65535,C=t.low>>>16,R=t.low&65535,L=0,V=0,X=0,at=0;return at+=f*R,X+=at>>>16,at&=65535,X+=d*R,V+=X>>>16,X&=65535,X+=f*C,V+=X>>>16,X&=65535,V+=a*R,L+=V>>>16,V&=65535,V+=d*C,L+=V>>>16,V&=65535,V+=f*T,L+=V>>>16,V&=65535,L+=n*R+a*C+d*T+f*c,L&=65535,Ke(X<<16|at,L<<16|V,this.unsigned)},re.mul=re.multiply,re.divide=function(t){if(Qi(t)||(t=Pn(t)),t.isZero())throw Error("division by zero");if(cn){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var r=(this.unsigned?cn.div_u:cn.div_s)(this.low,this.high,t.low,t.high);return Ke(r,cn.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Ro:Bn;var n,a,d;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Ro;if(t.gt(this.shru(1)))return TA;d=Ro}else{if(this.eq(bs)){if(t.eq(Uc)||t.eq(zy))return bs;if(t.eq(bs))return Uc;var f=this.shr(1);return n=f.div(t).shl(1),n.eq(Bn)?t.isNegative()?Uc:zy:(a=this.sub(t.mul(n)),d=n.add(a.div(t)),d)}else if(t.eq(bs))return this.unsigned?Ro:Bn;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();d=Bn}for(a=this;a.gte(t);){n=Math.max(1,Math.floor(a.toNumber()/t.toNumber()));for(var c=Math.ceil(Math.log(n)/Math.LN2),T=c<=48?1:xp(2,c-48),C=un(n),R=C.mul(t);R.isNegative()||R.gt(a);)n-=T,C=un(n,this.unsigned),R=C.mul(t);C.isZero()&&(C=Uc),d=d.add(C),a=a.sub(R)}return d},re.div=re.divide,re.modulo=function(t){if(Qi(t)||(t=Pn(t)),cn){var r=(this.unsigned?cn.rem_u:cn.rem_s)(this.low,this.high,t.low,t.high);return Ke(r,cn.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},re.mod=re.modulo,re.rem=re.modulo,re.not=function(){return Ke(~this.low,~this.high,this.unsigned)},re.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},re.clz=re.countLeadingZeros,re.countTrailingZeros=function(){return this.low?gA(this.low):gA(this.high)+32},re.ctz=re.countTrailingZeros,re.and=function(t){return Qi(t)||(t=Pn(t)),Ke(this.low&t.low,this.high&t.high,this.unsigned)},re.or=function(t){return Qi(t)||(t=Pn(t)),Ke(this.low|t.low,this.high|t.high,this.unsigned)},re.xor=function(t){return Qi(t)||(t=Pn(t)),Ke(this.low^t.low,this.high^t.high,this.unsigned)},re.shiftLeft=function(t){return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):Ke(0,this.low<<t-32,this.unsigned)},re.shl=re.shiftLeft,re.shiftRight=function(t){return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):Ke(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},re.shr=re.shiftRight,re.shiftRightUnsigned=function(t){return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?Ke(this.high,0,this.unsigned):Ke(this.high>>>t-32,0,this.unsigned)},re.shru=re.shiftRightUnsigned,re.shr_u=re.shiftRightUnsigned,re.rotateLeft=function(t){var r;return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?Ke(this.high,this.low,this.unsigned):t<32?(r=32-t,Ke(this.low<<t|this.high>>>r,this.high<<t|this.low>>>r,this.unsigned)):(t-=32,r=32-t,Ke(this.high<<t|this.low>>>r,this.low<<t|this.high>>>r,this.unsigned))},re.rotl=re.rotateLeft,re.rotateRight=function(t){var r;return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?Ke(this.high,this.low,this.unsigned):t<32?(r=32-t,Ke(this.high<<r|this.low>>>t,this.low<<r|this.high>>>t,this.unsigned)):(t-=32,r=32-t,Ke(this.low<<r|this.high>>>t,this.high<<r|this.low>>>t,this.unsigned))},re.rotr=re.rotateRight,re.toSigned=function(){return this.unsigned?Ke(this.low,this.high,!1):this},re.toUnsigned=function(){return this.unsigned?this:Ke(this.low,this.high,!0)},re.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},re.toBytesLE=function(){var t=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]},re.toBytesBE=function(){var t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,r>>>24,r>>>16&255,r>>>8&255,r&255]},cr.fromBytes=function(t,r,n){return n?cr.fromBytesLE(t,r):cr.fromBytesBE(t,r)},cr.fromBytesLE=function(t,r){return new cr(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)},cr.fromBytesBE=function(t,r){return new cr(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)};const o8=16;function SA(e){e==="X"&&(e="");const t=e.padEnd(o8,"0");return cr.fromString(t,!0,16)}function a8(e){if(e.isZero())return"X";let t=e.countTrailingZeros();const r=t%4;t=(t-r)/4;const n=t;t*=4;const d=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-n-d.length).join("0")+d}function l8(e,t){const r=c8(e).shiftRightUnsigned(2);return e.add(cr.fromNumber(2*t+1-4).multiply(r))}function c8(e){return e.and(e.not().add(1))}const u8=3,h8=2*30+1,CA=180/Math.PI;function d8(e){if(e.length===0)throw new Error(`Invalid Hilbert quad key ${e}`);const t=e.split("/"),r=parseInt(t[0],10),n=t[1],a=n.length;let d=0;const f=[0,0];for(let c=a-1;c>=0;c--){d=a-c;const T=n[c];let C=0,R=0;T==="1"?R=1:T==="2"?(C=1,R=1):T==="3"&&(C=1);const L=Math.pow(2,d-1);p8(L,f,C,R),f[0]+=L*C,f[1]+=L*R}if(r%2===1){const c=f[0];f[0]=f[1],f[1]=c}return{face:r,ij:f,level:d}}function f8(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<u8+h8;)t="0"+t;const r=t.lastIndexOf("1"),n=t.substring(0,3),a=t.substring(3,r),d=a.length/2,f=cr.fromString(n,!0,2).toString(10);let c="";if(d!==0)for(c=cr.fromString(a,!0,2).toString(4);c.length<d;)c="0"+c;return`${f}/${c}`}function IA(e,t,r){const n=1<<t;return[(e[0]+r[0])/n,(e[1]+r[1])/n]}function MA(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function RA(e){return[MA(e[0]),MA(e[1])]}function PA(e,[t,r]){switch(e){case 0:return[1,t,r];case 1:return[-t,1,r];case 2:return[-t,-r,1];case 3:return[-1,-r,-t];case 4:return[r,-1,-t];case 5:return[r,t,-1];default:throw new Error("Invalid face")}}function BA([e,t,r]){const n=Math.atan2(r,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*CA,n*CA]}function p8(e,t,r,n){if(n===0){r===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const a=t[0];t[0]=t[1],t[1]=a}}function _8(e){const t=IA(e.ij,e.level,[.5,.5]),r=RA(t),n=PA(e.face,r);return BA(n)}const g8=100;function DA(e){const{face:t,ij:r,level:n}=e,a=[[0,0],[0,1],[1,1],[1,0],[0,0]],d=Math.max(1,Math.ceil(g8*Math.pow(2,-n))),f=new Float64Array(4*d*2+2);let c=0,T=0;for(let C=0;C<4;C++){const R=a[C].slice(0),L=a[C+1],V=(L[0]-R[0])/d,X=(L[1]-R[1])/d;for(let at=0;at<d;at++){R[0]+=V,R[1]+=X;const nt=IA(r,n,R),K=RA(nt),It=PA(t,K),St=BA(It);Math.abs(St[1])>89.999&&(St[0]=T);const Ct=St[0]-T;St[0]+=Ct>180?-360:Ct<-180?360:0,f[c++]=St[0],f[c++]=St[1],T=St[0]}}return f[c++]=f[0],f[c++]=f[1],f}function Vy(e){const t=m8(e);return d8(t)}function m8(e){if(e.indexOf("/")>0)return e;const t=SA(e);return f8(t)}function y8(e){const t=Vy(e);return _8(t)}function b8(e){let t;if(e.face===2||e.face===5){let r=null,n=0;for(let a=0;a<4;a++){const d=`${e.face}/${a}`,f=Vy(d),c=DA(f);(typeof r>"u"||r===null)&&(r=new Float64Array(4*c.length)),r.set(c,n),n+=c.length}t=FA(r)}else{const r=DA(e);t=FA(r)}return t}function FA(e){if(e.length%2!==0)throw new Error("Invalid corners");const t=[],r=[];for(let n=0;n<e.length;n+=2)t.push(e[n]),r.push(e[n+1]);return t.sort((n,a)=>n-a),r.sort((n,a)=>n-a),{west:t[0],east:t[t.length-1],north:r[r.length-1],south:r[0]}}function v8(e,t){const r=t?.minimumHeight||0,n=t?.maximumHeight||0,a=Vy(e),d=b8(a),f=d.west,c=d.south,T=d.east,C=d.north,R=[];return R.push(new Bt(f,C,r)),R.push(new Bt(T,C,r)),R.push(new Bt(T,c,r)),R.push(new Bt(f,c,r)),R.push(new Bt(f,C,n)),R.push(new Bt(T,C,n)),R.push(new Bt(T,c,n)),R.push(new Bt(f,c,n)),R}function OA(e){const t=e.token,r={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},n=v8(t,r),a=y8(t),d=a[0],f=a[1],c=Er.WGS84.cartographicToCartesian([d,f,r.maximumHeight]),T=new Bt(c[0],c[1],c[2]);n.push(T);const C=mL(n);return[...C.center,...C.halfAxes]}const x8={QUADTREE:4,OCTREE:8};function w8(e,t,r){if(e?.box){const n=SA(e.s2VolumeInfo.token),a=l8(n,t),d=a8(a),f={...e.s2VolumeInfo};switch(f.token=d,r){case"OCTREE":const C=e.s2VolumeInfo,R=C.maximumHeight-C.minimumHeight,L=R/2,V=C.minimumHeight+R/2;C.minimumHeight=V-L,C.maximumHeight=V+L;break}return{box:OA(f),s2VolumeInfo:f}}}async function kA(e){const{subtree:t,subtreeData:r={level:0,x:0,y:0,z:0},parentData:n={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:a=0,implicitOptions:d,loaderOptions:f,s2VolumeBox:c}=e,{subdivisionScheme:T,subtreeLevels:C,maximumLevel:R,contentUrlTemplate:L,subtreesUriTemplate:V,basePath:X}=d,at={children:[],lodMetricValue:0,contentUrl:""};if(!R)return Mb.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${L} won't be loaded...`),at;const nt=n.localLevel+1,K=r.level+nt;if(K>R)return at;const It=x8[T],St=Math.log2(It),Ct=a&1,Ht=a>>1&1,Qt=a>>2&1,ee=cl(n.localX,Ct,1),ae=cl(n.localY,Ht,1),be=cl(n.localZ,Qt,1),ie=cl(r.x,ee,nt),le=cl(r.y,ae,nt),Ae=cl(r.z,be,nt),Fe=cl(n.mortonIndex,a,St),ze=nt===C&&jy(t.childSubtreeAvailability,Fe);let Ce,zr,ns,Hr;if(ze){const vi=`${X}/${V}`,xi=Hy(vi,K,ie,le,Ae);Ce=await Ko(xi,_A,f),Hr=0,zr={level:K,x:ie,y:le,z:Ae},ns={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else Ce=t,Hr=(It**nt-1)/(It-1)+Fe,zr=r,ns={mortonIndex:Fe,localLevel:nt,localX:ee,localY:ae,localZ:be};if(!jy(Ce.tileAvailability,Hr))return at;jy(Ce.contentAvailability,Hr)&&(at.contentUrl=Hy(L,K,ie,le,Ae));for(let vi=0;vi<It;vi++){const xi=w8(c,vi,T),li=await kA({subtree:Ce,subtreeData:zr,parentData:ns,childIndex:vi,implicitOptions:d,loaderOptions:f,s2VolumeBox:xi});(li.contentUrl||li.children.length)&&at.children.push(li)}return at.contentUrl||at.children.length?T8(at,{level:K,x:ie,y:le,z:Ae},d,c):at}function jy(e,t){let r;return Array.isArray(e)?(r=e[0],e.length>1&&Mb.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=e,"constant"in r?!!r.constant:r.explicitBitstream?S8(t,r.explicitBitstream):!1}function T8(e,t,r,n){const{basePath:a,refine:d,getRefine:f,lodMetricType:c,getTileType:T,rootLodMetricValue:C,rootBoundingVolume:R}=r,L=e.contentUrl&&e.contentUrl.replace(`${a}/`,""),V=C/2**t.level,X=n?.box?{box:n.box}:R,at=A8(X,t,r.subdivisionScheme);return{children:e.children,contentUrl:e.contentUrl,content:{uri:L},id:e.contentUrl,refine:f(d),type:T(e),lodMetricType:c,lodMetricValue:V,geometricError:V,transform:e.transform,boundingVolume:at}}function A8(e,t,r){if(e.region){const{level:n,x:a,y:d,z:f}=t,[c,T,C,R,L,V]=e.region,X=2**n,at=(C-c)/X,[nt,K]=[c+at*a,c+at*(a+1)],It=(R-T)/X,[St,Ct]=[T+It*d,T+It*(d+1)];let Ht,Qt;if(r==="OCTREE"){const ee=(V-L)/X;[Ht,Qt]=[L+ee*f,L+ee*(f+1)]}else[Ht,Qt]=[L,V];return{region:[nt,St,K,Ct,Ht,Qt]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}function cl(e,t,r){return(e<<r)+t}function Hy(e,t,r,n,a){const d=E8({level:t,x:r,y:n,z:a});return e.replace(/{level}|{x}|{y}|{z}/gi,f=>d[f])}function E8(e){const t={};for(const r in e)t[`{${r}}`]=e[r];return t}function S8(e,t){const r=Math.floor(e/8),n=e%8;return(t[r]>>n&1)===1}function Gy(e,t=""){if(!t)return Mo.EMPTY;const n=t.split("?")[0].split(".").pop();switch(n){case"pnts":return Mo.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Mo.SCENEGRAPH;default:return n||Mo.EMPTY}}function $y(e){switch(e){case"REPLACE":case"replace":return Rn.REPLACE;case"ADD":case"add":return Rn.ADD;default:return e}}function Wy(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const n=new URL(e,`${t}/`);return decodeURI(n.toString())}else if(e.startsWith("/"))return e;return e2(t,e)}function NA(e,t){if(!e)return null;let r;if(e.content){const a=e.content.uri||e.content?.url;typeof a<"u"&&(r=Wy(a,t))}return{...e,id:r,contentUrl:r,lodMetricType:kc.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Gy(e,r),refine:$y(e.refine)}}async function C8(e,t,r){let n=null;const a=UA(e.root);a&&e.root?n=await LA(e.root,e,t,a,r):n=NA(e.root,t);const d=[];for(d.push(n);d.length>0;){const f=d.pop()||{},c=f.children||[],T=[];for(const C of c){const R=UA(C);let L;R?L=await LA(C,e,t,R,r):L=NA(C,t),L&&(T.push(L),d.push(L))}f.children=T}return n}async function LA(e,t,r,n,a){const{subdivisionScheme:d,maximumLevel:f,availableLevels:c,subtreeLevels:T,subtrees:{uri:C}}=n,R=Hy(C,0,0,0,0),L=Wy(R,r),V=await Ko(L,_A,a),X=e.content?.uri,at=X?Wy(X,r):"",nt=t?.root?.refine,K=e.geometricError,It=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(It){const Qt={box:OA(It),s2VolumeInfo:It};e.boundingVolume=Qt}const St=e.boundingVolume,Ct={contentUrlTemplate:at,subtreesUriTemplate:C,subdivisionScheme:d,subtreeLevels:T,maximumLevel:Number.isFinite(c)?c-1:f,refine:nt,basePath:r,lodMetricType:kc.GEOMETRIC_ERROR,rootLodMetricValue:K,rootBoundingVolume:St,getTileType:Gy,getRefine:$y};return await I8(e,r,V,Ct,a)}async function I8(e,t,r,n,a){if(!e)return null;const{children:d,contentUrl:f}=await kA({subtree:r,implicitOptions:n,loaderOptions:a});let c,T=null;return f&&(c=f,T={uri:f.replace(`${t}/`,"")}),{...e,id:c,contentUrl:c,lodMetricType:kc.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Gy(e,c),refine:$y(e.refine),content:T||e.content,children:d}}function UA(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const zA={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:rA,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:M8,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function M8(e,t={},r){const n=t["3d-tiles"]||{};let a;return n.isTileset==="auto"?a=r?.url&&r.url.indexOf(".json")!==-1:a=n.isTileset,a?R8(e,t,r):P8(e,t,r)}async function R8(e,t,r){const n=JSON.parse(new TextDecoder().decode(e)),a=r?.url||"",d=B8(a),f=await C8(n,d,t||{});return{...n,shape:"tileset3d",loader:zA,url:a,queryString:r?.queryString||"",basePath:d,root:f||n.root,type:ms.TILES3D,lodMetricType:kc.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0}}async function P8(e,t,r){const n={content:{shape:"tile3d",featureIds:null}};return await fA(e,0,t,r,n.content),n.content}function B8(e){return ig(e)}const VA=[0],D8={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:zA,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,r)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}};class Xy extends Dw{initializeState(){"onTileLoadFail"in this.props&&Ye.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return!!(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({props:t,oldProps:r,changeFlags:n}){if(t.data&&t.data!==r.data&&this._loadTileset(t.data),n.viewportChanged){const{activeViewports:a}=this.state;Object.keys(a).length&&(this._updateTileset(a),this.state.lastUpdatedViewports=a,this.state.activeViewports={})}if(n.propsChanged){const{layerMap:a}=this.state;for(const d in a)a[d].needsUpdate=!0}}activateViewport(t){const{activeViewports:r,lastUpdatedViewports:n}=this.state;this.internalState.viewport=t,r[t.id]=t;const a=n?.[t.id];(!a||!t.equals(a))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:t,sourceLayer:r}){const n=r&&r.props.tile;return t.picked&&(t.object=n),t.sourceTile=n,t}filterSubLayer({layer:t,viewport:r}){const{tile:n}=t.props,{id:a}=r;return n.selected&&n.viewportIds.includes(a)}_updateAutoHighlight(t){const r=t.sourceTile,n=this.state.layerMap[r?.id];n&&n.layer&&n.layer.updateAutoHighlight(t)}async _loadTileset(t){const{loadOptions:r={}}=this.props,n=this.props.loader||this.props.loaders,a=Array.isArray(n)?n[0]:n,d={loadOptions:{...r}};let f=t;if(a.preload){const C=await a.preload(t,r);C.url&&(f=C.url),C.headers&&(d.loadOptions.fetch={...d.loadOptions.fetch,headers:C.headers}),Object.assign(d,C)}const c=await Ko(f,a,d.loadOptions),T=new g5(c,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...d});this.setState({tileset3d:T,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(T)}_onTileLoad(t){const{lastUpdatedViewports:r}=this.state;this.props.onTileLoad(t),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(t){delete this.state.layerMap[t.id],this.props.onTileUnload(t)}_updateTileset(t){if(!t)return;const{tileset3d:r}=this.state,{timeline:n}=this.context,a=Object.keys(t).length;!n||!a||!r||r.selectTiles(Object.values(t)).then(d=>{this.state.frameNumber!==d&&this.setState({frameNumber:d})})}_getSubLayer(t,r){if(!t.content)return null;switch(t.type){case Mo.POINTCLOUD:return this._makePointCloudLayer(t,r);case Mo.SCENEGRAPH:return this._make3DModelLayer(t);case Mo.MESH:return this._makeSimpleMeshLayer(t,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${t.content.type}`)}}_makePointCloudLayer(t,r){const{attributes:n,pointCount:a,constantRGBA:d,cartographicOrigin:f,modelMatrix:c}=t.content,{positions:T,normals:C,colors:R}=n;if(!T)return null;const L=r&&r.props.data||{header:{vertexCount:a},attributes:{POSITION:T,NORMAL:C,COLOR_0:R}},{pointSize:V,getPointColor:X}=this.props,at=this.getSubLayerClass("pointcloud",Zm);return new at({pointSize:V},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${t.id}`,tile:t,data:L,coordinateSystem:$e.METER_OFFSETS,coordinateOrigin:f,modelMatrix:c,getColor:d||X,_offset:0})}_make3DModelLayer(t){const{gltf:r,instances:n,cartographicOrigin:a,modelMatrix:d}=t.content,f=this.getSubLayerClass("scenegraph",yy);return new f({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${t.id}`,tile:t,data:n||VA,scenegraph:r,coordinateSystem:$e.METER_OFFSETS,coordinateOrigin:a,modelMatrix:d,getTransformMatrix:c=>c.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(t,r){const n=t.content,{attributes:a,indices:d,modelMatrix:f,cartographicOrigin:c,coordinateSystem:T=$e.METER_OFFSETS,material:C,featureIds:R}=n,{_getMeshColor:L}=this.props,V=r&&r.props.mesh||new gc({topology:"triangle-list",attributes:F8(a),indices:d}),X=this.getSubLayerClass("mesh",by);return new X(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${t.id}`,tile:t,mesh:V,data:VA,getColor:L(t),pbrMaterial:C,modelMatrix:f,coordinateOrigin:c,coordinateSystem:T,featureIds:R,_offset:0})}renderLayers(){const{tileset3d:t,layerMap:r}=this.state;return t?t.tiles.map(n=>{const a=r[n.id]=r[n.id]||{tile:n};let{layer:d}=a;return n.selected&&(d?a.needsUpdate&&(d=this._getSubLayer(n,d),a.needsUpdate=!1):d=this._getSubLayer(n)),a.layer=d,d}).filter(Boolean):null}}Xy.defaultProps=D8,Xy.layerName="Tile3DLayer";function F8(e){const t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}const qy=512,O8=Math.PI/180;function jA({map:e,gl:t,deck:r}){if(e.__deck)return e.__deck;const n=r?.props._customRender,a=r?.props.onLoad,d=$A({...r?.props,_customRender:()=>{e.triggerRepaint(),n?.("")}});let f;return(!r||r.props.gl===t)&&(Object.assign(d,{gl:t,width:null,height:null,touchAction:"unset",viewState:Uh(e)}),r?.isInitialized?HA(r,e):d.onLoad=()=>{a?.(),HA(f,e)}),r?(f=r,r.setProps(d),r.userData.isExternal=!0):(f=new Ch(d),e.on("remove",()=>{GA(e)})),f.userData.mapboxLayers=new Set,e.__deck=f,e.on("render",()=>{f.isInitialized&&V8(f,e)}),f}function HA(e,t){const r=()=>{e.isInitialized?j8(e,t):t.off("move",r)};t.on("move",r)}function GA(e){e.__deck?.finalize(),e.__deck=null}function $A(e){return{...e,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...e.parameters},views:e.views||[new bm({id:"mapbox"})]}}function k8(e,t){e.userData.mapboxLayers.add(t),Zy(e)}function N8(e,t){e.userData.mapboxLayers.delete(t),Zy(e)}function L8(e,t){Zy(e)}function U8(e,t,r){let{currentViewport:n}=e.userData,a=!1;n||(n=WA(e,t,!0),e.userData.currentViewport=n,a=!0),e.isInitialized&&e._drawLayers("mapbox-repaint",{viewports:[n],layerFilter:({layer:d})=>r.id===d.id||d.props.operation.includes("terrain"),clearStack:a,clearCanvas:!1})}function Uh(e){const{lng:t,lat:r}=e.getCenter(),n={longitude:(t+540)%360-180,latitude:r,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return e.getTerrain?.()&&z8(e,n),n}function z8(e,t){if(e.getFreeCameraOptions){const{position:r}=e.getFreeCameraOptions();if(!r||r.z===void 0)return;const n=e.transform.height,{longitude:a,latitude:d,pitch:f}=t,c=r.x*qy,T=(1-r.y)*qy,C=r.z*qy,R=hh([a,d]),L=c-R[0],V=T-R[1],X=Math.sqrt(L*L+V*V),at=f*O8,nt=1.5*n,K=at<.001?nt*Math.cos(at)/C:nt*Math.sin(at)/X;t.zoom=Math.log2(K);const It=nt*Math.cos(at)/K,St=C-It;t.position=[0,0,St/Df(d)]}else typeof e.transform.elevation=="number"&&(t.position=[0,0,e.transform.elevation])}function WA(e,t,r=!0){return new tl({id:"mapbox",x:0,y:0,width:e.width,height:e.height,...Uh(t),nearZMultiplier:r?.02:.1,nearZ:t.transform._nearZ/t.transform.height,farZ:t.transform._farZ/t.transform.height})}function V8(e,t){const{mapboxLayers:r,isExternal:n}=e.userData;if(n){const a=Array.from(r,R=>R.id),f=vc(e.props.layers,Boolean).some(R=>R&&!a.includes(R.id));let c=e.getViewports();const T=c.findIndex(R=>R.id==="mapbox"),C=c.length>1||T<0;(f||C)&&(T>=0&&(c=c.slice(),c[T]=WA(e,t,!1)),e._drawLayers("mapbox-repaint",{viewports:c,layerFilter:R=>(!e.props.layerFilter||e.props.layerFilter(R))&&(R.viewport.id!=="mapbox"||!a.includes(R.layer.id)),clearCanvas:!1}))}e.userData.currentViewport=null}function j8(e,t){e.setProps({viewState:Uh(t)}),e.needsRedraw({clearRedrawFlags:!0})}function Zy(e){if(e.userData.isExternal)return;const t=[];e.userData.mapboxLayers.forEach(r=>{const n=r.props.type,a=new n(r.props);t.push(a)}),e.setProps({layers:t})}class H8{constructor(t){if(!t.id)throw new Error("Layer must have an unique id");this.id=t.id,this.type="custom",this.renderingMode=t.renderingMode||"3d",this.map=null,this.deck=null,this.props=t}onAdd(t,r){this.map=t,this.deck=jA({map:t,gl:r,deck:this.props.deck}),k8(this.deck,this)}onRemove(){this.deck&&N8(this.deck,this)}setProps(t){Object.assign(this.props,t,{id:this.id}),this.deck&&L8(this.deck)}render(){U8(this.deck,this.map,this)}}const Yy="__UNDEFINED__";function wp(e,t,r,n){if(!e||!t||!e.style||!e.style._loaded)return;const a=vc(n,Boolean);if(r!==n){const c=vc(r,Boolean),T=new Set(c.map(C=>C.id));for(const C of a)T.delete(C.id);for(const C of T)e.getLayer(C)&&e.removeLayer(C)}for(const c of a){const T=e.getLayer(c.id);T?(T.implementation||T).setProps(c.props):e.addLayer(new H8({id:c.id,deck:t}),c.props.beforeId)}const d=e.style._order,f={};for(const c of a){let{beforeId:T}=c.props;(!T||!d.includes(T))&&(T=Yy),f[T]=f[T]||[],f[T].push(c.id)}for(const c in f){const T=f[c];let C=c===Yy?d.length:d.indexOf(c),R=c===Yy?void 0:c;for(let L=T.length-1;L>=0;L--){const V=T[L],X=d.indexOf(V);X!==C-1&&(e.moveLayer(V,R),X>C&&C++),C--,R=V}}}class G8{constructor(t){this._handleStyleChange=()=>{wp(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){const{clientWidth:a,clientHeight:d}=this._map.getContainer();Object.assign(this._container.style,{width:`${a}px`,height:`${d}px`})}},this._updateViewState=()=>{const a=this._deck;a&&(a.setProps({viewState:Uh(this._map)}),a.isInitialized&&a.redraw())},this._handleMouseEvent=a=>{const d=this._deck;if(!d||!d.isInitialized)return;const f={type:a.type,offsetCenter:a.point,srcEvent:a},c=this._lastMouseDownPoint;switch(!a.point&&c&&(f.deltaX=a.originalEvent.clientX-c.clientX,f.deltaY=a.originalEvent.clientY-c.clientY,f.offsetCenter={x:c.x+f.deltaX,y:c.y+f.deltaY}),f.type){case"mousedown":d._onPointerDown(f),this._lastMouseDownPoint={...a.point,clientX:a.originalEvent.clientX,clientY:a.originalEvent.clientY};break;case"dragstart":f.type="panstart",d._onEvent(f);break;case"drag":f.type="panmove",d._onEvent(f);break;case"dragend":f.type="panend",d._onEvent(f);break;case"click":f.tapCount=1,d._onEvent(f);break;case"dblclick":f.type="click",f.tapCount=2,d._onEvent(f);break;case"mousemove":f.type="pointermove",d._onPointerMove(f);break;case"mouseout":f.type="pointerleave",d._onPointerMove(f);break;default:return}};const{interleaved:r=!1,...n}=t;this._interleaved=r,this._props=n}setProps(t){this._interleaved&&t.layers&&wp(this._map,this._deck,this._props.layers,t.layers),Object.assign(this._props,t),this._deck&&this._deck.setProps(this._interleaved?$A(this._props):this._props)}onAdd(t){return this._map=t,this._interleaved?this._onAddInterleaved(t):this._onAddOverlaid(t)}_onAddOverlaid(t){const r=document.createElement("div");return Object.assign(r.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=r,this._deck=new Ch({...this._props,parent:r,viewState:Uh(t)}),t.on("resize",this._updateContainerSize),t.on("render",this._updateViewState),t.on("mousedown",this._handleMouseEvent),t.on("dragstart",this._handleMouseEvent),t.on("drag",this._handleMouseEvent),t.on("dragend",this._handleMouseEvent),t.on("mousemove",this._handleMouseEvent),t.on("mouseout",this._handleMouseEvent),t.on("click",this._handleMouseEvent),t.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(t){const r=t.painter.context.gl;return r instanceof WebGLRenderingContext&&Ye.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=jA({map:t,gl:r,deck:new Ch({...this._props,gl:r})}),t.on("styledata",this._handleStyleChange),wp(t,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){const t=this._map;t&&(this._interleaved?this._onRemoveInterleaved(t):this._onRemoveOverlaid(t)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(t){t.off("resize",this._updateContainerSize),t.off("render",this._updateViewState),t.off("mousedown",this._handleMouseEvent),t.off("dragstart",this._handleMouseEvent),t.off("drag",this._handleMouseEvent),t.off("dragend",this._handleMouseEvent),t.off("mousemove",this._handleMouseEvent),t.off("mouseout",this._handleMouseEvent),t.off("click",this._handleMouseEvent),t.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(t){t.off("styledata",this._handleStyleChange),wp(t,this._deck,this._props.layers,[]),GA(t)}getDefaultPosition(){return"top-left"}pickObject(t){return bi(this._deck),this._deck.pickObject(t)}pickMultipleObjects(t){return bi(this._deck),this._deck.pickMultipleObjects(t)}pickObjects(t){return bi(this._deck),this._deck.pickObjects(t)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}}class XA{olaMaps;apiKey;accessToken;mode;threedTileset;static Marker=Se.Marker;static Popup=Se.Popup;static NavigationControl=Se.NavigationControl;static GeolocateControl=Se.GeolocateControl;static ScaleControl=Se.ScaleControl;static FullscreenControl=Se.FullscreenControl;static AttributionControl=Se.AttributionControl;static TerrainControl=Se.TerrainControl;static LogoControl=Se.LogoControl;static GlobeControl=Se.GlobeControl;static LngLat=Se.LngLat;static LngLatBounds=Se.LngLatBounds;static Point=Se.Point;static MercatorCoordinate=Se.MercatorCoordinate;static GeoJSONSource=Se.GeoJSONSource;static VectorTileSource=Se.VectorTileSource;static RasterTileSource=Se.RasterTileSource;static RasterDEMTileSource=Se.RasterDEMTileSource;static ImageSource=Se.ImageSource;static VideoSource=Se.VideoSource;static CanvasSource=Se.CanvasSource;static MapMouseEvent=Se.MapMouseEvent;static MapTouchEvent=Se.MapTouchEvent;static MapWheelEvent=Se.MapWheelEvent;static AJAXError=Se.AJAXError;static BoxZoomHandler=Se.BoxZoomHandler;static CooperativeGesturesHandler=Se.CooperativeGesturesHandler;static DoubleClickZoomHandler=Se.DoubleClickZoomHandler;static DragPanHandler=Se.DragPanHandler;static DragRotateHandler=Se.DragRotateHandler;static KeyboardHandler=Se.KeyboardHandler;static ScrollZoomHandler=Se.ScrollZoomHandler;static TwoFingersTouchPitchHandler=Se.TwoFingersTouchPitchHandler;static TwoFingersTouchRotateHandler=Se.TwoFingersTouchRotateHandler;static TwoFingersTouchZoomHandler=Se.TwoFingersTouchZoomHandler;static TwoFingersTouchZoomRotateHandler=Se.TwoFingersTouchZoomRotateHandler;static EdgeInsets=Se.EdgeInsets;static Event=Se.Event;static Evented=Se.Evented;static Hash=Se.Hash;static Style=Se.Style;constructor({apiKey:t,accessToken:r="",mode:n="2d",threedTileset:a=_b}){this.apiKey=t,this.mode=n,this.threedTileset=a,this.accessToken=r}addOlaLogo(t){if(typeof window>"u")return;const r=document.getElementsByClassName("maplibregl-ctrl-bottom-left");let n="#000";t.style?.includes("dark")&&(n="#FFF");for(let a=0;a<r.length;a++){const d=document.createElement("div");d.style.position="absolute",d.style.bottom="4px",d.style.left="10px",d.style.zIndex="1000",d.innerHTML=gb(n),r[a].appendChild(d)}}addAttribution(t){const r=document.querySelectorAll(".maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-inner"),n=t?.style||"";r?.forEach(a=>{const d=a.querySelector("a");d&&(d.style.display="none");const f="ola-maps-link";if(!a.querySelector(`#${f}`)){const C=document.createElement("a");C.id=f,C.href="https://maps.olakrutrim.com/",C.target="_blank",C.textContent="Ola Maps ",a.appendChild(C)}const c="osm-link";if(!a.querySelector(`#${c}`)){const C=document.createElement("a");C.id=c,C.href="https://www.openstreetmap.org/copyright",C.target="_blank",C.textContent="| © OpenStreetMap contributors",a.appendChild(C)}const T="copernicus-attrib";if(n.includes("default_dark_standard_satellite")&&!a.querySelector(`#${T}`)){const C=document.createElement("span");C.id=T,C.textContent=" | Contains modified Copernicus Sentinel-2 data 2024",a.appendChild(C)}})}fetchStaticMap(t){try{return fetch(t).then(r=>r.blob())}catch(r){console.log(r)}}async add3dLayer(){if(!this.threedTileset)throw new Error("3d Tileset is not initialized");const t=new Xy({id:"tile-3d-layer",data:`${this.threedTileset}?api_key=${this.apiKey}`,beforeId:"poi_railway"}),r=new G8({interleaved:!0,layers:[t]});r&&this.olaMaps.on("style.load",()=>{this.olaMaps.setFilter("building-3d",["all",["!has","hide_3d"],["!=","render_as_3d",!0]]),this.olaMaps.addControl(r)})}init(t){this.olaMaps=new Se.Map({container:t?.container||"map",center:t?.center||[0,0],zoom:t?.zoom||9,hash:t?.hash||!1,style:t?.style||pb,transformRequest:(a,d)=>{if(this.accessToken)return{url:a,headers:{Authorization:`Bearer ${this.accessToken}`}};{const f=new URL(a);return d!=="Image"&&f.searchParams.append("api_key",this.apiKey),{url:f.toString()}}},...t}),this.mode==="3d"&&this.add3dLayer(),this.addOlaLogo(t),this.addAttribution({style:t?.style});const r={};return Object.getOwnPropertyNames(Se.Map.prototype).forEach(a=>{typeof this.olaMaps[a]=="function"&&(r[a]=this.olaMaps[a].bind(this.olaMaps))}),Object.keys(qu).forEach(a=>{typeof qu[a]=="function"?r[a]=(...d)=>new qu[a](...d):r[a]=qu[a]}),Object.getOwnPropertyNames(this.olaMaps).forEach(a=>{a in r||(r[a]=this.olaMaps[a])}),Object.assign(this.olaMaps,r)}addNavigationControls(t){return new Se.NavigationControl(t)}addGeolocateControls(t){return new Se.GeolocateControl(t)}getMercatorCoordinate(){return Se.MercatorCoordinate}addMarker(t){return new Se.Marker(t)}addPopup(t){return new Se.Popup(t)}getStaticMap(t,r){this.fetchStaticMap(t)?.then(a=>{const d=URL.createObjectURL(a),f=document.createElement("img");f.src=d;const c=document.getElementById(r);c&&!c.querySelector("img")?c?.appendChild(f):console.log("An image already exists in the element.")}).catch(a=>console.error(a))}}typeof window<"u"&&(window.OlaMaps=XA);const $8=Object.freeze(Object.defineProperty({__proto__:null,OlaMaps:XA},Symbol.toStringTag,{value:"Module"}));vn.OlaMaps=ps,vn.default3dTIleset=_b,vn.defaultStyleJson=pb,vn.getCookie=YS,vn.getOlaMapIcon=gb,vn.setCookie=KS,Object.defineProperty(vn,Symbol.toStringTag,{value:"Module"})}));
2404
+ `;function b6(e){const t=e.positions||e.POSITION,r=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}const v6={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};class by extends ty{getShaders(){const t=super.getShaders();return t.modules.push(Qg),{...t,vs:m6,fs:y6}}initializeState(){const{featureIds:t}=this.props;super.initializeState();const r=this.getAttributeManager();t&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(t){super.updateState(t);const{props:r,oldProps:n}=t;r.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(t){const{featureIds:r}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.uniforms.project_uCameraPosition,pickFeatureIds:!!r}),super.draw(t))}getModel(t){const{id:r,pbrMaterial:n}=this.props,a=this.parseMaterial(n,t);this.setState({parsedPBRMaterial:a});const d=this.getShaders();return b6(t.attributes),new ea(this.context.device,{...this.getShaders(),id:r,geometry:t,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...d.defines,...a?.defines,HAS_UV_REGIONS:t.attributes.uvRegions?1:0},parameters:a?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(t){const{model:r}=this.state;if(r){const{mesh:n}=this.props,a=this.parseMaterial(t,n);this.setState({parsedPBRMaterial:a}),r.setBindings(a.bindings),r.setUniforms(a.uniforms)}}parseMaterial(t,r){const n=!!(t.pbrMetallicRoughness&&t.pbrMetallicRoughness.baseColorTexture);return qw(this.context.device,{unlit:n,...t},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(t){const r=this.props.featureIds,n=new Uint8ClampedArray(r.length*t.size),a=[];for(let d=0;d<r.length;d++)this.encodePickingColor(r[d],a),n[d*3]=a[0],n[d*3+1]=a[1],n[d*3+2]=a[2];t.value=n}finalizeState(t){super.finalizeState(t),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}}by.layerName="MeshLayer",by.defaultProps=v6;const x6=6378137,w6=6378137,T6=6356752314245179e-9;function hp(e){return e}new Bt;function A6(e,t=[],r=hp){return"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):"x"in e?(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function E6(e,t=[]){return A6(e,t,yi._cartographicRadians?hp:fP)}function S6(e,t,r=hp){return"longitude"in t?(t.longitude=r(e[0]),t.latitude=r(e[1]),t.height=e[2]):"x"in t?(t.x=r(e[0]),t.y=r(e[1]),t.z=e[2]):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function C6(e,t){return S6(e,t,yi._cartographicRadians?hp:pP)}const MT=1e-14,I6=new Bt,RT={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"}},vy={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},kh={east:new Bt,north:new Bt,up:new Bt,west:new Bt,south:new Bt,down:new Bt},M6=new Bt,R6=new Bt,P6=new Bt;function PT(e,t,r,n,a,d){const f=RT[t]&&RT[t][r];Tn(f&&(!n||n===f));let c,T,C;const R=I6.copy(a);if(wn(R.x,0,MT)&&wn(R.y,0,MT)){const V=Math.sign(R.z);c=M6.fromArray(vy[t]),t!=="east"&&t!=="west"&&c.scale(V),T=R6.fromArray(vy[r]),r!=="east"&&r!=="west"&&T.scale(V),C=P6.fromArray(vy[n]),n!=="east"&&n!=="west"&&C.scale(V)}else{const{up:V,east:X,north:at}=kh;X.set(-R.y,R.x,0).normalize(),e.geodeticSurfaceNormal(R,V),at.copy(V).cross(X);const{down:nt,west:K,south:It}=kh;nt.copy(V).scale(-1),K.copy(X).scale(-1),It.copy(at).scale(-1),c=kh[t],T=kh[r],C=kh[n]}return d[0]=c.x,d[1]=c.y,d[2]=c.z,d[3]=0,d[4]=T.x,d[5]=T.y,d[6]=T.z,d[7]=0,d[8]=C.x,d[9]=C.y,d[10]=C.z,d[11]=0,d[12]=R.x,d[13]=R.y,d[14]=R.z,d[15]=1,d}const Fc=new Bt,B6=new Bt,D6=new Bt;function F6(e,t,r=[]){const{oneOverRadii:n,oneOverRadiiSquared:a,centerToleranceSquared:d}=t;Fc.from(e);const f=Fc.x,c=Fc.y,T=Fc.z,C=n.x,R=n.y,L=n.z,V=f*f*C*C,X=c*c*R*R,at=T*T*L*L,nt=V+X+at,K=Math.sqrt(1/nt);if(!Number.isFinite(K))return;const It=B6;if(It.copy(e).scale(K),nt<d)return It.to(r);const St=a.x,Ct=a.y,Ht=a.z,Qt=D6;Qt.set(It.x*St*2,It.y*Ct*2,It.z*Ht*2);let ee=(1-K)*Fc.len()/(.5*Qt.len()),ae=0,be,ie,le,Ae;do{ee-=ae,be=1/(1+ee*St),ie=1/(1+ee*Ct),le=1/(1+ee*Ht);const Fe=be*be,ze=ie*ie,Ce=le*le,zr=Fe*be,ns=ze*ie,Hr=Ce*le;Ae=V*Fe+X*ze+at*Ce-1;const Le=-2*(V*zr*St+X*ns*Ct+at*Hr*Ht);ae=Ae/Le}while(Math.abs(Ae)>D3);return Fc.scale([be,ie,le]).to(r)}const dp=new Bt,BT=new Bt,O6=new Bt,Mn=new Bt,k6=new Bt,fp=new Bt;class Er{constructor(t=0,r=0,n=0){this.centerToleranceSquared=B3,Tn(t>=0),Tn(r>=0),Tn(n>=0),this.radii=new Bt(t,r,n),this.radiiSquared=new Bt(t*t,r*r,n*n),this.radiiToTheFourth=new Bt(t*t*t*t,r*r*r*r,n*n*n*n),this.oneOverRadii=new Bt(t===0?0:1/t,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new Bt(t===0?0:1/(t*t),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(t,r,n),this.maximumRadius=Math.max(t,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||!!(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,r=[0,0,0]){const n=BT,a=O6,[,,d]=t;this.geodeticSurfaceNormalCartographic(t,n),a.copy(this.radiiSquared).scale(n);const f=Math.sqrt(n.dot(a));return a.scale(1/f),n.scale(d),a.add(n),a.to(r)}cartesianToCartographic(t,r=[0,0,0]){fp.from(t);const n=this.scaleToGeodeticSurface(fp,Mn);if(!n)return;const a=this.geodeticSurfaceNormal(n,BT),d=k6;d.copy(fp).subtract(n);const f=Math.atan2(a.y,a.x),c=Math.asin(a.z),T=Math.sign(Vg(d,fp))*yx(d);return C6([f,c,T],r)}eastNorthUpToFixedFrame(t,r=new He){return PT(this,"east","north","up",t,r)}localFrameToFixedFrame(t,r,n,a,d=new He){return PT(this,t,r,n,a,d)}geocentricSurfaceNormal(t,r=[0,0,0]){return dp.from(t).normalize().to(r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){const n=E6(t),a=n[0],d=n[1],f=Math.cos(d);return dp.set(f*Math.cos(a),f*Math.sin(a),Math.sin(d)).normalize(),dp.to(r)}geodeticSurfaceNormal(t,r=[0,0,0]){return dp.from(t).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(t,r){return F6(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){Mn.from(t);const n=Mn.x,a=Mn.y,d=Mn.z,f=this.oneOverRadiiSquared,c=1/Math.sqrt(n*n*f.x+a*a*f.y+d*d*f.z);return Mn.multiplyScalar(c).to(r)}transformPositionToScaledSpace(t,r=[0,0,0]){return Mn.from(t).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(t,r=[0,0,0]){return Mn.from(t).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(t,r=0,n=[0,0,0]){Tn(wn(this.radii.x,this.radii.y,Fx)),Tn(this.radii.z>0),Mn.from(t);const a=Mn.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(a)>=this.radii.z-r))return Mn.set(0,0,a).to(n)}}Er.WGS84=new Er(x6,w6,T6);class N6{item;previous;next;constructor(t,r,n){this.item=t,this.previous=r,this.next=n}}class L6{head=null;tail=null;_length=0;get length(){return this._length}add(t){const r=new N6(t,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,r){t!==r&&(this.remove(r),this._insert(t,r))}_insert(t,r){const n=t.next;t.next=r,this.tail===t?this.tail=r:n.previous=r,r.next=n,r.previous=t,++this._length}}class U6{_list;_sentinel;_trimTiles;constructor(){this._list=new L6,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){const r=t._cacheNode;r&&this._list.splice(this._sentinel,r)}add(t,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(t,r))}unloadTile(t,r,n){const a=r._cacheNode;a&&(this._list.remove(a),r._cacheNode=null,n&&n(t,r))}unloadTiles(t,r){const n=this._trimTiles;this._trimTiles=!1;const a=this._list,d=t.maximumMemoryUsage*1024*1024,f=this._sentinel;let c=a.head;for(;c!==f&&(t.gpuMemoryUsageInBytes>d||n);){const T=c.item;c=c.next,this.unloadTile(t,T,r)}}trim(){this._trimTiles=!0}}function z6(e,t){Ar(e),Ar(t);const{rtcCenter:r,gltfUpAxis:n}=t,{computedTransform:a,boundingVolume:{center:d}}=e;let f=new He(a);switch(r&&f.translate(r),n){case"Z":break;case"Y":const L=new He().rotateX(Math.PI/2);f=f.multiplyRight(L);break;case"X":const V=new He().rotateY(-Math.PI/2);f=f.multiplyRight(V);break}t.isQuantized&&f.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const c=new Bt(d);t.cartesianModelMatrix=f,t.cartesianOrigin=c;const T=Er.WGS84.cartesianToCartographic(c,new Bt),R=Er.WGS84.eastNorthUpToFixedFrame(c).invert();t.cartographicModelMatrix=R.multiplyRight(f),t.cartographicOrigin=T,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}const DT=new Bt,xy=new Bt,wy=new an([new so,new so,new so,new so,new so,new so]);function V6(e,t){const{cameraDirection:r,cameraUp:n,height:a}=e,{metersPerUnit:d}=e.distanceScales,f=pp(e,e.center),c=Er.WGS84.eastNorthUpToFixedFrame(f),T=e.unprojectPosition(e.cameraPosition),C=Er.WGS84.cartographicToCartesian(T,new Bt),R=new Bt(c.transformAsVector(new Bt(r).scale(d))).normalize(),L=new Bt(c.transformAsVector(new Bt(n).scale(d))).normalize();H6(e);const V=e.constructor,{longitude:X,latitude:at,width:nt,bearing:K,zoom:It}=e,St=new V({longitude:X,latitude:at,height:a,width:nt,bearing:K,zoom:It,pitch:0});return{camera:{position:C,direction:R,up:L},viewport:e,topDownViewport:St,height:a,cullingVolume:wy,frameNumber:t,sseDenominator:1.15}}function j6(e,t,r){if(r===0||e.length<=r)return[e,[]];const n=[],{longitude:a,latitude:d}=t.viewport;for(const[C,R]of e.entries()){const[L,V]=R.header.mbs,X=Math.abs(a-L),at=Math.abs(d-V),nt=Math.sqrt(at*at+X*X);n.push([C,nt])}const f=n.sort((C,R)=>C[1]-R[1]),c=[];for(let C=0;C<r;C++)c.push(e[f[C][0]]);const T=[];for(let C=r;C<f.length;C++)T.push(e[f[C][0]]);return[c,T]}function H6(e){const t=e.getFrustumPlanes(),r=FT(t.near,e.cameraPosition),n=pp(e,r),a=pp(e,e.cameraPosition,xy);let d=0;wy.planes[d++].fromPointNormal(n,DT.copy(n).subtract(a));for(const f in t){if(f==="near")continue;const c=t[f],T=FT(c,r,xy),C=pp(e,T,xy);wy.planes[d++].fromPointNormal(C,DT.copy(n).subtract(C))}}function FT(e,t,r=new Bt){const n=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-n).add(t),r}function pp(e,t,r=new Bt){const n=e.unprojectPosition(t);return Er.WGS84.cartographicToCartesian(n,r)}const G6=6378137,$6=6378137,Ty=6356752314245179e-9,Oc=new Bt;function W6(e,t){if(e instanceof Ph){const{halfAxes:r}=e,n=q6(r);return Math.log2(Ty/(n+t[2]))}else if(e instanceof Rh){const{radius:r}=e;return Math.log2(Ty/(r+t[2]))}else if(e.width&&e.height){const{width:r,height:n}=e,a=Math.log2(G6/r),d=Math.log2($6/n);return(a+d)/2}return 1}function OT(e,t,r){Er.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],Oc);const n=Math.sqrt(Math.pow(Oc[0]-r[0],2)+Math.pow(Oc[1]-r[1],2)+Math.pow(Oc[2]-r[2],2));return Math.log2(Ty/(n+t[2]))}function X6(e,t,r){const[n,a,d,f]=e;return OT({xmax:d,ymax:f,zmax:0},t,r)}function q6(e){e.getColumn(0,Oc);const t=e.getColumn(1),r=e.getColumn(2);return Oc.add(t).add(r).len()}const Ds={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5};var Rn;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(Rn||(Rn={}));var Mo;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(Mo||(Mo={}));var ms;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(ms||(ms={}));var kc;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(kc||(kc={}));const Z6={USE_OPTIMIZATION:1};function kT(e){return e!=null}const Ji=new Bt,_p=new Bt,Y6=new Bt,K6=new Bt,al=new Bt,NT=new Bt,LT=new Bt,UT=new Bt;function Ay(e,t,r){if(Ar(e,"3D Tile: boundingVolume must be defined"),e.box)return zT(e.box,t,r);if(e.region)return t5(e.region);if(e.sphere)return Q6(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function J6(e,t){if(e.box)return e5(t);if(e.region){const[r,n,a,d,f,c]=e.region;return[[xn(r),xn(n),f],[xn(a),xn(d),c]]}if(e.sphere)return r5(t);throw new Error("Unkown boundingVolume type")}function zT(e,t,r){const n=new Bt(e[0],e[1],e[2]);t.transform(n,n);let a=[];if(e.length===10){const C=e.slice(3,6),R=new ch;R.fromArray(e,6);const L=new Bt([1,0,0]),V=new Bt([0,1,0]),X=new Bt([0,0,1]);L.transformByQuaternion(R),L.scale(C[0]),V.transformByQuaternion(R),V.scale(C[1]),X.transformByQuaternion(R),X.scale(C[2]),a=[...L.toArray(),...V.toArray(),...X.toArray()]}else a=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const d=t.transformAsVector(a.slice(0,3)),f=t.transformAsVector(a.slice(3,6)),c=t.transformAsVector(a.slice(6,9)),T=new Xr([d[0],d[1],d[2],f[0],f[1],f[2],c[0],c[1],c[2]]);return kT(r)?(r.center=n,r.halfAxes=T,r):new Ph(n,T)}function Q6(e,t,r){const n=new Bt(e[0],e[1],e[2]);t.transform(n,n);const a=t.getScale(_p),d=Math.max(Math.max(a[0],a[1]),a[2]),f=e[3]*d;return kT(r)?(r.center=n,r.radius=f,r):new Rh(n,f)}function t5(e){const[t,r,n,a,d,f]=e,c=Er.WGS84.cartographicToCartesian([xn(t),xn(a),d],Y6),T=Er.WGS84.cartographicToCartesian([xn(n),xn(r),f],K6),C=new Bt().addVectors(c,T).multiplyByScalar(.5);return Er.WGS84.cartesianToCartographic(C,al),Er.WGS84.cartographicToCartesian([xn(n),al[1],al[2]],NT),Er.WGS84.cartographicToCartesian([al[0],xn(a),al[2]],LT),Er.WGS84.cartographicToCartesian([al[0],al[1],f],UT),zT([...C,...NT.subtract(C),...LT.subtract(C),...UT.subtract(C)],new He)}function e5(e){const t=VT(),{halfAxes:r}=e,n=new Bt(r.getColumn(0)),a=new Bt(r.getColumn(1)),d=new Bt(r.getColumn(2));for(let f=0;f<2;f++){for(let c=0;c<2;c++){for(let T=0;T<2;T++)Ji.copy(e.center),Ji.add(n),Ji.add(a),Ji.add(d),jT(t,Ji),d.negate();a.negate()}n.negate()}return t}function r5(e){const t=VT(),{center:r,radius:n}=e,a=Er.WGS84.scaleToGeodeticSurface(r,Ji);let d;a?d=Er.WGS84.geodeticSurfaceNormal(a):d=new Bt(0,0,1);let f=new Bt(d[2],-d[1],0);f.len()>0?f.normalize():f=new Bt(0,1,0);const c=f.clone().cross(d);for(const T of[f,c,d]){_p.copy(T).scale(n);for(let C=0;C<2;C++)Ji.copy(r),Ji.add(_p),jT(t,Ji),_p.negate()}return t}function VT(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function jT(e,t){Er.WGS84.cartesianToCartographic(t,Ji),e[0][0]=Math.min(e[0][0],Ji[0]),e[0][1]=Math.min(e[0][1],Ji[1]),e[0][2]=Math.min(e[0][2],Ji[2]),e[1][0]=Math.max(e[1][0],Ji[0]),e[1][1]=Math.max(e[1][1],Ji[1]),e[1][2]=Math.max(e[1][2],Ji[2])}new Bt,new Bt,new He,new Bt,new Bt,new Bt;function i5(e,t){const r=e*t;return 1-Math.exp(-(r*r))}function s5(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const r=e.dynamicScreenSpaceErrorComputedDensity,n=e.dynamicScreenSpaceErrorFactor;return i5(t,r)*n}return 0}function n5(e,t,r){const n=e.tileset,a=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,d=r?a:e.lodMetricValue;if(d===0)return 0;const f=Math.max(e._distanceToCamera,1e-7),{height:c,sseDenominator:T}=t,{viewDistanceScale:C}=n.options;let R=d*c*(C||1)/(f*T);return R-=s5(n,f),R}const Ey=new Bt,HT=new Bt,pa=new Bt,GT=new Bt,o5=new Bt,Sy=new He,$T=new He;function a5(e,t){if(e.lodMetricValue===0||isNaN(e.lodMetricValue))return"DIG";const r=2*WT(e,t);return r<2?"OUT":!e.header.children||r<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}function WT(e,t){const{topDownViewport:r}=t,n=e.header.mbs[1],a=e.header.mbs[0],d=e.header.mbs[2],f=e.header.mbs[3],c=[...e.boundingVolume.center],T=r.unprojectPosition(r.cameraPosition);Er.WGS84.cartographicToCartesian(T,Ey),HT.copy(Ey).subtract(c).normalize(),Er.WGS84.eastNorthUpToFixedFrame(c,Sy),$T.copy(Sy).invert(),pa.copy(Ey).transform($T);const C=Math.sqrt(pa[0]*pa[0]+pa[1]*pa[1]),R=C*C/pa[2];GT.copy([pa[0],pa[1],R]);const V=GT.transform(Sy).subtract(c).normalize(),at=HT.cross(V).normalize().scale(f).add(c),nt=Er.WGS84.cartesianToCartographic(at),K=r.project([a,n,d]),It=r.project(nt);return o5.copy(K).subtract(It).magnitude()}function l5(e){return{assetGltfUpAxis:e.asset&&e.asset.gltfUpAxis||"Y"}}class XT{_map=new Map;_array;_length;constructor(t=0){this._array=new Array(t),this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return Ar(t<this._array.length),this._array[t]}set(t,r){Ar(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=r,this._map.set(r,t)}delete(t){const r=this._map.get(t);r>=0&&(this._array.splice(r,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){const r=this.length++;this._array[r]=t,this._map.set(t,r)}}pop(){const t=this._array[--this.length];return this._map.delete(t),t}reserve(t){Ar(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){Ar(t>=0),this.length=t}trim(t){t==null&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}}const c5={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class gp{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new XT;_emptyTraversalStack=new XT;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...c5,...t}}traverse(t,r,n){this.root=t,this.options={...this.options,...n},this.reset(),this.updateTile(t,r),this._frameNumber=r.frameNumber,this.executeTraversal(t,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,r){const n=this._traversalStack;for(t._selectionDepth=1,n.push(t);n.length>0;){const d=n.pop();let f=!1;this.canTraverse(d,r)&&(this.updateChildTiles(d,r),f=this.updateAndPushChildren(d,r,n,d.hasRenderContent?d._selectionDepth+1:d._selectionDepth));const c=d.parent,T=!!(!c||c._shouldRefine),C=!f;d.hasRenderContent?d.refine===Rn.ADD?(this.loadTile(d,r),this.selectTile(d,r)):d.refine===Rn.REPLACE&&(this.loadTile(d,r),C&&this.selectTile(d,r)):(this.emptyTiles[d.id]=d,this.loadTile(d,r),C&&this.selectTile(d,r)),this.touchTile(d,r),d._shouldRefine=f&&T}const a=new Date().getTime();(this.traversalFinished(r)||a-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=a,this.options.onTraversalEnd(r))}updateChildTiles(t,r){const n=t.children;for(const a of n)this.updateTile(a,r)}updateAndPushChildren(t,r,n,a){const{loadSiblings:d,skipLevelOfDetail:f}=this.options,c=t.children;c.sort(this.compareDistanceToCamera.bind(this));const T=t.refine===Rn.REPLACE&&t.hasRenderContent&&!f;let C=!1,R=!0;for(const L of c)if(L._selectionDepth=a,L.isVisibleAndInRequestVolume?(n.find(L)&&n.delete(L),n.push(L),C=!0):(T||d)&&(this.loadTile(L,r),this.touchTile(L,r)),T){let V;if(L._inRequestVolume?L.hasRenderContent?V=L.contentAvailable:V=this.executeEmptyTraversal(L,r):V=!1,R=R&&V,!R)return!1}return C||(R=!1),R}updateTile(t,r){this.updateTileVisibility(t,r)}selectTile(t,r){this.shouldSelectTile(t)&&(t._selectedFrame=r.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,r){this.shouldLoadTile(t)&&(t._requestedFrame=r.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,r){t.tileset._cache.touch(t),t._touchedFrame=r.frameNumber}canTraverse(t,r){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:this.shouldRefine(t,r):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,r,n=!1){let a=t._screenSpaceError;return n&&(a=t.getScreenSpaceError(r,!0)),a>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,r){const n=[];if(this.options.viewportTraversersMap)for(const a in this.options.viewportTraversersMap)this.options.viewportTraversersMap[a]===r.viewport.id&&n.push(a);else n.push(r.viewport.id);t.updateVisibility(r,n)}compareDistanceToCamera(t,r){return t._distanceToCamera-r._distanceToCamera}anyChildrenVisible(t,r){let n=!1;for(const a of t.children)a.updateVisibility(r),n=n||a.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(t,r){let n=!0;const a=this._emptyTraversalStack;for(a.push(t);a.length>0;){const d=a.pop(),f=!d.hasRenderContent&&this.canTraverse(d,r),c=!d.hasRenderContent&&d.children.length===0;if(!f&&!d.contentAvailable&&!c&&(n=!1),this.updateTile(d,r),d.isVisibleAndInRequestVolume||(this.loadTile(d,r),this.touchTile(d,r)),f){const T=d.children;for(const C of T)a.push(C)}}return n}}const qT=new Bt;function u5(e){return e!=null}class Cy{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Ds.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new He;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new gp({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new He;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(t,r,n,a=""){this.header=r,this.tileset=t,this.id=a||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===Ds.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===Ds.UNLOADED}get contentExpired(){return this.contentState===Ds.EXPIRED}get contentFailed(){return this.contentState===Ds.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=J6(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,r){switch(this.tileset.type){case ms.I3S:return WT(this,t);case ms.TILES3D:return n5(this,t,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){const t=this.tileset._traverser,{skipLevelOfDetail:r}=t.options,n=this.refine===Rn.ADD||r;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Ds.UNLOADED)return-1;const a=this.parent,f=a&&(!n||this._screenSpaceError===0||a.hasTilesetContent)?a._screenSpaceError:this._screenSpaceError,c=t.root?t.root._screenSpaceError:0;return Math.max(c-f,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Ds.LOADING;const r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Ds.UNLOADED,!1;try{const n=this.tileset.getTileUrl(this.contentUrl),a=this.tileset.loader,d={...this.tileset.loadOptions,[a.id]:{...this.tileset.loadOptions[a.id],isTileset:this.type==="json",...this._getLoaderSpecificOptions(a.id)}};return this.content=await Ko(n,a,d),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Ds.READY,this._onContentLoaded(),!0}catch(n){throw this.contentState=Ds.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=Ds.UNLOADED,!0}updateVisibility(t,r){if(this._frameNumber===t.frameNumber)return;const n=this.parent,a=n?n._visibilityPlaneMask:an.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const d=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(d)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,a),this._visible=this._visibilityPlaneMask!==an.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=r}visibility(t,r){const{cullingVolume:n}=t,{boundingVolume:a}=this;return n.computeVisibilityWithPlaneMask(a,r)}contentVisibility(){return!0}distanceToTile(t){const r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){const r=this.boundingVolume;return qT.subVectors(r.center,t.position),t.direction.dot(qT)}insideViewerRequestVolume(t){const r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(u5(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){const t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=Ds.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){"lodMetricType"in t?this.lodMetricType=t.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 t?this.lodMetricValue=t.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(t){this.transform=t.transform?new He(t.transform):new He;const r=this.parent,n=this.tileset,a=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new He(a).multiplyRight(this.transform);const d=r&&r._initialTransform?r._initialTransform.clone():new He;this._initialTransform=new He(d).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Ds.UNLOADED,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=an.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(t){return t||this.parent&&this.parent.refine||Rn.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}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(t){this.boundingVolume=Ay(t.boundingVolume,this.computedTransform,this.boundingVolume);const r=t.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=Ay(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=Ay(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(t=new He){const r=t.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){switch(t){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 l5(this.tileset.tileset)}}}class h5 extends gp{compareDistanceToCamera(t,r){return r._distanceToCamera===0&&t._distanceToCamera===0?r._centerZDepth-t._centerZDepth:r._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,r){if(super.updateTileVisibility(t,r),!t.isVisibleAndInRequestVolume)return;const n=t.children.length>0;if(t.hasTilesetContent&&n){const f=t.children[0];this.updateTileVisibility(f,r),t._visible=f._visible;return}if(this.meetsScreenSpaceErrorEarly(t,r)){t._visible=!1;return}const a=t.refine===Rn.REPLACE,d=t._optimChildrenWithinParent===Z6.USE_OPTIMIZATION;if(a&&d&&n&&!this.anyChildrenVisible(t,r)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,r){const{parent:n}=t;return!n||n.hasTilesetContent||n.refine!==Rn.ADD?!1:!this.shouldRefine(t,r,!0)}}class d5{frameNumberMap=new Map;register(t,r){const n=this.frameNumberMap.get(t)||new Map,a=n.get(r)||0;n.set(r,a+1),this.frameNumberMap.set(t,n)}deregister(t,r){const n=this.frameNumberMap.get(t);if(!n)return;const a=n.get(r)||1;n.set(r,a-1)}isZero(t,r){return(this.frameNumberMap.get(t)?.get(r)||0)===0}}const Iy={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"};class f5{_statusMap;pendingTilesRegister=new d5;constructor(){this._statusMap={}}add(t,r,n,a){if(!this._statusMap[r]){const{frameNumber:d,viewport:{id:f}}=a;this._statusMap[r]={request:t,callback:n,key:r,frameState:a,status:Iy.REQUESTED},this.pendingTilesRegister.register(f,d),t().then(c=>{this._statusMap[r].status=Iy.COMPLETED;const{frameNumber:T,viewport:{id:C}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(C,T),this._statusMap[r].callback(c,a)}).catch(c=>{this._statusMap[r].status=Iy.ERROR;const{frameNumber:T,viewport:{id:C}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(C,T),n(c)})}}update(t,r){if(this._statusMap[t]){const{frameNumber:n,viewport:{id:a}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(a,n);const{frameNumber:d,viewport:{id:f}}=r;this.pendingTilesRegister.register(f,d),this._statusMap[t].frameState=r}}find(t){return this._statusMap[t]}hasPendingTiles(t,r){return!this.pendingTilesRegister.isZero(t,r)}}class p5 extends gp{_tileManager;constructor(t){super(t),this._tileManager=new f5}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,r){return t._lodJudge=a5(t,r),t._lodJudge==="DIG"}updateChildTiles(t,r){const n=t.header.children||[],a=t.children,d=t.tileset;for(const f of n){const c=`${f.id}-${r.viewport.id}`,T=a&&a.find(C=>C.id===c);if(T)T&&this.updateTile(T,r);else{let C=()=>this._loadTile(f.id,d);this._tileManager.find(c)?this._tileManager.update(c,r):(d.tileset.nodePages&&(C=()=>d.tileset.nodePagesTile.formTileFromNodePages(f.id)),this._tileManager.add(C,c,L=>this._onTileLoad(L,t,c),r))}}return!1}async _loadTile(t,r){const{loader:n}=r,a=r.getTileUrl(`${r.url}/nodes/${t}`),d={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await Ko(a,n,d)}_onTileLoad(t,r,n){const a=new Cy(r.tileset,t,r,n);r.children.push(a);const d=this._tileManager.find(a.id).frameState;this.updateTile(a,d),this._frameNumber===d.frameNumber&&(this.traversalFinished(d)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(a,d)}}const _5={description:"",ellipsoid:Er.WGS84,modelMatrix:new He,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},mp="Tiles In Tileset(s)",My="Tiles In Memory",ZT="Tiles In View",YT="Tiles To Render",KT="Tiles Loaded",Ry="Tiles Loading",JT="Tiles Unloaded",QT="Failed Tile Loads",tA="Points/Vertices",Py="Tile Memory Use",eA="Maximum Screen Space Error";class g5{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 U6;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(t,r){this.options={..._5,...r},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||ig(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new YC({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 sc({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(t)}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(t){this.options={...this.options,...t}}getTileUrl(t){if(t.startsWith("data:"))return t;let n=t;return this.queryParams.length&&(n=`${t}${t.includes("?")?"&":"?"}${this.queryParams}`),n}hasExtension(t){return this._extensionsUsed.indexOf(t)>-1}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),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(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;const r=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;const n=[];for(const a of r){const d=a.id;this._needTraverse(d)?n.push(d):this.traverseCounter--}for(const a of r){const d=a.id;if(this.roots[d]||(this.roots[d]=this._initializeTileHeaders(this.tileset,null)),!n.includes(d))continue;const f=V6(a,this._frameNumber);this._traverser.traverse(this.roots[d],f,this.options)}}_needTraverse(t){let r=t;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[t]),r===t}_onTraversalEnd(t){const r=t.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const n=this.frameStateData[r],a=Object.values(this._traverser.selectedTiles),[d,f]=j6(a,t,this.options.maximumTilesSelected);n.selectedTiles=d;for(const c of f)c.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const t in this.frameStateData){const r=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(r.selectedTiles),this._requestedTiles=this._requestedTiles.concat(r._requestedTiles),this._emptyTiles=this._emptyTiles.concat(r._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,r){if(t.length!==r.length)return!0;const n=new Set(t.map(f=>f.id)),a=new Set(r.map(f=>f.id));let d=t.filter(f=>!a.has(f.id)).length>0;return d=d||r.filter(f=>!n.has(f.id)).length>0,d}_loadTiles(){for(const t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,r)=>t._unloadTile(r))}_updateStats(){let t=0,r=0;for(const n of this.selectedTiles)n.contentAvailable&&n.content&&(t++,n.content.pointCount?r+=n.content.pointCount:r+=n.content.vertexCount);this.stats.get(ZT).count=this.selectedTiles.length,this.stats.get(YT).count=t,this.stats.get(tA).count=r,this.stats.get(eA).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(t){this.type===ms.I3S&&(this.calculateViewPropsI3S(),t.root=await t.root),this.root=this._initializeTileHeaders(t,null),this.type===ms.TILES3D&&(this._initializeTiles3DTileset(t),this.calculateViewPropsTiles3D()),this.type===ms.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){const t=this.tileset.fullExtent;if(t){const{xmin:n,xmax:a,ymin:d,ymax:f,zmin:c,zmax:T}=t;this.cartographicCenter=new Bt(n+(a-n)/2,d+(f-d)/2,c+(T-c)/2),this.cartesianCenter=new Bt,Er.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=OT(t,this.cartographicCenter,this.cartesianCenter);return}const r=this.tileset.store?.extent;if(r){const[n,a,d,f]=r;this.cartographicCenter=new Bt(n+(d-n)/2,a+(f-a)/2,0),this.cartesianCenter=new Bt,Er.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=X6(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new Bt,this.zoom=1}calculateViewPropsTiles3D(){const t=this.root,{center:r}=t.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new Bt,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new Bt,Er.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new Bt(0,0,-Er.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=W6(t.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(mp),this.stats.get(Ry),this.stats.get(My),this.stats.get(ZT),this.stats.get(YT),this.stats.get(KT),this.stats.get(JT),this.stats.get(QT),this.stats.get(tA),this.stats.get(Py,"memory"),this.stats.get(eA)}_initializeTileHeaders(t,r){const n=new Cy(this,t.root,r);if(r&&(r.children.push(n),n.depth=r.depth+1),this.type===ms.TILES3D){const a=[];for(a.push(n);a.length>0;){const d=a.pop();this.stats.get(mp).incrementCount();const f=d.header.children||[];for(const c of f){const T=new Cy(this,c,d);if(T.contentUrl?.includes("?session=")){const R=new URL(T.contentUrl).searchParams.get("session");R&&(this._queryParams.session=R)}d.children.push(T),T.depth=d.depth+1,a.push(T)}}}return n}_initializeTraverser(){let t;switch(this.type){case ms.TILES3D:t=h5;break;case ms.I3S:t=p5;break;default:t=gp}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let r;try{this._onStartTileLoading(),r=await t.loadContent()}catch(n){this._onTileLoadError(t,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}_onTileLoadError(t,r){this.stats.get(QT).incrementCount();const n=r.message||r.toString(),a=t.url;console.error(`A 3D tile failed to load: ${t.url} ${n}`),this.options.onTileError(t,n,a)}_onTileLoad(t,r){if(r){if(this.type===ms.I3S){const n=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(mp).reset(),this.stats.get(mp).addCount(n)}t&&t.content&&z6(t,t.content),this.updateContentTypes(t),this._addTileToCache(t),this.options.onTileLoad(t)}}updateContentTypes(t){if(this.type===ms.I3S)switch(t.header.isDracoGeometry&&(this.contentFormats.draco=!0),t.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break}else if(this.type===ms.TILES3D){const{extensionsRemoved:r=[]}=t.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(Ry).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Ry).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(KT).incrementCount(),this.stats.get(My).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(Py).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(My).decrementCount(),this.stats.get(JT).incrementCount(),this.stats.get(Py).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){const t=[];for(this.root&&t.push(this.root);t.length>0;){const r=t.pop();for(const n of r.children)t.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(t){const r=t,n=[];for(n.push(r);n.length>0;){t=n.pop();for(const a of t.children)n.push(a);t!==r&&this._destroyTile(t)}r.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeTiles3DTileset(t){if(t.queryString){const r=new URLSearchParams(t.queryString),n=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=t.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=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed||[],this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const rA="4.3.1",Nh={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GLTF:"glTF"};function iA(e,t,r){Ar(e instanceof ArrayBuffer);const n=new TextDecoder("utf8"),a=new Uint8Array(e,t,r);return n.decode(a)}function m5(e,t=0){const r=new DataView(e);return`${String.fromCharCode(r.getUint8(t+0))}${String.fromCharCode(r.getUint8(t+1))}${String.fromCharCode(r.getUint8(t+2))}${String.fromCharCode(r.getUint8(t+3))}`}const y5={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ai={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Ze={...y5,...ai},By={[ai.DOUBLE]:Float64Array,[ai.FLOAT]:Float32Array,[ai.UNSIGNED_SHORT]:Uint16Array,[ai.UNSIGNED_INT]:Uint32Array,[ai.UNSIGNED_BYTE]:Uint8Array,[ai.BYTE]:Int8Array,[ai.SHORT]:Int16Array,[ai.INT]:Int32Array},b5={DOUBLE:ai.DOUBLE,FLOAT:ai.FLOAT,UNSIGNED_SHORT:ai.UNSIGNED_SHORT,UNSIGNED_INT:ai.UNSIGNED_INT,UNSIGNED_BYTE:ai.UNSIGNED_BYTE,BYTE:ai.BYTE,SHORT:ai.SHORT,INT:ai.INT},Dy="Failed to convert GL type";class oo{static fromTypedArray(t){t=ArrayBuffer.isView(t)?t.constructor:t;for(const r in By)if(By[r]===t)return r;throw new Error(Dy)}static fromName(t){const r=b5[t];if(!r)throw new Error(Dy);return r}static getArrayType(t){switch(t){case ai.UNSIGNED_SHORT_5_6_5:case ai.UNSIGNED_SHORT_4_4_4_4:case ai.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const r=By[t];if(!r)throw new Error(Dy);return r}}static getByteSize(t){return oo.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return!!oo.getArrayType(t)}static createTypedArray(t,r,n=0,a){a===void 0&&(a=(r.byteLength-n)/oo.getByteSize(t));const d=oo.getArrayType(t);return new d(r,n,a)}}function v5(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}function x5(e,t=[0,0,0]){const r=e>>11&31,n=e>>5&63,a=e&31;return t[0]=r<<3,t[1]=n<<2,t[2]=a<<3,t}new zg,new Bt,new zg,new zg;function sA(e,t=255){return Eo(e,0,t)/t*2-1}function nA(e){return e<0?-1:1}function w5(e,t,r,n){if(v5(n),e<0||e>r||t<0||t>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(n.x=sA(e,r),n.y=sA(t,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){const a=n.x;n.x=(1-Math.abs(n.y))*nA(a),n.y=(1-Math.abs(a))*nA(n.y)}return n.normalize()}function T5(e,t,r){return w5(e,t,255,r)}class Fy{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(t,r){this.json=t,this.buffer=r}getExtension(t){return this.json.extensions&&this.json.extensions[t]}hasProperty(t){return!!this.json[t]}getGlobalProperty(t,r=Ze.UNSIGNED_INT,n=1){const a=this.json[t];return a&&Number.isFinite(a.byteOffset)?this._getTypedArrayFromBinary(t,r,n,1,a.byteOffset):a}getPropertyArray(t,r,n){const a=this.json[t];return a&&Number.isFinite(a.byteOffset)?("componentType"in a&&(r=oo.fromName(a.componentType)),this._getTypedArrayFromBinary(t,r,n,this.featuresLength,a.byteOffset)):this._getTypedArrayFromArray(t,r,a)}getProperty(t,r,n,a,d){const f=this.json[t];if(!f)return f;const c=this.getPropertyArray(t,r,n);if(n===1)return c[a];for(let T=0;T<n;++T)d[T]=c[n*a+T];return d}_getTypedArrayFromBinary(t,r,n,a,d){const f=this._cachedTypedArrays;let c=f[t];return c||(c=oo.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+d,a*n),f[t]=c),c}_getTypedArrayFromArray(t,r,n){const a=this._cachedTypedArrays;let d=a[t];return d||(d=oo.createTypedArray(r,n),a[t]=d),d}}const A5={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},E5={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},S5={SCALAR:(e,t,r)=>{t[r]=e},VEC2:(e,t,r)=>{t[2*r+0]=e[0],t[2*r+1]=e[1]},VEC3:(e,t,r)=>{t[3*r+0]=e[0],t[3*r+1]=e[1],t[3*r+2]=e[2]},VEC4:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT2:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT3:(e,t,r)=>{t[9*r+0]=e[0],t[9*r+1]=e[1],t[9*r+2]=e[2],t[9*r+3]=e[3],t[9*r+4]=e[4],t[9*r+5]=e[5],t[9*r+6]=e[6],t[9*r+7]=e[7],t[9*r+8]=e[8],t[9*r+9]=e[9]},MAT4:(e,t,r)=>{t[16*r+0]=e[0],t[16*r+1]=e[1],t[16*r+2]=e[2],t[16*r+3]=e[3],t[16*r+4]=e[4],t[16*r+5]=e[5],t[16*r+6]=e[6],t[16*r+7]=e[7],t[16*r+8]=e[8],t[16*r+9]=e[9],t[16*r+10]=e[10],t[16*r+11]=e[11],t[16*r+12]=e[12],t[16*r+13]=e[13],t[16*r+14]=e[14],t[16*r+15]=e[15]}};function C5(e,t,r,n){const{componentType:a}=e;Ar(e.componentType);const d=typeof a=="string"?oo.fromName(a):a,f=A5[e.type],c=E5[e.type],T=S5[e.type];return r+=e.byteOffset,{values:oo.createTypedArray(d,t,r,f*n),type:d,size:f,unpacker:c,packer:T}}const ao=e=>e!==void 0;function I5(e,t,r){if(!t)return null;let n=e.getExtension("3DTILES_batch_table_hierarchy");const a=t.HIERARCHY;return a&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=a,n=a),n?M5(n,r):null}function M5(e,t){let r,n,a;const d=e.instancesLength,f=e.classes;let c=e.classIds,T=e.parentCounts,C=e.parentIds,R=d;ao(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,a=getBinaryAccessor(c),c=a.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,d));let L;if(ao(T))for(ao(T.byteOffset)&&(T.componentType=defaultValue(T.componentType,GL.UNSIGNED_SHORT),T.type=AttributeType.SCALAR,a=getBinaryAccessor(T),T=a.createArrayBufferView(t.buffer,t.byteOffset+T.byteOffset,d)),L=new Uint16Array(d),R=0,r=0;r<d;++r)L[r]=R,R+=T[r];ao(C)&&ao(C.byteOffset)&&(C.componentType=defaultValue(C.componentType,GL.UNSIGNED_SHORT),C.type=AttributeType.SCALAR,a=getBinaryAccessor(C),C=a.createArrayBufferView(t.buffer,t.byteOffset+C.byteOffset,R));const V=f.length;for(r=0;r<V;++r){const K=f[r].length,It=f[r].instances,St=getBinaryProperties(K,It,t);f[r].instances=combine(St,It)}const X=new Array(V).fill(0),at=new Uint16Array(d);for(r=0;r<d;++r)n=c[r],at[r]=X[n],++X[n];const nt={classes:f,classIds:c,classIndexes:at,parentCounts:T,parentIndexes:L,parentIds:C};return B5(nt),nt}function Lh(e,t,r){if(!e)return;const n=e.parentCounts;return e.parentIds?r(e,t):n>0?R5(e,t,r):P5(e,t,r)}function R5(e,t,r){const n=e.classIds,a=e.parentCounts,d=e.parentIds,f=e.parentIndexes,c=n.length,T=scratchVisited;T.length=Math.max(T.length,c);const C=++marker,R=scratchStack;for(R.length=0,R.push(t);R.length>0;){if(t=R.pop(),T[t]===C)continue;T[t]=C;const L=r(e,t);if(ao(L))return L;const V=a[t],X=f[t];for(let at=0;at<V;++at){const nt=d[X+at];nt!==t&&R.push(nt)}}return null}function P5(e,t,r){let n=!0;for(;n;){const a=r(e,t);if(ao(a))return a;const d=e.parentIds[t];n=d!==t,t=d}throw new Error("traverseHierarchySingleParent")}function B5(e){const r=e.classIds.length;for(let n=0;n<r;++n)oA(e,n,stack)}function oA(e,t,r){const n=e.parentCounts,a=e.parentIds,d=e.parentIndexes,c=e.classIds.length;if(!ao(a))return;assert(t<c,`Parent index ${t} exceeds the total number of instances: ${c}`),assert(r.indexOf(t)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(t);const T=ao(n)?n[t]:1,C=ao(n)?d[t]:t;for(let R=0;R<T;++R){const L=a[C+R];L!==t&&oA(e,L,r)}r.pop(t)}function ys(e){return e!=null}const yp=(e,t)=>e,D5={HIERARCHY:!0,extensions:!0,extras:!0};class aA{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(t,r,n,a={}){Ar(n>=0),this.json=t||{},this.binary=r,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(const d in this.json)D5[d]||(this._properties[d]=this.json[d]);this._binaryProperties=this._initializeBinaryProperties(),a["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=I5(this,this.json,this.binary))}getExtension(t){return this.json&&this.json.extensions&&this.json.extensions[t]}memorySizeInBytes(){return 0}isClass(t,r){if(this._checkBatchId(t),Ar(typeof r=="string",r),this._hierarchy){const n=Lh(this._hierarchy,t,(a,d)=>{const f=a.classIds[d];return a.classes[f].name===r});return ys(n)}return!1}isExactClass(t,r){return Ar(typeof r=="string",r),this.getExactClassName(t)===r}getExactClassName(t){if(this._checkBatchId(t),this._hierarchy){const r=this._hierarchy.classIds[t];return this._hierarchy.classes[r].name}}hasProperty(t,r){return this._checkBatchId(t),Ar(typeof r=="string",r),ys(this._properties[r])||this._hasPropertyInHierarchy(t,r)}getPropertyNames(t,r){this._checkBatchId(t),r=ys(r)?r:[],r.length=0;const n=Object.keys(this._properties);return r.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(t,r),r}getProperty(t,r){if(this._checkBatchId(t),Ar(typeof r=="string",r),this._binaryProperties){const a=this._binaryProperties[r];if(ys(a))return this._getBinaryProperty(a,t)}const n=this._properties[r];if(ys(n))return yp(n[t]);if(this._hierarchy){const a=this._getHierarchyProperty(t,r);if(ys(a))return a}}setProperty(t,r,n){const a=this.featureCount;if(this._checkBatchId(t),Ar(typeof r=="string",r),this._binaryProperties){const f=this._binaryProperties[r];if(f){this._setBinaryProperty(f,t,n);return}}if(this._hierarchy&&this._setHierarchyProperty(this,t,r,n))return;let d=this._properties[r];ys(d)||(this._properties[r]=new Array(a),d=this._properties[r]),d[t]=yp(n)}_checkBatchId(t){if(!(t>=0&&t<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(t,r){return t.unpack(t.typedArray,r)}_setBinaryProperty(t,r,n){t.pack(n,t.typedArray,r)}_initializeBinaryProperties(){let t=null;for(const r in this._properties){const n=this._properties[r],a=this._initializeBinaryProperty(r,n);a&&(t=t||{},t[r]=a)}return t}_initializeBinaryProperty(t,r){if("byteOffset"in r){const n=r;Ar(this.binary,`Property ${t} requires a batch table binary.`),Ar(n.type,`Property ${t} requires a type.`);const a=C5(n,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:a.values,componentCount:a.size,unpack:a.unpacker,pack:a.packer}}return null}_hasPropertyInHierarchy(t,r){if(!this._hierarchy)return!1;const n=Lh(this._hierarchy,t,(a,d)=>{const f=a.classIds[d],c=a.classes[f].instances;return ys(c[r])});return ys(n)}_getPropertyNamesInHierarchy(t,r){Lh(this._hierarchy,t,(n,a)=>{const d=n.classIds[a],f=n.classes[d].instances;for(const c in f)f.hasOwnProperty(c)&&r.indexOf(c)===-1&&r.push(c)})}_getHierarchyProperty(t,r){return Lh(this._hierarchy,t,(n,a)=>{const d=n.classIds[a],f=n.classes[d],c=n.classIndexes[a],T=f.instances[r];return ys(T)?ys(T.typedArray)?this._getBinaryProperty(T,c):yp(T[c]):null})}_setHierarchyProperty(t,r,n,a){const d=Lh(this._hierarchy,r,(f,c)=>{const T=f.classIds[c],C=f.classes[T],R=f.classIndexes[c],L=C.instances[n];return ys(L)?(Ar(c===r,`Inherited property "${n}" is read-only.`),ys(L.typedArray)?this._setBinaryProperty(L,R,a):L[R]=yp(a),!0):!1});return ys(d)}}const Oy=4;function bp(e,t,r=0){const n=new DataView(t);if(e.magic=n.getUint32(r,!0),r+=Oy,e.version=n.getUint32(r,!0),r+=Oy,e.byteLength=n.getUint32(r,!0),r+=Oy,e.version!==1)throw new Error(`3D Tile Version ${e.version} not supported`);return r}const Nc=4,lA="b3dm tile in legacy format.";function ky(e,t,r){const n=new DataView(t);let a;e.header=e.header||{};let d=n.getUint32(r,!0);r+=Nc;let f=n.getUint32(r,!0);r+=Nc;let c=n.getUint32(r,!0);r+=Nc;let T=n.getUint32(r,!0);return r+=Nc,c>=570425344?(r-=Nc*2,a=d,c=f,T=0,d=0,f=0,console.warn(lA)):T>=570425344&&(r-=Nc,a=c,c=d,T=f,d=0,f=0,console.warn(lA)),e.header.featureTableJsonByteLength=d,e.header.featureTableBinaryByteLength=f,e.header.batchTableJsonByteLength=c,e.header.batchTableBinaryByteLength=T,e.header.batchLength=a,r}function Ny(e,t,r,n){return r=F5(e,t,r),r=O5(e,t,r),r}function F5(e,t,r,n){const{featureTableJsonByteLength:a,featureTableBinaryByteLength:d,batchLength:f}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:f||0},a&&a>0){const c=iA(t,r,a);e.featureTableJson=JSON.parse(c)}return r+=a||0,e.featureTableBinary=new Uint8Array(t,r,d),r+=d||0,r}function O5(e,t,r,n){const{batchTableJsonByteLength:a,batchTableBinaryByteLength:d}=e.header||{};if(a&&a>0){const f=iA(t,r,a);e.batchTableJson=JSON.parse(f),r+=a,d&&d>0&&(e.batchTableBinary=new Uint8Array(t,r,d),e.batchTableBinary=new Uint8Array(e.batchTableBinary),r+=d)}return r}function cA(e,t,r){if(!t&&(!e||!e.batchIds||!r))return null;const{batchIds:n,isRGB565:a,pointCount:d=0}=e;if(n&&r){const f=new Uint8ClampedArray(d*3);for(let c=0;c<d;c++){const T=n[c],R=r.getProperty(T,"dimensions").map(L=>L*255);f[c*3]=R[0],f[c*3+1]=R[1],f[c*3+2]=R[2]}return{type:Ze.UNSIGNED_BYTE,value:f,size:3,normalized:!0}}if(t&&a){const f=new Uint8ClampedArray(d*3);for(let c=0;c<d;c++){const T=x5(t[c]);f[c*3]=T[0],f[c*3+1]=T[1],f[c*3+2]=T[2]}return{type:Ze.UNSIGNED_BYTE,value:f,size:3,normalized:!0}}return t&&t.length===d*3?{type:Ze.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:Ze.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}const uA=new Bt;function k5(e,t){if(!t)return null;if(e.isOctEncoded16P){const r=new Float32Array((e.pointsLength||0)*3);for(let n=0;n<(e.pointsLength||0);n++)T5(t[n*2],t[n*2+1],uA),uA.toArray(r,n*3);return{type:Ze.FLOAT,size:2,value:r}}return{type:Ze.FLOAT,size:2,value:t}}function N5(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,L5(e,t)):{type:Ze.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}function L5(e,t){const r=new Bt,n=new Float32Array(e.pointCount*3);for(let a=0;a<e.pointCount;a++)r.set(t[a*3],t[a*3+1],t[a*3+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(n,a*3);return n}async function U5(e,t,r,n,a){r=bp(e,t,r),r=ky(e,t,r),r=Ny(e,t,r),z5(e);const{featureTable:d,batchTable:f}=V5(e);return await W5(e,d,f,n,a),j5(e,d,n),H5(e,d,f),G5(e,d),r}function z5(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}function V5(e){const t=new Fy(e.featureTableJson,e.featureTableBinary),r=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=r,e.featuresLength=r,e.pointsLength=r,e.pointCount=r,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",Ze.FLOAT,3);const n=$5(e,t);return{featureTable:t,batchTable:n}}function j5(e,t,r){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.positions){if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",Ze.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const n=t.getPropertyArray("POSITION_QUANTIZED",Ze.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Ze.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Ze.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=N5(e,n,r)}}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function H5(e,t,r){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.colors){let n=null;t.hasProperty("RGBA")?(n=t.getPropertyArray("RGBA",Ze.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?n=t.getPropertyArray("RGB",Ze.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(n=t.getPropertyArray("RGB565",Ze.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=cA(e,n,r)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",Ze.UNSIGNED_BYTE,4))}function G5(e,t){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.normals){let r=null;t.hasProperty("NORMAL")?r=t.getPropertyArray("NORMAL",Ze.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(r=t.getPropertyArray("NORMAL_OCT16P",Ze.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=k5(e,r)}}function $5(e,t){let r=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",Ze.UNSIGNED_SHORT,1),e.batchIds)){const n=t.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:a,batchTableBinary:d}=e;r=new aA(a,d,n)}return r}async function W5(e,t,r,n,a){let d,f,c;const T=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];T&&(c=T.properties);const C=t.getExtension("3DTILES_draco_point_compression");if(C){f=C.properties;const L=C.byteOffset,V=C.byteLength;if(!f||!Number.isFinite(L)||!V)throw new Error("Draco properties, byteOffset, and byteLength must be defined");d=(e.featureTableBinary||[]).slice(L,L+V),e.hasPositions=Number.isFinite(f.POSITION),e.hasColors=Number.isFinite(f.RGB)||Number.isFinite(f.RGBA),e.hasNormals=Number.isFinite(f.NORMAL),e.hasBatchIds=Number.isFinite(f.BATCH_ID),e.isTranslucent=Number.isFinite(f.RGBA)}if(!d)return!0;const R={buffer:d,properties:{...f,...c},batchTableProperties:c};return await X5(e,R,n,a)}async function X5(e,t,r,n){if(!n)return;const a={...r,draco:{...r?.draco,extraAttributes:t.batchTableProperties||{}}};delete a["3d-tiles"];const d=await Zu(t.buffer,wT,a,n),f=d.attributes.POSITION&&d.attributes.POSITION.value,c=d.attributes.COLOR_0&&d.attributes.COLOR_0.value,T=d.attributes.NORMAL&&d.attributes.NORMAL.value,C=d.attributes.BATCH_ID&&d.attributes.BATCH_ID.value,R=f&&d.attributes.POSITION.value.quantization,L=T&&d.attributes.NORMAL.value.quantization;if(R){const X=d.POSITION.data.quantization,at=X.range;e.quantizedVolumeScale=new Bt(at,at,at),e.quantizedVolumeOffset=new Bt(X.minValues),e.quantizedRange=(1<<X.quantizationBits)-1,e.isQuantizedDraco=!0}L&&(e.octEncodedRange=(1<<d.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const V={};if(t.batchTableProperties)for(const X of Object.keys(t.batchTableProperties))d.attributes[X]&&d.attributes[X].value&&(V[X.toLowerCase()]=d.attributes[X].value);e.attributes={positions:f,colors:cA(e,c,void 0),normals:T,batchIds:C,...V}}const Ly={URI:0,EMBEDDED:1};function hA(e,t,r,n){e.rotateYtoZ=!0;const a=(e.byteOffset||0)+(e.byteLength||0)-r;if(a===0)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=n?.["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=rg(t,r,a),e.gltfByteOffset=0,e.gltfByteLength=a,r%4===0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),(e.byteOffset||0)+(e.byteLength||0)}async function dA(e,t,r,n){const a=r?.["3d-tiles"]||{};if(q5(e,t),a.loadGLTF){if(!n)return;if(e.gltfUrl){const{fetch:d}=n,f=await d(e.gltfUrl,r);e.gltfArrayBuffer=await f.arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){const d=await Zu(e.gltfArrayBuffer,Oh,r,n);e.gltf=my(d),e.gpuMemoryUsageInBytes=lT(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}function q5(e,t,r){switch(t){case Ly.URI:if(e.gltfArrayBuffer){const n=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),d=new TextDecoder().decode(n);e.gltfUrl=d.replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case Ly.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function Z5(e,t,r,n,a){r=Y5(e,t,r,n),await dA(e,Ly.EMBEDDED,n,a);const d=e?.gltf?.extensions;return d&&d.CESIUM_RTC&&(e.rtcCenter=d.CESIUM_RTC.center),r}function Y5(e,t,r,n,a){r=bp(e,t,r),r=ky(e,t,r),r=Ny(e,t,r),r=hA(e,t,r,n);const d=new Fy(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=d.getGlobalProperty("RTC_CENTER",Ze.FLOAT,3),r}async function K5(e,t,r,n,a){return r=J5(e,t,r,n),await dA(e,e.gltfFormat||0,n,a),r}function J5(e,t,r,n,a){if(r=bp(e,t,r),e.version!==1)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);r=ky(e,t,r);const d=new DataView(t);if(e.gltfFormat=d.getUint32(r,!0),r+=4,r=Ny(e,t,r),r=hA(e,t,r,n),!e?.header?.featureTableJsonByteLength||e.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const f=new Fy(e.featureTableJson,e.featureTableBinary),c=f.getGlobalProperty("INSTANCES_LENGTH");if(f.featuresLength=c,!Number.isFinite(c))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=f.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=f.getGlobalProperty("RTC_CENTER",Ze.FLOAT,3);const T=new aA(e.batchTableJson,e.batchTableBinary,c);return Q5(e,f,T,c),r}function Q5(e,t,r,n){const a=new Array(n),d=new Bt;new Bt,new Bt,new Bt;const f=new Xr,c=new ch,T=new Bt,C={},R=new He,L=[],V=[],X=[],at=[];for(let nt=0;nt<n;nt++){let K;if(t.hasProperty("POSITION"))K=t.getProperty("POSITION",Ze.FLOAT,3,nt,d);else if(t.hasProperty("POSITION_QUANTIZED")){K=t.getProperty("POSITION_QUANTIZED",Ze.UNSIGNED_SHORT,3,nt,d);const ee=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Ze.FLOAT,3);if(!ee)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const ae=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Ze.FLOAT,3);if(!ae)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const be=65535;for(let ie=0;ie<3;ie++)K[ie]=K[ie]/be*ae[ie]+ee[ie]}if(!K)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(d.copy(K),C.translation=d,e.normalUp=t.getProperty("NORMAL_UP",Ze.FLOAT,3,nt,L),e.normalRight=t.getProperty("NORMAL_RIGHT",Ze.FLOAT,3,nt,V),e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",Ze.UNSIGNED_SHORT,2,nt,L),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",Ze.UNSIGNED_SHORT,2,nt,V),e.octNormalUp)throw e.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");e.eastNorthUp?(Er.WGS84.eastNorthUpToFixedFrame(d,R),R.getRotationMatrix3(f)):f.identity()}c.fromMatrix3(f),C.rotation=c,T.set(1,1,1);const It=t.getProperty("SCALE",Ze.FLOAT,1,nt,X);Number.isFinite(It)&&T.multiplyByScalar(It);const St=t.getProperty("SCALE_NON_UNIFORM",Ze.FLOAT,3,nt,L);St&&T.scale(St),C.scale=T;let Ct=t.getProperty("BATCH_ID",Ze.UNSIGNED_SHORT,1,nt,at);Ct===void 0&&(Ct=nt);const Ht=new He().fromQuaternion(C.rotation);R.identity(),R.translate(C.translation),R.multiplyRight(Ht),R.scale(C.scale);const Qt=R.clone();a[nt]={modelMatrix:Qt,batchId:Ct}}e.instances=a}async function t8(e,t,r,n,a,d){r=bp(e,t,r);const f=new DataView(t);for(e.tilesLength=f.getUint32(r,!0),r+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-r>12;){const c={shape:"tile3d"};e.tiles.push(c),r=await d(t,r,n,a,c)}return r}async function e8(e,t,r,n){if(e.rotateYtoZ=!0,e.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!n)return t.byteLength;const a=await Zu(t,Oh,r,n);e.gltf=my(a),e.gpuMemoryUsageInBytes=lT(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}async function fA(e,t=0,r,n,a={shape:"tile3d"}){switch(a.byteOffset=t,a.type=m5(e,t),a.type){case Nh.COMPOSITE:return await t8(a,e,t,r,n,fA);case Nh.BATCHED_3D_MODEL:return await Z5(a,e,t,r,n);case Nh.GLTF:return await e8(a,e,r,n);case Nh.INSTANCED_3D_MODEL:return await K5(a,e,t,r,n);case Nh.POINT_CLOUD:return await U5(a,e,t,r,n);default:throw new Error(`3DTileLoader: unknown type ${a.type}`)}}const r8=1952609651,i8=1;async function s8(e,t,r){if(new Uint32Array(e.slice(0,4))[0]!==r8)throw new Error("Wrong subtree file magic number");if(new Uint32Array(e.slice(4,8))[0]!==i8)throw new Error("Wrong subtree file verson, must be 1");const d=pA(e.slice(8,16)),f=new Uint8Array(e,24,d),T=new TextDecoder("utf8").decode(f),C=JSON.parse(T),R=pA(e.slice(16,24));let L=new ArrayBuffer(0);if(R&&(L=e.slice(24+d)),await vp(C,C.tileAvailability,L,r),Array.isArray(C.contentAvailability))for(const V of C.contentAvailability)await vp(C,V,L,r);else await vp(C,C.contentAvailability,L,r);return await vp(C,C.childSubtreeAvailability,L,r),C}async function vp(e,t,r,n){const a=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if(typeof a!="number")return;const d=e.bufferViews[a],f=e.buffers[d.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(f.uri){const T=`${n?.baseUrl||""}/${f.uri}`,R=await(await n.fetch(T)).arrayBuffer();t.explicitBitstream=new Uint8Array(R,d.byteOffset,d.byteLength);return}const c=e.buffers.slice(0,d.buffer).reduce((T,C)=>T+C.byteLength,0);t.explicitBitstream=new Uint8Array(r.slice(c,c+f.byteLength),d.byteOffset,d.byteLength)}function pA(e){const t=new DataView(e),r=t.getUint32(0,!0),n=t.getUint32(4,!0);return r+2**32*n}const _A={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:rA,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:s8,options:{}};var cn=null;try{cn=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 cr(e,t,r){this.low=e|0,this.high=t|0,this.unsigned=!!r}cr.prototype.__isLong__,Object.defineProperty(cr.prototype,"__isLong__",{value:!0});function Qi(e){return(e&&e.__isLong__)===!0}function gA(e){var t=Math.clz32(e&-e);return e?31-t:t}cr.isLong=Qi;var mA={},yA={};function ll(e,t){var r,n,a;return t?(e>>>=0,(a=0<=e&&e<256)&&(n=yA[e],n)?n:(r=Ke(e,0,!0),a&&(yA[e]=r),r)):(e|=0,(a=-128<=e&&e<128)&&(n=mA[e],n)?n:(r=Ke(e,e<0?-1:0,!1),a&&(mA[e]=r),r))}cr.fromInt=ll;function un(e,t){if(isNaN(e))return t?Ro:Bn;if(t){if(e<0)return Ro;if(e>=vA)return EA}else{if(e<=-xA)return bs;if(e+1>=xA)return AA}return e<0?un(-e,t).neg():Ke(e%Lc|0,e/Lc|0,t)}cr.fromNumber=un;function Ke(e,t,r){return new cr(e,t,r)}cr.fromBits=Ke;var xp=Math.pow;function Uy(e,t,r){if(e.length===0)throw Error("empty string");if(typeof t=="number"?(r=t,t=!1):t=!!t,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return t?Ro:Bn;if(r=r||10,r<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(n===0)return Uy(e.substring(1),t,r).neg();for(var a=un(xp(r,8)),d=Bn,f=0;f<e.length;f+=8){var c=Math.min(8,e.length-f),T=parseInt(e.substring(f,f+c),r);if(c<8){var C=un(xp(r,c));d=d.mul(C).add(un(T))}else d=d.mul(a),d=d.add(un(T))}return d.unsigned=t,d}cr.fromString=Uy;function Pn(e,t){return typeof e=="number"?un(e,t):typeof e=="string"?Uy(e,t):Ke(e.low,e.high,typeof t=="boolean"?t:e.unsigned)}cr.fromValue=Pn;var bA=65536,n8=1<<24,Lc=bA*bA,vA=Lc*Lc,xA=vA/2,wA=ll(n8),Bn=ll(0);cr.ZERO=Bn;var Ro=ll(0,!0);cr.UZERO=Ro;var Uc=ll(1);cr.ONE=Uc;var TA=ll(1,!0);cr.UONE=TA;var zy=ll(-1);cr.NEG_ONE=zy;var AA=Ke(-1,2147483647,!1);cr.MAX_VALUE=AA;var EA=Ke(-1,-1,!0);cr.MAX_UNSIGNED_VALUE=EA;var bs=Ke(0,-2147483648,!1);cr.MIN_VALUE=bs;var re=cr.prototype;re.toInt=function(){return this.unsigned?this.low>>>0:this.low},re.toNumber=function(){return this.unsigned?(this.high>>>0)*Lc+(this.low>>>0):this.high*Lc+(this.low>>>0)},re.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(bs)){var r=un(t),n=this.div(r),a=n.mul(r).sub(this);return n.toString(t)+a.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var d=un(xp(t,6),this.unsigned),f=this,c="";;){var T=f.div(d),C=f.sub(T.mul(d)).toInt()>>>0,R=C.toString(t);if(f=T,f.isZero())return R+c;for(;R.length<6;)R="0"+R;c=""+R+c}},re.getHighBits=function(){return this.high},re.getHighBitsUnsigned=function(){return this.high>>>0},re.getLowBits=function(){return this.low},re.getLowBitsUnsigned=function(){return this.low>>>0},re.getNumBitsAbs=function(){if(this.isNegative())return this.eq(bs)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,r=31;r>0&&(t&1<<r)==0;r--);return this.high!=0?r+33:r+1},re.isZero=function(){return this.high===0&&this.low===0},re.eqz=re.isZero,re.isNegative=function(){return!this.unsigned&&this.high<0},re.isPositive=function(){return this.unsigned||this.high>=0},re.isOdd=function(){return(this.low&1)===1},re.isEven=function(){return(this.low&1)===0},re.equals=function(t){return Qi(t)||(t=Pn(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low},re.eq=re.equals,re.notEquals=function(t){return!this.eq(t)},re.neq=re.notEquals,re.ne=re.notEquals,re.lessThan=function(t){return this.comp(t)<0},re.lt=re.lessThan,re.lessThanOrEqual=function(t){return this.comp(t)<=0},re.lte=re.lessThanOrEqual,re.le=re.lessThanOrEqual,re.greaterThan=function(t){return this.comp(t)>0},re.gt=re.greaterThan,re.greaterThanOrEqual=function(t){return this.comp(t)>=0},re.gte=re.greaterThanOrEqual,re.ge=re.greaterThanOrEqual,re.compare=function(t){if(Qi(t)||(t=Pn(t)),this.eq(t))return 0;var r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},re.comp=re.compare,re.negate=function(){return!this.unsigned&&this.eq(bs)?bs:this.not().add(Uc)},re.neg=re.negate,re.add=function(t){Qi(t)||(t=Pn(t));var r=this.high>>>16,n=this.high&65535,a=this.low>>>16,d=this.low&65535,f=t.high>>>16,c=t.high&65535,T=t.low>>>16,C=t.low&65535,R=0,L=0,V=0,X=0;return X+=d+C,V+=X>>>16,X&=65535,V+=a+T,L+=V>>>16,V&=65535,L+=n+c,R+=L>>>16,L&=65535,R+=r+f,R&=65535,Ke(V<<16|X,R<<16|L,this.unsigned)},re.subtract=function(t){return Qi(t)||(t=Pn(t)),this.add(t.neg())},re.sub=re.subtract,re.multiply=function(t){if(this.isZero())return this;if(Qi(t)||(t=Pn(t)),cn){var r=cn.mul(this.low,this.high,t.low,t.high);return Ke(r,cn.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Ro:Bn;if(this.eq(bs))return t.isOdd()?bs:Bn;if(t.eq(bs))return this.isOdd()?bs:Bn;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(wA)&&t.lt(wA))return un(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,a=this.high&65535,d=this.low>>>16,f=this.low&65535,c=t.high>>>16,T=t.high&65535,C=t.low>>>16,R=t.low&65535,L=0,V=0,X=0,at=0;return at+=f*R,X+=at>>>16,at&=65535,X+=d*R,V+=X>>>16,X&=65535,X+=f*C,V+=X>>>16,X&=65535,V+=a*R,L+=V>>>16,V&=65535,V+=d*C,L+=V>>>16,V&=65535,V+=f*T,L+=V>>>16,V&=65535,L+=n*R+a*C+d*T+f*c,L&=65535,Ke(X<<16|at,L<<16|V,this.unsigned)},re.mul=re.multiply,re.divide=function(t){if(Qi(t)||(t=Pn(t)),t.isZero())throw Error("division by zero");if(cn){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var r=(this.unsigned?cn.div_u:cn.div_s)(this.low,this.high,t.low,t.high);return Ke(r,cn.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Ro:Bn;var n,a,d;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Ro;if(t.gt(this.shru(1)))return TA;d=Ro}else{if(this.eq(bs)){if(t.eq(Uc)||t.eq(zy))return bs;if(t.eq(bs))return Uc;var f=this.shr(1);return n=f.div(t).shl(1),n.eq(Bn)?t.isNegative()?Uc:zy:(a=this.sub(t.mul(n)),d=n.add(a.div(t)),d)}else if(t.eq(bs))return this.unsigned?Ro:Bn;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();d=Bn}for(a=this;a.gte(t);){n=Math.max(1,Math.floor(a.toNumber()/t.toNumber()));for(var c=Math.ceil(Math.log(n)/Math.LN2),T=c<=48?1:xp(2,c-48),C=un(n),R=C.mul(t);R.isNegative()||R.gt(a);)n-=T,C=un(n,this.unsigned),R=C.mul(t);C.isZero()&&(C=Uc),d=d.add(C),a=a.sub(R)}return d},re.div=re.divide,re.modulo=function(t){if(Qi(t)||(t=Pn(t)),cn){var r=(this.unsigned?cn.rem_u:cn.rem_s)(this.low,this.high,t.low,t.high);return Ke(r,cn.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},re.mod=re.modulo,re.rem=re.modulo,re.not=function(){return Ke(~this.low,~this.high,this.unsigned)},re.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},re.clz=re.countLeadingZeros,re.countTrailingZeros=function(){return this.low?gA(this.low):gA(this.high)+32},re.ctz=re.countTrailingZeros,re.and=function(t){return Qi(t)||(t=Pn(t)),Ke(this.low&t.low,this.high&t.high,this.unsigned)},re.or=function(t){return Qi(t)||(t=Pn(t)),Ke(this.low|t.low,this.high|t.high,this.unsigned)},re.xor=function(t){return Qi(t)||(t=Pn(t)),Ke(this.low^t.low,this.high^t.high,this.unsigned)},re.shiftLeft=function(t){return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):Ke(0,this.low<<t-32,this.unsigned)},re.shl=re.shiftLeft,re.shiftRight=function(t){return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):Ke(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},re.shr=re.shiftRight,re.shiftRightUnsigned=function(t){return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?Ke(this.high,0,this.unsigned):Ke(this.high>>>t-32,0,this.unsigned)},re.shru=re.shiftRightUnsigned,re.shr_u=re.shiftRightUnsigned,re.rotateLeft=function(t){var r;return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?Ke(this.high,this.low,this.unsigned):t<32?(r=32-t,Ke(this.low<<t|this.high>>>r,this.high<<t|this.low>>>r,this.unsigned)):(t-=32,r=32-t,Ke(this.high<<t|this.low>>>r,this.low<<t|this.high>>>r,this.unsigned))},re.rotl=re.rotateLeft,re.rotateRight=function(t){var r;return Qi(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?Ke(this.high,this.low,this.unsigned):t<32?(r=32-t,Ke(this.high<<r|this.low>>>t,this.low<<r|this.high>>>t,this.unsigned)):(t-=32,r=32-t,Ke(this.low<<r|this.high>>>t,this.high<<r|this.low>>>t,this.unsigned))},re.rotr=re.rotateRight,re.toSigned=function(){return this.unsigned?Ke(this.low,this.high,!1):this},re.toUnsigned=function(){return this.unsigned?this:Ke(this.low,this.high,!0)},re.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},re.toBytesLE=function(){var t=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]},re.toBytesBE=function(){var t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,r>>>24,r>>>16&255,r>>>8&255,r&255]},cr.fromBytes=function(t,r,n){return n?cr.fromBytesLE(t,r):cr.fromBytesBE(t,r)},cr.fromBytesLE=function(t,r){return new cr(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)},cr.fromBytesBE=function(t,r){return new cr(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)};const o8=16;function SA(e){e==="X"&&(e="");const t=e.padEnd(o8,"0");return cr.fromString(t,!0,16)}function a8(e){if(e.isZero())return"X";let t=e.countTrailingZeros();const r=t%4;t=(t-r)/4;const n=t;t*=4;const d=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-n-d.length).join("0")+d}function l8(e,t){const r=c8(e).shiftRightUnsigned(2);return e.add(cr.fromNumber(2*t+1-4).multiply(r))}function c8(e){return e.and(e.not().add(1))}const u8=3,h8=2*30+1,CA=180/Math.PI;function d8(e){if(e.length===0)throw new Error(`Invalid Hilbert quad key ${e}`);const t=e.split("/"),r=parseInt(t[0],10),n=t[1],a=n.length;let d=0;const f=[0,0];for(let c=a-1;c>=0;c--){d=a-c;const T=n[c];let C=0,R=0;T==="1"?R=1:T==="2"?(C=1,R=1):T==="3"&&(C=1);const L=Math.pow(2,d-1);p8(L,f,C,R),f[0]+=L*C,f[1]+=L*R}if(r%2===1){const c=f[0];f[0]=f[1],f[1]=c}return{face:r,ij:f,level:d}}function f8(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<u8+h8;)t="0"+t;const r=t.lastIndexOf("1"),n=t.substring(0,3),a=t.substring(3,r),d=a.length/2,f=cr.fromString(n,!0,2).toString(10);let c="";if(d!==0)for(c=cr.fromString(a,!0,2).toString(4);c.length<d;)c="0"+c;return`${f}/${c}`}function IA(e,t,r){const n=1<<t;return[(e[0]+r[0])/n,(e[1]+r[1])/n]}function MA(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function RA(e){return[MA(e[0]),MA(e[1])]}function PA(e,[t,r]){switch(e){case 0:return[1,t,r];case 1:return[-t,1,r];case 2:return[-t,-r,1];case 3:return[-1,-r,-t];case 4:return[r,-1,-t];case 5:return[r,t,-1];default:throw new Error("Invalid face")}}function BA([e,t,r]){const n=Math.atan2(r,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*CA,n*CA]}function p8(e,t,r,n){if(n===0){r===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const a=t[0];t[0]=t[1],t[1]=a}}function _8(e){const t=IA(e.ij,e.level,[.5,.5]),r=RA(t),n=PA(e.face,r);return BA(n)}const g8=100;function DA(e){const{face:t,ij:r,level:n}=e,a=[[0,0],[0,1],[1,1],[1,0],[0,0]],d=Math.max(1,Math.ceil(g8*Math.pow(2,-n))),f=new Float64Array(4*d*2+2);let c=0,T=0;for(let C=0;C<4;C++){const R=a[C].slice(0),L=a[C+1],V=(L[0]-R[0])/d,X=(L[1]-R[1])/d;for(let at=0;at<d;at++){R[0]+=V,R[1]+=X;const nt=IA(r,n,R),K=RA(nt),It=PA(t,K),St=BA(It);Math.abs(St[1])>89.999&&(St[0]=T);const Ct=St[0]-T;St[0]+=Ct>180?-360:Ct<-180?360:0,f[c++]=St[0],f[c++]=St[1],T=St[0]}}return f[c++]=f[0],f[c++]=f[1],f}function Vy(e){const t=m8(e);return d8(t)}function m8(e){if(e.indexOf("/")>0)return e;const t=SA(e);return f8(t)}function y8(e){const t=Vy(e);return _8(t)}function b8(e){let t;if(e.face===2||e.face===5){let r=null,n=0;for(let a=0;a<4;a++){const d=`${e.face}/${a}`,f=Vy(d),c=DA(f);(typeof r>"u"||r===null)&&(r=new Float64Array(4*c.length)),r.set(c,n),n+=c.length}t=FA(r)}else{const r=DA(e);t=FA(r)}return t}function FA(e){if(e.length%2!==0)throw new Error("Invalid corners");const t=[],r=[];for(let n=0;n<e.length;n+=2)t.push(e[n]),r.push(e[n+1]);return t.sort((n,a)=>n-a),r.sort((n,a)=>n-a),{west:t[0],east:t[t.length-1],north:r[r.length-1],south:r[0]}}function v8(e,t){const r=t?.minimumHeight||0,n=t?.maximumHeight||0,a=Vy(e),d=b8(a),f=d.west,c=d.south,T=d.east,C=d.north,R=[];return R.push(new Bt(f,C,r)),R.push(new Bt(T,C,r)),R.push(new Bt(T,c,r)),R.push(new Bt(f,c,r)),R.push(new Bt(f,C,n)),R.push(new Bt(T,C,n)),R.push(new Bt(T,c,n)),R.push(new Bt(f,c,n)),R}function OA(e){const t=e.token,r={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},n=v8(t,r),a=y8(t),d=a[0],f=a[1],c=Er.WGS84.cartographicToCartesian([d,f,r.maximumHeight]),T=new Bt(c[0],c[1],c[2]);n.push(T);const C=mL(n);return[...C.center,...C.halfAxes]}const x8={QUADTREE:4,OCTREE:8};function w8(e,t,r){if(e?.box){const n=SA(e.s2VolumeInfo.token),a=l8(n,t),d=a8(a),f={...e.s2VolumeInfo};switch(f.token=d,r){case"OCTREE":const C=e.s2VolumeInfo,R=C.maximumHeight-C.minimumHeight,L=R/2,V=C.minimumHeight+R/2;C.minimumHeight=V-L,C.maximumHeight=V+L;break}return{box:OA(f),s2VolumeInfo:f}}}async function kA(e){const{subtree:t,subtreeData:r={level:0,x:0,y:0,z:0},parentData:n={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:a=0,implicitOptions:d,loaderOptions:f,s2VolumeBox:c}=e,{subdivisionScheme:T,subtreeLevels:C,maximumLevel:R,contentUrlTemplate:L,subtreesUriTemplate:V,basePath:X}=d,at={children:[],lodMetricValue:0,contentUrl:""};if(!R)return Mb.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${L} won't be loaded...`),at;const nt=n.localLevel+1,K=r.level+nt;if(K>R)return at;const It=x8[T],St=Math.log2(It),Ct=a&1,Ht=a>>1&1,Qt=a>>2&1,ee=cl(n.localX,Ct,1),ae=cl(n.localY,Ht,1),be=cl(n.localZ,Qt,1),ie=cl(r.x,ee,nt),le=cl(r.y,ae,nt),Ae=cl(r.z,be,nt),Fe=cl(n.mortonIndex,a,St),ze=nt===C&&jy(t.childSubtreeAvailability,Fe);let Ce,zr,ns,Hr;if(ze){const vi=`${X}/${V}`,xi=Hy(vi,K,ie,le,Ae);Ce=await Ko(xi,_A,f),Hr=0,zr={level:K,x:ie,y:le,z:Ae},ns={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else Ce=t,Hr=(It**nt-1)/(It-1)+Fe,zr=r,ns={mortonIndex:Fe,localLevel:nt,localX:ee,localY:ae,localZ:be};if(!jy(Ce.tileAvailability,Hr))return at;jy(Ce.contentAvailability,Hr)&&(at.contentUrl=Hy(L,K,ie,le,Ae));for(let vi=0;vi<It;vi++){const xi=w8(c,vi,T),li=await kA({subtree:Ce,subtreeData:zr,parentData:ns,childIndex:vi,implicitOptions:d,loaderOptions:f,s2VolumeBox:xi});(li.contentUrl||li.children.length)&&at.children.push(li)}return at.contentUrl||at.children.length?T8(at,{level:K,x:ie,y:le,z:Ae},d,c):at}function jy(e,t){let r;return Array.isArray(e)?(r=e[0],e.length>1&&Mb.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=e,"constant"in r?!!r.constant:r.explicitBitstream?S8(t,r.explicitBitstream):!1}function T8(e,t,r,n){const{basePath:a,refine:d,getRefine:f,lodMetricType:c,getTileType:T,rootLodMetricValue:C,rootBoundingVolume:R}=r,L=e.contentUrl&&e.contentUrl.replace(`${a}/`,""),V=C/2**t.level,X=n?.box?{box:n.box}:R,at=A8(X,t,r.subdivisionScheme);return{children:e.children,contentUrl:e.contentUrl,content:{uri:L},id:e.contentUrl,refine:f(d),type:T(e),lodMetricType:c,lodMetricValue:V,geometricError:V,transform:e.transform,boundingVolume:at}}function A8(e,t,r){if(e.region){const{level:n,x:a,y:d,z:f}=t,[c,T,C,R,L,V]=e.region,X=2**n,at=(C-c)/X,[nt,K]=[c+at*a,c+at*(a+1)],It=(R-T)/X,[St,Ct]=[T+It*d,T+It*(d+1)];let Ht,Qt;if(r==="OCTREE"){const ee=(V-L)/X;[Ht,Qt]=[L+ee*f,L+ee*(f+1)]}else[Ht,Qt]=[L,V];return{region:[nt,St,K,Ct,Ht,Qt]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}function cl(e,t,r){return(e<<r)+t}function Hy(e,t,r,n,a){const d=E8({level:t,x:r,y:n,z:a});return e.replace(/{level}|{x}|{y}|{z}/gi,f=>d[f])}function E8(e){const t={};for(const r in e)t[`{${r}}`]=e[r];return t}function S8(e,t){const r=Math.floor(e/8),n=e%8;return(t[r]>>n&1)===1}function Gy(e,t=""){if(!t)return Mo.EMPTY;const n=t.split("?")[0].split(".").pop();switch(n){case"pnts":return Mo.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Mo.SCENEGRAPH;default:return n||Mo.EMPTY}}function $y(e){switch(e){case"REPLACE":case"replace":return Rn.REPLACE;case"ADD":case"add":return Rn.ADD;default:return e}}function Wy(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const n=new URL(e,`${t}/`);return decodeURI(n.toString())}else if(e.startsWith("/"))return e;return e2(t,e)}function NA(e,t){if(!e)return null;let r;if(e.content){const a=e.content.uri||e.content?.url;typeof a<"u"&&(r=Wy(a,t))}return{...e,id:r,contentUrl:r,lodMetricType:kc.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Gy(e,r),refine:$y(e.refine)}}async function C8(e,t,r){let n=null;const a=UA(e.root);a&&e.root?n=await LA(e.root,e,t,a,r):n=NA(e.root,t);const d=[];for(d.push(n);d.length>0;){const f=d.pop()||{},c=f.children||[],T=[];for(const C of c){const R=UA(C);let L;R?L=await LA(C,e,t,R,r):L=NA(C,t),L&&(T.push(L),d.push(L))}f.children=T}return n}async function LA(e,t,r,n,a){const{subdivisionScheme:d,maximumLevel:f,availableLevels:c,subtreeLevels:T,subtrees:{uri:C}}=n,R=Hy(C,0,0,0,0),L=Wy(R,r),V=await Ko(L,_A,a),X=e.content?.uri,at=X?Wy(X,r):"",nt=t?.root?.refine,K=e.geometricError,It=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(It){const Qt={box:OA(It),s2VolumeInfo:It};e.boundingVolume=Qt}const St=e.boundingVolume,Ct={contentUrlTemplate:at,subtreesUriTemplate:C,subdivisionScheme:d,subtreeLevels:T,maximumLevel:Number.isFinite(c)?c-1:f,refine:nt,basePath:r,lodMetricType:kc.GEOMETRIC_ERROR,rootLodMetricValue:K,rootBoundingVolume:St,getTileType:Gy,getRefine:$y};return await I8(e,r,V,Ct,a)}async function I8(e,t,r,n,a){if(!e)return null;const{children:d,contentUrl:f}=await kA({subtree:r,implicitOptions:n,loaderOptions:a});let c,T=null;return f&&(c=f,T={uri:f.replace(`${t}/`,"")}),{...e,id:c,contentUrl:c,lodMetricType:kc.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Gy(e,c),refine:$y(e.refine),content:T||e.content,children:d}}function UA(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const zA={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:rA,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:M8,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function M8(e,t={},r){const n=t["3d-tiles"]||{};let a;return n.isTileset==="auto"?a=r?.url&&r.url.indexOf(".json")!==-1:a=n.isTileset,a?R8(e,t,r):P8(e,t,r)}async function R8(e,t,r){const n=JSON.parse(new TextDecoder().decode(e)),a=r?.url||"",d=B8(a),f=await C8(n,d,t||{});return{...n,shape:"tileset3d",loader:zA,url:a,queryString:r?.queryString||"",basePath:d,root:f||n.root,type:ms.TILES3D,lodMetricType:kc.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0}}async function P8(e,t,r){const n={content:{shape:"tile3d",featureIds:null}};return await fA(e,0,t,r,n.content),n.content}function B8(e){return ig(e)}const VA=[0],D8={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:zA,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,r)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}};class Xy extends Dw{initializeState(){"onTileLoadFail"in this.props&&Ye.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return!!(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({props:t,oldProps:r,changeFlags:n}){if(t.data&&t.data!==r.data&&this._loadTileset(t.data),n.viewportChanged){const{activeViewports:a}=this.state;Object.keys(a).length&&(this._updateTileset(a),this.state.lastUpdatedViewports=a,this.state.activeViewports={})}if(n.propsChanged){const{layerMap:a}=this.state;for(const d in a)a[d].needsUpdate=!0}}activateViewport(t){const{activeViewports:r,lastUpdatedViewports:n}=this.state;this.internalState.viewport=t,r[t.id]=t;const a=n?.[t.id];(!a||!t.equals(a))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:t,sourceLayer:r}){const n=r&&r.props.tile;return t.picked&&(t.object=n),t.sourceTile=n,t}filterSubLayer({layer:t,viewport:r}){const{tile:n}=t.props,{id:a}=r;return n.selected&&n.viewportIds.includes(a)}_updateAutoHighlight(t){const r=t.sourceTile,n=this.state.layerMap[r?.id];n&&n.layer&&n.layer.updateAutoHighlight(t)}async _loadTileset(t){const{loadOptions:r={}}=this.props,n=this.props.loader||this.props.loaders,a=Array.isArray(n)?n[0]:n,d={loadOptions:{...r}};let f=t;if(a.preload){const C=await a.preload(t,r);C.url&&(f=C.url),C.headers&&(d.loadOptions.fetch={...d.loadOptions.fetch,headers:C.headers}),Object.assign(d,C)}const c=await Ko(f,a,d.loadOptions),T=new g5(c,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...d});this.setState({tileset3d:T,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(T)}_onTileLoad(t){const{lastUpdatedViewports:r}=this.state;this.props.onTileLoad(t),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(t){delete this.state.layerMap[t.id],this.props.onTileUnload(t)}_updateTileset(t){if(!t)return;const{tileset3d:r}=this.state,{timeline:n}=this.context,a=Object.keys(t).length;!n||!a||!r||r.selectTiles(Object.values(t)).then(d=>{this.state.frameNumber!==d&&this.setState({frameNumber:d})})}_getSubLayer(t,r){if(!t.content)return null;switch(t.type){case Mo.POINTCLOUD:return this._makePointCloudLayer(t,r);case Mo.SCENEGRAPH:return this._make3DModelLayer(t);case Mo.MESH:return this._makeSimpleMeshLayer(t,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${t.content.type}`)}}_makePointCloudLayer(t,r){const{attributes:n,pointCount:a,constantRGBA:d,cartographicOrigin:f,modelMatrix:c}=t.content,{positions:T,normals:C,colors:R}=n;if(!T)return null;const L=r&&r.props.data||{header:{vertexCount:a},attributes:{POSITION:T,NORMAL:C,COLOR_0:R}},{pointSize:V,getPointColor:X}=this.props,at=this.getSubLayerClass("pointcloud",Zm);return new at({pointSize:V},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${t.id}`,tile:t,data:L,coordinateSystem:$e.METER_OFFSETS,coordinateOrigin:f,modelMatrix:c,getColor:d||X,_offset:0})}_make3DModelLayer(t){const{gltf:r,instances:n,cartographicOrigin:a,modelMatrix:d}=t.content,f=this.getSubLayerClass("scenegraph",yy);return new f({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${t.id}`,tile:t,data:n||VA,scenegraph:r,coordinateSystem:$e.METER_OFFSETS,coordinateOrigin:a,modelMatrix:d,getTransformMatrix:c=>c.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(t,r){const n=t.content,{attributes:a,indices:d,modelMatrix:f,cartographicOrigin:c,coordinateSystem:T=$e.METER_OFFSETS,material:C,featureIds:R}=n,{_getMeshColor:L}=this.props,V=r&&r.props.mesh||new gc({topology:"triangle-list",attributes:F8(a),indices:d}),X=this.getSubLayerClass("mesh",by);return new X(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${t.id}`,tile:t,mesh:V,data:VA,getColor:L(t),pbrMaterial:C,modelMatrix:f,coordinateOrigin:c,coordinateSystem:T,featureIds:R,_offset:0})}renderLayers(){const{tileset3d:t,layerMap:r}=this.state;return t?t.tiles.map(n=>{const a=r[n.id]=r[n.id]||{tile:n};let{layer:d}=a;return n.selected&&(d?a.needsUpdate&&(d=this._getSubLayer(n,d),a.needsUpdate=!1):d=this._getSubLayer(n)),a.layer=d,d}).filter(Boolean):null}}Xy.defaultProps=D8,Xy.layerName="Tile3DLayer";function F8(e){const t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}const qy=512,O8=Math.PI/180;function jA({map:e,gl:t,deck:r}){if(e.__deck)return e.__deck;const n=r?.props._customRender,a=r?.props.onLoad,d=$A({...r?.props,_customRender:()=>{e.triggerRepaint(),n?.("")}});let f;return(!r||r.props.gl===t)&&(Object.assign(d,{gl:t,width:null,height:null,touchAction:"unset",viewState:Uh(e)}),r?.isInitialized?HA(r,e):d.onLoad=()=>{a?.(),HA(f,e)}),r?(f=r,r.setProps(d),r.userData.isExternal=!0):(f=new Ch(d),e.on("remove",()=>{GA(e)})),f.userData.mapboxLayers=new Set,e.__deck=f,e.on("render",()=>{f.isInitialized&&V8(f,e)}),f}function HA(e,t){const r=()=>{e.isInitialized?j8(e,t):t.off("move",r)};t.on("move",r)}function GA(e){e.__deck?.finalize(),e.__deck=null}function $A(e){return{...e,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...e.parameters},views:e.views||[new bm({id:"mapbox"})]}}function k8(e,t){e.userData.mapboxLayers.add(t),Zy(e)}function N8(e,t){e.userData.mapboxLayers.delete(t),Zy(e)}function L8(e,t){Zy(e)}function U8(e,t,r){let{currentViewport:n}=e.userData,a=!1;n||(n=WA(e,t,!0),e.userData.currentViewport=n,a=!0),e.isInitialized&&e._drawLayers("mapbox-repaint",{viewports:[n],layerFilter:({layer:d})=>r.id===d.id||d.props.operation.includes("terrain"),clearStack:a,clearCanvas:!1})}function Uh(e){const{lng:t,lat:r}=e.getCenter(),n={longitude:(t+540)%360-180,latitude:r,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return e.getTerrain?.()&&z8(e,n),n}function z8(e,t){if(e.getFreeCameraOptions){const{position:r}=e.getFreeCameraOptions();if(!r||r.z===void 0)return;const n=e.transform.height,{longitude:a,latitude:d,pitch:f}=t,c=r.x*qy,T=(1-r.y)*qy,C=r.z*qy,R=hh([a,d]),L=c-R[0],V=T-R[1],X=Math.sqrt(L*L+V*V),at=f*O8,nt=1.5*n,K=at<.001?nt*Math.cos(at)/C:nt*Math.sin(at)/X;t.zoom=Math.log2(K);const It=nt*Math.cos(at)/K,St=C-It;t.position=[0,0,St/Df(d)]}else typeof e.transform.elevation=="number"&&(t.position=[0,0,e.transform.elevation])}function WA(e,t,r=!0){return new tl({id:"mapbox",x:0,y:0,width:e.width,height:e.height,...Uh(t),nearZMultiplier:r?.02:.1,nearZ:t.transform._nearZ/t.transform.height,farZ:t.transform._farZ/t.transform.height})}function V8(e,t){const{mapboxLayers:r,isExternal:n}=e.userData;if(n){const a=Array.from(r,R=>R.id),f=vc(e.props.layers,Boolean).some(R=>R&&!a.includes(R.id));let c=e.getViewports();const T=c.findIndex(R=>R.id==="mapbox"),C=c.length>1||T<0;(f||C)&&(T>=0&&(c=c.slice(),c[T]=WA(e,t,!1)),e._drawLayers("mapbox-repaint",{viewports:c,layerFilter:R=>(!e.props.layerFilter||e.props.layerFilter(R))&&(R.viewport.id!=="mapbox"||!a.includes(R.layer.id)),clearCanvas:!1}))}e.userData.currentViewport=null}function j8(e,t){e.setProps({viewState:Uh(t)}),e.needsRedraw({clearRedrawFlags:!0})}function Zy(e){if(e.userData.isExternal)return;const t=[];e.userData.mapboxLayers.forEach(r=>{const n=r.props.type,a=new n(r.props);t.push(a)}),e.setProps({layers:t})}class H8{constructor(t){if(!t.id)throw new Error("Layer must have an unique id");this.id=t.id,this.type="custom",this.renderingMode=t.renderingMode||"3d",this.map=null,this.deck=null,this.props=t}onAdd(t,r){this.map=t,this.deck=jA({map:t,gl:r,deck:this.props.deck}),k8(this.deck,this)}onRemove(){this.deck&&N8(this.deck,this)}setProps(t){Object.assign(this.props,t,{id:this.id}),this.deck&&L8(this.deck)}render(){U8(this.deck,this.map,this)}}const Yy="__UNDEFINED__";function wp(e,t,r,n){if(!e||!t||!e.style||!e.style._loaded)return;const a=vc(n,Boolean);if(r!==n){const c=vc(r,Boolean),T=new Set(c.map(C=>C.id));for(const C of a)T.delete(C.id);for(const C of T)e.getLayer(C)&&e.removeLayer(C)}for(const c of a){const T=e.getLayer(c.id);T?(T.implementation||T).setProps(c.props):e.addLayer(new H8({id:c.id,deck:t}),c.props.beforeId)}const d=e.style._order,f={};for(const c of a){let{beforeId:T}=c.props;(!T||!d.includes(T))&&(T=Yy),f[T]=f[T]||[],f[T].push(c.id)}for(const c in f){const T=f[c];let C=c===Yy?d.length:d.indexOf(c),R=c===Yy?void 0:c;for(let L=T.length-1;L>=0;L--){const V=T[L],X=d.indexOf(V);X!==C-1&&(e.moveLayer(V,R),X>C&&C++),C--,R=V}}}class G8{constructor(t){this._handleStyleChange=()=>{wp(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){const{clientWidth:a,clientHeight:d}=this._map.getContainer();Object.assign(this._container.style,{width:`${a}px`,height:`${d}px`})}},this._updateViewState=()=>{const a=this._deck;a&&(a.setProps({viewState:Uh(this._map)}),a.isInitialized&&a.redraw())},this._handleMouseEvent=a=>{const d=this._deck;if(!d||!d.isInitialized)return;const f={type:a.type,offsetCenter:a.point,srcEvent:a},c=this._lastMouseDownPoint;switch(!a.point&&c&&(f.deltaX=a.originalEvent.clientX-c.clientX,f.deltaY=a.originalEvent.clientY-c.clientY,f.offsetCenter={x:c.x+f.deltaX,y:c.y+f.deltaY}),f.type){case"mousedown":d._onPointerDown(f),this._lastMouseDownPoint={...a.point,clientX:a.originalEvent.clientX,clientY:a.originalEvent.clientY};break;case"dragstart":f.type="panstart",d._onEvent(f);break;case"drag":f.type="panmove",d._onEvent(f);break;case"dragend":f.type="panend",d._onEvent(f);break;case"click":f.tapCount=1,d._onEvent(f);break;case"dblclick":f.type="click",f.tapCount=2,d._onEvent(f);break;case"mousemove":f.type="pointermove",d._onPointerMove(f);break;case"mouseout":f.type="pointerleave",d._onPointerMove(f);break;default:return}};const{interleaved:r=!1,...n}=t;this._interleaved=r,this._props=n}setProps(t){this._interleaved&&t.layers&&wp(this._map,this._deck,this._props.layers,t.layers),Object.assign(this._props,t),this._deck&&this._deck.setProps(this._interleaved?$A(this._props):this._props)}onAdd(t){return this._map=t,this._interleaved?this._onAddInterleaved(t):this._onAddOverlaid(t)}_onAddOverlaid(t){const r=document.createElement("div");return Object.assign(r.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=r,this._deck=new Ch({...this._props,parent:r,viewState:Uh(t)}),t.on("resize",this._updateContainerSize),t.on("render",this._updateViewState),t.on("mousedown",this._handleMouseEvent),t.on("dragstart",this._handleMouseEvent),t.on("drag",this._handleMouseEvent),t.on("dragend",this._handleMouseEvent),t.on("mousemove",this._handleMouseEvent),t.on("mouseout",this._handleMouseEvent),t.on("click",this._handleMouseEvent),t.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(t){const r=t.painter.context.gl;return r instanceof WebGLRenderingContext&&Ye.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=jA({map:t,gl:r,deck:new Ch({...this._props,gl:r})}),t.on("styledata",this._handleStyleChange),wp(t,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){const t=this._map;t&&(this._interleaved?this._onRemoveInterleaved(t):this._onRemoveOverlaid(t)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(t){t.off("resize",this._updateContainerSize),t.off("render",this._updateViewState),t.off("mousedown",this._handleMouseEvent),t.off("dragstart",this._handleMouseEvent),t.off("drag",this._handleMouseEvent),t.off("dragend",this._handleMouseEvent),t.off("mousemove",this._handleMouseEvent),t.off("mouseout",this._handleMouseEvent),t.off("click",this._handleMouseEvent),t.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(t){t.off("styledata",this._handleStyleChange),wp(t,this._deck,this._props.layers,[]),GA(t)}getDefaultPosition(){return"top-left"}pickObject(t){return bi(this._deck),this._deck.pickObject(t)}pickMultipleObjects(t){return bi(this._deck),this._deck.pickMultipleObjects(t)}pickObjects(t){return bi(this._deck),this._deck.pickObjects(t)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}}class XA{olaMaps;apiKey;accessToken;mode;threedTileset;static Marker=Se.Marker;static Popup=Se.Popup;static NavigationControl=Se.NavigationControl;static GeolocateControl=Se.GeolocateControl;static ScaleControl=Se.ScaleControl;static FullscreenControl=Se.FullscreenControl;static AttributionControl=Se.AttributionControl;static TerrainControl=Se.TerrainControl;static LogoControl=Se.LogoControl;static GlobeControl=Se.GlobeControl;static LngLat=Se.LngLat;static LngLatBounds=Se.LngLatBounds;static Point=Se.Point;static MercatorCoordinate=Se.MercatorCoordinate;static GeoJSONSource=Se.GeoJSONSource;static VectorTileSource=Se.VectorTileSource;static RasterTileSource=Se.RasterTileSource;static RasterDEMTileSource=Se.RasterDEMTileSource;static ImageSource=Se.ImageSource;static VideoSource=Se.VideoSource;static CanvasSource=Se.CanvasSource;static MapMouseEvent=Se.MapMouseEvent;static MapTouchEvent=Se.MapTouchEvent;static MapWheelEvent=Se.MapWheelEvent;static AJAXError=Se.AJAXError;static BoxZoomHandler=Se.BoxZoomHandler;static CooperativeGesturesHandler=Se.CooperativeGesturesHandler;static DoubleClickZoomHandler=Se.DoubleClickZoomHandler;static DragPanHandler=Se.DragPanHandler;static DragRotateHandler=Se.DragRotateHandler;static KeyboardHandler=Se.KeyboardHandler;static ScrollZoomHandler=Se.ScrollZoomHandler;static TwoFingersTouchPitchHandler=Se.TwoFingersTouchPitchHandler;static TwoFingersTouchRotateHandler=Se.TwoFingersTouchRotateHandler;static TwoFingersTouchZoomHandler=Se.TwoFingersTouchZoomHandler;static TwoFingersTouchZoomRotateHandler=Se.TwoFingersTouchZoomRotateHandler;static EdgeInsets=Se.EdgeInsets;static Event=Se.Event;static Evented=Se.Evented;static Hash=Se.Hash;static Style=Se.Style;constructor({apiKey:t,accessToken:r="",mode:n="2d",threedTileset:a=_b}){this.apiKey=t,this.mode=n,this.threedTileset=a,this.accessToken=r}addOlaLogo(t){if(typeof window>"u")return;const r=document.getElementsByClassName("maplibregl-ctrl-bottom-left");let n="#000";t.style?.includes("dark")&&(n="#FFF");for(let a=0;a<r.length;a++){const d=document.createElement("div");d.style.position="absolute",d.style.bottom="4px",d.style.left="10px",d.style.zIndex="1000",d.innerHTML=gb(n),r[a].appendChild(d)}}addAttribution(t){const r=document.querySelectorAll(".maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib-inner"),n=t?.style||"";r?.forEach(a=>{const d=a.querySelector("a");d&&(d.style.display="none");const f="ola-maps-link";if(!a.querySelector(`#${f}`)){const C=document.createElement("a");C.id=f,C.href="https://maps.olakrutrim.com/",C.target="_blank",C.textContent="Ola Maps ",a.appendChild(C)}const c="osm-link";if(!a.querySelector(`#${c}`)){const C=document.createElement("a");C.id=c,C.href="https://www.openstreetmap.org/copyright",C.target="_blank",C.textContent="| © OpenStreetMap contributors",a.appendChild(C)}const T="copernicus-attrib";if(n.includes("default-dark-standard-satellite")&&!a.querySelector(`#${T}`)){const C=document.createElement("span");C.id=T,C.textContent=" | Contains modified Copernicus Sentinel-2 data 2024",a.appendChild(C)}})}fetchStaticMap(t){try{return fetch(t).then(r=>r.blob())}catch(r){console.log(r)}}async add3dLayer(){if(!this.threedTileset)throw new Error("3d Tileset is not initialized");const t=new Xy({id:"tile-3d-layer",data:`${this.threedTileset}?api_key=${this.apiKey}`,beforeId:"poi_railway"}),r=new G8({interleaved:!0,layers:[t]});r&&this.olaMaps.on("style.load",()=>{this.olaMaps.setFilter("building-3d",["all",["!has","hide_3d"],["!=","render_as_3d",!0]]),this.olaMaps.addControl(r)})}init(t){this.olaMaps=new Se.Map({container:t?.container||"map",center:t?.center||[0,0],zoom:t?.zoom||9,hash:t?.hash||!1,style:t?.style||pb,transformRequest:(a,d)=>{if(this.accessToken)return{url:a,headers:{Authorization:`Bearer ${this.accessToken}`}};{const f=new URL(a);return d!=="Image"&&f.searchParams.append("api_key",this.apiKey),{url:f.toString()}}},...t}),this.mode==="3d"&&this.add3dLayer(),this.addOlaLogo(t),this.addAttribution({style:t?.style});const r={};return Object.getOwnPropertyNames(Se.Map.prototype).forEach(a=>{typeof this.olaMaps[a]=="function"&&(r[a]=this.olaMaps[a].bind(this.olaMaps))}),Object.keys(qu).forEach(a=>{typeof qu[a]=="function"?r[a]=(...d)=>new qu[a](...d):r[a]=qu[a]}),Object.getOwnPropertyNames(this.olaMaps).forEach(a=>{a in r||(r[a]=this.olaMaps[a])}),Object.assign(this.olaMaps,r)}addNavigationControls(t){return new Se.NavigationControl(t)}addGeolocateControls(t){return new Se.GeolocateControl(t)}getMercatorCoordinate(){return Se.MercatorCoordinate}addMarker(t){return new Se.Marker(t)}addPopup(t){return new Se.Popup(t)}getStaticMap(t,r){this.fetchStaticMap(t)?.then(a=>{const d=URL.createObjectURL(a),f=document.createElement("img");f.src=d;const c=document.getElementById(r);c&&!c.querySelector("img")?c?.appendChild(f):console.log("An image already exists in the element.")}).catch(a=>console.error(a))}}typeof window<"u"&&(window.OlaMaps=XA);const $8=Object.freeze(Object.defineProperty({__proto__:null,OlaMaps:XA},Symbol.toStringTag,{value:"Module"}));vn.OlaMaps=ps,vn.default3dTIleset=_b,vn.defaultStyleJson=pb,vn.getCookie=YS,vn.getOlaMapIcon=gb,vn.setCookie=KS,Object.defineProperty(vn,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "olamaps-web-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Ola Maps Web SDK",
5
5
  "files": [
6
6
  "dist/*"