@maptalks/3dtiles 0.83.1 → 0.84.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.
@@ -1,23 +1,23 @@
1
1
  /*!
2
- * @maptalks/3dtiles v0.83.1
2
+ * @maptalks/3dtiles v0.84.0
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2023 maptalks.org
5
5
  */
6
- import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as n,mat4 as r,HighlightUtil as i,vec3 as o,mat3 as s,vec4 as a,quat as c,MaskRendererMixin as A,createREGL as l,MaskLayerMixin as f}from"@maptalks/gl";const h='function(t){var e="undefined"!=typeof Float32Array?Float32Array:Array;function r(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function A(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,r){var n=e[0],A=e[1],i=e[2],o=e[3],s=e[4],a=e[5],B=e[6],E=e[7],c=e[8],C=e[9],f=e[10],l=e[11],u=e[12],_=e[13],I=e[14],D=e[15],h=r[0],R=r[1],T=r[2],F=r[3];return t[0]=h*n+R*s+T*c+F*u,t[1]=h*A+R*a+T*C+F*_,t[2]=h*i+R*B+T*f+F*I,t[3]=h*o+R*E+T*l+F*D,h=r[4],R=r[5],T=r[6],F=r[7],t[4]=h*n+R*s+T*c+F*u,t[5]=h*A+R*a+T*C+F*_,t[6]=h*i+R*B+T*f+F*I,t[7]=h*o+R*E+T*l+F*D,h=r[8],R=r[9],T=r[10],F=r[11],t[8]=h*n+R*s+T*c+F*u,t[9]=h*A+R*a+T*C+F*_,t[10]=h*i+R*B+T*f+F*I,t[11]=h*o+R*E+T*l+F*D,h=r[12],R=r[13],T=r[14],F=r[15],t[12]=h*n+R*s+T*c+F*u,t[13]=h*A+R*a+T*C+F*_,t[14]=h*i+R*B+T*f+F*I,t[15]=h*o+R*E+T*l+F*D,t}function o(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function s(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function a(t,e){var r=e[0],n=e[1],A=e[2],i=e[3],o=r+r,s=n+n,a=A+A,B=r*o,E=n*o,c=n*s,C=A*o,f=A*s,l=A*a,u=i*o,_=i*s,I=i*a;return t[0]=1-c-l,t[1]=E+I,t[2]=C-_,t[3]=0,t[4]=E-I,t[5]=1-B-l,t[6]=f+u,t[7]=0,t[8]=C+_,t[9]=f-u,t[10]=1-B-c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function B(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function E(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function c(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function C(t,r,n){var A=new e(3);return A[0]=t,A[1]=r,A[2]=n,A}function f(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function l(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function u(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function _(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function I(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function D(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function h(t,e){var r=e[0]-t[0],n=e[1]-t[1],A=e[2]-t[2];return Math.sqrt(r*r+n*n+A*A)}function R(t,e){var r=e[0],n=e[1],A=e[2],i=r*r+n*n+A*A;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t}function T(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function F(t,e,r){var n=e[0],A=e[1],i=e[2],o=r[0],s=r[1],a=r[2];return t[0]=A*a-i*s,t[1]=i*o-n*a,t[2]=n*s-A*o,t}function P(t,e,r){var n=e[0],A=e[1],i=e[2],o=r[3]*n+r[7]*A+r[11]*i+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*A+r[8]*i+r[12])/o,t[1]=(r[1]*n+r[5]*A+r[9]*i+r[13])/o,t[2]=(r[2]*n+r[6]*A+r[10]*i+r[14])/o,t}var O=_,L=I,y=c;function M(t,e,r,n,A){return t[0]=e,t[1]=r,t[2]=n,t[3]=A,t}function N(t,e,r){var n=e[0],A=e[1],i=e[2],o=e[3];return t[0]=r[0]*n+r[4]*A+r[8]*i+r[12]*o,t[1]=r[1]*n+r[5]*A+r[9]*i+r[13]*o,t[2]=r[2]*n+r[6]*A+r[10]*i+r[14]*o,t[3]=r[3]*n+r[7]*A+r[11]*i+r[15]*o,t}function S(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function d(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function U(t,e,r,n){var A=e[0],i=e[1],o=e[2],s=e[3],a=r[0],B=r[1],E=r[2],c=r[3],C=void 0,f=void 0,l=void 0,u=void 0,_=void 0;return(f=A*a+i*B+o*E+s*c)<0&&(f=-f,a=-a,B=-B,E=-E,c=-c),1-f>1e-6?(C=Math.acos(f),l=Math.sin(C),u=Math.sin((1-n)*C)/l,_=Math.sin(n*C)/l):(u=1-n,_=n),t[0]=u*A+_*a,t[1]=u*i+_*B,t[2]=u*o+_*E,t[3]=u*s+_*c,t}E(),function(){var t,r=(t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var G,m=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};E(),C(1,0,0),C(0,1,0),S(),S(),G=new e(9),e!=Float32Array&&(G[1]=0,G[2]=0,G[3]=0,G[5]=0,G[6]=0,G[7]=0),G[0]=1,G[4]=1,G[8]=1;\n/*!\n * @maptalks/gltf-loader v0.83.1\n * LICENSE : UNLICENSED\n * (c) 2016-2023 maptalks.org\n */\nlet b=0;function p(t){return null==t}function w(t){return!p(t)}function H(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function K(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function g(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function V(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const J=[],X=[],v=[],Z=[0,0,0],x=d([]),k=[1,1,1];function W(t,e,r,n,A,i,o){const s=K(o);if((0===A||A===n*s.BYTES_PER_ELEMENT)&&i%s.BYTES_PER_ELEMENT==0){const A=new s(e,i,r*n);return t.set(A),t}0===A&&(A=n*s.BYTES_PER_ELEMENT);const a=new Uint8Array(n*s.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const B=new Uint8Array(e,A*o+i,n*s.BYTES_PER_ELEMENT);a.set(B),r=new s(a.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const Q="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function j(t,e,r){const n=new Uint8Array(t,e,r);return Q.decode(n)}const Y={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,A=H({},e);A.signal=n,A.method||(A.method="GET");const i=fetch(t,A).then(t=>{const r=this.t(t,e.responseType);return r.message?r:r.then(r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t})}).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t});return i.xhr=r,i},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",Y.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?Y.jsonp(t):((e=e||{}).responseType="json",Y.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+b++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise(t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)})}};class z{constructor(t,e,r){this.A=t,this.decoders=e,this.i=r,this.images={},this.o={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],A=this.s(e,n);return this.getImageByBuffer(A,r)}if(this.o[t.id])return this.o[t.id].then(()=>{const n=this.buffers[t.id],A=this.s(e,n);return this.getImageByBuffer(A,r)});if(g(t.uri)){const n=this.buffers[t.id]=V(t.uri),A=this.s(e,n);return this.getImageByBuffer(A,r)}return this.o[t.id]=Y.getArrayBuffer(t.uri,null).then(n=>{const A=this.buffers[t.id]=n.data,i=this.s(e,A);return this.getImageByBuffer(i,r)})}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.i});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const r=new Blob([t],{type:e.mimeType}),n=URL.createObjectURL(r);return this.B(e.id,n)}}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.o[t.id]?this.o[t.id].then(()=>this.images[t.id]):this.o[t.id]=this.B(t.id,e)}B(t,e){return new Promise((r,n)=>{this.A(e,(A,i)=>{A?n(A):(URL.revokeObjectURL(e),this.images[t]=i,r(this.images[t]))})})}}const q=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],$=[];class tt{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.C=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.l()}u(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this._(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const A=r.bufferViews[n.bufferView];return this.I(A).then(r=>{const{buffer:A,byteOffset:i}=r;return this.accessors[n.id]=this._(t,e,A,i)})}I(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then(()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})});if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(g(e.uri)){const t=this.buffers[e.id]=V(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=Y.getArrayBuffer(t,null).then(n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_(t,e,r,n=0){const A=this.gltf,i=A.accessors[e],o=void 0!==i.bufferView?A.bufferViews[i.bufferView]:{},s=(o.byteOffset||0)+n,a=this.D(i.type),B=K(i.componentType),E=o.byteStride||0,c={array:void 0,name:t,accessorName:e,byteLength:i.count*a*B.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:a,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(c.min=i.min),i.max&&(c.max=i.max),r)if(this.C)c.byteStride=E,c.byteOffset=s+(i.byteOffset||0),!E||E===a*B.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(c.array=this.h(r,i.count,a,s+(i.byteOffset||0),B),c.array.buffer.byteLength===c.byteLength&&(c.byteOffset=0)):c.array=new Uint8Array(r,s,o.byteLength);else if(i.interleaved){c.byteStride=0,c.byteOffset=0;const t=new B(i.count*a);if(c.array=W(t,r,i.count,a,E,s+(i.byteOffset||0),i.componentType),c.extensions&&c.extensions.WEB3D_quantized_attributes&&a>2){const t=new Float32Array(c.array.length),{decodeMatrix:e}=c.extensions.WEB3D_quantized_attributes;for(let r=0;r<c.array.length;r+=a){$[0]=c.array[r],$[1]=c.array[r+1],$[2]=c.array[r+2],$[3]=1;const n=N($,$,e);t[r]=n[0],t[r+1]=n[1],t[r+2]=n[2]}c.componentType=5126,c.array=t}}else c.byteStride=0,c.array=this.h(r,i.count,a,s+(i.byteOffset||0),B),c.byteOffset=c.array.byteOffset;else{c.array=new B(i.count);const t=c.min||c.max;t&&(c.array[0]=t[0],c.array[1]=t[1],c.array[2]=t[2])}return c}l(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}h(t,e,r,n,A){return n%A.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*A.BYTES_PER_ELEMENT),n=0),new A(t,n,r*e)}D(t){const e=q.indexOf(t);return q[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map(t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.I(e).then(n=>{const{buffer:A,byteOffset:i}=n,o=j(A,i+(e.byteOffset||0),r);return t.content=o,t})}if(t.uri){if(g(t.uri)){const e=V(t.uri),r=j(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return Y.get(e).then(e=>(t.content=e,t))}}return Promise.resolve(t)});return Promise.all(r).then(()=>t)}}class et extends z{constructor(t,e,r,n,A,i){super(n,A,i),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new tt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(w(t.name)&&(e.name=t.name),w(t.children)&&(e.children=t.children),w(t.jointName)&&(e.jointName=t.jointName),w(t.matrix)&&(e.matrix=t.matrix),w(t.rotation)&&(e.rotation=t.rotation),w(t.scale)&&(e.scale=t.scale),w(t.translation)&&(e.translation=t.translation),w(t.extras)&&(e.extras=t.extras),w(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const r=o(J,e.translation||Z),n=a(X,e.rotation||x),A=s(v,e.scale||k);return i(A,n,A),i(t,r,A)}return A(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}T(t){const e={};for(const r in t){const n=t[r];let A,i;n.instanceTechnique&&n.instanceTechnique.values?(A=n.instanceTechnique,i=A.values.diffuse):(A=n,i=A.values.tex||A.values.diffuseTex||A.values.diffuse);const o={baseColorTexture:{index:i}};n.name&&(o.name=n.name),n.extensions&&(o.extensions=n.extensions),n.extras&&(o.extras=n.extras),e[r]=o}return e}F(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,A=r.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,A);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}P(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.F(r).then(t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}})}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const A=this.gltf.textures[n];if(!A)return null;const i=this.gltf.samplers[A.sampler];return{format:A.format||6408,internalFormat:A.internalFormat||6408,type:A.type||5121,sampler:i,source:this.gltf.images[A.source]}}getMaterial(){return null}getAnimations(){return null}}class rt extends z{constructor(t,e,r,n,A,i){super(n,A,i),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new tt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return H(e,t),!w(t.weights)&&this.gltf.meshes&&w(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}P(t){const e=this.gltf.textures[t];if(!e)return null;let r=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(r=e.extensions.EXT_texture_webp.source),!w(r))return null;const n=this.gltf.images[r];return this.F(n).then(t=>{if(!t)return null;const r={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extensions:n.extensions,extras:n.extras}};H(r,e);const A=w(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return A&&(r.sampler=A,r.sampler.magFilter=A.magFilter||9729,r.sampler.minFilter=A.minFilter||9729,r.sampler.wrapS=A.wrapS||10497,r.sampler.wrapT=A.wrapT||10497),t.format&&(r.format=t.format),r})}F(t){if(!w(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.O(e,t)}return null}O(t,e){const r=this.s(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}s(t,e,r){r=r||0;const n=t.byteOffset+r,A=t.byteLength;return new Uint8Array(e,n,A)}L(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}getAnimations(t){const e=[];return t.forEach(t=>{e.push(this.getSamplers(t.samplers))}),Promise.all(e).then(e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t})}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(w(t[r].input)||w(t[r].output))&&(e.push(this.accessor.u("input",t[r].input)),e.push(this.accessor.u("output",t[r].output)));return Promise.all(e).then(e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t})}}const nt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class At{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),A=n.getUint32(4,!0);if(1===A)return At.readV1(n,e);if(2===A)return At.readV2(t,e);throw new Error("Unsupported glb version : "+A)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const A=it(t.buffer,20+e,n);return{json:JSON.parse(A),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,A;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const s=i.getUint32(o,!0);o+=4;const a=i.getUint32(o,!0);if(o+=4,1313821514===a)r=it(t,e+12+o,s);else if(5130562===a){A=e+12+o,n=s;break}o+=s}return{json:JSON.parse(r),glbBuffer:{byteOffset:A,buffer:t,byteLength:n}}}}function it(t,e,r){if(nt){const n=new Uint8Array(t,e,r);return nt.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let A=t[n++];if(128&A){let r=ot[A>>3&7];if(!(64&A)||!r||n+r>e)return null;for(A&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;A=A<<6|63&e}}r+=String.fromCharCode(A)}return r}(new Uint8Array(t,e,r))}const ot=[1,1,1,1,2,2,3,0],st=[0,0,0],at=[0,0,0,1],Bt=[1,1,1],Et={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},ct={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Ct={M(t,e,r,n,A,i,o,s){const a=w(t)?e.animations:[e.animations[0]],B={};for(let e=0;e<a.length;e++){const E=a[e],c=E.name||e;if(w(t)&&c!==t)continue;const C=E.channelsMap[r];if(C)for(let t=0;t<C.length;t++){const e=C[t];"translation"===e.target.path?(this.N(A,E.samplers[e.sampler],n,1),B.translation=f(st,A)):"rotation"===e.target.path?(this.S(i,E.samplers[e.sampler],n,1),B.rotation=m(at,i)):"scale"===e.target.path?(this.N(o,E.samplers[e.sampler],n,1),B.scale=f(Bt,o)):"weights"===e.target.path&&s&&(this.N(s,E.samplers[e.sampler],n,s.length),B.weights=s)}}return B},N(t,e,r,n){switch(e.interpolation){case"LINEAR":{const A=this.U(ct,e,r,1*n);A&&(t=function(t,e,r,n){for(let A=0;A<t.length;A++)t[A]=e[A]+n*(r[A]-e[A]);return t}(t,A.PREVIOUS,A.NEXT,A.INTERPOLATION));break}case"STEP":{const A=this.U(ct,e,r,1*n);A&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...A.PREVIOUS));break}case"CUBICSPLINE":{const A=this.U(ct,e,r,3*n);A&&(t=this.G(t,A,e.input.array,3*n));break}}return t},S(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.U(ct,e,r,1);n&&U(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.U(ct,e,r,1);n&&(t=M(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.U(ct,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.G(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},m(t,e){const r=t.length;let n,A,i,o=0,s=r-1,a=Math.floor((o+s)/2);for(;o<=r-1&&s>=0;){if(o===s)return null;if(t[a]<=e&&e<=t[a+1]){const r=t[a];return n=a,A=a+1,i=(e-r)/(t[a+1]-r),{preIndx:n,nextIndex:A,interpolation:i}}e<t[a]?(s=a,a=Math.floor((o+s)/2)):t[a+1]<e&&(o=a,a=Math.floor((o+s)/2))}return null},U(t,e,r,n){const A=e.input.array,i=e.output.array,o=e.output.itemSize;(r<A[0]||r>A[A.length-1])&&(r=Math.max(A[0],Math.min(A[A.length-1],r))),r===A[A.length-1]&&(r=A[0]);const s=this.m(A,r);if(!s||!s.nextIndex)return null;const{preIndx:a,nextIndex:B,interpolation:E}=s;t.PREINDEX=a,t.NEXTINDEX=B,t.INTERPOLATION=E;const c=o*n;return t.PREVIOUS=i.subarray(t.PREINDEX*c,(t.PREINDEX+1)*c),t.NEXT=i.subarray(t.NEXTINDEX*c,(t.NEXTINDEX+1)*c),t},G(t,e,r,n){const A=e.INTERPOLATION,i=r[e.PREINDEX],o=r[e.NEXTINDEX];for(let r=0;r<3;r++){const s=e.PREVIOUS[n+r],a=(o-i)*e.PREVIOUS[2*n+r],B=e.NEXT[3+r],E=(o-i)*e.NEXT[r],c=(2*Math.pow(A,3)-3*Math.pow(A,2)+1)*s+(Math.pow(A,3)-2*Math.pow(A,2)+A)*a+(2*-Math.pow(A,3)+3*Math.pow(A,2))*B+(Math.pow(A,3)-Math.pow(A,2))*E;t[r]=c}return t},getAnimationClip(t,e,r,n){const A=t.nodes[e]&&t.nodes[e].weights;return l(st,...Et.TRANSLATION),M(at,...Et.ROTATION),l(Bt,...Et.SCALE),this.M(n,t,e,r,st,at,Bt,A)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach((e,r)=>{let n=-1/0,A=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const r=i[t],o=e.samplers[r.sampler].input.array;o[o.length-1]>n&&(n=o[o.length-1]),o[0]<A&&(A=o[0])}const o=e.name||r;t.timeSpan[o]={max:n,min:A}}),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?w(e)?r[e]:r[Object.keys(r)[0]]:null}};let ft=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(ue){}t&&"undefined"!=typeof createImageBitmap&&(ft=!0)}const lt="undefined"==typeof document?null:document.createElement("canvas");class ut{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=At.read(e.buffer,e.byteOffset,e.byteLength);this.p(t,r,n)}else this.p(t,e);this.H=new tt(this.rootPath,this.gltf,this.glbBuffer),this.K()}K(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}V(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.H.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then(e=>(t.KHR_techniques_webgl=e,t)):Promise.resolve(t)}load(t){t=t||{};const e=this.J(t),r=this.X(),n=this.v(),A=this.V();return Promise.all([e,r,n,A]).then(t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0]))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return Ct.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return Ct.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return K(t)}static readInterleavedArray(t,e,r,n,A,i,o){return W(t,e,r,n,A,i,o)}p(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=ft?ht.bind(this):this.options.requestImage||_t,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new rt(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate((t,e,r)=>{e.id="buffer_"+r},"buffers"),this.adapter.iterate((t,e,r)=>{e.id="image_"+r},"images"),this.adapter.iterate((t,e,r)=>{e.id="accessor_"+r},"accessors")):(this.adapter=new et(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate((t,e,r)=>{e.id="accessor_"+r},"accessors"),this.adapter.iterate((t,e,r)=>{e.id="image_"+r},"images"))}Z(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!p(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map(t=>{const r=e[t];return r.nodeIndex=t,this.Z(r,e)});t.children=n}var r;return t}J(t){return this.k(t).then(t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.Z(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate((n,A,i)=>{const o={};A.name&&(o.name=A.name),A.nodes&&(o.nodes=A.nodes.map(e=>t[e])),this.gltf.scene===n&&(r=i),e.push(o)},"scenes");const n={textures:this.gltf.textures,asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.T(this.gltf.materials);n.materials=t}return n})}k(t){return this.W(t).then(()=>{const t=this.nodes={};return this.adapter.iterate((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n},"nodes"),t})}j(){this.skins=[];const t=[];return this.adapter.iterate((e,r,n)=>{t.push(this.Y(r).then(t=>{t.index=n,this.skins.push(t)}))},"skins"),t}Y(t){const e=t.inverseBindMatrices;return this.adapter.accessor.u("inverseBindMatrices",e).then(e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t))}X(){const t=this.gltf.animations;return w(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate((r,n,A)=>{e.push(this.q(n,t).then(t=>{t.index=A,this.meshes[r]=t}))},"meshes"),e=e.concat(this.j()),Promise.all(e)}q(t,e){const r=t.primitives.map(t=>this.$(t,e)).filter(t=>!!t);return Promise.all(r).then(e=>{const r={};return H(r,t),r.primitives=e,r})}v(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.P(r));return Promise.all(e).then(e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e})}$(t,e){let r;const n=[],A=t.extensions;if(w(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const A=this.adapter.accessor.u(`morphTargets_${t}_${e}`,r[t]);A&&n.push(A)}}if(A&&A.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:i,attributes:o}=A.KHR_draco_mesh_compression,s=this.gltf.bufferViews[i],a=this.H.I(s).then(r=>{const{buffer:n,byteOffset:A}=r;let{byteOffset:i}=s;const a=s.byteLength;i||(i=0);const B=new DataView(n,A+i,a),E={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(B,E).then(t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e})});n.push(a),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.u(t,e[t]);r&&n.push(r)}if(w(t.indices)){const e=this.adapter.accessor.u("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then(e=>{if(A&&A.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const i={attributes:e.reduce((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:A}=e,i=A.length/n;for(let e=0;e<i;e++)for(let i=0;i<n;i++){const o=e*n+i;A[o]<t[i]&&(t[i]=A[o]),A[o]>r[i]&&(r[i]=A[o])}if(e.quantization){const n=e.quantization,A=n.range/(1<<n.quantizationBits),i=n.minValues;D(t,t,A),u(t,t,i),D(r,r,A),u(r,r,i)}e.min=t,e.max=r}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t},{}),material:t.material};return r&&(i.indices=r),n&&(i.morphTargets=n),i.mode=w(t.mode)?t.mode:4,w(t.extras)&&(i.extras=t.extras),i})}}function _t(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!lt)return void e(new Error("There is no canvas to draw image!"));lt.width=r.width,lt.height=r.height;const t=lt.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),A={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,A)},r.onerror=function(t){e(t)},r.src=t}let It,Dt;function ht(t,e){It||(It=new OffscreenCanvas(2,2),Dt=It.getContext("2d",{willReadFrequently:!0})),fetch(t).then(t=>t.arrayBuffer()).then(t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(t=>{let{width:r,height:n}=t;Rt(r)||(r=Tt(r)),Rt(n)||(n=Tt(n));const A=this.options.maxTextureSize;A&&(r=Math.min(A,r),n=Math.min(A,n)),It.width=r,It.height=n,Dt.drawImage(t,0,0,r,n),t.close();const i=Dt.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(i.data)})}).catch(t=>{console.warn(t),e(t)})}function Rt(t){return 0==(t&t-1)&&0!==t}function Tt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Ft(t){return"object"==typeof t&&!!t}function Pt(t){return t*Math.PI/180}function Ot(t){return t/Math.PI*180}function Lt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const yt=[1,1,1,1,2,2,3,0];function Mt(t){const e=t.length;let r="";for(let n=0;n<e;){let A=t[n++];if(128&A){let r=yt[A>>3&7];if(!(64&A)||!r||n+r>e)return null;for(A&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;A=A<<6|63&e}}r+=String.fromCharCode(A)}return r}const Nt=new Array(3),St=new Array(3),dt=[40680631590769,40680631590769,40408299984661.445];const Ut=[1/6378137,1/6378137,1/6356752.314245179],Gt=[1/40680631590769,1/40680631590769,1/40408299984661.445],mt=new Array(3),bt=new Array(3),pt=new Array(3);function wt(t,e){const r=Gt,n=function(t,e,r,n,A){const i=e[0],o=e[1],s=e[2],a=r[0],B=r[1],E=r[2],c=i*i*a*a,C=o*o*B*B,f=s*s*E*E,l=c+C+f,u=Math.sqrt(1/l),_=D(Ht,e,u);if(l<A)return isFinite(u)?_:void 0;const I=n[0],h=n[1],R=n[2],T=Kt;T[0]=_[0]*I*2,T[1]=_[1]*h*2,T[2]=_[2]*R*2;let F,P,O,L,y,M,N,S,d,U,G,m=(1-u)*gt(e)/(.5*gt(T)),b=0;do{m-=b,O=1/(1+m*I),L=1/(1+m*h),y=1/(1+m*R),M=O*O,N=L*L,S=y*y,d=M*O,U=N*L,G=S*y,F=c*M+C*N+f*S-1,P=c*d*I+C*U*h+f*G*R;b=F/(-2*P)}while(Math.abs(F)>1e-12);return t[0]=i*O,t[1]=o*L,t[2]=s*y,t}(mt,e,Ut,r,.1);let A=L(bt,n,r);A=Vt(A,A);const i=O(pt,e,n),o=Math.atan2(A[1],A[0]),s=Math.asin(A[2]),a=Lt(T(i,e))*gt(i);return t[0]=Ot(o),t[1]=Ot(s),t[2]=a,t}const Ht=new Array(3),Kt=new Array(3);function gt(t){return c(t)}function Vt(t,e){const r=e[0],n=e[1],A=e[2];let i=r*r+n*n+A*A;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function Jt(t,e,r,n){r=r||0,n=n||r;const A=Math.abs(t-e);return A<=n||A<=r*Math.max(Math.abs(t),Math.abs(e))}function Xt(t,e){let r="";for(let n=0;n<4;n++){const A=t.getUint8(e+n);r+=String.fromCharCode(A)}return r}const vt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Zt(t,e,r){const n=new Uint8Array(t,e,r);return vt?JSON.parse(vt.decode(n)):JSON.parse(Mt(n))}function xt(t,e,r){const n=new Uint8Array(t,e,r);return vt?JSON.parse(vt.decode(n)):JSON.parse(Mt(n))}function kt(t,e,r){return{offset:e,byteLength:r}}function Wt(t,e,r,n){const{byteOffset:A,componentType:i,type:o}=t,{ctor:s,type:a}=function(t){return Yt[t]}(i||"UNSIGNED_SHORT"),B=function(t){if(!t)return 1;return jt[t]}(o);return{byteStride:0,byteOffset:A+r,itemSize:B,count:n*B,componentType:a,array:new s(e,r+A,n*B)}}function Qt(t,e,r,n){const A=Wt(t,e,r,n);return A.array.buffer.byteLength!==e.byteLength&&(A.array=A.array.slice()),A}const jt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Yt={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function zt(t){for(const e in Yt)if(t===Yt[e].ctor)return Yt[e].type;throw new Error("unrecognized ctor:"+t)}function qt(t,e,r,n){const A=t,i=e.length/3;for(let t=0;t<i;t++)A[3*t]=e[3*t]/65535*n[0]+r[0],A[3*t+1]=e[3*t+1]/65535*n[1]+r[1],A[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return A}function $t(t,e,r){const n=t.getUint32(12,!0),A=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),s=t.buffer;let a,B={},E={},c=null;n>0&&(B=Zt(s,e,n),e+=n),A>0&&(a=function(t,e,r){return{offset:e,byteLength:r}}(0,e,A),e+=A),i>0&&(E=xt(s,e,i),e+=i);const C=kt(0,e,o);return c=s.slice(C.offset,C.offset+C.byteLength),r.push(c),{featureTable:B,featureTableBin:a,batchTable:E,batchTableBin:c}}const te={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"}},ee={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},re={},ne={east:[],north:[],up:[],west:[],south:[],down:[]};let Ae=[],ie=[],oe=[];const se=[0,0,0];const ae=function(t,e){const r=te[t][e];let n;const A=t+e;return re[A]?n=re[A]:(n=function(n,A,i){if(function(t,e){var r=t[0],n=t[1],A=t[2],i=e[0],o=e[1],s=e[2];return Math.abs(r-i)<=1e-6*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(A-s)<=1e-6*Math.max(1,Math.abs(A),Math.abs(s))}(n,se))f(Ae,ee[t]),f(ie,ee[e]),f(oe,ee[r]);else if(Jt(n[0],0,1e-14)&&Jt(n[1],0,1e-14)){const A=Lt(n[2]);f(Ae,ee[t]),"east"!==t&&"west"!==t&&D(Ae,Ae,A),f(ie,ee[e]),"east"!==e&&"west"!==e&&D(ie,ie,A),f(oe,ee[r]),"east"!==r&&"west"!==r&&D(oe,oe,A)}else{!function(t,e){I(e,t,Gt),R(e,e)}(n,ne.up);const A=ne.up,i=ne.east;i[0]=-n[1],i[1]=n[0],i[2]=0,R(ne.east,i),F(ne.north,A,i),D(ne.down,ne.up,-1),D(ne.west,ne.east,-1),D(ne.south,ne.north,-1),Ae=ne[t],ie=ne[e],oe=ne[r]}return i[0]=Ae[0],i[1]=Ae[1],i[2]=Ae[2],i[3]=0,i[4]=ie[0],i[5]=ie[1],i[6]=ie[2],i[7]=0,i[8]=oe[0],i[9]=oe[1],i[10]=oe[2],i[11]=0,i[12]=n[0],i[13]=n[1],i[14]=n[2],i[15]=1,i},re[A]=n),n}("east","north"),Be={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Ee(t){return Be[t]}function ce(t){for(const e in Be)if(t===Be[e])return+e;throw new Error("unrecognized ctor:"+t)}function Ce(t){return 1===t?"FLOAT":"VEC"+t}\n/*!\n * @maptalks/gl v0.83.1\n * LICENSE : UNLICENSED\n * (c) 2016-2023 maptalks.com\n */const fe=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},le=fe(),ue=le.gl_trans__coders=le.gl_trans__coders||{};ue.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),A=le.gl_trans__coders=le.gl_trans__coders||{};let i=`${n}\\n const _____getGlobal = ${fe.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals[\'gl_trans__coders\'] = g___lobals[\'gl_trans__coders\'] || {};`;for(const t in A)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+=\'tran_____scoders["\'+t+\'"] =\'+A[t].toString()+"\\n;");return i+="\\n"+e.substring(n.length),i},ue.registerTranscoder=function(t,e){ue[t]=e},ue.getTranscoder=function(t){return ue[t]};let _e=null;function Ie(){return _e||(_e={"image/crn":ue.crn&&ue.crn(),"image/ktx2":ue.ktx2&&ue.ktx2(),"image/cttf":ue.ktx2&&ue.ktx2(),"draco":ue.draco&&ue.draco()}),_e}class De{constructor(t,e,r){this.A=t,this.tt=e||ut,this.i=r,this.et=Ie()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,A){return e?(n||(n=e.byteLength),this.rt(t,e,r,n,A)):Y.getArrayBuffer(t,{}).then(e=>{const A=e.data;return n||(n=A.byteLength),this.rt(t,A,r,n)})}rt(t,e,r,n,A){const i=A&&A.maxTextureSize,o=this.nt(e,r,n,t);if(o.error)return Promise.resolve(o);const s=t.substring(0,t.lastIndexOf("/")),a=new this.tt(s,o.glb,{transferable:!0,requestImage:this.A,decoders:this.et,supportedFormats:this.i,maxTextureSize:i});return a.load({skipAttributeTransform:!1}).then(e=>{e.url=`${t}-${r}-${n}`;const A=a.transferables;for(let t=0;t<o.transferables.length;t++)A.indexOf(o.transferables[t])<0&&A.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:A,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}})}nt(t,e,r,n){const A=new DataView(t,e,r),i=A.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+n;return console.warn(t),{error:t}}if(A.getUint32(8,!0)!==A.byteLength){const t="Length in b3dm header is inconsistent with b3dm\'s byte length, url: "+n;return console.warn(t),{error:t}}let o,s=A.getUint32(12,!0),a=A.getUint32(16,!0),B=A.getUint32(20,!0),E=A.getUint32(24,!0),c=28+e;B>=570425344?(c-=8,o=s,B=a,E=0,s=0,a=0):E>=570425344&&(c-=4,o=B,B=s,E=a,s=0,a=0);const C=[t];let f,l,u;if(s>0?(f=Zt(t,c,s),c+=s,o=f.BATCH_LENGTH):f={"BATCH_LENGTH":o},a>0&&(c+=a),B>0&&(l=xt(t,c,B),c+=B,E>0)){const e=kt(0,c,E);u=t.slice(e.offset,e.offset+e.byteLength),c+=E,C.push(u)}const _=f.BATCH_LENGTH,I={};if(f&&f.BATCH_ID){I.BATCH_ID=Qt(f.BATCH_ID,t,(void 0).offset,_);const e=I.BATCH_ID.array&&I.BATCH_ID.array.buffer;e&&C.indexOf(e)<0&&C.push(e)}return{count:o,transferables:C,featureTable:f,batchTable:l,batchTableBin:u,b3dm:I,glb:{buffer:t,byteOffset:c,byteLength:A.byteLength+A.byteOffset-c}}}At(){return null}}class he{constructor(t,e,r,n){this.A=t,this.tt=e||ut,this.i=r,this.et=Ie(),this.it=n}load(t,e,r=0,n=0,A){return e?(n||(n=e.byteLength),this.rt(t,e,r,n,A)):Y.getArrayBuffer(t,{}).then(e=>{const A=e.data;return n||(n=A.byteLength),this.rt(t,A,r,n)})}rt(t,e,r,n,A){return this.ot(t,e,r,n,A).then(({gltf:A,transferables:i})=>{const o=this.st(e,r,n,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete A.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:A})})}ot(t,e,r,n,A){const i=A&&A.maxTextureSize,o={transferable:!0,requestImage:this.A,decoders:this.et,supportedFormats:this.i,maxTextureSize:i},s=new DataView(e,r,n),a=32+s.getUint32(12,!0)+s.getUint32(16,!0)+s.getUint32(20,!0)+s.getUint32(24,!0);if(0===s.getUint32(28,!0)){let n=Mt(new Uint8Array(e,a+r,s.byteLength-a));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?Y.getArrayBuffer(n,{}).then(t=>this.Bt(n,{buffer:t.data,byteOffset:0},o)):Y.getJSON(n,{}).then(t=>this.Bt(n,t,o))}{const n={buffer:e,byteOffset:a+r,byteLength:s.byteLength-a};return this.Bt(t,n,o)}}Bt(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),A=new this.tt(n,e,r);return A.load({skipAttributeTransform:!0}).then(r=>{let n=0,i=0;return e.buffer&&(n=e.byteOffset||0,i=e.byteLength||0),r.url=`${t}-${n}-${i}`,{transferables:A.transferables,gltf:r}})}st(t,e,r,n){const A=new DataView(t,e,r),i=A.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+n;return console.warn(t),{error:t}}if(A.getUint32(8,!0)!==A.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:s,featureTableBin:a,batchTable:B,batchTableBin:E}=$t(A,32+e,o),c={},C=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.POSITION;c.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,3*C).slice()},o.push(c.POSITION.array.buffer)}else if(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,r=s.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=s.POSITION_QUANTIZED;c.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:C,componentType:5126,array:this.Et(new Uint16Array(t,n+a.offset,3*C),e,r)},o.push(c.POSITION.array.buffer)}if(s.BATCH_ID){c.BATCH_ID=Qt(s.BATCH_ID,t,a.offset,C);const e=c.BATCH_ID.array&&c.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(s.NORMAL_UP){let{byteOffset:e}=s.NORMAL_UP;c.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,3*C).slice()},o.push(c.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT.byteOffset,c.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,3*C).slice()},o.push(c.NORMAL_RIGHT.array.buffer)}else if(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;c.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:this.ct(new Uint16Array(t,e+a.offset,2*C))},o.push(c.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,c.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:this.ct(new Uint16Array(t,e+a.offset,2*C))},o.push(c.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.SCALE;c.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,C).slice()},o.push(c.SCALE.array.buffer)}else if(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.SCALE_NON_UNIFORM;c.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,3*C).slice()},o.push(c.SCALE_NON_UNIFORM.array.buffer)}return{count:C,batchTable:B,batchTableBin:E,featureTable:s,i3dm:c,transferables:o}}ct(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let A=0;A<e;A++)Re(n,t[2*A],t[2*A+1],65535),r[3*A]=n[0],r[3*A+1]=n[1],r[3*A+2]=n[2];return r}Et(t,e,r){return qt(new Float32Array(t.length),t,e,r)}At(){return null}}function Re(t,e,r,n){if(t[0]=Te(e,n),t[1]=Te(r,n),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Fe(e),t[1]=(1-Math.abs(e))*Fe(t[1])}return R(t,t)}function Te(t,e){return function(t,e,r){return t<e?e:t>r?r:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function Fe(t){return t<0?-1:1}class Pe{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.rt(t,e,r,n)):Y.getArrayBuffer(t,{}).then(e=>{const A=e.data;return n||(n=A.byteLength),this.rt(t,A,r,n)})}rt(t,e,r,n){return this.Ct(e,r,n,t).then(t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts})}Ct(t,e,r,n){const A=new DataView(t,e,r),i=A.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+n;return console.warn(t),{error:t}}if(A.getUint32(8,!0)!==A.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:s,featureTableBin:a,batchTable:B,batchTableBin:E}=$t(A,e+28,o),c=s.QUANTIZED_VOLUME_OFFSET,C=s.QUANTIZED_VOLUME_SCALE,f=s.POINTS_LENGTH;let l,u={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){u=s.extensions["3DTILES_draco_point_compression"],l=new DataView(t,u.byteOffset+a.offset,u.byteLength);const e={attributes:u.properties,useUniqueIDs:!1};return this.ft||(this.ft=Ie().draco),this.ft(l,e).then(e=>{const r=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=s.POSITION,r.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=s.RGB,r.RGBA=s.RGBA,r.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=s.NORMAL,r.NORMAL_OCT16P=s.NORMAL_OCT16P);const n=this.lt(t,e.attributes,a.offset,f,o,c,C);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:zt(t.constructor),array:t},o.push(t.buffer)}else if(s.BATCH_ID||Object.keys(B).length){s.BATCH_ID?n.BATCH_ID=Qt(s.BATCH_ID,t,a.offset,f):n.BATCH_ID=Oe(f);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:f,batchTable:B,batchTableBin:E,featureTable:s,pnts:n,transferables:o}})}const _=this.lt(t,s,a.offset,f,o,c,C);if(s.BATCH_ID||Object.keys(B).length){s.BATCH_ID?_.BATCH_ID=Qt(s.BATCH_ID,t,a.offset,f):_.BATCH_ID=Oe(f);const e=_.BATCH_ID.array&&_.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:f,batchTable:B,batchTableBin:E,featureTable:s,pnts:_,transferables:o})}lt(t,e,r,n,A,i,o){const s={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+3*n*4);o=new Float32Array(e)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},A.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:a}=e.POSITION_QUANTIZED;const{array:B}=e.POSITION_QUANTIZED;a=a||0;const E=B?0:r;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.Et(B||new Uint16Array(t,a+E,3*n),i,o)},A.push(s.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+4*n);o=new Uint8Array(e)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:o},A.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+3*n);o=new Uint8Array(e)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:o},A.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+2*n);o=new Uint16Array(e)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:o},A.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+3*n*4);o=new Float32Array(e)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},A.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+2*n);o=new Uint8Array(e)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:o},A.push(o.buffer)}return s}Et(t,e,r){return qt(new Float32Array(t.length),t,e,r)}At(){return null}}function Oe(t){const e=(r=t)<256?Uint8Array:r<65536?Uint16Array:Uint32Array;var r;const n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:zt(e),array:n}}class Le{constructor(t,e,r,n){this.i=r,this.A=t,this.tt=e||ut,this.it=n}load(t,e,r=0,n=0,A){return e?this.rt(t,e,r,n,A):Y.getArrayBuffer(t,{}).then(e=>{const A=e.data;return this.rt(t,A,r,n)})}rt(t,e,r,n,A){n||(n=e.byteLength);const i=this.ut(e,t,r,n),o=[];for(let r=0;r<i.length;r++){let n;if("b3dm"===i[r].magic)n=new De(this.A,this.tt,this.i);else if("i3dm"===i[r].magic)n=new he(this.A,this.tt,this.i,this.it);else if("pnts"===i[r].magic)n=new Pe;else{if("cmpt"!==i[r].magic){console.warn("Unsupported magic in CMPT tile:",i[r].magic);continue}n=new Le(this.A,this.tt,this.i,this.it)}o.push(n.load(t,e,i[r].offset,i[r].byteLength,A).then(t=>t))}return Promise.all(o).then(t=>({magic:"cmpt",tiles:t}))}ut(t,e,r,n){const A=new DataView(t,r,n),i=A.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===A.byteLength)return[];const o=[],s=A.getUint32(12,!0);let a=16;for(let e=0;e<s;e++){const e=Xt(A,a),n=A.getUint32(a+8,!0);o.push({magic:e,buffer:t,offset:a+r,byteLength:n}),a+=n}return o}}function ye(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,A=n.length;r<A;r++){const A=[];me(n[r],A,t,e)}}}const Me=[],Ne=[],Se=[],de=[0,0,0],Ue=d([]),Ge=[1,1,1];function me(t,e,r,n){const A=e.slice(0);if(t.matrix)A.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=o(Me,t.translation||de),r=a(Ne,t.rotation||Ue),n=s(Se,t.scale||Ge);i(n,r,n);const B=i([],e,n);A.push(B)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)me(t.children[e],A,r,n);if(void 0!==t.mesh){const e=t.mesh,i=r.meshes[e];if(i){const t=A.slice(0),o=i.primitives;for(let A=0,i=o.length;A<i;A++){const i=o[A];i&&(i.matrices=t,n(i,e,A,r))}}}}function be(t,e){let{byteOffset:r,byteStride:n,count:A}=t;const{componentType:i,itemSize:o}=t,s=t.array.buffer,a=i?ut.getTypedArrayCtor(i):t.array.constructor;if(r=void 0===r?t.array.byteOffset:r,n=n||0,A=A||t.array.length/o,(!n||n===o*a.BYTES_PER_ELEMENT)&&r%a.BYTES_PER_ELEMENT==0){const t=new a(s,r,A*o);for(let n=0;n<A*o;n+=o){e(new a(t.buffer,r+n*a.BYTES_PER_ELEMENT,o),n/o)}return}const B=new Uint8Array(o*a.BYTES_PER_ELEMENT);n||(n=o*a.BYTES_PER_ELEMENT);for(let t=0;t<A;t++){const A=new Uint8Array(s,n*t+r,o*a.BYTES_PER_ELEMENT);B.set(A);e(new a(B.buffer),t),A.set(B)}}const pe=[],we=[];function He(t){"3.0"===t.version&&(t=function(t){const e=JSON.parse(JSON.stringify(t)),r=e.rootTiles;for(let t=0;t<r.length;t++){const{boundingbox:e}=r[t],{center:n,xExtent:A,yExtent:i,zExtent:o}=e,s={x:2*n.x-A.x,y:2*n.y-i.y,z:2*n.z-o.z},a={x:A.x,y:i.y,z:o.z};e.min=s,e.max=a}return e.tiles=r,e}(t));const e={asset:{version:"1.0",gltfUpAxis:"Z",s3mType:t.dataType},extensions:t.extensions,geometricError:0,root:{boundingVolume:{},content:{uri:""},transform:[],geometricError:0,refine:"REPLACE",children:[]}},r=t.position.x,A=t.position.y,i=t.position.z,o=function(t,e,r,n){const A=dt,i=Math.cos(r);Nt[0]=i*Math.cos(e),Nt[1]=i*Math.sin(e),Nt[2]=Math.sin(r),Vt(Nt,Nt),I(St,A,Nt);const o=Math.sqrt(T(Nt,St));var s,a,B;return a=St,B=o,(s=St)[0]=a[0]/B,s[1]=a[1]/B,s[2]=a[2]/B,D(Nt,Nt,n),u(t,St,Nt)}([],Pt(r),Pt(A),i),s=ae(o,null,[]);e.root.transform=n([],s);const a=[];for(let r=0,n=t.tiles.length;r<n;r++)if(t.tiles[r].boundingbox){const n=t.tiles[r].boundingbox;l(pe,n.min.x,n.min.y,n.min.z),l(we,n.max.x,n.max.y,n.max.z);const A={center:[0,0,0],radius:0};Ke(pe,we,A),e.root.children.push({boundingVolume:{sphere:[...A.center,A.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(A)}else if(t.tiles[r].boundingsphere){const{boundingsphere:n}=t.tiles[r],A={center:[n.center.x,n.center.y,n.center.z],radius:n.radius};e.root.children.push({boundingVolume:{sphere:[...A.center,A.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(A)}const B=function(t,e){if(0===t.length)return e;const r=t.length;if(1===r)return function(t,e){return f(e.center,t.center),e.radius=t.radius,e}(t[0],e);if(2===r)return function(t,e,r){const n=t.center,A=t.radius,i=e.center,o=e.radius,s=_(Ve,i,n),a=er(s);if(A>=a+o)return t.clone(r),r;if(o>=a+A)return e.clone(r),r;const B=.5*(A+a+o),E=D(Je,s,(-A+B)/a);return u(E,E,n),f(r.center,E),r.radius=B,r}(t[0],t[1],e);const n=[];for(let e=0;e<r;e++)n.push(t[e].center);const A=(e=function(t,e){if(0===t.length)return e.center=l(e.center,0,0,0),e.radius=0,e;const r=f(Qe,t[0]),n=f(Xe,r),A=f(ve,r),i=f(Ze,r),o=f(xe,r),s=f(ke,r),a=f(We,r),B=t.length;for(let e=1;e<B;e++){f(r,t[e]);const B=r[0],E=r[1],c=r[2];B<n[0]&&f(n,r),B>o[0]&&f(o,r),E<A[1]&&f(A,r),E>s[1]&&f(s,r),c<i[2]&&f(i,r),c>a[2]&&f(a,r)}const E=tr(_(je,o,n)),c=tr(_(je,s,A)),C=tr(_(je,a,i));let u=n,I=o,D=E;c>D&&(D=c,u=A,I=s);C>D&&(D=C,u=i,I=a);const h=Ye;h[0]=.5*(u[0]+I[0]),h[1]=.5*(u[1]+I[1]),h[2]=.5*(u[2]+I[2]);let R=tr(_(je,I,h)),T=Math.sqrt(R);const F=ze;F[0]=n[0],F[1]=A[1],F[2]=i[2];const P=qe;P[0]=o[0],P[1]=s[1],P[2]=a[2];const O=ge(F,P,$e);let L=0;for(let e=0;e<B;e++){f(r,t[e]);const n=er(_(je,r,O));n>L&&(L=n);const A=tr(_(je,r,h));if(A>R){const t=Math.sqrt(A);T=.5*(T+t),R=T*T;const e=t-T;h[0]=(T*h[0]+e*r[0])/t,h[1]=(T*h[1]+e*r[1])/t,h[2]=(T*h[2]+e*r[2])/t}}T<L?(f(e.center,h),e.radius=T):(f(e.center,O),e.radius=L);return e}(n,e)).center;let i=e.radius;for(let e=0;e<r;e++){const r=t[e];i=Math.max(i,h(A,r.center)+r.radius)}return e.radius=i,e}(a,{center:[0,0,0],radius:0});return e.root.boundingVolume.sphere=[...B.center,B.radius],e}function Ke(t,e,r){let n=ge(t,e,r.center);return r.radius=h(n,e),r}function ge(t,e,r){return r[0]=.5*(t[0]+e[0]),r[1]=.5*(t[1]+e[1]),r[2]=.5*(t[2]+e[2]),r}const Ve=[],Je=[];const Xe=[],ve=[],Ze=[],xe=[],ke=[],We=[],Qe=[],je=[],Ye=[],ze=[],qe=[],$e=[];function tr(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function er(t){return Math.hypot(t[0],t[1],t[2])}\n/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function rr(t){let e=t.length;for(;--e>=0;)t[e]=0}const nr=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ar=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ir=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),or=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),sr=new Array(576);rr(sr);const ar=new Array(60);rr(ar);const Br=new Array(512);rr(Br);const Er=new Array(256);rr(Er);const cr=new Array(29);rr(cr);const Cr=new Array(30);function fr(t,e,r,n,A){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=A,this.has_stree=t&&t.length}let lr,ur,_r;function Ir(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}rr(Cr);const Dr=t=>t<256?Br[t]:Br[256+(t>>>7)],hr=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Rr=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,hr(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},Tr=(t,e,r)=>{Rr(t,r[2*e],r[2*e+1])},Fr=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},Pr=(t,e,r)=>{const n=new Array(16);let A,i,o=0;for(A=1;A<=15;A++)o=o+r[A-1]<<1,n[A]=o;for(i=0;i<=e;i++){let e=t[2*i+1];0!==e&&(t[2*i]=Fr(n[e]++,e))}},Or=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},Lr=t=>{t.bi_valid>8?hr(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},yr=(t,e,r,n)=>{const A=2*e,i=2*r;return t[A]<t[i]||t[A]===t[i]&&n[e]<=n[r]},Mr=(t,e,r)=>{const n=t.heap[r];let A=r<<1;for(;A<=t.heap_len&&(A<t.heap_len&&yr(e,t.heap[A+1],t.heap[A],t.depth)&&A++,!yr(e,n,t.heap[A],t.depth));)t.heap[r]=t.heap[A],r=A,A<<=1;t.heap[r]=n},Nr=(t,e,r)=>{let n,A,i,o,s=0;if(0!==t.sym_next)do{n=255&t.pending_buf[t.sym_buf+s++],n+=(255&t.pending_buf[t.sym_buf+s++])<<8,A=t.pending_buf[t.sym_buf+s++],0===n?Tr(t,A,e):(i=Er[A],Tr(t,i+256+1,e),o=nr[i],0!==o&&(A-=cr[i],Rr(t,A,o)),n--,i=Dr(n),Tr(t,i,r),o=Ar[i],0!==o&&(n-=Cr[i],Rr(t,n,o)))}while(s<t.sym_next);Tr(t,256,e)},Sr=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,A=e.stat_desc.has_stree,i=e.stat_desc.elems;let o,s,a,B=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<i;o++)0!==r[2*o]?(t.heap[++t.heap_len]=B=o,t.depth[o]=0):r[2*o+1]=0;for(;t.heap_len<2;)a=t.heap[++t.heap_len]=B<2?++B:0,r[2*a]=1,t.depth[a]=0,t.opt_len--,A&&(t.static_len-=n[2*a+1]);for(e.max_code=B,o=t.heap_len>>1;o>=1;o--)Mr(t,r,o);a=i;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Mr(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=s,r[2*a]=r[2*o]+r[2*s],t.depth[a]=(t.depth[o]>=t.depth[s]?t.depth[o]:t.depth[s])+1,r[2*o+1]=r[2*s+1]=a,t.heap[1]=a++,Mr(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,A=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,a=e.stat_desc.max_length;let B,E,c,C,f,l,u=0;for(C=0;C<=15;C++)t.bl_count[C]=0;for(r[2*t.heap[t.heap_max]+1]=0,B=t.heap_max+1;B<573;B++)E=t.heap[B],C=r[2*r[2*E+1]+1]+1,C>a&&(C=a,u++),r[2*E+1]=C,E>n||(t.bl_count[C]++,f=0,E>=s&&(f=o[E-s]),l=r[2*E],t.opt_len+=l*(C+f),i&&(t.static_len+=l*(A[2*E+1]+f)));if(0!==u){do{for(C=a-1;0===t.bl_count[C];)C--;t.bl_count[C]--,t.bl_count[C+1]+=2,t.bl_count[a]--,u-=2}while(u>0);for(C=a;0!==C;C--)for(E=t.bl_count[C];0!==E;)c=t.heap[--B],c>n||(r[2*c+1]!==C&&(t.opt_len+=(C-r[2*c+1])*r[2*c],r[2*c+1]=C),E--)}})(t,e),Pr(r,B,t.bl_count)},dr=(t,e,r)=>{let n,A,i=-1,o=e[1],s=0,a=7,B=4;for(0===o&&(a=138,B=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)A=o,o=e[2*(n+1)+1],++s<a&&A===o||(s<B?t.bl_tree[2*A]+=s:0!==A?(A!==i&&t.bl_tree[2*A]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,i=A,0===o?(a=138,B=3):A===o?(a=6,B=3):(a=7,B=4))},Ur=(t,e,r)=>{let n,A,i=-1,o=e[1],s=0,a=7,B=4;for(0===o&&(a=138,B=3),n=0;n<=r;n++)if(A=o,o=e[2*(n+1)+1],!(++s<a&&A===o)){if(s<B)do{Tr(t,A,t.bl_tree)}while(0!=--s);else 0!==A?(A!==i&&(Tr(t,A,t.bl_tree),s--),Tr(t,16,t.bl_tree),Rr(t,s-3,2)):s<=10?(Tr(t,17,t.bl_tree),Rr(t,s-3,3)):(Tr(t,18,t.bl_tree),Rr(t,s-11,7));s=0,i=A,0===o?(a=138,B=3):A===o?(a=6,B=3):(a=7,B=4)}};let Gr=!1;const mr=(t,e,r,n)=>{Rr(t,0+(n?1:0),3),Lr(t),hr(t,r),hr(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r};var br={_t:t=>{Gr||((()=>{let t,e,r,n,A;const i=new Array(16);for(r=0,n=0;n<28;n++)for(cr[n]=r,t=0;t<1<<nr[n];t++)Er[r++]=n;for(Er[r-1]=n,A=0,n=0;n<16;n++)for(Cr[n]=A,t=0;t<1<<Ar[n];t++)Br[A++]=n;for(A>>=7;n<30;n++)for(Cr[n]=A<<7,t=0;t<1<<Ar[n]-7;t++)Br[256+A++]=n;for(e=0;e<=15;e++)i[e]=0;for(t=0;t<=143;)sr[2*t+1]=8,t++,i[8]++;for(;t<=255;)sr[2*t+1]=9,t++,i[9]++;for(;t<=279;)sr[2*t+1]=7,t++,i[7]++;for(;t<=287;)sr[2*t+1]=8,t++,i[8]++;for(Pr(sr,287,i),t=0;t<30;t++)ar[2*t+1]=5,ar[2*t]=Fr(t,5);lr=new fr(sr,nr,257,286,15),ur=new fr(ar,Ar,0,30,15),_r=new fr(new Array(0),ir,0,19,7)})(),Gr=!0),t.l_desc=new Ir(t.dyn_ltree,lr),t.d_desc=new Ir(t.dyn_dtree,ur),t.bl_desc=new Ir(t.bl_tree,_r),t.bi_buf=0,t.bi_valid=0,Or(t)},It:mr,Dt:(t,e,r,n)=>{let A,i,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Sr(t,t.l_desc),Sr(t,t.d_desc),o=(t=>{let e;for(dr(t,t.dyn_ltree,t.l_desc.max_code),dr(t,t.dyn_dtree,t.d_desc.max_code),Sr(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*or[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),A=t.opt_len+3+7>>>3,i=t.static_len+3+7>>>3,i<=A&&(A=i)):A=i=r+5,r+4<=A&&-1!==e?mr(t,e,r,n):4===t.strategy||i===A?(Rr(t,2+(n?1:0),3),Nr(t,sr,ar)):(Rr(t,4+(n?1:0),3),((t,e,r,n)=>{let A;for(Rr(t,e-257,5),Rr(t,r-1,5),Rr(t,n-4,4),A=0;A<n;A++)Rr(t,t.bl_tree[2*or[A]+1],3);Ur(t,t.dyn_ltree,e-1),Ur(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Nr(t,t.dyn_ltree,t.dyn_dtree)),Or(t),n&&Lr(t)},ht:(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(Er[r]+256+1)]++,t.dyn_dtree[2*Dr(e)]++),t.sym_next===t.sym_end),Rt:t=>{Rr(t,2,3),Tr(t,256,sr),(t=>{16===t.bi_valid?(hr(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var pr=(t,e,r,n)=>{let A=65535&t|0,i=t>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{A=A+e[n++]|0,i=i+A|0}while(--o);A%=65521,i%=65521}return A|i<<16|0};const wr=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var Hr=(t,e,r,n)=>{const A=wr,i=n+r;t^=-1;for(let r=n;r<i;r++)t=t>>>8^A[255&(t^e[r])];return-1^t},Kr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},gr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_t:Vr,It:Jr,Dt:Xr,ht:vr,Rt:Zr}=br,{Z_NO_FLUSH:xr,Z_PARTIAL_FLUSH:kr,Z_FULL_FLUSH:Wr,Z_FINISH:Qr,Z_BLOCK:jr,Z_OK:Yr,Z_STREAM_END:zr,Z_STREAM_ERROR:qr,Z_DATA_ERROR:$r,Z_BUF_ERROR:tn,Z_DEFAULT_COMPRESSION:en,Z_FILTERED:rn,Z_HUFFMAN_ONLY:nn,Z_RLE:An,Z_FIXED:on,Z_DEFAULT_STRATEGY:sn,Z_UNKNOWN:an,Z_DEFLATED:Bn}=gr,En=(t,e)=>(t.msg=Kr[e],e),cn=t=>2*t-(t>4?9:0),Cn=t=>{let e=t.length;for(;--e>=0;)t[e]=0},fn=t=>{let e,r,n,A=t.w_size;e=t.hash_size,n=e;do{r=t.head[--n],t.head[n]=r>=A?r-A:0}while(--e);e=A,n=e;do{r=t.prev[--n],t.prev[n]=r>=A?r-A:0}while(--e)};let ln=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const un=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},_n=(t,e)=>{Xr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,un(t.strm)},In=(t,e)=>{t.pending_buf[t.pending++]=e},Dn=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},hn=(t,e,r,n)=>{let A=t.avail_in;return A>n&&(A=n),0===A?0:(t.avail_in-=A,e.set(t.input.subarray(t.next_in,t.next_in+A),r),1===t.state.wrap?t.adler=pr(t.adler,e,A,r):2===t.state.wrap&&(t.adler=Hr(t.adler,e,A,r)),t.next_in+=A,t.total_in+=A,A)},Rn=(t,e)=>{let r,n,A=t.max_chain_length,i=t.strstart,o=t.prev_length,s=t.nice_match;const a=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,B=t.window,E=t.w_mask,c=t.prev,C=t.strstart+258;let f=B[i+o-1],l=B[i+o];t.prev_length>=t.good_match&&(A>>=2),s>t.lookahead&&(s=t.lookahead);do{if(r=e,B[r+o]===l&&B[r+o-1]===f&&B[r]===B[i]&&B[++r]===B[i+1]){i+=2,r++;do{}while(B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&i<C);if(n=258-(C-i),i=C-258,n>o){if(t.match_start=e,o=n,n>=s)break;f=B[i+o-1],l=B[i+o]}}}while((e=c[e&E])>a&&0!=--A);return o<=t.lookahead?o:t.lookahead},Tn=t=>{const e=t.w_size;let r,n,A;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)&&(t.window.set(t.window.subarray(e,e+e-n),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),fn(t),n+=e),0===t.strm.avail_in)break;if(r=hn(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=r,t.lookahead+t.insert>=3)for(A=t.strstart-t.insert,t.ins_h=t.window[A],t.ins_h=ln(t,t.ins_h,t.window[A+1]);t.insert&&(t.ins_h=ln(t,t.ins_h,t.window[A+3-1]),t.prev[A&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=A,A++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},Fn=(t,e)=>{let r,n,A,i=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,s=t.strm.avail_in;do{if(r=65535,A=t.bi_valid+42>>3,t.strm.avail_out<A)break;if(A=t.strm.avail_out-A,n=t.strstart-t.block_start,r>n+t.strm.avail_in&&(r=n+t.strm.avail_in),r>A&&(r=A),r<i&&(0===r&&e!==Qr||e===xr||r!==n+t.strm.avail_in))break;o=e===Qr&&r===n+t.strm.avail_in?1:0,Jr(t,0,0,o),t.pending_buf[t.pending-4]=r,t.pending_buf[t.pending-3]=r>>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,un(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&(hn(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===o);return s-=t.strm.avail_in,s&&(s>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=s&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-s,t.strm.next_in),t.strstart),t.strstart+=s,t.insert+=s>t.w_size-t.insert?t.w_size-t.insert:s),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?4:e!==xr&&e!==Qr&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(A=t.window_size-t.strstart,t.strm.avail_in>A&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,A+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),A>t.strm.avail_in&&(A=t.strm.avail_in),A&&(hn(t.strm,t.window,t.strstart,A),t.strstart+=A,t.insert+=A>t.w_size-t.insert?t.w_size-t.insert:A),t.high_water<t.strstart&&(t.high_water=t.strstart),A=t.bi_valid+42>>3,A=t.pending_buf_size-A>65535?65535:t.pending_buf_size-A,i=A>t.w_size?t.w_size:A,n=t.strstart-t.block_start,(n>=i||(n||e===Qr)&&e!==xr&&0===t.strm.avail_in&&n<=A)&&(r=n>A?A:n,o=e===Qr&&0===t.strm.avail_in&&r===n?1:0,Jr(t,t.block_start,r,o),t.block_start+=r,un(t.strm)),o?3:1)},Pn=(t,e)=>{let r,n;for(;;){if(t.lookahead<262){if(Tn(t),t.lookahead<262&&e===xr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-262&&(t.match_length=Rn(t,r)),t.match_length>=3)if(n=vr(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=ln(t,t.ins_h,t.window[t.strstart+1]);else n=vr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Qr?(_n(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(_n(t,!1),0===t.strm.avail_out)?1:2},On=(t,e)=>{let r,n,A;for(;;){if(t.lookahead<262){if(Tn(t),t.lookahead<262&&e===xr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-262&&(t.match_length=Rn(t,r),t.match_length<=5&&(t.strategy===rn||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){A=t.strstart+t.lookahead-3,n=vr(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=A&&(t.ins_h=ln(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(_n(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=vr(t,0,t.window[t.strstart-1]),n&&_n(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=vr(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Qr?(_n(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(_n(t,!1),0===t.strm.avail_out)?1:2};function Ln(t,e,r,n,A){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=A}const yn=[new Ln(0,0,0,0,Fn),new Ln(4,4,8,4,Pn),new Ln(4,5,16,8,Pn),new Ln(4,6,32,32,Pn),new Ln(4,4,16,16,On),new Ln(8,16,32,32,On),new Ln(8,16,128,128,On),new Ln(8,32,128,256,On),new Ln(32,128,258,1024,On),new Ln(32,258,258,4096,On)];function Mn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Bn,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Cn(this.dyn_ltree),Cn(this.dyn_dtree),Cn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Cn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Cn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Nn=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||42!==e.status&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&113!==e.status&&666!==e.status?1:0},Sn=t=>{if(Nn(t))return En(t,qr);t.total_in=t.total_out=0,t.data_type=an;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=-2,Vr(e),Yr},dn=t=>{const e=Sn(t);var r;return e===Yr&&((r=t.state).window_size=2*r.w_size,Cn(r.head),r.max_lazy_match=yn[r.level].max_lazy,r.good_match=yn[r.level].good_length,r.nice_match=yn[r.level].nice_length,r.max_chain_length=yn[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),e},Un=(t,e,r,n,A,i)=>{if(!t)return qr;let o=1;if(e===en&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),A<1||A>9||r!==Bn||n<8||n>15||e<0||e>9||i<0||i>on||8===n&&1!==o)return En(t,qr);8===n&&(n=9);const s=new Mn;return t.state=s,s.strm=t,s.status=42,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=A+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new Uint8Array(2*s.w_size),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<A+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=3*(s.lit_bufsize-1),s.level=e,s.strategy=i,s.method=r,dn(t)};var Gn={deflateInit:(t,e)=>Un(t,e,Bn,15,8,sn),deflateInit2:Un,deflateReset:dn,deflateResetKeep:Sn,deflateSetHeader:(t,e)=>Nn(t)||2!==t.state.wrap?qr:(t.state.gzhead=e,Yr),deflate:(t,e)=>{if(Nn(t)||e>jr||e<0)return t?En(t,qr):qr;const r=t.state;if(!t.output||0!==t.avail_in&&!t.input||666===r.status&&e!==Qr)return En(t,0===t.avail_out?tn:qr);const n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(un(t),0===t.avail_out)return r.last_flush=-1,Yr}else if(0===t.avail_in&&cn(e)<=cn(n)&&e!==Qr)return En(t,tn);if(666===r.status&&0!==t.avail_in)return En(t,tn);if(42===r.status&&0===r.wrap&&(r.status=113),42===r.status){let e=Bn+(r.w_bits-8<<4)<<8,n=-1;if(n=r.strategy>=nn||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=n<<6,0!==r.strstart&&(e|=32),e+=31-e%31,Dn(r,e),0!==r.strstart&&(Dn(r,t.adler>>>16),Dn(r,65535&t.adler)),t.adler=1,r.status=113,un(t),0!==r.pending)return r.last_flush=-1,Yr}if(57===r.status)if(t.adler=0,In(r,31),In(r,139),In(r,8),r.gzhead)In(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),In(r,255&r.gzhead.time),In(r,r.gzhead.time>>8&255),In(r,r.gzhead.time>>16&255),In(r,r.gzhead.time>>24&255),In(r,9===r.level?2:r.strategy>=nn||r.level<2?4:0),In(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(In(r,255&r.gzhead.extra.length),In(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=Hr(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(In(r,0),In(r,0),In(r,0),In(r,0),In(r,0),In(r,9===r.level?2:r.strategy>=nn||r.level<2?4:0),In(r,3),r.status=113,un(t),0!==r.pending)return r.last_flush=-1,Yr;if(69===r.status){if(r.gzhead.extra){let e=r.pending,n=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+n>r.pending_buf_size;){let A=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+A),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>e&&(t.adler=Hr(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex+=A,un(t),0!==r.pending)return r.last_flush=-1,Yr;e=0,n-=A}let A=new Uint8Array(r.gzhead.extra);r.pending_buf.set(A.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending+=n,r.gzhead.hcrc&&r.pending>e&&(t.adler=Hr(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=Hr(t.adler,r.pending_buf,r.pending-n,n)),un(t),0!==r.pending)return r.last_flush=-1,Yr;n=0}e=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,In(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=Hr(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=Hr(t.adler,r.pending_buf,r.pending-n,n)),un(t),0!==r.pending)return r.last_flush=-1,Yr;n=0}e=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,In(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=Hr(t.adler,r.pending_buf,r.pending-n,n))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(un(t),0!==r.pending))return r.last_flush=-1,Yr;In(r,255&t.adler),In(r,t.adler>>8&255),t.adler=0}if(r.status=113,un(t),0!==r.pending)return r.last_flush=-1,Yr}if(0!==t.avail_in||0!==r.lookahead||e!==xr&&666!==r.status){let n=0===r.level?Fn(r,e):r.strategy===nn?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(Tn(t),0===t.lookahead)){if(e===xr)return 1;break}if(t.match_length=0,r=vr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Qr?(_n(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(_n(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===An?((t,e)=>{let r,n,A,i;const o=t.window;for(;;){if(t.lookahead<=258){if(Tn(t),t.lookahead<=258&&e===xr)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(A=t.strstart-1,n=o[A],n===o[++A]&&n===o[++A]&&n===o[++A])){i=t.strstart+258;do{}while(n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&A<i);t.match_length=258-(i-A),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=vr(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=vr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(_n(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Qr?(_n(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(_n(t,!1),0===t.strm.avail_out)?1:2})(r,e):yn[r.level].func(r,e);if(3!==n&&4!==n||(r.status=666),1===n||3===n)return 0===t.avail_out&&(r.last_flush=-1),Yr;if(2===n&&(e===kr?Zr(r):e!==jr&&(Jr(r,0,0,!1),e===Wr&&(Cn(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),un(t),0===t.avail_out))return r.last_flush=-1,Yr}return e!==Qr?Yr:r.wrap<=0?zr:(2===r.wrap?(In(r,255&t.adler),In(r,t.adler>>8&255),In(r,t.adler>>16&255),In(r,t.adler>>24&255),In(r,255&t.total_in),In(r,t.total_in>>8&255),In(r,t.total_in>>16&255),In(r,t.total_in>>24&255)):(Dn(r,t.adler>>>16),Dn(r,65535&t.adler)),un(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Yr:zr)},deflateEnd:t=>{if(Nn(t))return qr;const e=t.state.status;return t.state=null,113===e?En(t,$r):Yr},deflateSetDictionary:(t,e)=>{let r=e.length;if(Nn(t))return qr;const n=t.state,A=n.wrap;if(2===A||1===A&&42!==n.status||n.lookahead)return qr;if(1===A&&(t.adler=pr(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===A&&(Cn(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const i=t.avail_in,o=t.next_in,s=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,Tn(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=ln(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,Tn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=o,t.input=s,t.avail_in=i,n.wrap=A,Yr},deflateInfo:"pako deflate (from Nodeca project)"};const mn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var bn=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)mn(r,e)&&(t[e]=r[e])}}return t},pn=t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,A=t.length;e<A;e++){let A=t[e];r.set(A,n),n+=A.length}return r};let wn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){wn=!1}const Hn=new Uint8Array(256);for(let t=0;t<256;t++)Hn[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Hn[254]=Hn[254]=1;var Kn=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,A,i,o=t.length,s=0;for(A=0;A<o;A++)r=t.charCodeAt(A),55296==(64512&r)&&A+1<o&&(n=t.charCodeAt(A+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),A++)),s+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(s),i=0,A=0;i<s;A++)r=t.charCodeAt(A),55296==(64512&r)&&A+1<o&&(n=t.charCodeAt(A+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),A++)),r<128?e[i++]=r:r<2048?(e[i++]=192|r>>>6,e[i++]=128|63&r):r<65536?(e[i++]=224|r>>>12,e[i++]=128|r>>>6&63,e[i++]=128|63&r):(e[i++]=240|r>>>18,e[i++]=128|r>>>12&63,e[i++]=128|r>>>6&63,e[i++]=128|63&r);return e},gn=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,A;const i=new Array(2*r);for(A=0,n=0;n<r;){let e=t[n++];if(e<128){i[A++]=e;continue}let o=Hn[e];if(o>4)i[A++]=65533,n+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&n<r;)e=e<<6|63&t[n++],o--;o>1?i[A++]=65533:e<65536?i[A++]=e:(e-=65536,i[A++]=55296|e>>10&1023,i[A++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&wn)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(i,A)},Vn=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+Hn[t[r]]>e?r:e};var Jn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Xn=Object.prototype.toString,{Z_NO_FLUSH:vn,Z_SYNC_FLUSH:Zn,Z_FULL_FLUSH:xn,Z_FINISH:kn,Z_OK:Wn,Z_STREAM_END:Qn,Z_DEFAULT_COMPRESSION:jn,Z_DEFAULT_STRATEGY:Yn,Z_DEFLATED:zn}=gr;function qn(t){this.options=bn({level:jn,method:zn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Yn},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Jn,this.strm.avail_out=0;let r=Gn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Wn)throw new Error(Kr[r]);if(e.header&&Gn.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Kn(e.dictionary):"[object ArrayBuffer]"===Xn.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Gn.deflateSetDictionary(this.strm,t),r!==Wn)throw new Error(Kr[r]);this.Tt=!0}}function $n(t,e){const r=new qn(e);if(r.push(t,!0),r.err)throw r.msg||Kr[r.err];return r.result}qn.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let A,i;if(this.ended)return!1;for(i=e===~~e?e:!0===e?kn:vn,"string"==typeof t?r.input=Kn(t):"[object ArrayBuffer]"===Xn.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(i===Zn||i===xn)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(A=Gn.deflate(r,i),A===Qn)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),A=Gn.deflateEnd(this.strm),this.onEnd(A),this.ended=!0,A===Wn;if(0!==r.avail_out){if(i>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},qn.prototype.onData=function(t){this.chunks.push(t)},qn.prototype.onEnd=function(t){t===Wn&&(this.result=pn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var tA={Deflate:qn,deflate:$n,deflateRaw:function(t,e){return(e=e||{}).raw=!0,$n(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,$n(t,e)},constants:gr};var eA=function(t,e){let r,n,A,i,o,s,a,B,E,c,C,f,l,u,_,I,D,h,R,T,F,P,O,L;const y=t.state;r=t.next_in,O=t.input,n=r+(t.avail_in-5),A=t.next_out,L=t.output,i=A-(e-t.avail_out),o=A+(t.avail_out-257),s=y.dmax,a=y.wsize,B=y.whave,E=y.wnext,c=y.window,C=y.hold,f=y.bits,l=y.lencode,u=y.distcode,_=(1<<y.lenbits)-1,I=(1<<y.distbits)-1;t:do{f<15&&(C+=O[r++]<<f,f+=8,C+=O[r++]<<f,f+=8),D=l[C&_];e:for(;;){if(h=D>>>24,C>>>=h,f-=h,h=D>>>16&255,0===h)L[A++]=65535&D;else{if(!(16&h)){if(0==(64&h)){D=l[(65535&D)+(C&(1<<h)-1)];continue e}if(32&h){y.mode=16191;break t}t.msg="invalid literal/length code",y.mode=16209;break t}R=65535&D,h&=15,h&&(f<h&&(C+=O[r++]<<f,f+=8),R+=C&(1<<h)-1,C>>>=h,f-=h),f<15&&(C+=O[r++]<<f,f+=8,C+=O[r++]<<f,f+=8),D=u[C&I];r:for(;;){if(h=D>>>24,C>>>=h,f-=h,h=D>>>16&255,!(16&h)){if(0==(64&h)){D=u[(65535&D)+(C&(1<<h)-1)];continue r}t.msg="invalid distance code",y.mode=16209;break t}if(T=65535&D,h&=15,f<h&&(C+=O[r++]<<f,f+=8,f<h&&(C+=O[r++]<<f,f+=8)),T+=C&(1<<h)-1,T>s){t.msg="invalid distance too far back",y.mode=16209;break t}if(C>>>=h,f-=h,h=A-i,T>h){if(h=T-h,h>B&&y.sane){t.msg="invalid distance too far back",y.mode=16209;break t}if(F=0,P=c,0===E){if(F+=a-h,h<R){R-=h;do{L[A++]=c[F++]}while(--h);F=A-T,P=L}}else if(E<h){if(F+=a+E-h,h-=E,h<R){R-=h;do{L[A++]=c[F++]}while(--h);if(F=0,E<R){h=E,R-=h;do{L[A++]=c[F++]}while(--h);F=A-T,P=L}}}else if(F+=E-h,h<R){R-=h;do{L[A++]=c[F++]}while(--h);F=A-T,P=L}for(;R>2;)L[A++]=P[F++],L[A++]=P[F++],L[A++]=P[F++],R-=3;R&&(L[A++]=P[F++],R>1&&(L[A++]=P[F++]))}else{F=A-T;do{L[A++]=L[F++],L[A++]=L[F++],L[A++]=L[F++],R-=3}while(R>2);R&&(L[A++]=L[F++],R>1&&(L[A++]=L[F++]))}break}}break}}while(r<n&&A<o);R=f>>3,r-=R,f-=R<<3,C&=(1<<f)-1,t.next_in=r,t.next_out=A,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=A<o?o-A+257:257-(A-o),y.hold=C,y.bits=f};const rA=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),nA=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),AA=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),iA=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var oA=(t,e,r,n,A,i,o,s)=>{const a=s.bits;let B,E,c,C,f,l,u=0,_=0,I=0,D=0,h=0,R=0,T=0,F=0,P=0,O=0,L=null;const y=new Uint16Array(16),M=new Uint16Array(16);let N,S,d,U=null;for(u=0;u<=15;u++)y[u]=0;for(_=0;_<n;_++)y[e[r+_]]++;for(h=a,D=15;D>=1&&0===y[D];D--);if(h>D&&(h=D),0===D)return A[i++]=20971520,A[i++]=20971520,s.bits=1,0;for(I=1;I<D&&0===y[I];I++);for(h<I&&(h=I),F=1,u=1;u<=15;u++)if(F<<=1,F-=y[u],F<0)return-1;if(F>0&&(0===t||1!==D))return-1;for(M[1]=0,u=1;u<15;u++)M[u+1]=M[u]+y[u];for(_=0;_<n;_++)0!==e[r+_]&&(o[M[e[r+_]]++]=_);if(0===t?(L=U=o,l=20):1===t?(L=rA,U=nA,l=257):(L=AA,U=iA,l=0),O=0,_=0,u=I,f=i,R=h,T=0,c=-1,P=1<<h,C=P-1,1===t&&P>852||2===t&&P>592)return 1;for(;;){N=u-T,o[_]+1<l?(S=0,d=o[_]):o[_]>=l?(S=U[o[_]-l],d=L[o[_]-l]):(S=96,d=0),B=1<<u-T,E=1<<R,I=E;do{E-=B,A[f+(O>>T)+E]=N<<24|S<<16|d|0}while(0!==E);for(B=1<<u-1;O&B;)B>>=1;if(0!==B?(O&=B-1,O+=B):O=0,_++,0==--y[u]){if(u===D)break;u=e[r+o[_]]}if(u>h&&(O&C)!==c){for(0===T&&(T=h),f+=I,R=u-T,F=1<<R;R+T<D&&(F-=y[R+T],!(F<=0));)R++,F<<=1;if(P+=1<<R,1===t&&P>852||2===t&&P>592)return 1;c=O&C,A[c]=h<<24|R<<16|f-i|0}}return 0!==O&&(A[f+O]=u-T<<24|64<<16|0),s.bits=h,0};const{Z_FINISH:sA,Z_BLOCK:aA,Z_TREES:BA,Z_OK:EA,Z_STREAM_END:cA,Z_NEED_DICT:CA,Z_STREAM_ERROR:fA,Z_DATA_ERROR:lA,Z_MEM_ERROR:uA,Z_BUF_ERROR:_A,Z_DEFLATED:IA}=gr,DA=16209,hA=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function RA(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const TA=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<16180||e.mode>16211?1:0},FA=t=>{if(TA(t))return fA;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=16180,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,EA},PA=t=>{if(TA(t))return fA;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,FA(t)},OA=(t,e)=>{let r;if(TA(t))return fA;const n=t.state;return e<0?(r=0,e=-e):(r=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?fA:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,PA(t))},LA=(t,e)=>{if(!t)return fA;const r=new RA;t.state=r,r.strm=t,r.window=null,r.mode=16180;const n=OA(t,e);return n!==EA&&(t.state=null),n};let yA,MA,NA=!0;const SA=t=>{if(NA){yA=new Int32Array(512),MA=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(oA(1,t.lens,0,288,yA,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;oA(2,t.lens,0,32,MA,0,t.work,{bits:5}),NA=!1}t.lencode=yA,t.lenbits=9,t.distcode=MA,t.distbits=5},dA=(t,e,r,n)=>{let A;const i=t.state;return null===i.window&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new Uint8Array(i.wsize)),n>=i.wsize?(i.window.set(e.subarray(r-i.wsize,r),0),i.wnext=0,i.whave=i.wsize):(A=i.wsize-i.wnext,A>n&&(A=n),i.window.set(e.subarray(r-n,r-n+A),i.wnext),(n-=A)?(i.window.set(e.subarray(r-n,r),0),i.wnext=n,i.whave=i.wsize):(i.wnext+=A,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=A))),0};var UA={inflateReset:PA,inflateReset2:OA,inflateResetKeep:FA,inflateInit:t=>LA(t,15),inflateInit2:LA,inflate:(t,e)=>{let r,n,A,i,o,s,a,B,E,c,C,f,l,u,_,I,D,h,R,T,F,P,O=0;const L=new Uint8Array(4);let y,M;const N=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(TA(t)||!t.output||!t.input&&0!==t.avail_in)return fA;r=t.state,16191===r.mode&&(r.mode=16192),o=t.next_out,A=t.output,a=t.avail_out,i=t.next_in,n=t.input,s=t.avail_in,B=r.hold,E=r.bits,c=s,C=a,P=EA;t:for(;;)switch(r.mode){case 16180:if(0===r.wrap){r.mode=16192;break}for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(2&r.wrap&&35615===B){0===r.wbits&&(r.wbits=15),r.check=0,L[0]=255&B,L[1]=B>>>8&255,r.check=Hr(r.check,L,2,0),B=0,E=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&B)<<8)+(B>>8))%31){t.msg="incorrect header check",r.mode=DA;break}if((15&B)!==IA){t.msg="unknown compression method",r.mode=DA;break}if(B>>>=4,E-=4,F=8+(15&B),0===r.wbits&&(r.wbits=F),F>15||F>r.wbits){t.msg="invalid window size",r.mode=DA;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=512&B?16189:16191,B=0,E=0;break;case 16181:for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(r.flags=B,(255&r.flags)!==IA){t.msg="unknown compression method",r.mode=DA;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=DA;break}r.head&&(r.head.text=B>>8&1),512&r.flags&&4&r.wrap&&(L[0]=255&B,L[1]=B>>>8&255,r.check=Hr(r.check,L,2,0)),B=0,E=0,r.mode=16182;case 16182:for(;E<32;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.head&&(r.head.time=B),512&r.flags&&4&r.wrap&&(L[0]=255&B,L[1]=B>>>8&255,L[2]=B>>>16&255,L[3]=B>>>24&255,r.check=Hr(r.check,L,4,0)),B=0,E=0,r.mode=16183;case 16183:for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.head&&(r.head.xflags=255&B,r.head.os=B>>8),512&r.flags&&4&r.wrap&&(L[0]=255&B,L[1]=B>>>8&255,r.check=Hr(r.check,L,2,0)),B=0,E=0,r.mode=16184;case 16184:if(1024&r.flags){for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.length=B,r.head&&(r.head.extra_len=B),512&r.flags&&4&r.wrap&&(L[0]=255&B,L[1]=B>>>8&255,r.check=Hr(r.check,L,2,0)),B=0,E=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(f=r.length,f>s&&(f=s),f&&(r.head&&(F=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(i,i+f),F)),512&r.flags&&4&r.wrap&&(r.check=Hr(r.check,n,f,i)),s-=f,i+=f,r.length-=f),r.length))break t;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===s)break t;f=0;do{F=n[i+f++],r.head&&F&&r.length<65536&&(r.head.name+=String.fromCharCode(F))}while(F&&f<s);if(512&r.flags&&4&r.wrap&&(r.check=Hr(r.check,n,f,i)),s-=f,i+=f,F)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===s)break t;f=0;do{F=n[i+f++],r.head&&F&&r.length<65536&&(r.head.comment+=String.fromCharCode(F))}while(F&&f<s);if(512&r.flags&&4&r.wrap&&(r.check=Hr(r.check,n,f,i)),s-=f,i+=f,F)break t}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(4&r.wrap&&B!==(65535&r.check)){t.msg="header crc mismatch",r.mode=DA;break}B=0,E=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=16191;break;case 16189:for(;E<32;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}t.adler=r.check=hA(B),B=0,E=0,r.mode=16190;case 16190:if(0===r.havedict)return t.next_out=o,t.avail_out=a,t.next_in=i,t.avail_in=s,r.hold=B,r.bits=E,CA;t.adler=r.check=1,r.mode=16191;case 16191:if(e===aA||e===BA)break t;case 16192:if(r.last){B>>>=7&E,E-=7&E,r.mode=16206;break}for(;E<3;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}switch(r.last=1&B,B>>>=1,E-=1,3&B){case 0:r.mode=16193;break;case 1:if(SA(r),r.mode=16199,e===BA){B>>>=2,E-=2;break t}break;case 2:r.mode=16196;break;case 3:t.msg="invalid block type",r.mode=DA}B>>>=2,E-=2;break;case 16193:for(B>>>=7&E,E-=7&E;E<32;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if((65535&B)!=(B>>>16^65535)){t.msg="invalid stored block lengths",r.mode=DA;break}if(r.length=65535&B,B=0,E=0,r.mode=16194,e===BA)break t;case 16194:r.mode=16195;case 16195:if(f=r.length,f){if(f>s&&(f=s),f>a&&(f=a),0===f)break t;A.set(n.subarray(i,i+f),o),s-=f,i+=f,a-=f,o+=f,r.length-=f;break}r.mode=16191;break;case 16196:for(;E<14;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(r.nlen=257+(31&B),B>>>=5,E-=5,r.ndist=1+(31&B),B>>>=5,E-=5,r.ncode=4+(15&B),B>>>=4,E-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=DA;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;E<3;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.lens[N[r.have++]]=7&B,B>>>=3,E-=3}for(;r.have<19;)r.lens[N[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,y={bits:r.lenbits},P=oA(0,r.lens,0,19,r.lencode,0,r.work,y),r.lenbits=y.bits,P){t.msg="invalid code lengths set",r.mode=DA;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;O=r.lencode[B&(1<<r.lenbits)-1],_=O>>>24,I=O>>>16&255,D=65535&O,!(_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(D<16)B>>>=_,E-=_,r.lens[r.have++]=D;else{if(16===D){for(M=_+2;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(B>>>=_,E-=_,0===r.have){t.msg="invalid bit length repeat",r.mode=DA;break}F=r.lens[r.have-1],f=3+(3&B),B>>>=2,E-=2}else if(17===D){for(M=_+3;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}B>>>=_,E-=_,F=0,f=3+(7&B),B>>>=3,E-=3}else{for(M=_+7;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}B>>>=_,E-=_,F=0,f=11+(127&B),B>>>=7,E-=7}if(r.have+f>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=DA;break}for(;f--;)r.lens[r.have++]=F}}if(r.mode===DA)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=DA;break}if(r.lenbits=9,y={bits:r.lenbits},P=oA(1,r.lens,0,r.nlen,r.lencode,0,r.work,y),r.lenbits=y.bits,P){t.msg="invalid literal/lengths set",r.mode=DA;break}if(r.distbits=6,r.distcode=r.distdyn,y={bits:r.distbits},P=oA(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,y),r.distbits=y.bits,P){t.msg="invalid distances set",r.mode=DA;break}if(r.mode=16199,e===BA)break t;case 16199:r.mode=16200;case 16200:if(s>=6&&a>=258){t.next_out=o,t.avail_out=a,t.next_in=i,t.avail_in=s,r.hold=B,r.bits=E,eA(t,C),o=t.next_out,A=t.output,a=t.avail_out,i=t.next_in,n=t.input,s=t.avail_in,B=r.hold,E=r.bits,16191===r.mode&&(r.back=-1);break}for(r.back=0;O=r.lencode[B&(1<<r.lenbits)-1],_=O>>>24,I=O>>>16&255,D=65535&O,!(_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(I&&0==(240&I)){for(h=_,R=I,T=D;O=r.lencode[T+((B&(1<<h+R)-1)>>h)],_=O>>>24,I=O>>>16&255,D=65535&O,!(h+_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}B>>>=h,E-=h,r.back+=h}if(B>>>=_,E-=_,r.back+=_,r.length=D,0===I){r.mode=16205;break}if(32&I){r.back=-1,r.mode=16191;break}if(64&I){t.msg="invalid literal/length code",r.mode=DA;break}r.extra=15&I,r.mode=16201;case 16201:if(r.extra){for(M=r.extra;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.length+=B&(1<<r.extra)-1,B>>>=r.extra,E-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;O=r.distcode[B&(1<<r.distbits)-1],_=O>>>24,I=O>>>16&255,D=65535&O,!(_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(0==(240&I)){for(h=_,R=I,T=D;O=r.distcode[T+((B&(1<<h+R)-1)>>h)],_=O>>>24,I=O>>>16&255,D=65535&O,!(h+_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}B>>>=h,E-=h,r.back+=h}if(B>>>=_,E-=_,r.back+=_,64&I){t.msg="invalid distance code",r.mode=DA;break}r.offset=D,r.extra=15&I,r.mode=16203;case 16203:if(r.extra){for(M=r.extra;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.offset+=B&(1<<r.extra)-1,B>>>=r.extra,E-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=DA;break}r.mode=16204;case 16204:if(0===a)break t;if(f=C-a,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=DA;break}f>r.wnext?(f-=r.wnext,l=r.wsize-f):l=r.wnext-f,f>r.length&&(f=r.length),u=r.window}else u=A,l=o-r.offset,f=r.length;f>a&&(f=a),a-=f,r.length-=f;do{A[o++]=u[l++]}while(--f);0===r.length&&(r.mode=16200);break;case 16205:if(0===a)break t;A[o++]=r.length,a--,r.mode=16200;break;case 16206:if(r.wrap){for(;E<32;){if(0===s)break t;s--,B|=n[i++]<<E,E+=8}if(C-=a,t.total_out+=C,r.total+=C,4&r.wrap&&C&&(t.adler=r.check=r.flags?Hr(r.check,A,C,o-C):pr(r.check,A,C,o-C)),C=a,4&r.wrap&&(r.flags?B:hA(B))!==r.check){t.msg="incorrect data check",r.mode=DA;break}B=0,E=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;E<32;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(4&r.wrap&&B!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=DA;break}B=0,E=0}r.mode=16208;case 16208:P=cA;break t;case DA:P=lA;break t;case 16210:return uA;case 16211:default:return fA}return t.next_out=o,t.avail_out=a,t.next_in=i,t.avail_in=s,r.hold=B,r.bits=E,(r.wsize||C!==t.avail_out&&r.mode<DA&&(r.mode<16206||e!==sA))&&dA(t,t.output,t.next_out,C-t.avail_out),c-=t.avail_in,C-=t.avail_out,t.total_in+=c,t.total_out+=C,r.total+=C,4&r.wrap&&C&&(t.adler=r.check=r.flags?Hr(r.check,A,C,t.next_out-C):pr(r.check,A,C,t.next_out-C)),t.data_type=r.bits+(r.last?64:0)+(16191===r.mode?128:0)+(16199===r.mode||16194===r.mode?256:0),(0===c&&0===C||e===sA)&&P===EA&&(P=_A),P},inflateEnd:t=>{if(TA(t))return fA;let e=t.state;return e.window&&(e.window=null),t.state=null,EA},inflateGetHeader:(t,e)=>{if(TA(t))return fA;const r=t.state;return 0==(2&r.wrap)?fA:(r.head=e,e.done=!1,EA)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,A,i;return TA(t)?fA:(n=t.state,0!==n.wrap&&16190!==n.mode?fA:16190===n.mode&&(A=1,A=pr(A,e,r,0),A!==n.check)?lA:(i=dA(t,e,r,r),i?(n.mode=16210,uA):(n.havedict=1,EA)))},inflateInfo:"pako inflate (from Nodeca project)"};var GA=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const mA=Object.prototype.toString,{Z_NO_FLUSH:bA,Z_FINISH:pA,Z_OK:wA,Z_STREAM_END:HA,Z_NEED_DICT:KA,Z_STREAM_ERROR:gA,Z_DATA_ERROR:VA,Z_MEM_ERROR:JA}=gr;function XA(t){this.options=bn({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Jn,this.strm.avail_out=0;let r=UA.inflateInit2(this.strm,e.windowBits);if(r!==wA)throw new Error(Kr[r]);if(this.header=new GA,UA.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Kn(e.dictionary):"[object ArrayBuffer]"===mA.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=UA.inflateSetDictionary(this.strm,e.dictionary),r!==wA)))throw new Error(Kr[r])}function vA(t,e){const r=new XA(e);if(r.push(t),r.err)throw r.msg||Kr[r.err];return r.result}XA.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,A=this.options.dictionary;let i,o,s;if(this.ended)return!1;for(o=e===~~e?e:!0===e?pA:bA,"[object ArrayBuffer]"===mA.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),i=UA.inflate(r,o),i===KA&&A&&(i=UA.inflateSetDictionary(r,A),i===wA?i=UA.inflate(r,o):i===VA&&(i=KA));r.avail_in>0&&i===HA&&r.state.wrap>0&&0!==t[r.next_in];)UA.inflateReset(r),i=UA.inflate(r,o);switch(i){case gA:case VA:case KA:case JA:return this.onEnd(i),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||i===HA))if("string"===this.options.to){let t=Vn(r.output,r.next_out),e=r.next_out-t,A=gn(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(A)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(i!==wA||0!==s){if(i===HA)return i=UA.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},XA.prototype.onData=function(t){this.chunks.push(t)},XA.prototype.onEnd=function(t){t===wA&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=pn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var ZA={Inflate:XA,inflate:vA,inflateRaw:function(t,e){return(e=e||{}).raw=!0,vA(t,e)},ungzip:vA,constants:gr};const{Deflate:xA,deflate:kA,deflateRaw:WA,gzip:QA}=tA,{Inflate:jA,inflate:YA,inflateRaw:zA,ungzip:qA}=ZA;var $A={Deflate:xA,deflate:kA,deflateRaw:WA,gzip:QA,Inflate:jA,inflate:YA,inflateRaw:zA,ungzip:qA,constants:gr},ti=5,ei=11,ri=13,ni=14;function Ai(t,e,r,n){var A=t|e<<8,i=A>>11&31,o=A>>5&63,s=31&A;return r[n+0]=i<<3|i>>2,r[n+1]=o<<2|o>>4,r[n+2]=s<<3|s>>2,r[n+3]=255,A}var ii=new Uint8Array(16),oi=new Uint8Array(16);function si(t,e,r,n){var A=0;0!=(6&n)&&(A=8),function(t,e,r,n){for(var A=Ai(e[r+0],e[r+1],ii,0),i=Ai(e[r+2],e[r+3],ii,4),o=0;o<3;o++){var s=ii[o],a=ii[4+o];n&&A<=i?(ii[8+o]=(s+a)/2,ii[12+o]=0):(ii[8+o]=(2*s+a)/3,ii[12+o]=(s+2*a)/3)}for(ii[11]=255,ii[15]=n&&A<=i?0:255,o=0;o<4;++o){var B=e[r+4+o];oi[4*o+0]=3&B,oi[4*o+1]=B>>2&3,oi[4*o+2]=B>>4&3,oi[4*o+3]=B>>6&3}for(o=0;o<16;++o)for(var E=4*oi[o],c=0;c<4;++c)t[4*o+c]=ii[E+c]}(t,e,r+A,0!=(1&n)),0!=(2&n)?function(t,e,r){for(var n=0;n<8;++n){var A=bytes[r+n],i=15&A,o=240&A;t[8*n+3]=i|i<<4,t[8*n+7]=o|o>>4}}(t,0,r):0!=(4&n)&&function(t,e,r){var n=e[r+0],A=e[r+1];if(ii[0]=n,ii[1]=A,n<=A){for(var i=1;i<5;++i)ii[1+i]=((5-i)*n+i*A)/5;ii[6]=0,ii[7]=255}else for(i=1;i<7;++i)ii[1+i]=((7-i)*n+i*A)/7;r+=2;var o=0;for(i=0;i<2;++i){for(var s=0,a=0;a<3;++a){s|=e[r++]<<8*a}for(a=0;a<8;++a){var B=s>>3*a&7;oi[o++]=B}}for(i=0;i<16;++i)t[4*i+3]=ii[oi[i]]}(t,e,r)}var ai=new Uint16Array(4);\n/*! @brief Decompresses an image in memory.\n\n @param rgba\t\tStorage for the decompressed pixels.\n @param width\tThe width of the source image.\n @param height\tThe height of the source image.\n @param blocks\tThe compressed DXT blocks.\n @param flags\tCompression flags.\n\n The decompressed pixels will be written as a contiguous array of width*height\n 16 rgba values, with each component as 1 byte each. In memory this is:\n\n { r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height\n\n The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,\n however, DXT1 will be used by default if none is specified. All other flags\n are ignored.\n\n Internally this function calls squish::Decompress for each block.\n */\nvar Bi=new Uint8Array(64);function Ei(t){}Ei.decode=function(t,e,r,n,A){if(null!=t&&null!=n&&0!=r&&0!=e){var i=0;1&(i=A>11||5===A?4:33)&&32&i?function(t,e,r,n){for(var A=t,i=0,o=0,s=0,a=0,B=0,E=0,c=0,C=0,f=0,l=e/4,u=r/4,_=0;_<u;_++)for(var I=0;I<l;I++)s=4*((u-_)*l+I),ai[0]=n[s],ai[1]=n[s+1],a=31&ai[0],B=2016&ai[0],E=63488&ai[0],c=31&ai[1],C=2016&ai[1],f=63488&ai[1],ai[2]=5*a+3*c>>3|5*B+3*C>>3&2016|5*E+3*f>>3&63488,ai[3]=5*c+3*a>>3|5*C+3*B>>3&2016|5*f+3*E>>3&63488,i=n[s+2],A[o=4*_*e+4*I]=ai[3&i],A[o+1]=ai[i>>2&3],A[o+2]=ai[i>>4&3],A[o+3]=ai[i>>6&3],A[o+=e]=ai[i>>8&3],A[o+1]=ai[i>>10&3],A[o+2]=ai[i>>12&3],A[o+3]=ai[i>>14],i=n[s+3],A[o+=e]=ai[3&i],A[o+1]=ai[i>>2&3],A[o+2]=ai[i>>4&3],A[o+3]=ai[i>>6&3],A[o+=e]=ai[i>>8&3],A[o+1]=ai[i>>10&3],A[o+2]=ai[i>>12&3],A[o+3]=ai[i>>14]}(t,e,r,n):function(t,e,r,n,A,i){for(var o=0!=(1&A)?8:16,s=0,a=0;a<r;a+=4)for(var B=0;B<e;B+=4){si(Bi,n,s,A);for(var E=0,c=0;c<4;++c)for(var C=0;C<4;++C){var f=B+C,l=a+c;if(f<e&&l<r){var u=4*(e*(r-l)+f);if(i===ri||i===ni)t[u+2]=Bi[E++],t[u+1]=Bi[E++],t[u+0]=Bi[E++],t[u+3]=Bi[E++];else for(var _=0;_<4;++_)t[u++]=Bi[E++]}else E+=4}s+=o}}(t,e,r,n,i,A)}};var ci=function(){var t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),e=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var r,n="B9h79tEBBBE8fV9gBB9gVUUUUUEU9gIUUUB9gEUEU9gIUUUEUIKQBEEEDDDILLLVE9wEEEVIEBEOWEUEC+Q/IEKR/LEdO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9f9kw9j9v9kw9WwvTw949C919m9mwvBEy9tw79o9v9wT9f9kw9j9v9kw69u9kw949C919m9mwvBDe9tw79o9v9wT9f9kw9j9v9kw69u9kw949Twg91w9u9jwBIl9tw79o9v9wT9f9kw9j9v9kws9p2Twv9P9jTBLk9tw79o9v9wT9f9kw9j9v9kws9p2Twv9R919hTBVl9tw79o9v9wT9f9kw9j9v9kws9p2Twvt949wBOL79iv9rBRQ+x8yQDBK/qMEZU8jJJJJBCJ/EB9rGV8kJJJJBC9+HODNADCEFAL0MBCUHOAIrBBC+gE9HMBAVAIALFGRAD9rADZ1JJJBHWCJ/ABAD9uC/wfBgGOCJDAOCJD6eHdAICEFHLCBHQDNINAQAE9PMEAdAEAQ9rAQAdFAE6eHKDNDNADtMBAKCSFGOC9wgHXAOCL4CIFCD4HMAWCJDFHpCBHSALHZINDNARAZ9rAM9PMBCBHLXIKAZAMFHLDNAXtMBCBHhCBHIINDNARAL9rCk9PMBCBHLXVKAWCJ/CBFAIFHODNDNDNDNDNAZAICO4FrBBAhCOg4CIgpLBEDIBKAO9CB83IBAOCWF9CB83IBXIKAOALrBLALrBBGoCO4GaAaCIsGae86BBAOCEFALCLFAaFGarBBAoCL4CIgGcAcCIsGce86BBAOCDFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCIFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCLFAaAoFGarBBALrBEGoCO4GcAcCIsGce86BBAOCVFAaAcFGarBBAoCL4CIgGcAcCIsGce86BBAOCOFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCRFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCWFAaAoFGarBBALrBDGoCO4GcAcCIsGce86BBAOCdFAaAcFGarBBAoCL4CIgGcAcCIsGce86BBAOCQFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCKFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCXFAaAoFGorBBALrBIGLCO4GaAaCIsGae86BBAOCMFAoAaFGorBBALCL4CIgGaAaCIsGae86BBAOCpFAoAaFGorBBALCD4CIgGaAaCIsGae86BBAOCSFAoAaFGOrBBALCIgGLALCIsGLe86BBAOALFHLXDKAOALrBWALrBBGoCL4GaAaCSsGae86BBAOCEFALCWFAaFGarBBAoCSgGoAoCSsGoe86BBAOCDFAaAoFGorBBALrBEGaCL4GcAcCSsGce86BBAOCIFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCLFAoAaFGorBBALrBDGaCL4GcAcCSsGce86BBAOCVFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCOFAoAaFGorBBALrBIGaCL4GcAcCSsGce86BBAOCRFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCWFAoAaFGorBBALrBLGaCL4GcAcCSsGce86BBAOCdFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCQFAoAaFGorBBALrBVGaCL4GcAcCSsGce86BBAOCKFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCXFAoAaFGorBBALrBOGaCL4GcAcCSsGce86BBAOCMFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCpFAoAaFGorBBALrBRGLCL4GaAaCSsGae86BBAOCSFAoAaFGOrBBALCSgGLALCSsGLe86BBAOALFHLXEKAOAL8pBB83BBAOCWFALCWF8pBB83BBALCZFHLKAhCDFHhAICZFGIAX6MBKKDNALMBCBHLXIKDNAKtMBAWASFrBBHhCBHOApHIINAIAWCJ/CBFAOFrBBGZCE4CBAZCEg9r7AhFGh86BBAIADFHIAOCEFGOAK9HMBKKApCEFHpALHZASCEFGSAD9HMBKKABAQAD2FAWCJDFAKAD2Z1JJJB8aAWAWCJDFAKCUFAD2FADZ1JJJB8aKAKCBALeAQFHQALMBKC9+HOXEKCBC99ARAL9rADCAADCA0eseHOKAVCJ/EBF8kJJJJBAOK+OoEZU8jJJJJBC/AE9rGV8kJJJJBC9+HODNAECI9uGRChFAL0MBCUHOAIrBBGWC/wEgC/gE9HMBAWCSgGdCE0MBAVC/ABFCfECJEZ+JJJJB8aAVCuF9CU83IBAVC8wF9CU83IBAVCYF9CU83IBAVCAF9CU83IBAVCkF9CU83IBAVCZF9CU83IBAV9CU83IWAV9CU83IBAIALFC9wFHQAICEFGWARFHKDNAEtMBCMCSAdCEseHXABHICBHdCBHMCBHpCBHLCBHOINDNAKAQ9NMBC9+HOXIKDNDNAWrBBGRC/vE0MBAVC/ABFARCL4CU7AOFCSgCITFGSYDLHZASYDBHhDNARCSgGSAX9PMBAVARCU7ALFCSgCDTFYDBAdASeHRAStHSDNDNADCD9HMBABAh87EBABCLFAR87EBABCDFAZ87EBXEKAIAhbDBAICWFARbDBAICLFAZbDBKAdASFHdAVC/ABFAOCITFGoARbDBAoAZbDLAVALCDTFARbDBAVC/ABFAOCEFCSgGOCITFGZAhbDBAZARbDLALASFHLAOCEFHOXDKDNDNASCSsMBAMASFASC987FCEFHMXEKAK8sBBGSCfEgHRDNDNASCU9MMBAKCEFHKXEKAK8sBEGSCfBgCRTARCfBgvHRDNASCU9MMBAKCDFHKXEKAK8sBDGSCfBgCpTARvHRDNASCU9MMBAKCIFHKXEKAK8sBIGSCfBgCxTARvHRDNASCU9MMBAKCLFHKXEKAKrBLC3TARvHRAKCVFHKKARCE4CBARCEg9r7AMFHMKDNDNADCD9HMBABAh87EBABCLFAM87EBABCDFAZ87EBXEKAIAhbDBAICWFAMbDBAICLFAZbDBKAVC/ABFAOCITFGRAMbDBARAZbDLAVALCDTFAMbDBAVC/ABFAOCEFCSgGOCITFGRAhbDBARAMbDLALCEFHLAOCEFHOXEKDNARCPE0MBAVALAQARCSgFrBBGSCL4GZ9rCSgCDTFYDBAdCEFGhAZeHRAVALAS9rCSgCDTFYDBAhAZtGoFGhASCSgGZeHSAZtHZDNDNADCD9HMBABAd87EBABCLFAS87EBABCDFAR87EBXEKAIAdbDBAICWFASbDBAICLFARbDBKAVALCDTFAdbDBAVC/ABFAOCITFGaARbDBAaAdbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALAoFCSgGLCDTFASbDBAVC/ABFAOCDFCSgGOCITFGRAdbDBARASbDLAOCEFHOALAZFHLAhAZFHdXEKAdCBAKrBBGaeGZARC/+EsGcFHRAaCSgHhDNDNAaCL4GoMBARCEFHSXEKARHSAVALAo9rCSgCDTFYDBHRKDNDNAhMBASCEFHdXEKASHdAVALAa9rCSgCDTFYDBHSKDNDNActMBAKCEFHaXEKAK8sBEGaCfEgHZDNDNAaCU9MMBAKCDFHaXEKAK8sBDGaCfBgCRTAZCfBgvHZDNAaCU9MMBAKCIFHaXEKAK8sBIGaCfBgCpTAZvHZDNAaCU9MMBAKCLFHaXEKAK8sBLGaCfBgCxTAZvHZDNAaCU9MMBAKCVFHaXEKAKCOFHaAKrBVC3TAZvHZKAZCE4CBAZCEg9r7AMFGMHZKDNDNAoCSsMBAaHcXEKAa8sBBGKCfEgHRDNDNAKCU9MMBAaCEFHcXEKAa8sBEGKCfBgCRTARCfBgvHRDNAKCU9MMBAaCDFHcXEKAa8sBDGKCfBgCpTARvHRDNAKCU9MMBAaCIFHcXEKAa8sBIGKCfBgCxTARvHRDNAKCU9MMBAaCLFHcXEKAaCVFHcAarBLC3TARvHRKARCE4CBARCEg9r7AMFGMHRKDNDNAhCSsMBAcHKXEKAc8sBBGKCfEgHSDNDNAKCU9MMBAcCEFHKXEKAc8sBEGKCfBgCRTASCfBgvHSDNAKCU9MMBAcCDFHKXEKAc8sBDGKCfBgCpTASvHSDNAKCU9MMBAcCIFHKXEKAc8sBIGKCfBgCxTASvHSDNAKCU9MMBAcCLFHKXEKAcCVFHKAcrBLC3TASvHSKASCE4CBASCEg9r7AMFGMHSKDNDNADCD9HMBABAZ87EBABCLFAS87EBABCDFAR87EBXEKAIAZbDBAICWFASbDBAICLFARbDBKAVC/ABFAOCITFGaARbDBAaAZbDLAVALCDTFAZbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCDFCSgCITFGRAZbDBARASbDLAVALAotAoCSsvFGLCSgCDTFASbDBALAhtAhCSsvFHLAOCIFHOKAWCEFHWABCOFHBAICXFHIAOCSgHOALCSgHLApCIFGpAE6MBKKCBC99AKAQseHOKAVC/AEF8kJJJJBAOK/tLEDU8jJJJJBCZ9rHVC9+HODNAECVFAL0MBCUHOAIrBBC/+EgC/QE9HMBAV9CB83IWAICEFHOAIALFC98FHIDNAEtMBDNADCDsMBINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKAVCWFALCEgCDTvGDALCD4CBALCE4CEg9r7ADYDBFGLbDBABALbDBABCLFHBAECUFGEMBXDKKINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKABALCD4CBALCE4CEg9r7AVCWFALCEgCDTvGLYDBFGD87EBALADbDBABCDFHBAECUFGEMBKKCBC99AOAIseHOKAOK+lVOEUE99DUD99EUD99DNDNADCL9HMBAEtMEINDNDNjBBBzjBBB+/ABCDFGD8sBB+yAB8sBBGI+yGL+L+TABCEFGV8sBBGO+yGR+L+TGWjBBBB9gGdeAWjBB/+9CAWAWnjBBBBAWAdeGQAQ+MGKAICU9KeALmGLALnAQAKAOCU9KeARmGQAQnmm+R+VGRnmGW+LjBBB9P9dtMBAW+oHIXEKCJJJJ94HIKADAI86BBDNDNjBBBzjBBB+/AQjBBBB9geAQARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKAVAD86BBDNDNjBBBzjBBB+/ALjBBBB9geALARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKABAD86BBABCLFHBAECUFGEMBXDKKAEtMBINDNDNjBBBzjBBB+/ABCLFGD8uEB+yAB8uEBGI+yGL+L+TABCDFGV8uEBGO+yGR+L+TGWjBBBB9gGdeAWjB/+fsAWAWnjBBBBAWAdeGQAQ+MGKAICU9KeALmGLALnAQAKAOCU9KeARmGQAQnmm+R+VGRnmGW+LjBBB9P9dtMBAW+oHIXEKCJJJJ94HIKADAI87EBDNDNjBBBzjBBB+/AQjBBBB9geAQARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKAVAD87EBDNDNjBBBzjBBB+/ALjBBBB9geALARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKABAD87EBABCWFHBAECUFGEMBKKK/SILIUI99IUE99DNAEtMBCBHIABHLINDNDNj/zL81zALCOF8uEBGVCIv+y+VGOAL8uEB+ynGRjB/+fsnjBBBzjBBB+/ARjBBBB9gemGW+LjBBB9P9dtMBAW+oHdXEKCJJJJ94HdKALCLF8uEBHQALCDF8uEBHKABAVCEFCIgAIvCETFAd87EBDNDNAOAK+ynGWjB/+fsnjBBBzjBBB+/AWjBBBB9gemGX+LjBBB9P9dtMBAX+oHKXEKCJJJJ94HKKABAVCDFCIgAIvCETFAK87EBDNDNAOAQ+ynGOjB/+fsnjBBBzjBBB+/AOjBBBB9gemGX+LjBBB9P9dtMBAX+oHQXEKCJJJJ94HQKABAVCUFCIgAIvCETFAQ87EBDNDNjBBJzARARn+TAWAWn+TAOAOn+TGRjBBBBARjBBBB9ge+RjB/+fsnjBBBzmGR+LjBBB9P9dtMBAR+oHQXEKCJJJJ94HQKABAVCIgAIvCETFAQ87EBALCWFHLAICLFHIAECUFGEMBKKK6BDNADCD4AE2GEtMBINABABYDBGDCWTCW91+yADCk91ClTCJJJ/8IF++nuDBABCLFHBAECUFGEMBKKK9TEIUCBCBYDJ1JJBGEABCIFC98gFGBbDJ1JJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIK/lEEEUDNDNAEABvCIgtMBABHIXEKDNDNADCZ9PMBABHIXEKABHIINAIAEYDBbDBAICLFAECLFYDBbDBAICWFAECWFYDBbDBAICXFAECXFYDBbDBAICZFHIAECZFHEADC9wFGDCS0MBKKADCL6MBINAIAEYDBbDBAECLFHEAICLFHIADC98FGDCI0MBKKDNADtMBINAIAErBB86BBAICEFHIAECEFHEADCUFGDMBKKABK/AEEDUDNDNABCIgtMBABHIXEKAECfEgC+B+C+EW2HLDNDNADCZ9PMBABHIXEKABHIINAIALbDBAICXFALbDBAICWFALbDBAICLFALbDBAICZFHIADC9wFGDCS0MBKKADCL6MBINAIALbDBAICLFHIADC98FGDCI0MBKKDNADtMBINAIAE86BBAICEFHIADCUFGDMBKKABKKKEBCJWKLZ9kBB";WebAssembly.validate(t)&&(n="B9h79tEBBBE5V9gBB9gVUUUUUEU9gIUUUB9gDUUB9gEUEUIMXBBEBEEDIDIDLLVE9wEEEVIEBEOWEUEC+Q/aEKR/LEdO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9f9kw9j9v9kw9WwvTw949C919m9mwvBDy9tw79o9v9wT9f9kw9j9v9kw69u9kw949C919m9mwvBLe9tw79o9v9wT9f9kw9j9v9kw69u9kw949Twg91w9u9jwBVl9tw79o9v9wT9f9kw9j9v9kws9p2Twv9P9jTBOk9tw79o9v9wT9f9kw9j9v9kws9p2Twv9R919hTBWl9tw79o9v9wT9f9kw9j9v9kws9p2Twvt949wBQL79iv9rBKQ/j6XLBZIK9+EVU8jJJJJBCZ9rHBCBHEINCBHDCBHIINABCWFADFAICJUAEAD4CEgGLe86BBAIALFHIADCEFGDCW9HMBKAEC+Q+YJJBFAI86BBAECITC+Q1JJBFAB8pIW83IBAECEFGECJD9HMBKK1HLSUD97EUO978jJJJJBCJ/KB9rGV8kJJJJBC9+HODNADCEFAL0MBCUHOAIrBBC+gE9HMBAVAIALFGRAD9rAD/8QBBCJ/ABAD9uC/wfBgGOCJDAOCJD6eHWAICEFHOCBHdDNINAdAE9PMEAWAEAd9rAdAWFAE6eHQDNDNADtMBAQCSFGLC9wgGKCI2HXAKCETHMALCL4CIFCD4HpCBHSINAOHZCBHhDNINDNARAZ9rAp9PMBCBHOXVKAVCJ/CBFAhAK2FHoAZApFHOCBHIDNAKC/AB6MBARAO9rC/gB6MBCBHLINAoALFHIDNDNDNDNDNAZALCO4FrBBGaCIgpLBEDIBKAICBPhPKLBXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLBAOCZFHOKDNDNDNDNDNAaCD4CIgpLBEDIBKAICBPhPKLZXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLZAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLZAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLZAOCZFHOKDNDNDNDNDNAaCL4CIgpLBEDIBKAICBPhPKLAXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLAAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLAAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLAAOCZFHOKDNDNDNDNDNAaCO4pLBEDIBKAICBPhPKL8wXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBAaC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKL8wAOCLFAlPqBFAaC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBAaC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKL8wAOCWFAlPqBFAaC+Q+YJJBFrBBFHOXEKAIAOPBBBPKL8wAOCZFHOKALC/ABFHIALCJEFAK0MEAIHLARAO9rC/fB0MBKKDNAIAK9PMBAICI4HLINDNARAO9rCk9PMBCBHOXRKAoAIFHaDNDNDNDNDNAZAICO4FrBBALCOg4CIgpLBEDIBKAaCBPhPKLBXIKAaAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAaAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAaAOPBBBPKLBAOCZFHOKALCDFHLAICZFGIAK6MBKKDNAOtMBAOHZAhCEFGhCLsMDXEKKCBHOXIKDNAKtMBAVCJDFASFHIAVASFPBDBHlCBHaINAIAVCJ/CBFAaFGLPBLBGxCEP9tAxCEPSGcP9OP9hP9RGxALAKFPBLBGkCEP9tAkAcP9OP9hP9RGkPMBZEhDoIaLcVxOqRlGyALAMFPBLBG8aCEP9tA8aAcP9OP9hP9RG8aALAXFPBLBGeCEP9tAeAcP9OP9hP9RGePMBZEhDoIaLcVxOqRlG3PMBEZhDIoaLVcxORqlGcAcPMBEDIBEDIBEDIBEDIAlP9uGlPeBbDBAIADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAyA3PMWdkyQK8aeXM35pS8e8fGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAxAkPMWkdyQ8aKeX3M5p8eS8fGxA8aAePMWkdyQ8aKeX3M5p8eS8fGkPMBEZhDIoaLVcxORqlGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAxAkPMWdkyQK8aeXM35pS8e8fGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFHIAaCZFGaAK6MBKKASCLFGSAD6MBKKABAdAD2FAVCJDFAQAD2/8QBBAVAVCJDFAQCUFAD2FAD/8QBBKAQCBAOeAdFHdAOMBKC9+HOXEKCBC99ARAO9rADCAADCA0eseHOKAVCJ/KBF8kJJJJBAOKWBZ+BJJJBK+KoEZU8jJJJJBC/AE9rGV8kJJJJBC9+HODNAECI9uGRChFAL0MBCUHOAIrBBGWC/wEgC/gE9HMBAWCSgGdCE0MBAVC/ABFCfECJE/8KBAVCuF9CU83IBAVC8wF9CU83IBAVCYF9CU83IBAVCAF9CU83IBAVCkF9CU83IBAVCZF9CU83IBAV9CU83IWAV9CU83IBAIALFC9wFHQAICEFGWARFHKDNAEtMBCMCSAdCEseHXABHICBHdCBHMCBHpCBHLCBHOINDNAKAQ9NMBC9+HOXIKDNDNAWrBBGRC/vE0MBAVC/ABFARCL4CU7AOFCSgCITFGSYDLHZASYDBHhDNARCSgGSAX9PMBAVARCU7ALFCSgCDTFYDBAdASeHRAStHSDNDNADCD9HMBABAh87EBABCLFAR87EBABCDFAZ87EBXEKAIAhbDBAICWFARbDBAICLFAZbDBKAdASFHdAVC/ABFAOCITFGoARbDBAoAZbDLAVALCDTFARbDBAVC/ABFAOCEFCSgGOCITFGZAhbDBAZARbDLALASFHLAOCEFHOXDKDNDNASCSsMBAMASFASC987FCEFHMXEKAK8sBBGSCfEgHRDNDNASCU9MMBAKCEFHKXEKAK8sBEGSCfBgCRTARCfBgvHRDNASCU9MMBAKCDFHKXEKAK8sBDGSCfBgCpTARvHRDNASCU9MMBAKCIFHKXEKAK8sBIGSCfBgCxTARvHRDNASCU9MMBAKCLFHKXEKAKrBLC3TARvHRAKCVFHKKARCE4CBARCEg9r7AMFHMKDNDNADCD9HMBABAh87EBABCLFAM87EBABCDFAZ87EBXEKAIAhbDBAICWFAMbDBAICLFAZbDBKAVC/ABFAOCITFGRAMbDBARAZbDLAVALCDTFAMbDBAVC/ABFAOCEFCSgGOCITFGRAhbDBARAMbDLALCEFHLAOCEFHOXEKDNARCPE0MBAVALAQARCSgFrBBGSCL4GZ9rCSgCDTFYDBAdCEFGhAZeHRAVALAS9rCSgCDTFYDBAhAZtGoFGhASCSgGZeHSAZtHZDNDNADCD9HMBABAd87EBABCLFAS87EBABCDFAR87EBXEKAIAdbDBAICWFASbDBAICLFARbDBKAVALCDTFAdbDBAVC/ABFAOCITFGaARbDBAaAdbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALAoFCSgGLCDTFASbDBAVC/ABFAOCDFCSgGOCITFGRAdbDBARASbDLAOCEFHOALAZFHLAhAZFHdXEKAdCBAKrBBGaeGZARC/+EsGcFHRAaCSgHhDNDNAaCL4GoMBARCEFHSXEKARHSAVALAo9rCSgCDTFYDBHRKDNDNAhMBASCEFHdXEKASHdAVALAa9rCSgCDTFYDBHSKDNDNActMBAKCEFHaXEKAK8sBEGaCfEgHZDNDNAaCU9MMBAKCDFHaXEKAK8sBDGaCfBgCRTAZCfBgvHZDNAaCU9MMBAKCIFHaXEKAK8sBIGaCfBgCpTAZvHZDNAaCU9MMBAKCLFHaXEKAK8sBLGaCfBgCxTAZvHZDNAaCU9MMBAKCVFHaXEKAKCOFHaAKrBVC3TAZvHZKAZCE4CBAZCEg9r7AMFGMHZKDNDNAoCSsMBAaHcXEKAa8sBBGKCfEgHRDNDNAKCU9MMBAaCEFHcXEKAa8sBEGKCfBgCRTARCfBgvHRDNAKCU9MMBAaCDFHcXEKAa8sBDGKCfBgCpTARvHRDNAKCU9MMBAaCIFHcXEKAa8sBIGKCfBgCxTARvHRDNAKCU9MMBAaCLFHcXEKAaCVFHcAarBLC3TARvHRKARCE4CBARCEg9r7AMFGMHRKDNDNAhCSsMBAcHKXEKAc8sBBGKCfEgHSDNDNAKCU9MMBAcCEFHKXEKAc8sBEGKCfBgCRTASCfBgvHSDNAKCU9MMBAcCDFHKXEKAc8sBDGKCfBgCpTASvHSDNAKCU9MMBAcCIFHKXEKAc8sBIGKCfBgCxTASvHSDNAKCU9MMBAcCLFHKXEKAcCVFHKAcrBLC3TASvHSKASCE4CBASCEg9r7AMFGMHSKDNDNADCD9HMBABAZ87EBABCLFAS87EBABCDFAR87EBXEKAIAZbDBAICWFASbDBAICLFARbDBKAVC/ABFAOCITFGaARbDBAaAZbDLAVALCDTFAZbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCDFCSgCITFGRAZbDBARASbDLAVALAotAoCSsvFGLCSgCDTFASbDBALAhtAhCSsvFHLAOCIFHOKAWCEFHWABCOFHBAICXFHIAOCSgHOALCSgHLApCIFGpAE6MBKKCBC99AKAQseHOKAVC/AEF8kJJJJBAOK/tLEDU8jJJJJBCZ9rHVC9+HODNAECVFAL0MBCUHOAIrBBC/+EgC/QE9HMBAV9CB83IWAICEFHOAIALFC98FHIDNAEtMBDNADCDsMBINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKAVCWFALCEgCDTvGDALCD4CBALCE4CEg9r7ADYDBFGLbDBABALbDBABCLFHBAECUFGEMBXDKKINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKABALCD4CBALCE4CEg9r7AVCWFALCEgCDTvGLYDBFGD87EBALADbDBABCDFHBAECUFGEMBKKCBC99AOAIseHOKAOK/xVDIUO978jJJJJBCA9rGI8kJJJJBDNDNADCL9HMBDNAEC98gGLtMBABHDCBHVINADADPBBBGOCkP+rECkP+sEP/6EGRAOCWP+rECkP+sEP/6EARP/gEAOCZP+rECkP+sEP/6EGWP/gEP/kEP/lEGdCBPhP+2EGQARCJJJJ94PhGKP9OP9RP/kEGRjBB/+9CPaARARP/mEAdAdP/mEAWAQAWAKP9OP9RP/kEGRARP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGQP/kECfEPhP9OAOCJJJ94PhP9OP9QARAWP/mEAQP/kECWP+rECJ/+IPhP9OP9QAdAWP/mEAQP/kECZP+rECJJ/8RPhP9OP9QPKBBADCZFHDAVCLFGVAL6MBKKALAE9PMEAIAECIgGVCDTGDvCBCZAD9r/8KBAIABALCDTFGLAD/8QBBDNAVtMBAIAIPBLBGOCkP+rECkP+sEP/6EGRAOCWP+rECkP+sEP/6EARP/gEAOCZP+rECkP+sEP/6EGWP/gEP/kEP/lEGdCBPhP+2EGQARCJJJJ94PhGKP9OP9RP/kEGRjBB/+9CPaARARP/mEAdAdP/mEAWAQAWAKP9OP9RP/kEGRARP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGQP/kECfEPhP9OAOCJJJ94PhP9OP9QARAWP/mEAQP/kECWP+rECJ/+IPhP9OP9QAdAWP/mEAQP/kECZP+rECJJ/8RPhP9OP9QPKLBKALAIAD/8QBBXEKABAEC98gGDZ+HJJJBADAE9PMBAIAECIgGLCITGVFCBCAAV9r/8KBAIABADCITFGDAV/8QBBAIALZ+HJJJBADAIAV/8QBBKAICAF8kJJJJBK+yIDDUR97DNAEtMBCBHDINABCZFGIAIPBBBGLCBPhGVCJJ98P3ECJJ98P3IGOP9OABPBBBGRALPMLVORXMpScxql358e8fCffEPhP9OP/6EARALPMBEDIWdQKZhoaky8aeGLCZP+sEP/6EGWP/gEALCZP+rECZP+sEP/6EGdP/gEP/kEP/lEGLjB/+fsPaAdALAVP+2EGVAdCJJJJ94PhGQP9OP9RP/kEGdAdP/mEALALP/mEAWAVAWAQP9OP9RP/kEGLALP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGVP/kECZP+rEAdAWP/mEAVP/kECffIPhP9OP9QGdALAWP/mEAVP/kECUPSCBPlDCBPlICBPlOCBPlRCBPlQCBPlKCBPlpCBPlSP9OGLPMWdkyQK8aeXM35pS8e8fP9QPKBBABARAOP9OAdALPMBEZhDIoaLVcxORqlP9QPKBBABCAFHBADCLFGDAE6MBKKK94EIU8jJJJJBCA9rGI8kJJJJBABAEC98gGLZ+JJJJBDNALAE9PMBAIAECIgGVCITGEFCBCAAE9r/8KBAIABALCITFGBAE/8QBBAIAVZ+JJJJBABAIAE/8QBBKAICAF8kJJJJBK/hILDUE97EUV978jJJJJBCZ9rHDDNAEtMBCBHIINADABPBBBGLABCZFGVPBBBGOPMLVORXMpScxql358e8fGRCZP+sEGWCLP+rEPKLBABjBBJzPaj/zL81zPaAWCIPhP9QP/6EP/nEGWALAOPMBEDIWdQKZhoaky8aeGLCZP+rECZP+sEP/6EP/mEGOAOP/mEAWALCZP+sEP/6EP/mEGdAdP/mEAWARCZP+rECZP+sEP/6EP/mEGRARP/mEP/kEP/kEP/lECBPhP+4EP/jEjB/+fsPaGWP/mEjBBN0PaGLP/kECffIPhGQP9OAdAWP/mEALP/kECZP+rEP9QGdARAWP/mEALP/kECZP+rEAOAWP/mEALP/kEAQP9OP9QGWPMBEZhDIoaLVcxORqlGLP5BADPBLBPeB+t+J83IBABCWFALP5EADPBLBPeE+t+J83IBAVAdAWPMWdkyQK8aeXM35pS8e8fGWP5BADPBLBPeD+t+J83IBABCkFAWP5EADPBLBPeI+t+J83IBABCAFHBAICLFGIAE6MBKKK/3EDIUE978jJJJJBC/AB9rHIDNADCD4AE2GLC98gGVtMBCBHDABHEINAEAEPBBBGOCWP+rECWP+sEP/6EAOCkP+sEClP+rECJJJ/8IPhP+uEP/mEPKBBAECZFHEADCLFGDAV6MBKKDNAVAL9PMBAIALCIgGDCDTGEvCBC/ABAE9r/8KBAIABAVCDTFGVAE/8QBBDNADtMBAIAIPBLBGOCWP+rECWP+sEP/6EAOCkP+sEClP+rECJJJ/8IPhP+uEP/mEPKLBKAVAIAE/8QBBKK9TEIUCBCBYDJ1JJBGEABCIFC98gFGBbDJ1JJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIKKKEBCJWKLZ9tBB");var A=WebAssembly.instantiate(function(t){for(var r=new Uint8Array(t.length),n=0;n<t.length;++n){var A=t.charCodeAt(n);r[n]=A>96?A-71:A>64?A-65:A>47?A+4:A>46?63:62}var i=0;for(let n=0;n<t.length;++n)r[i++]=r[n]<60?e[r[n]]:64*(r[n]-60)+r[++n];return r.buffer.slice(0,i)}(n),{}).then((function(t){(r=t.instance).exports.__wasm_call_ctors()}));function i(t,e,n,A,i,o){var s=r.exports.sbrk,a=n+3&-4,B=s(a*A),E=s(i.length),c=new Uint8Array(r.exports.memory.buffer);c.set(i,E);var C=t(B,n,A,E,i.length);if(0==C&&o&&o(B,a,A),e.set(c.subarray(B,B+n*A)),s(B-s(0)),0!=C)throw new Error("Malformed buffer data: "+C)}var o={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},s={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:A,supported:!0,decodeVertexBuffer:function(t,e,n,A,s){i(r.exports.meshopt_decodeVertexBuffer,t,e,n,A,r.exports[o[s]])},decodeIndexBuffer:function(t,e,n,A){i(r.exports.meshopt_decodeIndexBuffer,t,e,n,A)},decodeIndexSequence:function(t,e,n,A){i(r.exports.meshopt_decodeIndexSequence,t,e,n,A)},decodeGltfBuffer:function(t,e,n,A,a,B){i(r.exports[s[a]],t,e,n,A,r.exports[o[B]])}}}();function Ci(){}Ci.s3tc=!0,Ci.pvrtc=!1,Ci.etc1=!1;const fi=1,li=2,ui=3,_i=0,Ii=1,Di=2,hi={0:Uint32Array.BYTES_PER_ELEMENT,1:Float32Array.BYTES_PER_ELEMENT,2:Float64Array.BYTES_PER_ELEMENT},Ri=10,Ti=11,Fi=1,Pi=2,Oi=16,Li=32,yi=1,Mi=4,Ni=16,Si=32,di=64,Ui=128,Gi=512,mi=1024;function bi(t,e,r){r=t.byteLength;return t=t.subarray(0,0+r),new TextDecoder("utf-8").decode(t)}function pi(t,e,r){let n=e.getUint32(r,!0);return r+=Uint32Array.BYTES_PER_ELEMENT,{string:bi(new Uint8Array(t,r,n)),bytesOffset:r+=n,length:n}}function wi(t,e,r,n){let A={},i=[],o=new Array(16);for(let t=0;t<16;t++)o[t]=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;A.matrix=o,A.skeletonNames=i;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<s;n++){let n=pi(t,e,r);i.push(n.string),r=n.bytesOffset}return n.push(A),r}function Hi(t,e,r,n,A){let i={};i.rangeList=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,i.rangeMode=e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let o={};o.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,o.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,o.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;let s=e.getFloat64(r,!0);if(r+=Float64Array.BYTES_PER_ELEMENT,i.boundingSphere={center:o,radius:s},3===A){const t={};t.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,t.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,t.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;const n={};n.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,n.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,n.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;const A={};A.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,A.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,A.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;const o={};o.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,o.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,o.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,i.obb={xExtent:n,yExtent:A,zExtent:o,obbCenter:t}}let a=pi(t,e,r),B=a.string;r=a.bytesOffset;let E=B.indexOf("Geometry");if(-1!==E){let t=B.substring(E);B=B.replace(t,"")}i.childTile=B,i.geodes=[];let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<c;n++)r=wi(t,e,r,i.geodes);if(n.push(i),3===A){r=pi(t,e,r).bytesOffset}return r}function Ki(t,e,r,n){let A=e.getUint32(r,!0);if(n.verticesCount=A,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=i*Float32Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let s=A*i*Float32Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,s);r+=s;let B=n.vertexAttributes,E=n.attrLocation;return E.aPosition=B.length,B.push({index:E.aPosition,typedArray:a,componentsPerAttribute:i,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function gi(t,e,r,n){let A=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,A<=0)return r;let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let s=A*i*Float32Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,s);r+=s;let B=n.vertexAttributes,E=n.attrLocation;return E.aNormal=B.length,B.push({index:E.aNormal,typedArray:a,componentsPerAttribute:i,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function Vi(t,e,r,n){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let i,o=n.verticesCount;if(A>0){e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let n=A*Uint8Array.BYTES_PER_ELEMENT*4;i=new Uint8Array(t,r,n).slice(0,n),r+=n}else{i=new Uint8Array(4*o);for(let t=0;t<o;t++)i[4*t]=255,i[4*t+1]=255,i[4*t+2]=255,i[4*t+3]=255}let s=n.vertexAttributes,a=n.attrLocation;return a.aColor=s.length,s.push({index:a.aColor,typedArray:i,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),n.vertexColor=i,r}function Ji(t,e,r,n){let A=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,A<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let i=A*Uint8Array.BYTES_PER_ELEMENT*4,o=new Uint8Array(t,r,i);r+=i;let s=n.vertexAttributes,a=n.attrLocation;return a.aSecondColor=s.length,s.push({index:a.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),r}function Xi(t,e,r,n){let A=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let i=0;i<A;i++){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s=A*o*Float32Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,s);r+=s;let B="aTexCoord"+i,E=n.vertexAttributes,c=n.attrLocation;c[B]=E.length,E.push({index:c[B],typedArray:a,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:o*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}return r}function vi(t,e,r,n){let A=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let i=n.vertexAttributes,o=n.attrLocation;for(let s=0;s<A;s++){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let a=A*s*Float32Array.BYTES_PER_ELEMENT;if(17===s||29===s){let e=new Uint8Array(t,r,a);n.instanceCount=A,n.instanceMode=s,n.instanceBuffer=e,n.instanceIndex=1;let B,E=s*A*4,c=e.slice(0,E);n.vertexColorInstance=c,17===s?(B=17*Float32Array.BYTES_PER_ELEMENT,o.uv2=i.length,i.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:B,instanceDivisor:1}),o.uv3=i.length,i.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv4=i.length,i.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.secondary_colour=i.length,i.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv6=i.length,i.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1})):29===s&&(B=29*Float32Array.BYTES_PER_ELEMENT,o.uv1=i.length,i.push({index:o.uv1,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:B,instanceDivisor:1,byteLength:a}),o.uv2=i.length,i.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv3=i.length,i.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv4=i.length,i.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv5=i.length,i.push({index:o.uv5,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv6=i.length,i.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv7=i.length,i.push({index:o.uv7,componentsPerAttribute:3,componentDatatype:5126,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.secondary_colour=i.length,i.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:27*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv9=i.length,i.push({index:o.uv9,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:28*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}))}else{let t=A*s;n.instanceBounds=new Float32Array(t);for(let A=0;A<t;A++)n.instanceBounds[A]=e.getFloat32(r+A*Float32Array.BYTES_PER_ELEMENT,!0)}r+=a}return r}function Zi(t,e,r,n,A){if(3===A&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT),r=Vi(t,e,r=gi(t,e,r=Ki(t,e,r,n),n),n),3!==A&&(r=Ji(t,e,r,n)),r=vi(t,e,r=Xi(t,e,r,n),n),3===A){r=function(t,e,r,n){const A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let i=0;i<A;i++){const A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;const o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;const s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;const a=A*o*hi[s],B=new Uint8Array(t,r,a);r+=a;const E=n.vertexAttributes,c=n.attrLocation,C="aCustom"+i;c[C]=E.length,E.push({index:c[C],typedArray:B,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,normalize:!1})}return r}(t,e,r,n);const A=pi(t,e,r);r=A.bytesOffset,n.customVertexAttribute=JSON.parse(A.string);const i="aCustom"+n.customVertexAttribute.TextureCoordMatrix,o="aCustom"+n.customVertexAttribute.VertexWeight;void 0!==n.attrLocation[i]&&(n.attrLocation.aTextureCoordMatrix=n.attrLocation[i],delete n.attrLocation[i]),void 0!==n.attrLocation[o]&&(n.attrLocation.aVertexWeight=n.attrLocation[o],delete n.attrLocation[o]);let s=r%4;s&&(s=4-s),r=function(t,e,r,n){const A=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,A<=0)return r;const i=e.getUint16(r,!0);return r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=A*i*Float32Array.BYTES_PER_ELEMENT}(0,e,r+=s)}return r}function xi(t,e,r,n,A,i){let o,s=0;const a=A.vertexAttributes,B=A.attrLocation;switch(e){case Mi:case Ni:case Si:s=2*Uint16Array.BYTES_PER_ELEMENT,0!=(16&i)||e!==Ni&&e!==Si||(s=2*Float32Array.BYTES_PER_ELEMENT),o=new Uint8Array(t*s);break;case di:case Ui:s=4*Uint8Array.BYTES_PER_ELEMENT,o=new Uint8Array(4*t);break;case Gi:case mi:s=Float32Array.BYTES_PER_ELEMENT*r,o=new Uint8Array(t*r*4);break;default:s=4*Uint16Array.BYTES_PER_ELEMENT,o=new Uint8Array(t*s)}let E,c;switch(ci.decodeVertexBuffer(o,t,s,n,n.length),e){case yi:B.aPosition=a.length,a.push({index:B.aPosition,typedArray:new Uint16Array(o.buffer,0,o.length/2),componentsPerAttribute:4,componentDatatype:5122,offsetInBytes:0,strideInBytes:0,normalize:!1}),A.verticesCount=t;break;case Mi:B.aNormal=a.length,a.push({index:B.aNormal,typedArray:new Int16Array(o.buffer,0,o.length/2),componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case Ni:0==(16&i)?(c=5126,E=new Float32Array(o.buffer,0,o.length/4)):(c=5122,E=new Uint16Array(o.buffer,0,o.length/2)),B.aTexCoord0=a.length,a.push({index:B.aTexCoord0,typedArray:E,componentsPerAttribute:2,componentDatatype:c,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case Si:0==(16&i)?(c=5126,E=new Float32Array(o.buffer,0,o.length/4)):(c=5122,E=new Uint16Array(o.buffer,0,o.length/2)),B.aTexCoord1=a.length,a.push({index:B.aTexCoord1,typedArray:E,componentsPerAttribute:2,componentDatatype:c,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case di:B.aColor=a.length,a.push({index:B.aColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:0,normalize:!0});break;case Ui:B.aSecondColor=a.length,a.push({index:B.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5120,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case Gi:B.aCustom0=a.length,a.push({index:B.aCustom0,typedArray:new Float32Array(o.buffer,0,o.length/4),componentsPerAttribute:r,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case mi:B.aCustom1=a.length,a.push({index:B.aCustom1,typedArray:new Float32Array(o.buffer,0,o.length/4),componentsPerAttribute:r,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,normalize:!1})}}function ki(t,e,r,n,A){const i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,n.compressOptions=i;const o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,n.minVerticesValue={x:0,y:0,z:0,w:0},n.minTexCoordValue=[{x:0,y:0},{x:0,y:0}],n.texCoordCompressConstant=[{x:0,y:0,z:0},{x:0,y:0,z:0}];for(let A=0;A<o;A++){const s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.minVerticesValue.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,n.minVerticesValue.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,n.minVerticesValue.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;const a=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const B=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const E=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const c=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const C=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const f=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const l=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const u=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT,n.minTexCoordValue[0].x=E,n.minTexCoordValue[0].y=c,n.minTexCoordValue[1].x=l,n.minTexCoordValue[1].y=u,n.texCoordCompressConstant[0].x=a,n.texCoordCompressConstant[0].y=B,n.texCoordCompressConstant[1].x=C,n.texCoordCompressConstant[1].y=f;const _=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;for(let A=0;A<_;A++){const A=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;let o=0;A!==Gi&&A!==mi||(o=e.getInt32(r,!0),r+=Int32Array.BYTES_PER_ELEMENT);const a=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;const B=new Uint8Array(t,r,a);let E=(r+=Uint8Array.BYTES_PER_ELEMENT*a)%4;E&&(E=4-E),r+=E,xi(s,A,o,B,n,i)}let I=pi(t,e,r);r=I.bytesOffset,n.customVertexAttribute=JSON.parse(I.string);let D="aCustom"+n.customVertexAttribute.TextureCoordMatrix,h="aCustom"+n.customVertexAttribute.VertexWeight;void 0!==n.attrLocation[D]&&(n.attrLocation.aTextureCoordMatrix=n.attrLocation[D],A===o-1&&delete n.attrLocation[D]),void 0!==n.attrLocation[h]&&(n.attrLocation.aVertexWeight=n.attrLocation[h],A===o-1&&delete n.attrLocation[h]);let R=r%4;R&&(R=4-R),r+=R}return r}function Wi(t,e,r,n,A){const i=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;for(let A=0;A<i;A++){const A={},i=e.getInt32(r,!0);if(r+=Int32Array.BYTES_PER_ELEMENT,i<1)continue;const o=e.getInt8(r,!0);r+=Int8Array.BYTES_PER_ELEMENT,e.getInt8(r,!0),r+=Int8Array.BYTES_PER_ELEMENT;const s=e.getInt8(r,!0);r+=Int8Array.BYTES_PER_ELEMENT,e.getInt8(r,!0),r+=Int8Array.BYTES_PER_ELEMENT;const a=e.getInt32(r,!0);let B;r+=Int32Array.BYTES_PER_ELEMENT,13!==s?(B=new Uint8Array(t,r,a),r+=Uint8Array.BYTES_PER_ELEMENT*a):(B=new Uint32Array(t,r,a),r+=Uint32Array.BYTES_PER_ELEMENT*a);let E,c=r%4;c&&(c=4-c),r+=c,13!==s?(E=new Uint8Array(i*Uint32Array.BYTES_PER_ELEMENT),ci.decodeIndexBuffer(E,i,Uint32Array.BYTES_PER_ELEMENT,B)):E=B;const C=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT,A.indexType=o;const f=0===o?new Uint16Array(i):new Uint32Array(i);A.indicesCount=i;const l=new Uint32Array(E.buffer,E.byteOffset,E.byteLength/4);f.set(l,0),A.indicesTypedArray=f,A.primitiveType=s;for(let n=0;n<C;n++){const n=pi(t,e,r);r=n.bytesOffset,A.materialCode=n.string}n.push(A),c=r%4,c&&(c=4-c),r+=c}return r}function Qi(t,e,r,n){let A=e.getUint32(r,!0);return n.compressOptions=A,r+=Uint32Array.BYTES_PER_ELEMENT,r=(A&Fi)===Fi?function(t,e,r,n){let A=e.getUint32(r,!0);if(n.verticesCount=A,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=i*Int16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let s=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;let a={};a.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,a.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,a.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,a.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=s,n.minVerticesValue=a;let B=A*i*Int16Array.BYTES_PER_ELEMENT,E=new Uint8Array(t,r,B);r+=B;let c=n.vertexAttributes,C=n.attrLocation;return C.aPosition=c.length,c.push({index:C.aPosition,typedArray:E,componentsPerAttribute:i,componentDatatype:5122,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}(t,e,r,n):Ki(t,e,r,n),r=(A&Pi)===Pi?function(t,e,r,n){let A=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,A<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=2*A*Int16Array.BYTES_PER_ELEMENT,s=new Uint8Array(t,r,o);r+=o;let a=n.vertexAttributes,B=n.attrLocation;return B.aNormal=a.length,a.push({index:B.aNormal,typedArray:s,componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:i,normalize:!1}),r}(t,e,r,n):gi(t,e,r,n),r=Ji(t,e,r=Vi(t,e,r,n),n),r=(A&Oi)===Oi?function(t,e,r,n){n.texCoordCompressConstant=[],n.minTexCoordValue=[];let A=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let i=0;i<A;i++){let A=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,r+=3*Uint8Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let a=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT,n.texCoordCompressConstant.push(a);let B={};B.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,B.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,B.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,B.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.minTexCoordValue.push(B);let E=o*s*Int16Array.BYTES_PER_ELEMENT,c=new Uint8Array(t,r,E),C=(r+=E)%4;0!==C&&(r+=4-C);let f="aTexCoord"+i,l=n.vertexAttributes,u=n.attrLocation;if(u[f]=l.length,l.push({index:u[f],typedArray:c,componentsPerAttribute:s,componentDatatype:5122,offsetInBytes:0,strideInBytes:s*Int16Array.BYTES_PER_ELEMENT,normalize:!1}),A){E=o*Float32Array.BYTES_PER_ELEMENT;let e=new Uint8Array(t,r,E);r+=E,n.texCoordZMatrix=!0,f="aTexCoordZ"+i,u[f]=l.length,l.push({index:u[f],typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:Float32Array.BYTES_PER_ELEMENT,normalize:!1})}}return r}(t,e,r,n):Xi(t,e,r,n),(A&Li)===Li&&(n.textureCoordIsW=!0),r=vi(t,e,r,n)}function ji(t,e,r,n,A){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<i;o++){let i={};3===A&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT);let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,e.getUint8(r,!0),r+=Uint8Array.BYTES_PER_ELEMENT;let a=e.getUint8(r,!0);if(r+=Uint8Array.BYTES_PER_ELEMENT,r+=Uint8Array.BYTES_PER_ELEMENT,o>0){let e,n=null;1===s||3===s?(e=o*Uint32Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e)):(e=o*Uint16Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e),o%2!=0&&(e+=2)),i.indicesTypedArray=n,r+=e}i.indicesCount=o,i.indexType=s,i.primitiveType=a;let B=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<B;n++){let n=pi(t,e,r),A=n.string;r=n.bytesOffset,i.materialCode=A}if(0!==r%4){r+=4-r%4}n.push(i)}return r}let Yi={red:0,green:0,blue:0,alpha:0};function zi(t,e,r){let n=t.vertexAttributes,A=t.attrLocation,i=n.length;A[1===r?"instanceId":"batchId"]=i,n.push({index:i,typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,instanceDivisor:r})}Ci.parseBuffer=function(t){let e=0,r={version:void 0,groupNode:void 0,geoPackage:{},matrials:void 0,texturePackage:{}},n=new DataView(t);r.version=n.getFloat32(e,!0),e+=Float32Array.BYTES_PER_ELEMENT,r.version>=2&&(n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT),r.version>=3&&(n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT),n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT;let A=function(t,e){let r=new Uint8Array(t,e);return $A.inflate(r).buffer}(t,e);n=new DataView(A),e=0;let i=n.getUint32(e,!0);return e+=Uint32Array.BYTES_PER_ELEMENT,e=function(t,e,r,n){let A={},i=[];e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let A=0;A<o;A++)r=Hi(t,e,r,i,n.version);A.pageLods=i;let s=r%4;return 0!==s&&(r+=4-s),n.groupNode=A,r}(A,n,e,r),e=function(t,e,r,n,A){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<i;o++){3===A&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT);let i=pi(t,e,r),o=i.string;r=i.bytesOffset;let s=i.length%4;0!==s&&(r+=4-s);let a=e.getUint32(r,!0);if(r+=Int32Array.BYTES_PER_ELEMENT,3===A)switch(a){case _i:a=fi;break;case Ii:a=ui;break;case Di:a=li}let B={vertexAttributes:[],attrLocation:{},instanceCount:0,instanceMode:0,instanceIndex:-1};a===fi?r=Zi(t,e,r,B,A):a===li&&3===A?r=ki(t,e,r,B):a===li&&(r=Qi(t,e,r,B));let E=[];r=a===li&&3===A?Wi(t,e,r,E):ji(t,e,r,E,A);let c=void 0;2===E.length&&13===E[1].primitiveType&&E[1].indicesCount>=3&&(c=S3MEdgeProcessor.createEdgeDataByIndices(B,E[1])),n[o]={vertexPackage:B,arrIndexPackage:E,edgeGeometry:c},3===A&&(e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT)}if(3!==A){r+=e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT}return r}(A,n,e,r.geoPackage,r.version),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let i=0;i<A;i++){let A=pi(t,e,r),i=A.string;r=A.bytesOffset;let o=A.length%4;0!==o&&(r+=4-o),e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let B=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let E=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let C=new Uint8Array(t,r,E);r+=E;let f=c===Ri||c===Ti?33776:33779;if(22===B&&(f=36196),!Ci.s3tc&&(33776===f||33779===f)){let t=new Uint8Array(s*a*4);Ei.decode(t,s,a,C,c),C=t,B=0,f=c===Ri||c===Ri?273:4369}n[i]={id:i,width:s,height:a,compressType:B,nFormat:c,internalFormat:f,arrayBufferView:C}}return r}(A,n,e,r.texturePackage),e=function(t,e,r,n){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let i=bi(new Uint8Array(t,r,A));return r+=A,n.materials=JSON.parse(i),r}(A,n,e,r),function(t,e,r,n,A,i){if(3===i&&(n=e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT),1==(1&n)){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<n;o++){let n=pi(t,e,r),o=n.string;r=n.bytesOffset;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a={};if(A[o].pickInfo=a,-1==A[o].vertexPackage.instanceIndex){let t=new Float32Array(A[o].vertexPackage.verticesCount);for(let n=0;n<s;n++){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=[];for(let A=0;A<i;A++){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,t.fill(n,A,A+i),o.push({vertexColorOffset:A,vertexColorCount:i,batchId:n})}a[A]=o}zi(A[o].vertexPackage,t,void 0)}else{let t=A[o].vertexPackage.instanceCount,n=A[o].vertexPackage.instanceBuffer,B=A[o].vertexPackage.instanceMode,E=new Float32Array(t),c=[];for(let t=0;t<s;t++){let t=e.getUint32(r,!0);c.push(t),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let t=0;t<n;t++)e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT,3===i&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT)}let C=17===B?16:28;C*=Float32Array.BYTES_PER_ELEMENT;for(let e=0;e<t;e++){E[e]=e;let t=e*B*Float32Array.BYTES_PER_ELEMENT+C;Cesium.Color.unpack(n,t,Yi);let r=2===i?c[e]:Yi.red+256*Yi.green+65536*Yi.blue;void 0===a[r]&&(a[r]={vertexColorCount:1,instanceIds:[],vertexColorOffset:e}),a[r].instanceIds.push(e)}zi(A[o].vertexPackage,E,1)}}}}(A,n,e,i,r.geoPackage,r.version),r};class qi{constructor(t,e,{width:r,height:n,colorDepth:A,format:i}){if(this.format=i,this.offset=e,this.depth=A,this.stride=\n/*!\n * decode-bmp\n * https://github.com/LinusU/decode-bmp\n * MIT License\n */\nfunction(t){const e=t%4;return e?t+4-e:t}(r*this.depth/8),this.size=this.stride*n,this.data=t.subarray(this.offset,this.offset+this.size),this.size!==this.data.byteLength)throw new Error("Truncated bitmap data")}get(t,e,r){const n=this.format.indexOf(r);if(1===this.depth){return(this.data[e*this.stride+(t/8|0)]&1<<7-t%8*1)>>7-t%8*1}if(2===this.depth){return(this.data[e*this.stride+(t/4|0)]&3<<6-t%4*2)>>>6-t%4*2}if(4===this.depth){return(this.data[e*this.stride+(t/2|0)]&15<<4-t%2*4)>>>4-t%2*4}return this.data[e*this.stride+t*(this.depth/8)+n]}}function $i(t,e,r,n,{width:A=0,height:i=0,icon:o=!1}={}){const s=new DataView(e,r,n);let a,B,E,c,C;o?(a=s.getUint32(0,!0),B=s.getUint32(4,!0)/1|0,E=s.getUint32(8,!0)/2|0,c=s.getUint16(14,!0),C=s.getUint32(32,!0)):(!function(t){if(19778!==t)throw new Error("Invalid magic byte 0x"+t.toString(16))}(s.getUint16(0,!0)),a=14+s.getUint32(14,!0),B=s.getUint32(18,!0),E=s.getUint32(22,!0),c=s.getUint16(28,!0),C=s.getUint32(46,!0)),0===C&&c<=8&&(C=1<<c);const f=0===B?A:B,l=0===E?i:E,u=new Uint8Array(s.buffer,s.byteOffset+a,s.byteLength-a),_=t.byteLength===f*l*4;return C?function(t,e,r,{width:n,height:A,colorDepth:i,colorCount:o,icon:s}){if(8!==i&&4!==i&&2!==i&&1!==i)throw new Error(`A color depth of ${i} is not supported`);const a=new qi(r,0,{width:o,height:1,colorDepth:32,format:"BGRA"}),B=new qi(r,a.offset+a.size,{width:n,height:A,colorDepth:i,format:"C"}),E=s?new qi(r,B.offset+B.size,{width:n,height:A,colorDepth:1,format:"A"}):null,c=t;let C=0;for(let t=0;t<A;t++)for(let r=0;r<n;r++){const n=B.get(r,A-t-1,"C");c[C++]=a.get(n,0,"R"),c[C++]=a.get(n,0,"G"),c[C++]=a.get(n,0,"B"),e&&(c[C++]=E&&E.get(r,A-t-1,"A")?0:255)}return c}(t,_,u,{width:f,height:l,colorDepth:c,colorCount:C,icon:o}):function(t,e,r,{width:n,height:A,colorDepth:i,icon:o}){if(32!==i&&24!==i)throw new Error(`A color depth of ${i} is not supported`);const s=new qi(r,0,{width:n,height:A,colorDepth:i,format:"BGRA"}),a=24===i&&o?new qi(r,s.offset+s.size,{width:n,height:A,colorDepth:1,format:"A"}):null,B=t;let E=0;for(let t=0;t<A;t++)for(let r=0;r<n;r++)B[E++]=s.get(r,A-t-1,"R"),B[E++]=s.get(r,A-t-1,"G"),B[E++]=s.get(r,A-t-1,"B"),e&&(B[E++]=32===i?s.get(r,A-t-1,"A"):a&&a.get(r,A-t-1,"A")?0:255);return B}(t,_,u,{width:f,height:l,colorDepth:c,icon:o})}var to=Object.freeze({DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,IMPLEMENTATION_COLOR_READ_TYPE:35738,IMPLEMENTATION_COLOR_READ_FORMAT:35739,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444,COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGBA_ASTC_4x4_WEBGL:37808,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGBA_BPTC_UNORM:36492,HALF_FLOAT_OES:36193,DOUBLE:5130,READ_BUFFER:3074,UNPACK_ROW_LENGTH:3314,UNPACK_SKIP_ROWS:3315,UNPACK_SKIP_PIXELS:3316,PACK_ROW_LENGTH:3330,PACK_SKIP_ROWS:3331,PACK_SKIP_PIXELS:3332,COLOR:6144,DEPTH:6145,STENCIL:6146,RED:6403,RGB8:32849,RGBA8:32856,RGB10_A2:32857,TEXTURE_BINDING_3D:32874,UNPACK_SKIP_IMAGES:32877,UNPACK_IMAGE_HEIGHT:32878,TEXTURE_3D:32879,TEXTURE_WRAP_R:32882,MAX_3D_TEXTURE_SIZE:32883,UNSIGNED_INT_2_10_10_10_REV:33640,MAX_ELEMENTS_VERTICES:33e3,MAX_ELEMENTS_INDICES:33001,TEXTURE_MIN_LOD:33082,TEXTURE_MAX_LOD:33083,TEXTURE_BASE_LEVEL:33084,TEXTURE_MAX_LEVEL:33085,MIN:32775,MAX:32776,DEPTH_COMPONENT24:33190,MAX_TEXTURE_LOD_BIAS:34045,TEXTURE_COMPARE_MODE:34892,TEXTURE_COMPARE_FUNC:34893,CURRENT_QUERY:34917,QUERY_RESULT:34918,QUERY_RESULT_AVAILABLE:34919,STREAM_READ:35041,STREAM_COPY:35042,STATIC_READ:35045,STATIC_COPY:35046,DYNAMIC_READ:35049,DYNAMIC_COPY:35050,MAX_DRAW_BUFFERS:34852,DRAW_BUFFER0:34853,DRAW_BUFFER1:34854,DRAW_BUFFER2:34855,DRAW_BUFFER3:34856,DRAW_BUFFER4:34857,DRAW_BUFFER5:34858,DRAW_BUFFER6:34859,DRAW_BUFFER7:34860,DRAW_BUFFER8:34861,DRAW_BUFFER9:34862,DRAW_BUFFER10:34863,DRAW_BUFFER11:34864,DRAW_BUFFER12:34865,DRAW_BUFFER13:34866,DRAW_BUFFER14:34867,DRAW_BUFFER15:34868,MAX_FRAGMENT_UNIFORM_COMPONENTS:35657,MAX_VERTEX_UNIFORM_COMPONENTS:35658,SAMPLER_3D:35679,SAMPLER_2D_SHADOW:35682,FRAGMENT_SHADER_DERIVATIVE_HINT:35723,PIXEL_PACK_BUFFER:35051,PIXEL_UNPACK_BUFFER:35052,PIXEL_PACK_BUFFER_BINDING:35053,PIXEL_UNPACK_BUFFER_BINDING:35055,FLOAT_MAT2x3:35685,FLOAT_MAT2x4:35686,FLOAT_MAT3x2:35687,FLOAT_MAT3x4:35688,FLOAT_MAT4x2:35689,FLOAT_MAT4x3:35690,SRGB:35904,SRGB8:35905,SRGB8_ALPHA8:35907,COMPARE_REF_TO_TEXTURE:34894,RGBA32F:34836,RGB32F:34837,RGBA16F:34842,RGB16F:34843,VERTEX_ATTRIB_ARRAY_INTEGER:35069,MAX_ARRAY_TEXTURE_LAYERS:35071,MIN_PROGRAM_TEXEL_OFFSET:35076,MAX_PROGRAM_TEXEL_OFFSET:35077,MAX_VARYING_COMPONENTS:35659,TEXTURE_2D_ARRAY:35866,TEXTURE_BINDING_2D_ARRAY:35869,R11F_G11F_B10F:35898,UNSIGNED_INT_10F_11F_11F_REV:35899,RGB9_E5:35901,UNSIGNED_INT_5_9_9_9_REV:35902,TRANSFORM_FEEDBACK_BUFFER_MODE:35967,MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:35968,TRANSFORM_FEEDBACK_VARYINGS:35971,TRANSFORM_FEEDBACK_BUFFER_START:35972,TRANSFORM_FEEDBACK_BUFFER_SIZE:35973,TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:35976,RASTERIZER_DISCARD:35977,MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:35978,MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:35979,INTERLEAVED_ATTRIBS:35980,SEPARATE_ATTRIBS:35981,TRANSFORM_FEEDBACK_BUFFER:35982,TRANSFORM_FEEDBACK_BUFFER_BINDING:35983,RGBA32UI:36208,RGB32UI:36209,RGBA16UI:36214,RGB16UI:36215,RGBA8UI:36220,RGB8UI:36221,RGBA32I:36226,RGB32I:36227,RGBA16I:36232,RGB16I:36233,RGBA8I:36238,RGB8I:36239,RED_INTEGER:36244,RGB_INTEGER:36248,RGBA_INTEGER:36249,SAMPLER_2D_ARRAY:36289,SAMPLER_2D_ARRAY_SHADOW:36292,SAMPLER_CUBE_SHADOW:36293,UNSIGNED_INT_VEC2:36294,UNSIGNED_INT_VEC3:36295,UNSIGNED_INT_VEC4:36296,INT_SAMPLER_2D:36298,INT_SAMPLER_3D:36299,INT_SAMPLER_CUBE:36300,INT_SAMPLER_2D_ARRAY:36303,UNSIGNED_INT_SAMPLER_2D:36306,UNSIGNED_INT_SAMPLER_3D:36307,UNSIGNED_INT_SAMPLER_CUBE:36308,UNSIGNED_INT_SAMPLER_2D_ARRAY:36311,DEPTH_COMPONENT32F:36012,DEPTH32F_STENCIL8:36013,FLOAT_32_UNSIGNED_INT_24_8_REV:36269,FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:33296,FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:33297,FRAMEBUFFER_ATTACHMENT_RED_SIZE:33298,FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:33299,FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:33300,FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:33301,FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:33302,FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:33303,FRAMEBUFFER_DEFAULT:33304,UNSIGNED_INT_24_8:34042,DEPTH24_STENCIL8:35056,UNSIGNED_NORMALIZED:35863,DRAW_FRAMEBUFFER_BINDING:36006,READ_FRAMEBUFFER:36008,DRAW_FRAMEBUFFER:36009,READ_FRAMEBUFFER_BINDING:36010,RENDERBUFFER_SAMPLES:36011,FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:36052,MAX_COLOR_ATTACHMENTS:36063,COLOR_ATTACHMENT1:36065,COLOR_ATTACHMENT2:36066,COLOR_ATTACHMENT3:36067,COLOR_ATTACHMENT4:36068,COLOR_ATTACHMENT5:36069,COLOR_ATTACHMENT6:36070,COLOR_ATTACHMENT7:36071,COLOR_ATTACHMENT8:36072,COLOR_ATTACHMENT9:36073,COLOR_ATTACHMENT10:36074,COLOR_ATTACHMENT11:36075,COLOR_ATTACHMENT12:36076,COLOR_ATTACHMENT13:36077,COLOR_ATTACHMENT14:36078,COLOR_ATTACHMENT15:36079,FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:36182,MAX_SAMPLES:36183,HALF_FLOAT:5131,RG:33319,RG_INTEGER:33320,R8:33321,RG8:33323,R16F:33325,R32F:33326,RG16F:33327,RG32F:33328,R8I:33329,R8UI:33330,R16I:33331,R16UI:33332,R32I:33333,R32UI:33334,RG8I:33335,RG8UI:33336,RG16I:33337,RG16UI:33338,RG32I:33339,RG32UI:33340,VERTEX_ARRAY_BINDING:34229,R8_SNORM:36756,RG8_SNORM:36757,RGB8_SNORM:36758,RGBA8_SNORM:36759,SIGNED_NORMALIZED:36764,COPY_READ_BUFFER:36662,COPY_WRITE_BUFFER:36663,COPY_READ_BUFFER_BINDING:36662,COPY_WRITE_BUFFER_BINDING:36663,UNIFORM_BUFFER:35345,UNIFORM_BUFFER_BINDING:35368,UNIFORM_BUFFER_START:35369,UNIFORM_BUFFER_SIZE:35370,MAX_VERTEX_UNIFORM_BLOCKS:35371,MAX_FRAGMENT_UNIFORM_BLOCKS:35373,MAX_COMBINED_UNIFORM_BLOCKS:35374,MAX_UNIFORM_BUFFER_BINDINGS:35375,MAX_UNIFORM_BLOCK_SIZE:35376,MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:35377,MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:35379,UNIFORM_BUFFER_OFFSET_ALIGNMENT:35380,ACTIVE_UNIFORM_BLOCKS:35382,UNIFORM_TYPE:35383,UNIFORM_SIZE:35384,UNIFORM_BLOCK_INDEX:35386,UNIFORM_OFFSET:35387,UNIFORM_ARRAY_STRIDE:35388,UNIFORM_MATRIX_STRIDE:35389,UNIFORM_IS_ROW_MAJOR:35390,UNIFORM_BLOCK_BINDING:35391,UNIFORM_BLOCK_DATA_SIZE:35392,UNIFORM_BLOCK_ACTIVE_UNIFORMS:35394,UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:35395,UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:35396,UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:35398,INVALID_INDEX:4294967295,MAX_VERTEX_OUTPUT_COMPONENTS:37154,MAX_FRAGMENT_INPUT_COMPONENTS:37157,MAX_SERVER_WAIT_TIMEOUT:37137,OBJECT_TYPE:37138,SYNC_CONDITION:37139,SYNC_STATUS:37140,SYNC_FLAGS:37141,SYNC_FENCE:37142,SYNC_GPU_COMMANDS_COMPLETE:37143,UNSIGNALED:37144,SIGNALED:37145,ALREADY_SIGNALED:37146,TIMEOUT_EXPIRED:37147,CONDITION_SATISFIED:37148,WAIT_FAILED:37149,SYNC_FLUSH_COMMANDS_BIT:1,VERTEX_ATTRIB_ARRAY_DIVISOR:35070,ANY_SAMPLES_PASSED:35887,ANY_SAMPLES_PASSED_CONSERVATIVE:36202,SAMPLER_BINDING:35097,RGB10_A2UI:36975,INT_2_10_10_10_REV:36255,TRANSFORM_FEEDBACK:36386,TRANSFORM_FEEDBACK_PAUSED:36387,TRANSFORM_FEEDBACK_ACTIVE:36388,TRANSFORM_FEEDBACK_BINDING:36389,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_SRGB8_ETC2:37493,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37494,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37495,COMPRESSED_RGBA8_ETC2_EAC:37496,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37497,TEXTURE_IMMUTABLE_FORMAT:37167,MAX_ELEMENT_INDEX:36203,TEXTURE_IMMUTABLE_LEVELS:33503,MAX_TEXTURE_MAX_ANISOTROPY_EXT:34047});let eo={UNSIGNED_BYTE:to.UNSIGNED_BYTE,UNSIGNED_SHORT:to.UNSIGNED_SHORT,UNSIGNED_INT:to.UNSIGNED_INT,FLOAT:to.FLOAT,HALF_FLOAT:to.HALF_FLOAT_OES,UNSIGNED_INT_24_8:to.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:to.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:to.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:to.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(t,e){switch(t){case eo.UNSIGNED_BYTE:return to.UNSIGNED_BYTE;case eo.UNSIGNED_SHORT:return to.UNSIGNED_SHORT;case eo.UNSIGNED_INT:return to.UNSIGNED_INT;case eo.FLOAT:return to.FLOAT;case eo.HALF_FLOAT:return e.webgl2?to.HALF_FLOAT:to.HALF_FLOAT_OES;case eo.UNSIGNED_INT_24_8:return to.UNSIGNED_INT_24_8;case eo.UNSIGNED_SHORT_4_4_4_4:return to.UNSIGNED_SHORT_4_4_4_4;case eo.UNSIGNED_SHORT_5_5_5_1:return to.UNSIGNED_SHORT_5_5_5_1;case eo.UNSIGNED_SHORT_5_6_5:return eo.UNSIGNED_SHORT_5_6_5}},isPacked:function(t){return t===eo.UNSIGNED_INT_24_8||t===eo.UNSIGNED_SHORT_4_4_4_4||t===eo.UNSIGNED_SHORT_5_5_5_1||t===eo.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(t){switch(t){case eo.UNSIGNED_BYTE:return 1;case eo.UNSIGNED_SHORT:case eo.UNSIGNED_SHORT_4_4_4_4:case eo.UNSIGNED_SHORT_5_5_5_1:case eo.UNSIGNED_SHORT_5_6_5:case eo.HALF_FLOAT:return 2;case eo.UNSIGNED_INT:case eo.FLOAT:case eo.UNSIGNED_INT_24_8:return 4}},validate:function(t){return t===eo.UNSIGNED_BYTE||t===eo.UNSIGNED_SHORT||t===eo.UNSIGNED_INT||t===eo.FLOAT||t===eo.HALF_FLOAT||t===eo.UNSIGNED_INT_24_8||t===eo.UNSIGNED_SHORT_4_4_4_4||t===eo.UNSIGNED_SHORT_5_5_5_1||t===eo.UNSIGNED_SHORT_5_6_5}};var ro=Object.freeze(eo);let no={DEPTH_COMPONENT:to.DEPTH_COMPONENT,DEPTH_STENCIL:to.DEPTH_STENCIL,ALPHA:to.ALPHA,RGB:to.RGB,RGBA:to.RGBA,LUMINANCE:to.LUMINANCE,LUMINANCE_ALPHA:to.LUMINANCE_ALPHA,RGB_DXT1:to.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:to.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:to.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:to.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:to.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:to.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:to.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:to.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:to.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:to.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:to.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:to.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:to.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(t){switch(t){case no.RGB:return 3;case no.RGBA:return 4;case no.LUMINANCE_ALPHA:return 2;case no.ALPHA:case no.LUMINANCE:default:return 1}},validate:function(t){return t===no.DEPTH_COMPONENT||t===no.DEPTH_STENCIL||t===no.ALPHA||t===no.RGB||t===no.RGBA||t===no.LUMINANCE||t===no.LUMINANCE_ALPHA||t===no.RGB_DXT1||t===no.RGBA_DXT1||t===no.RGBA_DXT3||t===no.RGBA_DXT5||t===no.RGB_PVRTC_4BPPV1||t===no.RGB_PVRTC_2BPPV1||t===no.RGBA_PVRTC_4BPPV1||t===no.RGBA_PVRTC_2BPPV1||t===no.RGBA_ASTC||t===no.RGB_ETC1||t===no.RGB8_ETC2||t===no.RGBA8_ETC2_EAC||t===no.RGBA_BC7},isColorFormat:function(t){return t===no.ALPHA||t===no.RGB||t===no.RGBA||t===no.LUMINANCE||t===no.LUMINANCE_ALPHA},isDepthFormat:function(t){return t===no.DEPTH_COMPONENT||t===no.DEPTH_STENCIL},isCompressedFormat:function(t){return t===no.RGB_DXT1||t===no.RGBA_DXT1||t===no.RGBA_DXT3||t===no.RGBA_DXT5||t===no.RGB_PVRTC_4BPPV1||t===no.RGB_PVRTC_2BPPV1||t===no.RGBA_PVRTC_4BPPV1||t===no.RGBA_PVRTC_2BPPV1||t===no.RGBA_ASTC||t===no.RGB_ETC1||t===no.RGB8_ETC2||t===no.RGBA8_ETC2_EAC||t===no.RGBA_BC7},isDXTFormat:function(t){return t===no.RGB_DXT1||t===no.RGBA_DXT1||t===no.RGBA_DXT3||t===no.RGBA_DXT5},isPVRTCFormat:function(t){return t===no.RGB_PVRTC_4BPPV1||t===no.RGB_PVRTC_2BPPV1||t===no.RGBA_PVRTC_4BPPV1||t===no.RGBA_PVRTC_2BPPV1},isASTCFormat:function(t){return t===no.RGBA_ASTC},isETC1Format:function(t){return t===no.RGB_ETC1},isETC2Format:function(t){return t===no.RGB8_ETC2||t===no.RGBA8_ETC2_EAC},isBC7Format:function(t){return t===no.RGBA_BC7},compressedTextureSizeInBytes:function(t,e,r){switch(t){case no.RGB_DXT1:case no.RGBA_DXT1:case no.RGB_ETC1:case no.RGB8_ETC2:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*8;case no.RGBA_DXT3:case no.RGBA_DXT5:case no.RGBA_ASTC:case no.RGBA8_ETC2_EAC:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*16;case no.RGB_PVRTC_4BPPV1:case no.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(e,8)*Math.max(r,8)*4+7)/8);case no.RGB_PVRTC_2BPPV1:case no.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(e,16)*Math.max(r,8)*2+7)/8);case no.RGBA_BC7:return Math.ceil(e/4)*Math.ceil(r/4)*16;default:return 0}},textureSizeInBytes:function(t,e,r,n){let A=no.componentsLength(t);return ro.isPacked(e)&&(A=1),A*ro.sizeInBytes(e)*r*n},alignmentInBytes:function(t,e,r){let n=no.textureSizeInBytes(t,e,r,1)%4;return 0===n?4:2===n?2:1},createTypedArray:function(t,e,r,n){let A,i=ro.sizeInBytes(e);return A=i===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:i===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:i===Float32Array.BYTES_PER_ELEMENT&&e===ro.FLOAT?Float32Array:Uint32Array,new A(no.componentsLength(t)*r*n)},flipY:function(t,e,r,n,A){if(1===A)return t;let i=no.createTypedArray(e,r,n,A),o=no.componentsLength(e),s=n*o;for(let e=0;e<A;++e){let r=e*n*o,a=(A-e-1)*n*o;for(let e=0;e<s;++e)i[a+e]=t[r+e]}return i},toInternalFormat:function(t,e,r){if(!r.webgl2)return t;if(t===no.DEPTH_STENCIL)return to.DEPTH24_STENCIL8;if(t===no.DEPTH_COMPONENT){if(e===ro.UNSIGNED_SHORT)return to.DEPTH_COMPONENT16;if(e===ro.UNSIGNED_INT)return to.DEPTH_COMPONENT24}if(e===ro.FLOAT)switch(t){case no.RGBA:return to.RGBA32F;case no.RGB:return to.RGB32F;case no.RG:return to.RG32F;case no.R:return to.R32F}if(e===ro.HALF_FLOAT)switch(t){case no.RGBA:return to.RGBA16F;case no.RGB:return to.RGB16F;case no.RG:return to.RG16F;case no.R:return to.R16F}return t}};var Ao=Object.freeze(no);function io(t,e,r,n,A,i){const o=function(t,e,r,n){let A=t.length,i=r,o=n,s=0;for(;i>0&&o>0;){let t=Ao.compressedTextureSizeInBytes(e,i,o);if(s+=t,i>>=1,o>>=1,0===i&&0===o)break;i=Math.max(i,1),o=Math.max(o,1)}return s===A}(t,r,A,i);if(!o)return null;const s=6410===r||4369===r;let a=0,B=A,E=i;const c=[];do{let n=Ao.compressedTextureSizeInBytes(r,B,E),A=new Uint8Array(t.buffer,e+a,n);c.push(A),B=Math.max(B>>1,1),E=Math.max(E>>1,1),a+=n}while(a<t.byteLength&&o);return{flipY:s,mipmap:c}}const oo=1,so=2,ao=4,Bo=16;function Eo(t,e){const r={};if(t.compressOptions){let e=t.compressOptions;(e&oo)===oo&&(r.COMPRESS_VERTEX=1),(e&so)===so&&(r.COMPRESS_NORMAL=1),(e&ao)===ao&&(r.COMPRESS_COLOR=1),(e&Bo)===Bo&&(r.COMPRESS_TEXCOORD=1)}e.push(r)}function co(t){if(t&&Ft(t)){const e=[];for(const r in t)e.push(t[r]);return e}return t}function Co(t,e){const r={},n=t.compressOptions;(n&oo)===oo&&(r.decode_position_min=co(t.minVerticesValue),r.decode_position_normConstant=co(t.vertCompressConstant)),(n&so)===so&&(r.normal_rangeConstant=co(t.normalRangeConstant)),(n&Bo)===Bo&&(t.texCoordCompressConstant.length>0&&(r.decode_texCoord0_min=co(t.minTexCoordValue[0]),r.decode_texCoord0_normConstant=co(t.texCoordCompressConstant[0]),r.decode_texCoord0_vNormConstant=co(t.texCoordCompressConstant[0])),t.texCoordCompressConstant.length>1&&(r.decode_texCoord1_min=co(t.minTexCoordValue[1]),r.decode_texCoord1_normConstant=co(t.texCoordCompressConstant[1]),r.decode_texCoord1_vNormConstant=co(t.texCoordCompressConstant[1])),t.texCoordCompressConstant.length>2&&(r.decode_texCoord2_min=co(t.minTexCoordValue[2]),r.decode_texCoord2_normConstant=co(t.texCoordCompressConstant[2])),t.texCoordCompressConstant.length>3&&(r.decode_texCoord3_min=co(t.minTexCoordValue[3]),r.decode_texCoord3_normConstant=co(t.texCoordCompressConstant[3])),t.texCoordCompressConstant.length>4&&(r.decode_texCoord4_min=co(t.minTexCoordValue[4]),r.decode_texCoord4_normConstant=co(t.texCoordCompressConstant[4])),t.texCoordCompressConstant.length>5&&(r.decode_texCoord5_min=co(t.minTexCoordValue[5]),r.decode_texCoord5_normConstant=co(t.texCoordCompressConstant[5])),t.texCoordCompressConstant.length>6&&(r.decode_texCoord6_min=co(t.minTexCoordValue[6]),r.decode_texCoord6_normConstant=co(t.texCoordCompressConstant[6])),t.texCoordCompressConstant.length>7&&(r.decode_texCoord7_min=co(t.minTexCoordValue[7]),r.decode_texCoord7_normConstant=co(t.texCoordCompressConstant[7]))),e.push(r)}function fo(t,e){let r,n,A,i=t.bytesOffset,o=Ci.parseBuffer(t.buffer,i),s=o.geoPackage,a=o.groupNode.pageLods,B=[],E=[],c=[],C=[],f=[],l=[],u=[],_=[],I=[];if(!a[0].geodes[0])return null;let D=a[0].geodes[0].matrix;const h=[];let R={};for(let t=0;t<o.materials.material.length;t++)R[o.materials.material[t].material.id]=o.materials.material[t].material;let T=0,F=Number.MAX_VALUE,P=Number.MAX_VALUE,O=Number.MAX_VALUE,L=Number.MIN_VALUE,y=Number.MIN_VALUE,M=Number.MIN_VALUE;for(let t in s){let e=s[t].vertexPackage;r=e.verticesCount;let i=e.vertexAttributes[0].typedArray.buffer,o=e.vertexAttributes[0].typedArray.byteOffset,a=e.vertexAttributes[0].componentsPerAttribute;A=new(Ee(e.vertexAttributes[0].componentDatatype))(i,e.vertexAttributes[0].offsetInBytes+o,r*a);const D=co(e.minVerticesValue)||[0,0,0],N=co(e.vertCompressConstant)||0;for(let t=0;t<r;t++){let e=A[t*a]*N+D[0],r=A[t*a+1]*N+D[1],n=A[t*a+2]*N+D[2];F=Math.min(F,e),P=Math.min(P,r),O=Math.min(O,n),L=Math.max(L,e),y=Math.max(y,r),M=Math.max(M,n)}B.push(A),go("aColor",e,i,r,C),go("aTexCoord0",e,i,r,c),go("aTextureCoordMatrix",e,i,r,h),go("batchId",e,i,r,f),Eo(e,u),Co(e,_);let S=s[t].arrIndexPackage[0].indicesTypedArray,d=S.byteLength/s[t].arrIndexPackage[0].indicesCount;n=new(4===d?Uint32Array:2===d?Uint16Array:Uint8Array)(S.buffer,(s[t].arrIndexPackage[0].bytesOffset||0)+S.byteOffset,s[t].arrIndexPackage[0].indicesCount),E.push(n),T+=n.length,I.push(r);let U=s[t].arrIndexPackage[0].materialCode;l.push(R[U])}let N=[F,P,O],S=[L,y,M];const d=o.version;return function(t,e,r,n,A,i,o,s,a,B,E,c,C,f,l,u,_,I,D){let h=0;for(const t in a)a[t].width*a[t].height*4>h&&(h=a[t].width*a[t].height*4);(!uo||h>uo)&&(lo=new Uint8ClampedArray(h+122),uo=h);const R=[],T={magFilter:9729,minFilter:9729,wrapS:10497,wrapT:10497},F={},P={},O=[],L=[],y=[];for(let B=0;B<r.length;B++){const D=e[B],h=t[B],M=r[B],N=A&&A[B]&&A[B],S=i&&i[B],d=n&&n[B]&&n[B],U=o&&o[B]&&o[B],G=s&&s[B]&&s[B],m={POSITION:{array:M,componentType:ce(M.constructor),count:h,byteOffset:M.byteOffset,byteStride:0,byteLength:M.byteLength,type:Ce(M.length/h),itemSize:M.length/h,name:"POSITION",min:E,max:c}};O.indexOf(M.buffer)<0&&O.push(M.buffer),N&&Vo(m,"TEXCOORD_0",N,h,O),S&&Vo(m,"TextureCoordMatrix",S,h,O),d&&Vo(m,"NORMAL",d,h,O),U&&Vo(m,"COLOR_0",U,h,O),G&&Vo(m,"_BATCHID",G,h,O);const b={attributes:m,material:B,compressDefines:l[B],compressUniforms:u[B],indices:{array:D.slice(),itemSize:1,byteLength:D.byteLength,byteOffset:0,byteStride:0,name:D,count:D.length,componentType:5123},mode:4};O.push(b.indices.array.buffer);const p={primitives:[b],index:B};P[B]=p;const w={mesh:B,nodeIndex:B,matrix:I};F[B]=w,L.push({nodes:[w]});const H=f[B],K={uFillForeColor:[1,1,1,1]};let g=H.ambient;K.ambientColor=[g.r,g.g,g.b,g.a];let V=H.diffuse;K.uDiffuseColor=[V.r,V.g,V.b,V.a];let J=H.specular;K.specularColor=[J.r,J.g,J.b,J.a],K.shininess=H.shininess,K.bTransparentSorting=H.transparentsorting;let X=H.textureunitstates;if(X.length){K.uTexMatrix=X[0].textureunitstate.texmodmatrix;const t=X[0].textureunitstate.id,e=a[t];if(K.uTexture0Width=e.width,X[1]){const t=X[1].textureunitstate.id,e=a[t];K.uTexture1Width=e.width}}y.push({pbrMetallicRoughness:{baseColorFactor:[.8,.8,.8,1],metallicFactor:0,roughnessFactor:.5},extensions:{KHR_techniques_webgl:{technique:0,values:K}}}),R.push(Do(B,f,C,a,_).then(t=>{if(!t)return null;const{array:e,mipmap:r,width:n,height:A,format:i,flipY:o}=t;if(e&&O.indexOf(e.buffer)<0&&O.push(e.buffer),r)for(let t=0;t<r.length;t++)e&&O.indexOf(r[t].buffer)<0&&O.push(r[t].buffer);let s=T;return r&&(s={magFilter:T.magFilter,minFilter:9987,wrapS:T.wrapS,wrapT:T.wrapT}),{materialIndex:B,image:{mipmap:r,array:e,flipY:!!o,width:n,height:A,mimeType:"image/bmp"},sampler:s,format:i,source:B}}))}return Promise.all(R).then(t=>{t=t.filter(t=>!!t);for(let e=0;e<t.length;e++){const{materialIndex:r}=t[e];let n="uTexture";y[r].extensions.KHR_techniques_webgl.values.uTexture&&(n="uTexture2"),y[r].extensions.KHR_techniques_webgl.values[n]={"index":e,"texCoord":r},delete t[e].materialIndex}return{transferables:O,gltf:{"asset":{"generator":"S3M","version":"2.0","s3mVersion":D},"scene":0,"scenes":L,"nodes":F,"meshes":P,"materials":y,"skins":[],"animations":null,"textures":t,"transferables":[{},{},{},{},{}]}}})}(I,E,B,null,c,h,C,f,o.texturePackage,0,N,S,[],l,u,_,e,D,d).then(({gltf:t,transferables:e})=>({gltf:t,featureTable:{"BATCH_LENGTH":0},transferables:e,pageLods:a}))}Ci.multiplyByPoint=function(t,e,r){let n=e.x,A=e.y,i=e.z,o=t[0]*n+t[4]*A+t[8]*i+t[12],s=t[1]*n+t[5]*A+t[9]*i+t[13],a=t[2]*n+t[6]*A+t[10]*i+t[14];return r.x=o,r.y=s,r.z=a,r};let lo,uo=0;let _o=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(En){}t&&"undefined"!=typeof createImageBitmap&&(_o=!0)}const Io={};function Do(t,e,r,n,A){const i=lo;return new Promise((function(r){!function(t){if(e[t].textureunitstates[0]){let o,s=e[t].textureunitstates[0].textureunitstate.id,a=n[s],B=a.arrayBufferView,E=a.nFormat,c=a.internalFormat;if(function(t){return t===Lo||t===yo||t===Mo||t===No||t===So||t===Uo||t===Go||t===mo||t===bo||t===po||t===wo||t===Ho||t===Ko}(c)&&a.width===a.height){const t=io(B,B.byteOffset,c,0,a.width,a.height);if(t){const{mipmap:e,flipY:n}=t;return void r({format:c,mipmap:e,flipY:n,width:a.width,height:a.height})}}o=E>ei||E===ti?122+a.width*a.height*4:61+a.width*a.height,Ei.decode(i.subarray(122),a.width,a.height,B,E),function(t,e,r){let n=r*(4*e+e%4),A=n+o,i=new DataView(t);var o=0;i.setUint16(o,19778,!0),o+=2,i.setUint32(o,A,!0),o+=4,i.setUint32(o,0,!0),o+=4,i.setUint32(o,122,!0),o+=4,i.setUint32(o,108,!0),o+=4,i.setUint32(o,e,!0),o+=4,i.setUint32(o,r,!0),o+=4,i.setUint16(o,1,!0),o+=2,i.setUint16(o,32,!0),o+=2,i.setUint32(o,this.compress,!0),o+=4,i.setUint32(o,n,!0),o+=4,i.setUint32(o,2835,!0),o+=4,i.setUint32(o,2835,!0),o+=4,i.setUint8(o,0,!0),o+=4,i.setUint32(o,0,!0),o+=4,i.setUint32(o,16711680,!0),o+=4,i.setUint32(o,65280,!0),o+=4,i.setUint32(o,255,!0),o+=4,i.setUint32(o,4278190080,!0),o+=4,i.setUint32(o,1466527264,!0),o+=4}(i.buffer,a.width,a.height);let{width:C,height:f}=a;ho(C)||(C=Ro(C)),ho(f)||(f=Ro(f));const l=A;let u;l&&(C=Math.min(l,C),f=Math.min(l,f));let _=6408;const I=a.width*a.height*4;!_o||C===a.width&&f===a.height?(u=new Uint8Array(3*I/4),_=6407):(Io[I]||(Io[I]=new Uint8Array(I)),u=Io[I]),u=$i(u,i.buffer,0,o),!_o||C===a.width&&f===a.height||(u=function(t,e,r,n,A){To||(To=new OffscreenCanvas(2,2),Fo=To.getContext("2d"),Po=new OffscreenCanvas(2,2),Oo=Po.getContext("2d",{willReadFrequently:!0}));const i=new ImageData(new Uint8ClampedArray(t.buffer),e,r);return To.width=e,To.height=r,Fo.putImageData(i,0,0),Po.width=n,Po.height=A,Oo.drawImage(To,0,0,n,A),Oo.getImageData(0,0,n,A).data}(u,a.width,a.height,C,f)),u.buffer===(Io[I]&&Io[I].buffer)&&(u=new Uint8Array(u)),r({array:u,width:C,height:f,format:_})}else r(null)}(t)}))}function ho(t){return 0==(t&t-1)&&0!==t}function Ro(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}let To,Fo,Po,Oo;const Lo=33776,yo=33777,Mo=33778,No=33779,So=35840,Uo=35841,Go=35842,mo=35843,bo=37808,po=36196,wo=37492,Ho=37496,Ko=36492;function go(t,e,r,n,A){let i=e.attrLocation[t];if(i){const t=e.vertexAttributes[i];if(t.typedArray.buffer!==r)A.push(t.typedArray);else{let e=t.componentsPerAttribute;let i=new(Ee(t.componentDatatype))(r,t.offsetInBytes+t.typedArray.byteOffset,n*e);A.push(i)}}else A.push(void 0)}function Vo(t,e,r,n,A){t[e]={array:r,componentType:ce(r.constructor),count:n,byteOffset:r.byteOffset,byteStride:0,byteLength:r.byteLength,type:Ce(r.length/n),itemSize:r.length/n,name:e},A.indexOf(r.buffer)<0&&A.push(r.buffer)}var Jo=ko("DXT1"),Xo=ko("DXT3"),vo=ko("DXT5"),Zo=ko("DX10"),xo=function(t){var e,r,n=new Int32Array(t,0,31);if(542327876!==n[0])throw new Error("Invalid magic number in DDS header");if(4&!n[20])throw new Error("Unsupported format, must contain a FourCC code");var A=n[21];switch(A){case Jo:e=8,r="dxt1";break;case Xo:e=16,r="dxt3";break;case vo:e=16,r="dxt5";break;case 116:r="rgba32f";break;case Zo:var i=new Uint32Array(t.slice(128,148));r=i[0];var o=i[1];if(i[2],i[3],i[4],3!==o||2!==r)throw new Error("Unsupported DX10 texture format "+r);r="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(s=A,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;var a=n[2],B=1;131072&a&&(B=Math.max(1,n[7]));var E=!1;512&n[28]&&(E=!0);var c,C=n[4],f=n[3],l=n[1]+4,u=C,_=f,I=[];A===Zo&&(l+=20);if(E)for(var D=0;D<6;D++){if("rgba32f"!==r)throw new Error("Only RGBA32f cubemaps are supported");C=u,f=_;for(var h=Math.log(C)/Math.log(2)+1,R=0;R<h;R++)c=C*f*16,I.push({offset:l,length:c,shape:[C,f]}),R<B&&(l+=c),C=Math.floor(C/2),f=Math.floor(f/2)}else for(R=0;R<B;R++)c=Math.max(4,C)/4*Math.max(4,f)/4*e,I.push({offset:l,length:c,shape:[C,f]}),l+=c,C=Math.floor(C/2),f=Math.floor(f/2);return{shape:[u,_],images:I,format:r,flags:a,cubemap:E}};function ko(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}const Wo=Math.PI/180,Qo=6378137*Math.PI/180;function jo(t,e,r){if("EPSG:3857"===r)return function(t,e){const r=85.0511287798,n=e[0],A=Math.max(Math.min(r,e[1]),-r);let i;i=0===A?0:Math.log(Math.tan((90+A)*Wo/2))/Wo;return t[0]=n*Qo,t[1]=i*Qo,t}(t,e);if("EPSG:4326"===r||"EPSG:4490"===r||"identity"===r)return Yo(t,e);if("baidu"===r)return Yo(t,e);throw new Error("unsupported projection:"+r)}function Yo(t,e){return t[0]=e[0],t[1]=e[1],t}const zo=A([]),qo=Ie().draco,$o=Ie().ktx2,ts={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},es={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function rs(t,e,r,n){const i=[],o=[],s=[];for(let e=0;e<t.meshes.length;e++){const{geometry:r,material:n}=t.meshes[e],A=Y.getArrayBuffer(r.url);A.xhr.url=r.url,s.push(A.xhr);const a=A.then(t=>({buffer:t}));i.push(a);const B=[];if(Bs(n,B),B.length){const t=B.map(t=>{const e=Y.getArrayBuffer(t.url);return e.xhr.url=t.url,s.push(e.xhr),e.then(e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format})});i.push(...t)}o[e]=B.length}const a=Promise.all(i).then(i=>{for(let t=0;t<i.length;t++)if(!i[t]||!i[t].buffer)return Promise.resolve(null);const s=[];let a=0;for(let t=0;t<o.length;t++){const e=o[t];s.push({geoBuffer:{data:i[a].buffer.data},textureBuffers:i.slice(a+1,e+a+1).map(t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format}))}),a+=1+e}return function(t,e,r,n,i){const o={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},s=[];for(let a=0;a<t.meshes.length;a++){let{material:B}=t.meshes[a];const{geometry:E}=t.meshes[a];let c;const C=e[a].geoBuffer.data;if(!C)continue;const f=us(C);c=f?As(o,a,E,C,t.transform,t.center,i):os(o,a,E,C,t.transform,t.center,i),s.push(c),o.nodes[a]={mesh:a,nodeIndex:a,matrix:A([])},o.scenes[0].nodes[a]=o.nodes[a],B||(B=ts);const l=as(a,o,B,e[a].textureBuffers,r,n);s.push(l)}return Promise.all(s).then(()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables}))}(t,s,e,n,r)});return a.xhr=s,a}const ns={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function As(t,e,r,n,A,i,o){const s=r.info.compressedAttributes.attributes.reduce((t,e,r)=>{const n=es[e];if(!n)return t;return t[n.name||e]=r,t},{});return qo(n,{attributes:s,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then(r=>ss(r,t,e,A,i,o))}const is={position:function(t,e,r){const n=3*t.vertexCount,A=new Float32Array(e,r,n);return t.position={array:A,componentType:5126,itemSize:3,count:n/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},r+=4*n},normal:function(t,e,r){const n=3*t.vertexCount,A=new Float32Array(e,r,n);return t.normal={array:A,componentType:5126,itemSize:3,count:n/3,type:"VEC3"},r+=4*n},uv0:function(t,e,r){const n=2*t.vertexCount,A=new Float32Array(e,r,n);return t.uv0={array:A,componentType:5126,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},color:function(t,e,r){const n=4*t.vertexCount,A=new Uint8Array(e,r,n);return t.color={array:A,componentType:5121,itemSize:4,count:n/4,type:"VEC4"},r+=n},featureId:function(t,e,r){return r+=8*t.featureCount},id:function(t,e,r){return r+=8*t.featureCount},faceRange:function(t,e,r){const n=2*t.featureCount,A=new Uint32Array(e,r,n);return t.faceRange={array:A,componentType:5125,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},uvRegion:function(t,e,r){const n=4*t.vertexCount,A=new Uint16Array(e,r,n);return t["uv-region"]={array:A,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n},region:function(t,e,r){const n=4*t.vertexCount,A=new Uint16Array(e,r,n);return t["uv-region"]={array:A,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n}};function os(t,e,r,n,A,i,o){const s={vertexCount:0},a=new DataView(n);try{let t=0;s.vertexCount=a.getUint32(t,1),t+=4,s.featureCount=a.getUint32(t,1),t+=4;const e=r.info.ordering?null:r.info;if(e){const r=[];for(const t in e)"offset"!==t&&""!==t&&r.push(t);for(let e=0;e<r.length;e++)is[r[e]]?t=is[r[e]](s,n,t):console.error("Unknown decoder for",r[e])}else{const e=r.info;let A=e.ordering,i=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<A.length;e++){const r=is[A[e]];r||console.log(A[e]),t=r(s,n,t)}for(let e=0;e<i.length;e++){const r=is[i[e]];r||console.log(i[e]),t=r(s,n,t)}}}catch(t){}s.scale_x=1,s.scale_y=1;const B={};for(const t in s){const e=es[t]&&es[t].name;e&&(B[e]=s[t])}if(s.faceRange){const t=s.faceRange.array,e=t.length/2,r=(E=e)<=255?Uint8Array:E<=65535?Uint16Array:Uint32Array,n=new r(B.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const r=e/2,A=t[e],i=t[e+1];for(let t=A;t<=i;t++)n[3*t]=r,n[3*t+1]=r,n[3*t+2]=r}B._BATCHID={componentType:ce(r),array:n,itemSize:1,count:n.length,type:"SCALAR"}}var E;return ss({attributes:B},t,e,A,i,o)}function ss(t,e,r,n,A,i){const o={attributes:t.attributes,material:r,indices:t.indices,mode:4};!function(t){const e=t.array,r=t.meta&&t.meta["i3s-scale_x"],n=t.meta&&t.meta["i3s-scale_y"];if(r&&n&&(1!==r||1!==n))for(let t=0;t<e.length;t+=3)e[t]*=r.value,e[t+1]*=n.value}(t.attributes.POSITION);const s=function(t,e,r,n){const A=r;let i,o=[0,0,0,1];const s=[0,0],a=jo([],r,n);a[2]=r[2];const E=e&&B(zo,e);return be(t,t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],E||(o=P(o,o,e)),A&&u(o,o,A),jo(s,o,n),i=o[2],t[0]=s[0]-a[0],t[1]=s[1]-a[1],t[2]=i-a[2],t)),a}(t.attributes.POSITION,n,A,i);e.meshes[r]={primitives:[o],index:r},e.extensions.MAPTALKS_RTC={projCenter:s},e.extensions.CESIUM_RTC={rtcCoord:A};for(const r in t.attributes)ls(e.transferables,t.attributes[r].array.buffer);return t.indices&&ls(e.transferables,t.indices.array.buffer),o}function as(t,e,r,n,A,i){const o=n.map(t=>function(t,e,r,n,A){if("dds"===e){const e=xo(t),n=e.images.map(e=>new Uint8Array(t,e.offset,e.length)),A="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:n,width:e.shape[0],height:e.shape[1],mimeType:r},sampler:ns,format:A})}if("png"===e||"jpg"===e)return function(t,e){Es||(Es=new OffscreenCanvas(2,2),cs=Es.getContext("2d",{willReadFrequently:!0}));const r=new Blob([new Uint8Array(t)]);return createImageBitmap(r).then(t=>{let{width:r,height:n}=t;Cs(r)||(r=fs(r)),Cs(n)||(n=fs(n));const A=e;A&&(r=Math.min(A,r),n=Math.min(A,n)),Es.width=r,Es.height=n,cs.drawImage(t,0,0,r,n),t.close();const i=cs.getImageData(0,0,r,n);return{width:r,height:n,array:new Uint8Array(i.data)}}).catch(()=>({width:2,height:2,array:new Uint8Array(4)}))}(t,A).then(t=>{t.mimeType=r;return{image:t,sampler:ns,format:6408}});if("ktx2"===e)return $o(t,n).then(t=>(t.mimeType=r,{image:t,sampler:ns,format:t.format}));return null}(t.data,t.format,t.mimeType,A,i).then(t=>{if(t.image)if(t.image.array)ls(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let r=0;r<t.image.mipmap.length;r++)ls(e.transferables,t.image.mipmap[r].buffer);return t}));return Promise.all(o).then(n=>{!function t(e,r,n,A){const i=JSON.parse(JSON.stringify(n)),o=r.textures;A.ptr||(A.ptr=0);for(const e in n)n[e]&&n[e].url?(o.push(A[A.ptr++]),i[e]={index:o.length-1},void 0!==n[e].factor&&(i[e].scale=n[e].factor)):Ft(n[e])&&(i[e]=t(-1,r,n[e],A));e>=0&&(r.materials[e]=i);return i}(t,e,r,n)})}function Bs(t,e){for(const r in t)t[r]&&t[r].url?e.push({url:t[r].url,mimeType:t[r].mimeType,format:t[r].format}):Ft(t[r])&&Bs(t[r],e)}let Es,cs;function Cs(t){return 0==(t&t-1)&&0!==t}function fs(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function ls(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function us(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}const _s=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Is=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],Ds="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let hs,Rs=!1;if("undefined"!=typeof OffscreenCanvas){try{hs=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(En){}hs&&"undefined"!=typeof createImageBitmap&&(Rs=!0)}const Ts=A([]),Fs=[0,0,0],Ps=[],Os=[],Ls=[],ys=[];class Ms{constructor(t,e,r,n){this.id=t,this.options=e,this.Ft=this.requestImage.bind(this),this.Pt=r,this.Ot={},n(null,{},[])}Lt(t){this.yt||(this.i=t,this.Mt=new Pe,this.yt=new De(this.Ft,ut,t),this.Nt=new he(this.Ft,ut,t))}requestImage(t,e){Rs?fetch(t).then(t=>t.arrayBuffer()).then(t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(t=>{(void 0).width=t.width,(void 0).height=t.height,hs.drawImage(t,0,0);const r=hs.getImageData(0,0,(void 0).width,(void 0).height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(r.data)})}):this.Pt("requestImage",{url:t},null,e)}loadTile(t,e){this.Lt(t.supportedFormats);const r=t.url,n=t.arraybuffer;if(function(t){return t.indexOf("i3s:")>=0}(r)){const n=t.i3sInfo,A=this.options.services[t.rootIdx].maxTextureSize||1024,i=rs(n,t.supportedFormats,this.options.projection,A);return i.then(t=>{if(delete this.Ot[r],!t)return void e({status:404,url:r,i3sInfo:n});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:n});t.gltf.url=r;const{transferables:A}=t;t.magic="b3dm",e(null,t,A)}),void(this.Ot[r]=i.xhr)}if(n){delete this.Ot[r];const A=new DataView(n),i=Xt(A,0);if("{"===i[0]||" "===i[0]||"<"===i[0]){const A=function(t,e,r){if(Ds){const n=new Uint8Array(t,e,r);return Ds.decode(n)}return Mt(new Uint8Array(t,e,r))}(n,0,n.byteLength),i=JSON.parse(A);this.St(t.rootIdx,i,n,r,e)}else{const o=A.getFloat32(0,!0);1===o||2===o||3===o?this.dt(n,r,t,e):this.Ut(n,r,t,i,e)}}else{const n=this.options.services[t.rootIdx];let A=n.urlParams;A&&(A=(r.indexOf("?")>0?"&":"?")+A);const i=r.replace(/\\+/g,"%2B");let o=Y.getArrayBuffer(i+(A||""),n.fetchOptions);const s=o.xhr;o=o.then(n=>{delete this.Ot[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))}).catch(t=>{delete this.Ot[r],e(t)}),this.Ot[r]=s}}Ut(t,e,r,n,A){const i=this.options.services[r.rootIdx];if("b3dm"===n){this.yt.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{if(t.error)return void A(t);const{content:e,transferables:n}=this.Gt(t,r);A(null,e,n)}).catch(t=>{A(t)})}else if("pnts"===n){const n=r.transform;this.Mt.load(e,t).then(t=>{const{content:e,transferables:i}=this.bt(t,n,r.rootIdx);A(null,e,i)})}else if("i3dm"===n){const n=r.transform;this.Nt.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{const{content:e,transferables:i}=this.bt(t,n,r.rootIdx);A(null,e,i)})}else if("cmpt"===n){new Le(this.Ft,ut,this.i,i.maxTextureSize||1024).load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{const{content:e,transferables:n}=this.pt(t,r);A(null,e,n)}).catch(t=>{A(t)})}}dt(t,e,r,n){fo({buffer:t,bytesOffset:0},this.options.services[r.rootIdx].maxTextureSize||1024).then(t=>{t.gltf.url=e;const{content:A,transferables:i}=this.Gt(t,r);if(A.magic="b3dm",t.pageLods){const e=this.wt(t.pageLods);e.length&&(A.children=e)}n(null,A,i)})}wt(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!n.childTile)continue;const A={boundingVolume:{sphere:[n.boundingSphere.center.x,n.boundingSphere.center.y,n.boundingSphere.center.z,n.boundingSphere.radius]},content:{uri:n.childTile},geometricError:n.boundingSphere.radius/n.rangeList*16,refine:"REPLACE"};e.push(A)}return e}St(t,e,r,n,A){return e.dataType&&e.position?void A(null,He(e)):(e.capabilities,void A(null,e))}pt(t,e){const{tiles:r}=t,n={magic:"cmpt",content:[]},A=[];for(let t=0;t<r.length;t++){const{magic:i}=r[t];if("b3dm"===i){const{content:i,transferables:o}=this.Gt(r[t],e);Us(A,o),n.content.push(i)}else if("i3dm"===i||"pnts"===i){const{transform:i,rootIdx:o}=e,{content:s,transferables:a}=this.bt(r[t],i,o);Us(A,a),n.content.push(s)}else if("cmpt"===i){const{content:i,transferables:o}=this.pt(r[t],e);Us(A,o),n.content.push(i)}}return{content:n,transferables:A}}Gt(t,e){const{gltf:r,transferables:n,featureTable:A}=t,i=function(t){if(!t||!t.meshes)return!1;let e=1;const r=[];for(const n in t.meshes){const A=t.meshes[n],{primitives:i}=A;if(i)for(let t=0;t<i.length;t++){const n=i[t].attributes&&i[t].attributes.POSITION;if(!n||!n.array)continue;n.array.buffer.visited||(n.array.buffer.visited=e++);const A=e-1+"-"+(n.byteOffset||0);if(r.indexOf(A)>=0)return!0;r.push(A)}}return!1}(r);return this.Ht(t.gltf),t.gltf.asset||(t.gltf.asset={}),i?(t.gltf.asset.sharePosition=!0,this.Kt(r,A,e.upAxis,e.transform)):this.gt(r,A,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:n}}bt(t,e,n){const{featureTable:A}=t,i=t.pnts||t.i3dm,o=A&&A.RTC_CENTER||[0,0,0];if(A.EAST_NORTH_UP&&!i.NORMAL_UP&&!i.NORMAL_UP_OCT32P){const e=new Float32Array(3*i.POSITION.array.length),n=[],A=[],s=[];be(i.POSITION,(t,i)=>{u(s,t,o),ae(s,null,n),r(A,n);!function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8]}(e.subarray(9*i,9*(i+1)),A)}),i.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const s={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Ss(i.POSITION.array,3,o,Ts,s);const a=ds(s),B=f([],a),E=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];be(i.POSITION,t=>{t[0]=t[0]+o[0]-B[0],t[1]=t[1]+o[1]-B[1],t[2]=t[2]+o[2]-B[2],t[0]<E[0]&&(E[0]=t[0]),t[1]<E[1]&&(E[1]=t[1]),t[2]<E[2]&&(E[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])}),i.POSITION.min=E,i.POSITION.max=c,e&&P(a,a,e);const C=this.Vt(a);t.rtcCenter=B,t.rtcCoord=C,t.rootIdx=n;const l=t.transferables;return delete t.transferables,{content:t,transferables:l}}Ht(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const r=e[t].image&&e[t].image.array;if(r&&r.length){const n=r[0],A=r[1],i=r[2],o=r[3];let s=!0;for(let t=4;t<r.length;t+=4)if(r[t]!==n||r[t+1]!==A||r[t+2]!==i||r[t+3]!==o){s=!1;break}s&&(e[t].image.color=[n/255,A/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const r=this.Ot[t.url];if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t].abort();else r&&r.abort&&r.abort();delete this.Ot[t.url],e(null)}Jt(t,e,r,n){const o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let s=_s;"X"===(r=r&&r.toUpperCase())?s=Is:"Z"===r&&(s=Ts),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o),t.extensions.MAPTALKS_RTC={};const a={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};ye(t,t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=A(Ps);t.matrices&&Gs(e,t.matrices);const r=t.attributes.POSITION.array,B=t.attributes.POSITION.itemSize;i(e,s,e),n&&i(e,n,e),Ss(r,B,o||Fs,e,a,t.compressUniforms)});const B=ds(a);return{rtcCenter:o,modelCenter:B,upAxisTransform:s}}Kt(t,e,r,n){const{modelCenter:o,upAxisTransform:s,rtcCenter:a}=this.Jt(t,e,r),B=f([],o);n&&P(o,o,n),t.extensions.CESIUM_RTC.rtcCoord=this.Vt(o),a||(ye(t,t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const r=A(Ps);t.matrices&&Gs(r,t.matrices),i(r,s,r);const n=function(t,e){var r=e[0],n=e[1],A=e[2],i=e[3],o=e[4],s=e[5],a=e[6],B=e[7],E=e[8],c=e[9],C=e[10],f=e[11],l=e[12],u=e[13],_=e[14],I=e[15],D=r*s-n*o,h=r*a-A*o,R=r*B-i*o,T=n*a-A*s,F=n*B-i*s,P=A*B-i*a,O=E*u-c*l,L=E*_-C*l,y=E*I-f*l,M=c*_-C*u,N=c*I-f*u,S=C*I-f*_,d=D*S-h*N+R*M+T*y-F*L+P*O;return d?(d=1/d,t[0]=(s*S-a*N+B*M)*d,t[1]=(A*N-n*S-i*M)*d,t[2]=(u*P-_*F+I*T)*d,t[3]=(C*F-c*P-f*T)*d,t[4]=(a*y-o*S-B*L)*d,t[5]=(r*S-A*y+i*L)*d,t[6]=(_*R-l*P-I*h)*d,t[7]=(E*P-C*R+f*h)*d,t[8]=(o*N-s*y+B*O)*d,t[9]=(n*y-r*N-i*O)*d,t[10]=(l*F-u*R+I*D)*d,t[11]=(c*R-E*F-f*D)*d,t[12]=(s*L-o*M-a*O)*d,t[13]=(r*M-n*L+A*O)*d,t[14]=(u*h-l*T-_*D)*d,t[15]=(E*T-c*h+C*D)*d,t):null}(Os,r),o=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];be(e,t=>{P(t,t,r),t[0]=t[0]-B[0],t[1]=t[1]-B[1],t[2]=t[2]-B[2],P(t,t,n),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>a[0]&&(a[0]=t[0]),t[1]>a[1]&&(a[1]=t[1]),t[2]>a[2]&&(a[2]=t[2])}),e.min=o,e.max=a,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}}),t.extensions.CESIUM_RTC.center=B)}gt(t,e,r,n){const{modelCenter:A,rtcCenter:i}=this.Jt(t,e,r,n),o=this.Xt(A);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.CESIUM_RTC.rtcCoord=this.Vt(A),ye(t,e=>{if(e.attributes&&e.attributes.POSITION){e.attributes.NORMAL&&this.vt(e.attributes.NORMAL,e.matrices,r),e.attributes.TANGENT&&this.vt(e.attributes.TANGENT,e.matrices,r);const{newPositions:A}=this.Zt(e.attributes.POSITION,e.matrices,i,t.extensions.MAPTALKS_RTC,r,n,e.compressUniforms),{componentType:o}=e.attributes.POSITION;5126!==o&&(e.attributes.POSITION.array=new Float32Array(A))}});for(const e in t.nodes){t.nodes[e].matrix=Ts}}Xt(t){0===y(t)?l(Ls,0,0,-6378137):wt(Ls,t);const e=this.options.projection;jo(ys,Ls,e);const r=Ls[2],n=[];return n[0]=ys[0],n[1]=ys[1],n[2]=r,n}vt(t,e,A){let i;i="Y"===A?_s:"X"===A?Is:Ts;const o=n([],i);if(Gs(o,e),B(o,Ts))return;const s=r([],o),a=[];be(t,t=>(function(t,e,r){var n=e[0],A=e[1],i=e[2];t[0]=n*r[0]+A*r[3]+i*r[6],t[1]=n*r[1]+A*r[4]+i*r[7],t[2]=n*r[2]+A*r[5]+i*r[8]}(a,t,s),R(a,a),f(t,a),a))}Zt(t,e,r,n,i,o,s){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const a=A([]);Gs(a,e);const E=this.options.projection;i=i&&i.toUpperCase();const c=r;let C=null;"Y"===i?C=_s:"X"===i&&(C=Is);let f=[0,0,0,1];const _=[0,0,0],I=[0,0],D=n.projCenter,h=o&&B(Ts,o),R=t.min=t.min||[],T=t.max=t.max||[];l(R,1/0,1/0,1/0),l(T,-1/0,-1/0,-1/0);const F=s||{},{decode_position_min:O,decode_position_normConstant:L}=F;let M=[0,0,0,0],N=1;O&&(M=O),L&&(N=L);const S=[];return be(t,t=>{if(f[0]=t[0]*N+M[0],f[1]=t[1]*N+M[1],f[2]=t[2]*N+M[2],f=P(f,f,a),C&&(f=P(f,f,C)),c&&u(f,f,c),o&&!h&&(f=P(f,f,o)),0===y(f)?l(_,0,0,-6378137):wt(_,f),jo(I,_,E),t instanceof Float32Array)t[0]=I[0]-D[0],t[1]=I[1]-D[1],t[2]=_[2]-D[2];else{const e=I[0]-D[0],r=I[1]-D[1],n=_[2]-D[2];S.push(e),S.push(r),S.push(n),S.push(t[3])}return t[0]<R[0]&&(R[0]=t[0]),t[1]<R[1]&&(R[1]=t[1]),t[2]<R[2]&&(R[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2]),t}),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:D,newPositions:S}}Vt(t){return 0===y(t)?l([],0,0,-6378137):wt([],t)}onRemove(){}}const Ns=[];function Ss(t,e,r,n,A,i){const o=i||{},{decode_position_min:s,decode_position_normConstant:a}=o;let B=[0,0,0,0],E=1;s&&(B=s),a&&(E=a);for(let i=0,o=t.length;i<o;i+=e){const{xmin:o,ymin:s,xmax:a,ymax:c,hmin:C,hmax:f}=A;l(Ns,t[i]*E+B[0],t[i+1]*E+B[1],t[i+2]*E+B[2]),P(Ns,Ns,n);const _=u(Ns,r,Ns);_[0]<o&&(A.xmin=_[0]),_[0]>a&&(A.xmax=_[0]),_[1]<s&&(A.ymin=_[1]),_[1]>c&&(A.ymax=_[1]),e>2&&(_[2]<C&&(A.hmin=_[2]),_[2]>f&&(A.hmax=_[2]))}}function ds(t){const{xmax:e,ymax:r,xmin:n,ymin:A,hmin:i,hmax:o}=t,s=[(n+e)/2,(A+r)/2,(i+o)/2];return e===-1/0&&(s[0]=0),r===-1/0&&(s[1]=0),o===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Us(t,e){for(let r=0;r<e.length;r++)t.indexOf(e[r])<0&&t.push(e[r])}function Gs(t,e){const r=t;for(let t=e.length-1;t>=0;t--)i(r,e[t],r);return r}let ms=0;class bs{constructor(t){this.workerId=t,this.workers={},this.xt={}}addLayer({actorId:t,mapId:e,layerId:r,params:n},A){if(this.kt(e,r))return;const i=this.Wt(e,r),o=n.options,s=this.send.bind(this,t);this.workers[i]=new Ms(r,o,s,A)}removeLayer({mapId:t,layerId:e},r){const n=this.kt(t,e),A=this.Wt(t,e);delete this.workers[A],n&&n.onRemove(r)}loadTile({mapId:t,layerId:e,params:r},n){const A=this.kt(t,e);A&&A.loadTile(r,n)}abortTileLoading({mapId:t,layerId:e,params:r},n){const A=this.kt(t,e);A&&A.abortTileLoading(r,n)}receive(t){const e=t.callback,r=this.xt[e];delete this.xt[e],r&&t.error?r(new Error(t.error)):r&&r(null,t.data)}send(t,e,r,n,A){const i=A?`${t}-${ms++}`:null;A&&(this.xt[i]=A),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:r,callback:String(i)},n||[])}Wt(t,e){return`${t}-${e}`}kt(t,e){const r=this.Wt(t,e);return this.workers[r]}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;this.dispatcher||(this.dispatcher=new bs(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[r.command]({actorId:r.actorId,mapId:r.mapId,layerId:r.layerId,params:r.params},(t,r,n)=>{t instanceof Error&&(t={message:t.message}),e(t,r,n)})},Object.defineProperty(t,"Qt",{value:!0})}';for(
6
+ import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as n,mat4 as r,HighlightUtil as s,vec3 as i,mat3 as o,vec4 as a,quat as c,MaskRendererMixin as h,createREGL as u,MaskLayerMixin as f}from"@maptalks/gl";const l='function(t){var e="undefined"!=typeof Float32Array?Float32Array:Array;function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function r(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function s(t,e,n){var r=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=e[8],h=e[9],y=e[10],m=e[11],d=e[12],p=e[13],b=e[14],w=e[15],g=n[0],T=n[1],A=n[2],_=n[3];return t[0]=g*r+T*a+A*l+_*d,t[1]=g*s+T*c+A*h+_*p,t[2]=g*o+T*u+A*y+_*b,t[3]=g*i+T*f+A*m+_*w,g=n[4],T=n[5],A=n[6],_=n[7],t[4]=g*r+T*a+A*l+_*d,t[5]=g*s+T*c+A*h+_*p,t[6]=g*o+T*u+A*y+_*b,t[7]=g*i+T*f+A*m+_*w,g=n[8],T=n[9],A=n[10],_=n[11],t[8]=g*r+T*a+A*l+_*d,t[9]=g*s+T*c+A*h+_*p,t[10]=g*o+T*u+A*y+_*b,t[11]=g*i+T*f+A*m+_*w,g=n[12],T=n[13],A=n[14],_=n[15],t[12]=g*r+T*a+A*l+_*d,t[13]=g*s+T*c+A*h+_*p,t[14]=g*o+T*u+A*y+_*b,t[15]=g*i+T*f+A*m+_*w,t}function o(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function i(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function a(t,e){var n=e[0],r=e[1],s=e[2],o=e[3],i=n+n,a=r+r,c=s+s,u=n*i,f=r*i,l=r*a,h=s*i,y=s*a,m=s*c,d=o*i,p=o*a,b=o*c;return t[0]=1-l-m,t[1]=f+b,t[2]=h-p,t[3]=0,t[4]=f-b,t[5]=1-u-m,t[6]=y+d,t[7]=0,t[8]=h+p,t[9]=y-d,t[10]=1-u-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function c(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function u(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function f(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function l(t,n,r){var s=new e(3);return s[0]=t,s[1]=n,s[2]=r,s}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function y(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function m(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function d(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function p(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function b(t,e){var n=e[0],r=e[1],s=e[2],o=n*n+r*r+s*s;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function w(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function g(t,e,n){var r=e[0],s=e[1],o=e[2],i=n[0],a=n[1],c=n[2];return t[0]=s*c-o*a,t[1]=o*i-r*c,t[2]=r*a-s*i,t}function T(t,e,n){var r=e[0],s=e[1],o=e[2],i=n[3]*r+n[7]*s+n[11]*o+n[15];return i=i||1,t[0]=(n[0]*r+n[4]*s+n[8]*o+n[12])/i,t[1]=(n[1]*r+n[5]*s+n[9]*o+n[13])/i,t[2]=(n[2]*r+n[6]*s+n[10]*o+n[14])/i,t}var A=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},_=d,S=f;function x(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function M(t,e,n){var r=e[0],s=e[1],o=e[2],i=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*o+n[12]*i,t[1]=n[1]*r+n[5]*s+n[9]*o+n[13]*i,t[2]=n[2]*r+n[6]*s+n[10]*o+n[14]*i,t[3]=n[3]*r+n[7]*s+n[11]*o+n[15]*i,t}function O(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function v(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function I(t,e,n,r){var s=e[0],o=e[1],i=e[2],a=e[3],c=n[0],u=n[1],f=n[2],l=n[3],h=void 0,y=void 0,m=void 0,d=void 0,p=void 0;return(y=s*c+o*u+i*f+a*l)<0&&(y=-y,c=-c,u=-u,f=-f,l=-l),1-y>1e-6?(h=Math.acos(y),m=Math.sin(h),d=Math.sin((1-r)*h)/m,p=Math.sin(r*h)/m):(d=1-r,p=r),t[0]=d*s+p*c,t[1]=d*o+p*u,t[2]=d*i+p*f,t[3]=d*a+p*l,t}u(),function(){var t,n=(t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var U,C=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};u(),l(1,0,0),l(0,1,0),O(),O(),U=new e(9),e!=Float32Array&&(U[1]=0,U[2]=0,U[3]=0,U[5]=0,U[6]=0,U[7]=0),U[0]=1,U[4]=1,U[8]=1;\n/*!\n * @maptalks/gltf-loader v0.84.0\n * LICENSE : UNLICENSED\n * (c) 2016-2023 maptalks.org\n */\nlet E=0;function P(t){return null==t}function B(t){return!P(t)}function N(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function F(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function D(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function R(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const L=[],z=[],V=[],k=[0,0,0],j=v([]),q=[1,1,1];function G(t,e,n,r,s,o,i){const a=F(i);if((0===s||s===r*a.BYTES_PER_ELEMENT)&&o%a.BYTES_PER_ELEMENT==0){const s=new a(e,o,n*r);return t.set(s),t}0===s&&(s=r*a.BYTES_PER_ELEMENT);const c=new Uint8Array(r*a.BYTES_PER_ELEMENT);for(let i=0;i<n;i++){let n=null;const u=new Uint8Array(e,s*i+o,r*a.BYTES_PER_ELEMENT);c.set(u),n=new a(c.buffer,0,r);for(let e=0;e<r;e++)t[i*r+e]=n[e]}return t}const $="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function H(t,e,n){const r=new Uint8Array(t,e,n);return $.decode(r)}const X={get:function(t,e={}){e||(e={});const n=new AbortController,r=n.signal,s=N({},e);s.signal=r,s.method||(s.method="GET");const o=fetch(t,s).then(t=>{const n=this.t(t,e.responseType);return n.message?n:n.then(n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t})}).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t});return o.xhr=n,o},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",X.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?X.jsonp(t):((e=e||{}).responseType="json",X.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+E++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise(t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)})}};class J{constructor(t,e,n){this.s=t,this.decoders=e,this.o=n,this.images={},this.i={}}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.u(e,r);return this.getImageByBuffer(s,n)}if(this.i[t.id])return this.i[t.id].then(()=>{const r=this.buffers[t.id],s=this.u(e,r);return this.getImageByBuffer(s,n)});if(D(t.uri)){const r=this.buffers[t.id]=R(t.uri),s=this.u(e,r);return this.getImageByBuffer(s,n)}return this.i[t.id]=X.getArrayBuffer(t.uri,null).then(r=>{const s=this.buffers[t.id]=r.data,o=this.u(e,s);return this.getImageByBuffer(o,n)})}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;if(n[e.mimeType])return n[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const n=new Blob([t],{type:e.mimeType}),r=URL.createObjectURL(n);return this.l(e.id,r)}}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.i[t.id]?this.i[t.id].then(()=>this.images[t.id]):this.i[t.id]=this.l(t.id,e)}l(t,e){return new Promise((n,r)=>{this.s(e,(s,o)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=o,n(this.images[t]))})})}}const K=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],Y=[];class Q{constructor(t,e,n){this.rootPath=t,this.gltf=e,this.h=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.m()}p(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.g(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this.T(s).then(n=>{const{buffer:s,byteOffset:o}=n;return this.accessors[r.id]=this.g(t,e,s,o)})}T(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then(()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})});if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(D(e.uri)){const t=this.buffers[e.id]=R(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=X.getArrayBuffer(t,null).then(r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}g(t,e,n,r=0){const s=this.gltf,o=s.accessors[e],i=void 0!==o.bufferView?s.bufferViews[o.bufferView]:{},a=(i.byteOffset||0)+r,c=this.A(o.type),u=F(o.componentType),f=i.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:o.count*c*u.BYTES_PER_ELEMENT,componentType:o.componentType,count:o.count,type:o.type,itemSize:c,max:o.max,min:o.min,extensions:o.extensions};if(o.min&&(l.min=o.min),o.max&&(l.max=o.max),n)if(this.h)l.byteStride=f,l.byteOffset=a+(o.byteOffset||0),!f||f===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this._(n,o.count,c,a+(o.byteOffset||0),u),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(n,a,i.byteLength);else if(o.interleaved){l.byteStride=0,l.byteOffset=0;const t=new u(o.count*c);if(l.array=G(t,n,o.count,c,f,a+(o.byteOffset||0),o.componentType),l.extensions&&l.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(l.array.length),{decodeMatrix:e}=l.extensions.WEB3D_quantized_attributes;for(let n=0;n<l.array.length;n+=c){Y[0]=l.array[n],Y[1]=l.array[n+1],Y[2]=l.array[n+2],Y[3]=1;const r=M(Y,Y,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}l.componentType=5126,l.array=t}}else l.byteStride=0,l.array=this._(n,o.count,c,a+(o.byteOffset||0),u),l.byteOffset=l.array.byteOffset;else{l.array=new u(o.count);const t=l.min||l.max;t&&(l.array[0]=t[0],l.array[1]=t[1],l.array[2]=t[2])}return l}m(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}_(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}A(t){const e=K.indexOf(t);return K[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map(t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.T(e).then(r=>{const{buffer:s,byteOffset:o}=r,i=H(s,o+(e.byteOffset||0),n);return t.content=i,t})}if(t.uri){if(D(t.uri)){const e=R(t.uri),n=H(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return X.get(e).then(e=>(t.content=e,t))}}return Promise.resolve(t)});return Promise.all(n).then(()=>t)}}class W extends J{constructor(t,e,n,r,s,o){super(r,s,o),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new Q(t,e,n)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(B(t.name)&&(e.name=t.name),B(t.children)&&(e.children=t.children),B(t.jointName)&&(e.jointName=t.jointName),B(t.matrix)&&(e.matrix=t.matrix),B(t.rotation)&&(e.rotation=t.rotation),B(t.scale)&&(e.scale=t.scale),B(t.translation)&&(e.translation=t.translation),B(t.extras)&&(e.extras=t.extras),B(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const n=o(L,e.translation||k),r=a(z,e.rotation||j),c=i(V,e.scale||q);return s(c,r,c),s(t,n,c)}return r(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}S(t){const e={};for(const n in t){const r=t[n];let s,o;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,o=s.values.diffuse):(s=r,o=s.values.tex||s.values.diffuseTex||s.values.diffuse);const i={baseColorTexture:{index:o}};r.name&&(i.name=r.name),r.extensions&&(i.extensions=r.extensions),r.extras&&(i.extras=r.extras),e[n]=i}return e}M(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,o=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(o,t)}return this.requestExternalImage(t)}O(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.M(n).then(t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}})}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const o=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:o,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}class Z extends J{constructor(t,e,n,r,s,o){super(r,s,o),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new Q(t,e,n)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return N(e,t),!B(t.weights)&&this.gltf.meshes&&B(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}O(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!B(n))return null;const r=this.gltf.images[n];return this.M(r).then(t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};N(n,e);const s=B(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||9729,n.sampler.minFilter=s.minFilter||9729,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),t.format&&(n.format=t.format),n})}M(t){if(!B(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.v(e,t)}return null}v(t,e){const n=this.u(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}u(t,e,n){n=n||0;const r=t.byteOffset+n,s=t.byteLength;return new Uint8Array(e,r,s)}I(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);return n.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)))}getAnimations(t){const e=[];return t.forEach(t=>{e.push(this.getSamplers(t.samplers))}),Promise.all(e).then(e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t})}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(B(t[n].input)||B(t[n].output))&&(e.push(this.accessor.p("input",t[n].input)),e.push(this.accessor.p("output",t[n].output)));return Promise.all(e).then(e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t})}}const tt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class et{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return et.readV1(r,e);if(2===s)return et.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const s=nt(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const o=new DataView(t,e+12);let i=0;for(;i<o.byteLength;){const a=o.getUint32(i,!0);i+=4;const c=o.getUint32(i,!0);if(i+=4,1313821514===c)n=nt(t,e+12+i,a);else if(5130562===c){s=e+12+i,r=a;break}i+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function nt(t,e,n){if(tt){const r=new Uint8Array(t,e,n);return tt.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=rt[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const rt=[1,1,1,1,2,2,3,0],st=[0,0,0],ot=[0,0,0,1],it=[1,1,1],at={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},ct={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ut={U(t,e,n,r,s,o,i,a){const c=B(t)?e.animations:[e.animations[0]],u={};for(let e=0;e<c.length;e++){const f=c[e],l=f.name||e;if(B(t)&&l!==t)continue;const y=f.channelsMap[n];if(y)for(let t=0;t<y.length;t++){const e=y[t];"translation"===e.target.path?(this.C(s,f.samplers[e.sampler],r,1),u.translation=h(st,s)):"rotation"===e.target.path?(this.P(o,f.samplers[e.sampler],r,1),u.rotation=C(ot,o)):"scale"===e.target.path?(this.C(i,f.samplers[e.sampler],r,1),u.scale=h(it,i)):"weights"===e.target.path&&a&&(this.C(a,f.samplers[e.sampler],r,a.length),u.weights=a)}}return u},C(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.B(ct,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.B(ct,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.B(ct,e,n,3*r);s&&(t=this.N(t,s,e.input.array,3*r));break}}return t},P(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.B(ct,e,n,1);r&&I(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.B(ct,e,n,1);r&&(t=x(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.B(ct,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.N(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},F(t,e){const n=t.length;let r,s,o,i=0,a=n-1,c=Math.floor((i+a)/2);for(;i<=n-1&&a>=0;){if(i===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,o=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:o}}e<t[c]?(a=c,c=Math.floor((i+a)/2)):t[c+1]<e&&(i=c,c=Math.floor((i+a)/2))}return null},B(t,e,n,r){const s=e.input.array,o=e.output.array,i=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.F(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=f;const l=i*r;return t.PREVIOUS=o.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=o.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},N(t,e,n,r){const s=e.INTERPOLATION,o=n[e.PREINDEX],i=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(i-o)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(i-o)*e.NEXT[n],l=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*u+(Math.pow(s,3)-Math.pow(s,2))*f;t[n]=l}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return y(st,...at.TRANSLATION),x(ot,...at.ROTATION),y(it,...at.SCALE),this.U(r,t,e,n,st,ot,it,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach((e,n)=>{let r=-1/0,s=1/0;const o=e.channels;for(let t=0;t<o.length;t++){const n=o[t],i=e.samplers[n.sampler].input.array;i[i.length-1]>r&&(r=i[i.length-1]),i[0]<s&&(s=i[0])}const i=e.name||n;t.timeSpan[i]={max:r,min:s}}),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?B(e)?n[e]:n[Object.keys(n)[0]]:null}};let ft=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(oe){}t&&"undefined"!=typeof createImageBitmap&&(ft=!0)}const lt="undefined"==typeof document?null:document.createElement("canvas");class ht{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=et.read(e.buffer,e.byteOffset,e.byteLength);this.D(t,n,r)}else this.D(t,e);this.R=new Q(this.rootPath,this.gltf,this.glbBuffer),this.L()}L(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}V(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.R.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then(e=>(t.KHR_techniques_webgl=e,t)):Promise.resolve(t)}load(t){t=t||{};const e=this.k(t),n=this.j(),r=this.q(),s=this.V();return Promise.all([e,n,r,s]).then(t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0]))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return ut.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return ut.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return F(t)}static readInterleavedArray(t,e,n,r,s,o,i){return G(t,e,n,r,s,o,i)}D(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=ft?pt.bind(this):this.options.requestImage||yt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Z(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate((t,e,n)=>{e.id="buffer_"+n},"buffers"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors")):(this.adapter=new W(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"))}G(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||function(t){return!P(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const r=t.children.map(t=>{const n=e[t];return n.nodeIndex=t,this.G(n,e)});t.children=r}var n;return t}k(t){return this.$(t).then(t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.G(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate((r,s,o)=>{const i={};s.name&&(i.name=s.name),s.nodes&&(i.nodes=s.nodes.map(e=>t[e])),this.gltf.scene===r&&(n=o),e.push(i)},"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.S(this.gltf.materials);r.materials=t}return r})}$(t){return this.H(t).then(()=>{const t=this.nodes={};return this.adapter.iterate((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r},"nodes"),t})}X(){this.skins=[];const t=[];return this.adapter.iterate((e,n,r)=>{t.push(this.J(n).then(t=>{t.index=r,this.skins.push(t)}))},"skins"),t}J(t){const e=t.inverseBindMatrices;return this.adapter.accessor.p("inverseBindMatrices",e).then(e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t))}j(){const t=this.gltf.animations;return B(t)?this.adapter.getAnimations(t):null}H(t){this.meshes={};let e=[];return this.adapter.iterate((n,r,s)=>{e.push(this.K(r,t).then(t=>{t.index=s,this.meshes[n]=t}))},"meshes"),e=e.concat(this.X()),Promise.all(e)}K(t,e){const n=t.primitives.map(t=>this.Y(t,e)).filter(t=>!!t);return Promise.all(n).then(e=>{const n={};return N(n,t),n.primitives=e,n})}q(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.O(n));return Promise.all(e).then(e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t].image.array;if(e[t]&&n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e})}Y(t,e){let n;const r=[],s=t.extensions;if(B(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.p(`morphTargets_${t}_${e}`,n[t]);s&&r.push(s)}}if(s&&s.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:o,attributes:i}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[o],c=this.R.T(a).then(n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:o}=a;const c=a.byteLength;o||(o=0);const u=new DataView(r,s+o,c),f={attributes:i,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,f).then(t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e})});r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.p(t,e[t]);n&&r.push(n)}if(B(t.indices)){const e=this.adapter.accessor.p("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then(e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const o={attributes:e.reduce((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,o=s.length/r;for(let e=0;e<o;e++)for(let o=0;o<r;o++){const i=e*r+o;s[i]<t[o]&&(t[o]=s[i]),s[i]>n[o]&&(n[o]=s[i])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),o=r.minValues;p(t,t,s),m(t,t,o),p(n,n,s),m(n,n,o)}e.min=t,e.max=n}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t},{}),material:t.material};return n&&(o.indices=n),r&&(o.morphTargets=r),o.mode=B(t.mode)?t.mode:4,B(t.extras)&&(o.extras=t.extras),o})}}function yt(t,e){const n=new Image;n.crossOrigin="",n.onload=()=>{if(!lt)return void e(new Error("There is no canvas to draw image!"));lt.width=n.width,lt.height=n.height;const t=lt.getContext("2d",{willReadFrequently:!0});t.drawImage(n,0,0,n.width,n.height);const r=t.getImageData(0,0,n.width,n.height),s={width:n.width,height:n.height,data:new Uint8Array(r.data)};e(null,s)},n.onerror=function(t){e(t)},n.src=t}let mt,dt;function pt(t,e){mt||(mt=new OffscreenCanvas(2,2),dt=mt.getContext("2d",{willReadFrequently:!0})),fetch(t).then(t=>t.arrayBuffer()).then(t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(t=>{let{width:n,height:r}=t;bt(n)||(n=wt(n)),bt(r)||(r=wt(r));const s=this.options.maxTextureSize;s&&(n=Math.min(s,n),r=Math.min(s,r)),mt.width=n,mt.height=r,dt.drawImage(t,0,0,n,r),t.close();const o=dt.getImageData(0,0,n,r);e(null,{width:n,height:r,data:new Uint8Array(o.data)})}).catch(t=>{console.warn(t),e(t)})}function bt(t){return 0==(t&t-1)&&0!==t}function wt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function gt(t){return"object"==typeof t&&!!t}function Tt(t){return t/Math.PI*180}function At(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const _t=[1,1,1,1,2,2,3,0];function St(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=_t[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}new Array(3),new Array(3);const xt=[1/6378137,1/6378137,1/6356752.314245179],Mt=[1/40680631590769,1/40680631590769,1/40408299984661.445],Ot=new Array(3),vt=new Array(3),It=new Array(3);function Ut(t,e){const n=Mt,r=function(t,e,n,r,s){const o=e[0],i=e[1],a=e[2],c=n[0],u=n[1],f=n[2],l=o*o*c*c,h=i*i*u*u,y=a*a*f*f,m=l+h+y,d=Math.sqrt(1/m),b=p(Ct,e,d);if(m<s)return isFinite(d)?b:void 0;const w=r[0],g=r[1],T=r[2],A=Et;A[0]=b[0]*w*2,A[1]=b[1]*g*2,A[2]=b[2]*T*2;let _,S,x,M,O,v,I,U,C,E,P,B=(1-d)*Pt(e)/(.5*Pt(A)),N=0;do{B-=N,x=1/(1+B*w),M=1/(1+B*g),O=1/(1+B*T),v=x*x,I=M*M,U=O*O,C=v*x,E=I*M,P=U*O,_=l*v+h*I+y*U-1,S=l*C*w+h*E*g+y*P*T;N=_/(-2*S)}while(Math.abs(_)>1e-12);return t[0]=o*x,t[1]=i*M,t[2]=a*O,t}(Ot,e,xt,n,.1);let s=_(vt,r,n);s=function(t,e){const n=e[0],r=e[1],s=e[2];let o=n*n+r*r+s*s;o>0&&(o=Math.sqrt(o),t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o);return t}(s,s);const o=A(It,e,r),i=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=At(w(o,e))*Pt(o);return t[0]=Tt(i),t[1]=Tt(a),t[2]=c,t}const Ct=new Array(3),Et=new Array(3);function Pt(t){return f(t)}function Bt(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function Nt(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Ft="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Dt(t,e,n){const r=new Uint8Array(t,e,n);return Ft?JSON.parse(Ft.decode(r)):JSON.parse(St(r))}function Rt(t,e,n){const r=new Uint8Array(t,e,n);return Ft?JSON.parse(Ft.decode(r)):JSON.parse(St(r))}function Lt(t,e,n){return{offset:e,byteLength:n}}function zt(t,e,n,r){const{byteOffset:s,componentType:o,type:i}=t,{ctor:a,type:c}=function(t){return jt[t]}(o||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return kt[t]}(i);return{byteStride:0,byteOffset:s+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+s,r*u)}}function Vt(t,e,n,r){const s=zt(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}const kt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const jt={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function qt(t){for(const e in jt)if(t===jt[e].ctor)return jt[e].type;throw new Error("unrecognized ctor:"+t)}function Gt(t,e,n,r){const s=t,o=e.length/3;for(let t=0;t<o;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function $t(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),i=t.getUint32(24,!0),a=t.buffer;let c,u={},f={},l=null;r>0&&(u=Dt(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),o>0&&(f=Rt(a,e,o),e+=o);const h=Lt(0,e,i);return l=a.slice(h.offset,h.offset+h.byteLength),n.push(l),{featureTable:u,featureTableBin:c,batchTable:f,batchTableBin:l}}const Ht={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"}},Xt={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Jt={},Kt={east:[],north:[],up:[],west:[],south:[],down:[]};let Yt=[],Qt=[],Wt=[];const Zt=[0,0,0];const te=function(t,e){const n=Ht[t][e];let r;const s=t+e;return Jt[s]?r=Jt[s]:(r=function(r,s,o){if(function(t,e){var n=t[0],r=t[1],s=t[2],o=e[0],i=e[1],a=e[2];return Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-i)<=1e-6*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}(r,Zt))h(Yt,Xt[t]),h(Qt,Xt[e]),h(Wt,Xt[n]);else if(Bt(r[0],0,1e-14)&&Bt(r[1],0,1e-14)){const s=At(r[2]);h(Yt,Xt[t]),"east"!==t&&"west"!==t&&p(Yt,Yt,s),h(Qt,Xt[e]),"east"!==e&&"west"!==e&&p(Qt,Qt,s),h(Wt,Xt[n]),"east"!==n&&"west"!==n&&p(Wt,Wt,s)}else{!function(t,e){d(e,t,Mt),b(e,e)}(r,Kt.up);const s=Kt.up,o=Kt.east;o[0]=-r[1],o[1]=r[0],o[2]=0,b(Kt.east,o),g(Kt.north,s,o),p(Kt.down,Kt.up,-1),p(Kt.west,Kt.east,-1),p(Kt.south,Kt.north,-1),Yt=Kt[t],Qt=Kt[e],Wt=Kt[n]}return o[0]=Yt[0],o[1]=Yt[1],o[2]=Yt[2],o[3]=0,o[4]=Qt[0],o[5]=Qt[1],o[6]=Qt[2],o[7]=0,o[8]=Wt[0],o[9]=Wt[1],o[10]=Wt[2],o[11]=0,o[12]=r[0],o[13]=r[1],o[14]=r[2],o[15]=1,o},Jt[s]=r),r}("east","north"),ee={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function ne(t){for(const e in ee)if(t===ee[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n * @maptalks/gl v0.84.0\n * LICENSE : UNLICENSED\n * (c) 2016-2023 maptalks.com\n */const re=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},se=re(),oe=se.gl_trans__coders=se.gl_trans__coders||{};oe.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=se.gl_trans__coders=se.gl_trans__coders||{};let o=`${r}\\n const _____getGlobal = ${re.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals[\'gl_trans__coders\'] = g___lobals[\'gl_trans__coders\'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(o+=\'tran_____scoders["\'+t+\'"] =\'+s[t].toString()+"\\n;");return o+="\\n"+e.substring(r.length),o},oe.registerTranscoder=function(t,e){oe[t]=e},oe.getTranscoder=function(t){return oe[t]};let ie=null;function ae(){return ie||(ie={"image/crn":oe.crn&&oe.crn(),"image/ktx2":oe.ktx2&&oe.ktx2(),"image/cttf":oe.ktx2&&oe.ktx2(),"draco":oe.draco&&oe.draco()}),ie}class ce{constructor(t,e,n){this.s=t,this.W=e||ht,this.o=n,this.Z=ae()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.tt(t,e,n,r,s)):X.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.tt(t,s,n,r)})}tt(t,e,n,r,s){const o=s&&s.maxTextureSize,i=this.et(e,n,r,t);if(i.error)return Promise.resolve(i);const a=t.substring(0,t.lastIndexOf("/")),c=new this.W(a,i.glb,{transferable:!0,requestImage:this.s,decoders:this.Z,supportedFormats:this.o,maxTextureSize:o});return c.load({skipAttributeTransform:!1}).then(e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<i.transferables.length;t++)s.indexOf(i.transferables[t])<0&&s.push(i.transferables[t]);return{magic:"b3dm",count:i.count,transferables:s,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,gltf:e}})}et(t,e,n,r){const s=new DataView(t,e,n),o=s.getUint32(4,!0);if(1!==o){const t="Unsupported b3dm version: "+o+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm\'s byte length, url: "+r;return console.warn(t),{error:t}}let i,a=s.getUint32(12,!0),c=s.getUint32(16,!0),u=s.getUint32(20,!0),f=s.getUint32(24,!0),l=28+e;u>=570425344?(l-=8,i=a,u=c,f=0,a=0,c=0):f>=570425344&&(l-=4,i=u,u=a,f=c,a=0,c=0);const h=[t];let y,m,d;if(a>0?(y=Dt(t,l,a),l+=a,i=y.BATCH_LENGTH):y={"BATCH_LENGTH":i},c>0&&(l+=c),u>0&&(m=Rt(t,l,u),l+=u,f>0)){const e=Lt(0,l,f);d=t.slice(e.offset,e.offset+e.byteLength),l+=f,h.push(d)}const p=y.BATCH_LENGTH,b={};if(y&&y.BATCH_ID){b.BATCH_ID=Vt(y.BATCH_ID,t,(void 0).offset,p);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:i,transferables:h,featureTable:y,batchTable:m,batchTableBin:d,b3dm:b,glb:{buffer:t,byteOffset:l,byteLength:s.byteLength+s.byteOffset-l}}}nt(){return null}}class ue{constructor(t,e,n,r){this.s=t,this.W=e||ht,this.o=n,this.Z=ae(),this.rt=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.tt(t,e,n,r,s)):X.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.tt(t,s,n,r)})}tt(t,e,n,r,s){return this.st(t,e,n,r,s).then(({gltf:s,transferables:o})=>{const i=this.ot(e,n,r,t);if(i.error)return Promise.resolve(i);for(let t=0;t<o.length;t++)-1===i.transferables.indexOf(o[t])&&i.transferables.push(o[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:i.count,transferables:i.transferables,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,i3dm:i.i3dm,gltf:s})})}st(t,e,n,r,s){const o=s&&s.maxTextureSize,i={transferable:!0,requestImage:this.s,decoders:this.Z,supportedFormats:this.o,maxTextureSize:o},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=St(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?X.getArrayBuffer(r,{}).then(t=>this.it(r,{buffer:t.data,byteOffset:0},i)):X.getJSON(r,{}).then(t=>this.it(r,t,i))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.it(t,r,i)}}it(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.W(r,e,n);return s.load({skipAttributeTransform:!0}).then(n=>{let r=0,o=0;return e.buffer&&(r=e.byteOffset||0,o=e.byteLength||0),n.url=`${t}-${r}-${o}`,{transferables:s.transferables,gltf:n}})}ot(t,e,n,r){const s=new DataView(t,e,n),o=s.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=$t(s,32+e,i),l={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ct(new Uint16Array(t,r+c.offset,3*h),e,n)},i.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Vt(a.BATCH_ID,t,c.offset,h);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ut(new Uint16Array(t,e+c.offset,2*h))},i.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ut(new Uint16Array(t,e+c.offset,2*h))},i.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},i.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:f,featureTable:a,i3dm:l,transferables:i}}ut(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)fe(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}ct(t,e,n){return Gt(new Float32Array(t.length),t,e,n)}nt(){return null}}function fe(t,e,n,r){if(t[0]=le(e,r),t[1]=le(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*he(e),t[1]=(1-Math.abs(e))*he(t[1])}return b(t,t)}function le(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function he(t){return t<0?-1:1}class ye{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.tt(t,e,n,r)):X.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.tt(t,s,n,r)})}tt(t,e,n,r){return this.ft(e,n,r,t).then(t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts})}ft(t,e,n,r){const s=new DataView(t,e,n),o=s.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=$t(s,e+28,i),l=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,y=a.POINTS_LENGTH;let m,d={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){d=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,d.byteOffset+c.offset,d.byteLength);const e={attributes:d.properties,useUniqueIDs:!1};return this.lt||(this.lt=ae().draco),this.lt(m,e).then(e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.ht(t,e.attributes,c.offset,y,i,l,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:qt(t.constructor),array:t},i.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Vt(a.BATCH_ID,t,c.offset,y):r.BATCH_ID=me(y);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return{count:y,batchTable:u,batchTableBin:f,featureTable:a,pnts:r,transferables:i}})}const p=this.ht(t,a,c.offset,y,i,l,h);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?p.BATCH_ID=Vt(a.BATCH_ID,t,c.offset,y):p.BATCH_ID=me(y);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:f,featureTable:a,pnts:p,transferables:i})}ht(t,e,n,r,s,o,i){const a={};if(e.POSITION){let{byteOffset:o,array:i}=e.POSITION;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},s.push(i.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const f=u?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.ct(u||new Uint16Array(t,c+f,3*r),o,i)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:o,array:i}=e.RGBA;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+4*r);i=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:i},s.push(i.buffer)}else if(e.RGB){let{byteOffset:o,array:i}=e.RGB;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r);i=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:i},s.push(i.buffer)}else if(e.RGB565){let{byteOffset:o,array:i}=e.RGB565;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:i},s.push(i.buffer)}if(e.NORMAL){let{byteOffset:o,array:i}=e.NORMAL;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},s.push(i.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:o,array:i}=e.NORMAL_OCT16P;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:i},s.push(i.buffer)}return a}ct(t,e,n){return Gt(new Float32Array(t.length),t,e,n)}nt(){return null}}function me(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:qt(e),array:r}}class de{constructor(t,e,n,r){this.o=n,this.s=t,this.W=e||ht,this.rt=r}load(t,e,n=0,r=0,s){return e?this.tt(t,e,n,r,s):X.getArrayBuffer(t,{}).then(e=>{const s=e.data;return this.tt(t,s,n,r)})}tt(t,e,n,r,s){r||(r=e.byteLength);const o=this.yt(e,t,n,r),i=[];for(let n=0;n<o.length;n++){let r;if("b3dm"===o[n].magic)r=new ce(this.s,this.W,this.o);else if("i3dm"===o[n].magic)r=new ue(this.s,this.W,this.o,this.rt);else if("pnts"===o[n].magic)r=new ye;else{if("cmpt"!==o[n].magic){console.warn("Unsupported magic in CMPT tile:",o[n].magic);continue}r=new de(this.s,this.W,this.o,this.rt)}i.push(r.load(t,e,o[n].offset,o[n].byteLength,s).then(t=>t))}return Promise.all(i).then(t=>({magic:"cmpt",tiles:t}))}yt(t,e,n,r){const s=new DataView(t,n,r),o=s.getUint32(4,!0);if(1!==o){const t="Unsupported cmpt version: "+o+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const i=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Nt(s,c),r=s.getUint32(c+8,!0);i.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return i}}function pe(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];Se(r[n],s,t,e)}}}const be=[],we=[],ge=[],Te=[0,0,0],Ae=v([]),_e=[1,1,1];function Se(t,e,n,r){const c=e.slice(0);if(t.matrix)c.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=o(be,t.translation||Te),n=a(we,t.rotation||Ae),r=i(ge,t.scale||_e);s(r,n,r);const u=s([],e,r);c.push(u)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)Se(t.children[e],c,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=c.slice(0),o=s.primitives;for(let s=0,i=o.length;s<i;s++){const i=o[s];i&&(i.matrices=t,r(i,e,s,n))}}}}function xe(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:o,itemSize:i}=t,a=t.array.buffer,c=o?ht.getTypedArrayCtor(o):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/i,(!r||r===i*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*i);for(let r=0;r<s*i;r+=i){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,i),r/i)}return}const u=new Uint8Array(i*c.BYTES_PER_ELEMENT);r||(r=i*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,i*c.BYTES_PER_ELEMENT);u.set(s);e(new c(u.buffer),t),s.set(u)}}var Me=Ce("DXT1"),Oe=Ce("DXT3"),ve=Ce("DXT5"),Ie=Ce("DX10"),Ue=function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var s=r[21];switch(s){case Me:e=8,n="dxt1";break;case Oe:e=16,n="dxt3";break;case ve:e=16,n="dxt5";break;case 116:n="rgba32f";break;case Ie:var o=new Uint32Array(t.slice(128,148));n=o[0];var i=o[1];if(o[2],o[3],o[4],3!==i||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=s,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var f=!1;512&r[28]&&(f=!0);var l,h=r[4],y=r[3],m=r[1]+4,d=h,p=y,b=[];s===Ie&&(m+=20);if(f)for(var w=0;w<6;w++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=d,y=p;for(var g=Math.log(h)/Math.log(2)+1,T=0;T<g;T++)l=h*y*16,b.push({offset:m,length:l,shape:[h,y]}),T<u&&(m+=l),h=Math.floor(h/2),y=Math.floor(y/2)}else for(T=0;T<u;T++)l=Math.max(4,h)/4*Math.max(4,y)/4*e,b.push({offset:m,length:l,shape:[h,y]}),m+=l,h=Math.floor(h/2),y=Math.floor(y/2);return{shape:[d,p],images:b,format:n,flags:c,cubemap:f}};function Ce(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}const Ee=Math.PI/180,Pe=6378137*Math.PI/180;function Be(t,e,n){if("EPSG:3857"===n)return function(t,e){const n=85.0511287798,r=e[0],s=Math.max(Math.min(n,e[1]),-n);let o;o=0===s?0:Math.log(Math.tan((90+s)*Ee/2))/Ee;return t[0]=r*Pe,t[1]=o*Pe,t}(t,e);if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return Ne(t,e);if("baidu"===n)return Ne(t,e);throw new Error("unsupported projection:"+n)}function Ne(t,e){return t[0]=e[0],t[1]=e[1],t}const Fe=r([]),De=ae().draco,Re=ae().ktx2,Le={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},ze={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Ve(t,e,n,s){const o=[],i=[],a=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],s=X.getArrayBuffer(n.url);s.xhr.url=n.url,a.push(s.xhr);const c=s.then(t=>({buffer:t}));o.push(c);const u=[];if(Xe(r,u),u.length){const t=u.map(t=>{const e=X.getArrayBuffer(t.url);return e.xhr.url=t.url,a.push(e.xhr),e.then(e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format})});o.push(...t)}i[e]=u.length}const c=Promise.all(o).then(o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const a=[];let c=0;for(let t=0;t<i.length;t++){const e=i[t];a.push({geoBuffer:{data:o[c].buffer.data},textureBuffers:o.slice(c+1,e+c+1).map(t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format}))}),c+=1+e}return function(t,e,n,s,o){const i={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},a=[];for(let c=0;c<t.meshes.length;c++){let{material:u}=t.meshes[c];const{geometry:f}=t.meshes[c];let l;const h=e[c].geoBuffer.data;if(!h)continue;const y=Ze(h);l=y?je(i,c,f,h,t.transform,t.center,o):Ge(i,c,f,h,t.transform,t.center,o),a.push(l),i.nodes[c]={mesh:c,nodeIndex:c,matrix:r([])},i.scenes[0].nodes[c]=i.nodes[c],u||(u=Le);const m=He(c,i,u,e[c].textureBuffers,n,s);a.push(m)}return Promise.all(a).then(()=>({gltf:i,featureTable:{BATCH_LENGTH:0},transferables:i.transferables}))}(t,a,e,s,n)});return c.xhr=a,c}const ke={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function je(t,e,n,r,s,o,i){const a=n.info.compressedAttributes.attributes.reduce((t,e,n)=>{const r=ze[e];if(!r)return t;return t[r.name||e]=n,t},{});return De(r,{attributes:a,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then(n=>$e(n,t,e,s,o,i))}const qe={position:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.position={array:s,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.normal={array:s,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,s=new Float32Array(e,n,r);return t.uv0={array:s,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,s=new Uint8Array(e,n,r);return t.color={array:s,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,s=new Uint32Array(e,n,r);return t.faceRange={array:s,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Ge(t,e,n,r,s,o,i){const a={vertexCount:0},c=new DataView(r);try{let t=0;a.vertexCount=c.getUint32(t,1),t+=4,a.featureCount=c.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)qe[n[e]]?t=qe[n[e]](a,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let s=e.ordering,o=e.featureAttributeOrder;const i=null;i&&i.geometryData&&i.geometryData[0]&&i.geometryData[0].params;for(let e=0;e<s.length;e++){const n=qe[s[e]];n||console.log(s[e]),t=n(a,r,t)}for(let e=0;e<o.length;e++){const n=qe[o[e]];n||console.log(o[e]),t=n(a,r,t)}}}catch(t){}a.scale_x=1,a.scale_y=1;const u={};for(const t in a){const e=ze[t]&&ze[t].name;e&&(u[e]=a[t])}if(a.faceRange){const t=a.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(u.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,s=t[e],o=t[e+1];for(let t=s;t<=o;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}u._BATCHID={componentType:ne(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return $e({attributes:u},t,e,s,o,i)}function $e(t,e,n,r,s,o){const i={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const a=function(t,e,n,r){const s=n;let o,i=[0,0,0,1];const a=[0,0],u=Be([],n,r);u[2]=n[2];const f=e&&c(Fe,e);return xe(t,t=>(i[0]=t[0],i[1]=t[1],i[2]=t[2],f||(i=T(i,i,e)),s&&m(i,i,s),Be(a,i,r),o=i[2],t[0]=a[0]-u[0],t[1]=a[1]-u[1],t[2]=o-u[2],t)),u}(t.attributes.POSITION,r,s,o);e.meshes[n]={primitives:[i],index:n},e.extensions.MAPTALKS_RTC={projCenter:a},e.extensions.CESIUM_RTC={rtcCoord:s};for(const n in t.attributes)We(e.transferables,t.attributes[n].array.buffer);return t.indices&&We(e.transferables,t.indices.array.buffer),i}function He(t,e,n,r,s,o){const i=r.map(t=>function(t,e,n,r,s){if("dds"===e){const e=Ue(t),r=e.images.map(e=>new Uint8Array(t,e.offset,e.length)),s="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:ke,format:s})}if("png"===e||"jpg"===e)return function(t,e){Je||(Je=new OffscreenCanvas(2,2),Ke=Je.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then(t=>{let{width:n,height:r}=t;Ye(n)||(n=Qe(n)),Ye(r)||(r=Qe(r));const s=e;s&&(n=Math.min(s,n),r=Math.min(s,r)),Je.width=n,Je.height=r,Ke.drawImage(t,0,0,n,r),t.close();const o=Ke.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(o.data)}}).catch(()=>({width:2,height:2,array:new Uint8Array(4)}))}(t,s).then(t=>{t.mimeType=n;return{image:t,sampler:ke,format:6408}});if("ktx2"===e)return Re(t,r).then(t=>(t.mimeType=n,{image:t,sampler:ke,format:t.format}));return null}(t.data,t.format,t.mimeType,s,o).then(t=>{if(t.image)if(t.image.array)We(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)We(e.transferables,t.image.mipmap[n].buffer);return t}));return Promise.all(i).then(r=>{!function t(e,n,r,s){const o=JSON.parse(JSON.stringify(r)),i=n.textures;s.ptr||(s.ptr=0);for(const e in r)r[e]&&r[e].url?(i.push(s[s.ptr++]),o[e]={index:i.length-1},void 0!==r[e].factor&&(o[e].scale=r[e].factor)):gt(r[e])&&(o[e]=t(-1,n,r[e],s));e>=0&&(n.materials[e]=o);return o}(t,e,n,r)})}function Xe(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):gt(t[n])&&Xe(t[n],e)}let Je,Ke;function Ye(t){return 0==(t&t-1)&&0!==t}function Qe(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function We(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function Ze(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}const tn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],en=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],nn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let rn,sn=!1;if("undefined"!=typeof OffscreenCanvas){try{rn=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}rn&&"undefined"!=typeof createImageBitmap&&(sn=!0)}const on=r([]),an=[0,0,0],cn=[],un=[],fn=[],ln=[];class hn{constructor(t,e,n,r){this.id=t,this.options=e,this.dt=this.requestImage.bind(this),this.pt=n,this.bt={},r(null,{},[])}wt(t){this.gt||(this.o=t,this.Tt=new ye,this.gt=new ce(this.dt,ht,t),this.At=new ue(this.dt,ht,t))}requestImage(t,e){sn?fetch(t).then(t=>t.arrayBuffer()).then(t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(t=>{(void 0).width=t.width,(void 0).height=t.height,rn.drawImage(t,0,0);const n=rn.getImageData(0,0,(void 0).width,(void 0).height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})}):this.pt("requestImage",{url:t},null,e)}loadTile(t,e){this.wt(t.supportedFormats);const n=t.url,r=t.arraybuffer;if(function(t){return t.indexOf("i3s:")>=0}(n)){const r=t.i3sInfo,s=this.options.services[t.rootIdx].maxTextureSize||1024,o=Ve(r,t.supportedFormats,this.options.projection,s);return o.then(t=>{if(delete this.bt[n],!t)return void e({status:404,url:n,i3sInfo:r});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:n,i3sInfo:r});t.gltf.url=n;const{transferables:s}=t;t.magic="b3dm",e(null,t,s)}),void(this.bt[n]=o.xhr)}if(r){delete this.bt[n];const s=Nt(new DataView(r),0);if("{"===s[0]||" "===s[0]||"<"===s[0]){const s=function(t,e,n){if(nn){const r=new Uint8Array(t,e,n);return nn.decode(r)}return St(new Uint8Array(t,e,n))}(r,0,r.byteLength),o=JSON.parse(s);this._t(t.rootIdx,o,r,n,e)}else this.St(r,n,t,s,e)}else{const r=this.options.services[t.rootIdx];let s=r.urlParams;s&&(s=(n.indexOf("?")>0?"&":"?")+s);const o=n.replace(/\\+/g,"%2B");let i=X.getArrayBuffer(o+(s||""),r.fetchOptions);const a=i.xhr;i=i.then(r=>{delete this.bt[n],r&&r.status?e(r):(t.arraybuffer=r&&r.data,this.loadTile(t,e))}).catch(t=>{delete this.bt[n],e(t)}),this.bt[n]=a}}St(t,e,n,r,s){const o=this.options.services[n.rootIdx];if("b3dm"===r){this.gt.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||1024}).then(t=>{if(t.error)return void s(t);const{content:e,transferables:r}=this.xt(t,n);s(null,e,r)}).catch(t=>{s(t)})}else if("pnts"===r){const r=n.transform;this.Tt.load(e,t).then(t=>{const{content:e,transferables:o}=this.Mt(t,r,n.rootIdx);s(null,e,o)})}else if("i3dm"===r){const r=n.transform;this.At.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||1024}).then(t=>{const{content:e,transferables:o}=this.Mt(t,r,n.rootIdx);s(null,e,o)})}else if("cmpt"===r){new de(this.dt,ht,this.o,o.maxTextureSize||1024).load(e,t,0,0,{maxTextureSize:o.maxTextureSize||1024}).then(t=>{const{content:e,transferables:r}=this.Ot(t,n);s(null,e,r)}).catch(t=>{s(t)})}}vt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const s={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(s)}return e}_t(t,e,n,r,s){return e.capabilities,void s(null,e)}Ot(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},s=[];for(let t=0;t<n.length;t++){const{magic:o}=n[t];if("b3dm"===o){const{content:o,transferables:i}=this.xt(n[t],e);pn(s,i),r.content.push(o)}else if("i3dm"===o||"pnts"===o){const{transform:o,rootIdx:i}=e,{content:a,transferables:c}=this.Mt(n[t],o,i);pn(s,c),r.content.push(a)}else if("cmpt"===o){const{content:o,transferables:i}=this.Ot(n[t],e);pn(s,i),r.content.push(o)}}return{content:r,transferables:s}}xt(t,e){const{gltf:n,transferables:r,featureTable:s}=t,o=function(t){if(!t||!t.meshes)return!1;let e=1;const n=[];for(const r in t.meshes){const s=t.meshes[r],{primitives:o}=s;if(o)for(let t=0;t<o.length;t++){const r=o[t].attributes&&o[t].attributes.POSITION;if(!r||!r.array)continue;r.array.buffer.visited||(r.array.buffer.visited=e++);const s=e-1+"-"+(r.byteOffset||0);if(n.indexOf(s)>=0)return!0;n.push(s)}}return!1}(n);return this.It(t.gltf),t.gltf.asset||(t.gltf.asset={}),o?(t.gltf.asset.sharePosition=!0,this.Ut(n,s,e.upAxis,e.transform)):this.Ct(n,s,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:r}}Mt(t,e,r){const{featureTable:s}=t,o=t.pnts||t.i3dm,i=s&&s.RTC_CENTER||[0,0,0];if(s.EAST_NORTH_UP&&!o.NORMAL_UP&&!o.NORMAL_UP_OCT32P){const e=new Float32Array(3*o.POSITION.array.length),r=[],s=[],a=[];xe(o.POSITION,(t,o)=>{m(a,t,i),te(a,null,r),n(s,r);!function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8]}(e.subarray(9*o,9*(o+1)),s)}),o.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const a={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};mn(o.POSITION.array,3,i,on,a);const c=dn(a),u=h([],c),f=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];xe(o.POSITION,t=>{t[0]=t[0]+i[0]-u[0],t[1]=t[1]+i[1]-u[1],t[2]=t[2]+i[2]-u[2],t[0]<f[0]&&(f[0]=t[0]),t[1]<f[1]&&(f[1]=t[1]),t[2]<f[2]&&(f[2]=t[2]),t[0]>l[0]&&(l[0]=t[0]),t[1]>l[1]&&(l[1]=t[1]),t[2]>l[2]&&(l[2]=t[2])}),o.POSITION.min=f,o.POSITION.max=l,e&&T(c,c,e);const y=this.Et(c);t.rtcCenter=u,t.rtcCoord=y,t.rootIdx=r;const d=t.transferables;return delete t.transferables,{content:t,transferables:d}}It(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],s=n[1],o=n[2],i=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==s||n[t+2]!==o||n[t+3]!==i){a=!1;break}a&&(e[t].image.color=[r/255,s/255,o/255,i/255],delete e[t].image.array)}}}abortTileLoading(t,e){const n=this.bt[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.bt[t.url],e(null)}Pt(t,e,n,o){const i=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let a=tn;"X"===(n=n&&n.toUpperCase())?a=en:"Z"===n&&(a=on),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),i&&(t.extensions.CESIUM_RTC.center=i),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};pe(t,t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=r(cn);t.matrices&&bn(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;s(e,a,e),o&&s(e,o,e),mn(n,u,i||an,e,c,t.compressUniforms)});const u=dn(c);return{rtcCenter:i,modelCenter:u,upAxisTransform:a}}Ut(t,e,n,o){const{modelCenter:i,upAxisTransform:a,rtcCenter:c}=this.Pt(t,e,n),u=h([],i);o&&T(i,i,o),t.extensions.CESIUM_RTC.rtcCoord=this.Et(i),c||(pe(t,t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const n=r(cn);t.matrices&&bn(n,t.matrices),s(n,a,n);const o=function(t,e){var n=e[0],r=e[1],s=e[2],o=e[3],i=e[4],a=e[5],c=e[6],u=e[7],f=e[8],l=e[9],h=e[10],y=e[11],m=e[12],d=e[13],p=e[14],b=e[15],w=n*a-r*i,g=n*c-s*i,T=n*u-o*i,A=r*c-s*a,_=r*u-o*a,S=s*u-o*c,x=f*d-l*m,M=f*p-h*m,O=f*b-y*m,v=l*p-h*d,I=l*b-y*d,U=h*b-y*p,C=w*U-g*I+T*v+A*O-_*M+S*x;return C?(C=1/C,t[0]=(a*U-c*I+u*v)*C,t[1]=(s*I-r*U-o*v)*C,t[2]=(d*S-p*_+b*A)*C,t[3]=(h*_-l*S-y*A)*C,t[4]=(c*O-i*U-u*M)*C,t[5]=(n*U-s*O+o*M)*C,t[6]=(p*T-m*S-b*g)*C,t[7]=(f*S-h*T+y*g)*C,t[8]=(i*I-a*O+u*x)*C,t[9]=(r*O-n*I-o*x)*C,t[10]=(m*_-d*T+b*w)*C,t[11]=(l*T-f*_-y*w)*C,t[12]=(a*M-i*v-c*x)*C,t[13]=(n*v-r*M+s*x)*C,t[14]=(d*g-m*A-p*w)*C,t[15]=(f*A-l*g+h*w)*C,t):null}(un,n),i=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];xe(e,t=>{T(t,t,n),t[0]=t[0]-u[0],t[1]=t[1]-u[1],t[2]=t[2]-u[2],T(t,t,o),t[0]<i[0]&&(i[0]=t[0]),t[1]<i[1]&&(i[1]=t[1]),t[2]<i[2]&&(i[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])}),e.min=i,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}}),t.extensions.CESIUM_RTC.center=u)}Ct(t,e,n,r){const{modelCenter:s,rtcCenter:o}=this.Pt(t,e,n,r),i=this.Bt(s);t.extensions.MAPTALKS_RTC.projCenter=i,t.extensions.CESIUM_RTC.rtcCoord=this.Et(s),pe(t,e=>{if(e.attributes&&e.attributes.POSITION){e.attributes.NORMAL&&this.Nt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.Nt(e.attributes.TANGENT,e.matrices,n);const{newPositions:s}=this.Ft(e.attributes.POSITION,e.matrices,o,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms),{componentType:i}=e.attributes.POSITION;5126!==i&&(e.attributes.POSITION.array=new Float32Array(s))}});for(const e in t.nodes){t.nodes[e].matrix=on}}Bt(t){0===S(t)?y(fn,0,0,-6378137):Ut(fn,t);const e=this.options.projection;Be(ln,fn,e);const n=fn[2],r=[];return r[0]=ln[0],r[1]=ln[1],r[2]=n,r}Nt(t,e,r){let s;s="Y"===r?tn:"X"===r?en:on;const o=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],s);if(bn(o,e),c(o,on))return;const i=n([],o),a=[];xe(t,t=>(function(t,e,n){var r=e[0],s=e[1],o=e[2];t[0]=r*n[0]+s*n[3]+o*n[6],t[1]=r*n[1]+s*n[4]+o*n[7],t[2]=r*n[2]+s*n[5]+o*n[8]}(a,t,i),b(a,a),h(t,a),a))}Ft(t,e,n,s,o,i,a){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const u=r([]);bn(u,e);const f=this.options.projection;o=o&&o.toUpperCase();const l=n;let h=null;"Y"===o?h=tn:"X"===o&&(h=en);let d=[0,0,0,1];const p=[0,0,0],b=[0,0],w=s.projCenter,g=i&&c(on,i),A=t.min=t.min||[],_=t.max=t.max||[];y(A,1/0,1/0,1/0),y(_,-1/0,-1/0,-1/0);const x=a||{},{decode_position_min:M,decode_position_normConstant:O}=x;let v=[0,0,0,0],I=1;M&&(v=M),O&&(I=O);const U=[];return xe(t,t=>{if(d[0]=t[0]*I+v[0],d[1]=t[1]*I+v[1],d[2]=t[2]*I+v[2],d=T(d,d,u),h&&(d=T(d,d,h)),l&&m(d,d,l),i&&!g&&(d=T(d,d,i)),0===S(d)?y(p,0,0,-6378137):Ut(p,d),Be(b,p,f),t instanceof Float32Array)t[0]=b[0]-w[0],t[1]=b[1]-w[1],t[2]=p[2]-w[2];else{const e=b[0]-w[0],n=b[1]-w[1],r=p[2]-w[2];U.push(e),U.push(n),U.push(r),U.push(t[3])}return t[0]<A[0]&&(A[0]=t[0]),t[1]<A[1]&&(A[1]=t[1]),t[2]<A[2]&&(A[2]=t[2]),t[0]>_[0]&&(_[0]=t[0]),t[1]>_[1]&&(_[1]=t[1]),t[2]>_[2]&&(_[2]=t[2]),t}),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:w,newPositions:U}}Et(t){return 0===S(t)?y([],0,0,-6378137):Ut([],t)}onRemove(){}}const yn=[];function mn(t,e,n,r,s,o){const i=o||{},{decode_position_min:a,decode_position_normConstant:c}=i;let u=[0,0,0,0],f=1;a&&(u=a),c&&(f=c);for(let o=0,i=t.length;o<i;o+=e){const{xmin:i,ymin:a,xmax:c,ymax:l,hmin:h,hmax:d}=s;y(yn,t[o]*f+u[0],t[o+1]*f+u[1],t[o+2]*f+u[2]),T(yn,yn,r);const p=m(yn,n,yn);p[0]<i&&(s.xmin=p[0]),p[0]>c&&(s.xmax=p[0]),p[1]<a&&(s.ymin=p[1]),p[1]>l&&(s.ymax=p[1]),e>2&&(p[2]<h&&(s.hmin=p[2]),p[2]>d&&(s.hmax=p[2]))}}function dn(t){const{xmax:e,ymax:n,xmin:r,ymin:s,hmin:o,hmax:i}=t,a=[(r+e)/2,(s+n)/2,(o+i)/2];return e===-1/0&&(a[0]=0),n===-1/0&&(a[1]=0),i===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function pn(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function bn(t,e){const n=t;for(let t=e.length-1;t>=0;t--)s(n,e[t],n);return n}let wn=0;class gn{constructor(t){this.workerId=t,this.workers={},this.Dt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},s){if(this.Rt(e,n))return;const o=this.Lt(e,n),i=r.options,a=this.send.bind(this,t);this.workers[o]=new hn(n,i,a,s)}removeLayer({mapId:t,layerId:e},n){const r=this.Rt(t,e),s=this.Lt(t,e);delete this.workers[s],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const s=this.Rt(t,e);s&&s.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const s=this.Rt(t,e);s&&s.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.Dt[e];delete this.Dt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,s){const o=s?`${t}-${wn++}`:null;s&&(this.Dt[o]=s),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(o)},r||[])}Lt(t,e){return`${t}-${e}`}Rt(t,e){const n=this.Lt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new gn(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},(t,n,r)=>{t instanceof Error&&(t={message:t.message}),e(t,n,r)})},Object.defineProperty(t,"zt",{value:!0})}';for(
7
7
  /*!
8
8
  * Contains code from THREE.js
9
9
  * MIT License
10
10
  * https://github.com/mrdoob/three.js
11
11
  */
12
- var u=[],E=0;E<6;E++)u[E]=[];var d=[];function _(t,e,n){C(t);for(var r=0;r<6;r++)if(!n||"0"!==n.charAt(r)){var i=u[r];if(d[0]=i[0]>0?e[1][0]:e[0][0],d[1]=i[1]>0?e[1][1]:e[0][1],d[2]=i[2]>0?e[1][2]:e[0][2],m(i,d)<0)return!1}return!0}function B(t,e){var n=e,r=t,i=e,o=r[0],s=r[1],a=r[2],c=Math.abs(o*i[3]+s*i[6]+a*i[9])+Math.abs(o*i[4]+s*i[7]+a*i[10])+Math.abs(o*i[5]+s*i[8]+a*i[11]),A=m(t,n);return!(A<=-c)}function C(t){var e=t,n=e[0],r=e[1],i=e[2],o=e[3],s=e[4],a=e[5],c=e[6],A=e[7],l=e[8],f=e[9],h=e[10],E=e[11],d=e[12],_=e[13],B=e[14],C=e[15];T(u[0],o-n,A-s,E-l,C-d),T(u[1],o+n,A+s,E+l,C+d),T(u[2],o+r,A+a,E+f,C+_),T(u[3],o-r,A-a,E-f,C-_),T(u[4],o-i,A-c,E-h,C-B),T(u[5],o+i,A+c,E+h,C+B)}function T(t,e,n,r,i){var o=1/Math.sqrt(e*e+n*n+r*r);return t[0]=e*o,t[1]=n*o,t[2]=r*o,t[3]=i*o,t}function m(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function g(t){return null==t}function p(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function y(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function R(t){return"object"==typeof t&&!!t}function I(t){return"number"==typeof t&&!isNaN(t)}function b(t){return t*Math.PI/180}function x(t){return t/Math.PI*180}function M(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function P(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const N=[1,1,1,1,2,2,3,0];function D(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=N[i>>3&7];if(!(64&i)||!n||r+n>e)return null;for(i&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;i=i<<6|63&e}}n+=String.fromCharCode(i)}return n}function S(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function O(t){return t.flat?t.flat(1/0):t.reduce((t,e)=>t.concat(e),[])}function L(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function F(t){return 0===t.indexOf("data:")}function w(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),i=r.length,o=new Uint8Array(i);for(let t=0;t<i;t++)o[t]=r.charCodeAt(t);return o.buffer}function v(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}var U=Object.freeze({__proto__:null,isNil:g,extend:p,isFunction:y,isObject:R,isNumber:I,toRadian:b,toDegree:x,getAbsoluteURL:M,sign:P,stringFromUTF8Array:D,setColumn3:S,flatArr:O,getBatchIdArrayType:L,isBase64:F,base64URLToArrayBuffer:w,pushIn:v});var G="undefined"!=typeof Float32Array?Float32Array:Array;function H(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function V(t,e,n){var r=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],A=e[6],l=e[7],f=e[8],h=e[9],u=e[10],E=e[11],d=e[12],_=e[13],B=e[14],C=e[15],T=n[0],m=n[1],g=n[2],p=n[3];return t[0]=T*r+m*a+g*f+p*d,t[1]=T*i+m*c+g*h+p*_,t[2]=T*o+m*A+g*u+p*B,t[3]=T*s+m*l+g*E+p*C,T=n[4],m=n[5],g=n[6],p=n[7],t[4]=T*r+m*a+g*f+p*d,t[5]=T*i+m*c+g*h+p*_,t[6]=T*o+m*A+g*u+p*B,t[7]=T*s+m*l+g*E+p*C,T=n[8],m=n[9],g=n[10],p=n[11],t[8]=T*r+m*a+g*f+p*d,t[9]=T*i+m*c+g*h+p*_,t[10]=T*o+m*A+g*u+p*B,t[11]=T*s+m*l+g*E+p*C,T=n[12],m=n[13],g=n[14],p=n[15],t[12]=T*r+m*a+g*f+p*d,t[13]=T*i+m*c+g*h+p*_,t[14]=T*o+m*A+g*u+p*B,t[15]=T*s+m*l+g*E+p*C,t}function K(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function k(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function X(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],s=n+n,a=r+r,c=i+i,A=n*s,l=r*s,f=r*a,h=i*s,u=i*a,E=i*c,d=o*s,_=o*a,B=o*c;return t[0]=1-f-E,t[1]=l+B,t[2]=h-_,t[3]=0,t[4]=l-B,t[5]=1-A-E,t[6]=u+d,t[7]=0,t[8]=h+_,t[9]=u-d,t[10]=1-A-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function z(){var t=new G(3);return G!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Y(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function J(t,e,n){var r=new G(3);return r[0]=t,r[1]=e,r[2]=n,r}function Z(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function W(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function j(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function Q(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function q(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function $(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function tt(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function et(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function nt(t,e,n){var r=e[0],i=e[1],o=e[2],s=n[0],a=n[1],c=n[2];return t[0]=i*c-o*a,t[1]=o*s-r*c,t[2]=r*a-i*s,t}var rt=Q,it=q,ot=Y;function st(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function at(t,e,n){var r=e[0],i=e[1],o=e[2],s=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*s,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*s,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*s,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*s,t}function ct(){var t=new G(4);return G!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function At(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function lt(t,e,n,r){var i=e[0],o=e[1],s=e[2],a=e[3],c=n[0],A=n[1],l=n[2],f=n[3],h=void 0,u=void 0,E=void 0,d=void 0,_=void 0;return(u=i*c+o*A+s*l+a*f)<0&&(u=-u,c=-c,A=-A,l=-l,f=-f),1-u>1e-6?(h=Math.acos(u),E=Math.sin(h),d=Math.sin((1-r)*h)/E,_=Math.sin(r*h)/E):(d=1-r,_=r),t[0]=d*i+_*c,t[1]=d*o+_*A,t[2]=d*s+_*l,t[3]=d*a+_*f,t}z(),function(){var t,e=(t=new G(4),G!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var ft,ht=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};z(),J(1,0,0),J(0,1,0),ct(),ct(),ft=new G(9),G!=Float32Array&&(ft[1]=0,ft[2]=0,ft[3]=0,ft[5]=0,ft[6]=0,ft[7]=0),ft[0]=1,ft[4]=1,ft[8]=1;
12
+ var d=[],m=0;m<6;m++)d[m]=[];var p=[];function y(t,e,n){g(t);for(var r=0;r<6;r++)if(!n||"0"!==n.charAt(r)){var s=d[r];if(p[0]=s[0]>0?e[1][0]:e[0][0],p[1]=s[1]>0?e[1][1]:e[0][1],p[2]=s[2]>0?e[1][2]:e[0][2],w(s,p)<0)return!1}return!0}function b(t,e){var n=e,r=t,s=e,i=r[0],o=r[1],a=r[2],c=Math.abs(i*s[3]+o*s[6]+a*s[9])+Math.abs(i*s[4]+o*s[7]+a*s[10])+Math.abs(i*s[5]+o*s[8]+a*s[11]),h=w(t,n);return!(h<=-c)}function g(t){var e=t,n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],h=e[7],u=e[8],f=e[9],l=e[10],m=e[11],p=e[12],y=e[13],b=e[14],g=e[15];T(d[0],i-n,h-o,m-u,g-p),T(d[1],i+n,h+o,m+u,g+p),T(d[2],i+r,h+a,m+f,g+y),T(d[3],i-r,h-a,m-f,g-y),T(d[4],i-s,h-c,m-l,g-b),T(d[5],i+s,h+c,m+l,g+b)}function T(t,e,n,r,s){var i=1/Math.sqrt(e*e+n*n+r*r);return t[0]=e*i,t[1]=n*i,t[2]=r*i,t[3]=s*i,t}function w(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function _(t){return null==t}function A(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function O(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function x(t){return"object"==typeof t&&!!t}function I(t){return"number"==typeof t&&!isNaN(t)}function S(t){return t*Math.PI/180}function M(t){return t/Math.PI*180}function E(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function v(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const N=[1,1,1,1,2,2,3,0];function C(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=N[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}function R(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function B(t){return t.flat?t.flat(1/0):t.reduce((t,e)=>t.concat(e),[])}function U(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function P(t){return 0===t.indexOf("data:")}function L(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),s=r.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=r.charCodeAt(t);return i.buffer}function D(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}var F=Object.freeze({__proto__:null,isNil:_,extend:A,isFunction:O,isObject:x,isNumber:I,toRadian:S,toDegree:M,getAbsoluteURL:E,sign:v,stringFromUTF8Array:C,setColumn3:R,flatArr:B,getBatchIdArrayType:U,isBase64:P,base64URLToArrayBuffer:L,pushIn:D});var k="undefined"!=typeof Float32Array?Float32Array:Array;function V(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function H(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],h=e[6],u=e[7],f=e[8],l=e[9],d=e[10],m=e[11],p=e[12],y=e[13],b=e[14],g=e[15],T=n[0],w=n[1],_=n[2],A=n[3];return t[0]=T*r+w*a+_*f+A*p,t[1]=T*s+w*c+_*l+A*y,t[2]=T*i+w*h+_*d+A*b,t[3]=T*o+w*u+_*m+A*g,T=n[4],w=n[5],_=n[6],A=n[7],t[4]=T*r+w*a+_*f+A*p,t[5]=T*s+w*c+_*l+A*y,t[6]=T*i+w*h+_*d+A*b,t[7]=T*o+w*u+_*m+A*g,T=n[8],w=n[9],_=n[10],A=n[11],t[8]=T*r+w*a+_*f+A*p,t[9]=T*s+w*c+_*l+A*y,t[10]=T*i+w*h+_*d+A*b,t[11]=T*o+w*u+_*m+A*g,T=n[12],w=n[13],_=n[14],A=n[15],t[12]=T*r+w*a+_*f+A*p,t[13]=T*s+w*c+_*l+A*y,t[14]=T*i+w*h+_*d+A*b,t[15]=T*o+w*u+_*m+A*g,t}function G(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function j(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function z(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,f=r*a,l=s*o,d=s*a,m=s*c,p=i*o,y=i*a,b=i*c;return t[0]=1-f-m,t[1]=u+b,t[2]=l-y,t[3]=0,t[4]=u-b,t[5]=1-h-m,t[6]=d+p,t[7]=0,t[8]=l+y,t[9]=d-p,t[10]=1-h-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function q(){var t=new k(3);return k!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function X(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function K(t,e,n){var r=new k(3);return r[0]=t,r[1]=e,r[2]=n,r}function $(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function W(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function Y(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function J(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Z(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function Q(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function tt(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t}function et(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function nt(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[0],a=n[1],c=n[2];return t[0]=s*c-i*a,t[1]=i*o-r*c,t[2]=r*a-s*o,t}var rt=J,st=Z,it=X;function ot(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function at(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,t[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,t[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,t[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,t}function ct(){var t=new k(4);return k!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ht(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function ut(t,e,n,r){var s=e[0],i=e[1],o=e[2],a=e[3],c=n[0],h=n[1],u=n[2],f=n[3],l=void 0,d=void 0,m=void 0,p=void 0,y=void 0;return(d=s*c+i*h+o*u+a*f)<0&&(d=-d,c=-c,h=-h,u=-u,f=-f),1-d>1e-6?(l=Math.acos(d),m=Math.sin(l),p=Math.sin((1-r)*l)/m,y=Math.sin(r*l)/m):(p=1-r,y=r),t[0]=p*s+y*c,t[1]=p*i+y*h,t[2]=p*o+y*u,t[3]=p*a+y*f,t}q(),function(){var t,e=(t=new k(4),k!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var ft,lt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};q(),K(1,0,0),K(0,1,0),ct(),ct(),ft=new k(9),k!=Float32Array&&(ft[1]=0,ft[2]=0,ft[3]=0,ft[5]=0,ft[6]=0,ft[7]=0),ft[0]=1,ft[4]=1,ft[8]=1;
13
13
  /*!
14
- * @maptalks/gltf-loader v0.83.1
14
+ * @maptalks/gltf-loader v0.84.0
15
15
  * LICENSE : UNLICENSED
16
16
  * (c) 2016-2023 maptalks.org
17
17
  */
18
- let ut=0;function Et(t){return null==t}function dt(t){return!Et(t)}function _t(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function Bt(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+t)}function Ct(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function Tt(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const mt=[],gt=[],pt=[],yt=[0,0,0],Rt=At([]),It=[1,1,1];function bt(t,e,n,r,i,o,s){const a=Bt(s);if((0===i||i===r*a.BYTES_PER_ELEMENT)&&o%a.BYTES_PER_ELEMENT==0){const i=new a(e,o,n*r);return t.set(i),t}0===i&&(i=r*a.BYTES_PER_ELEMENT);const c=new Uint8Array(r*a.BYTES_PER_ELEMENT);for(let s=0;s<n;s++){let n=null;const A=new Uint8Array(e,i*s+o,r*a.BYTES_PER_ELEMENT);c.set(A),n=new a(c.buffer,0,r);for(let e=0;e<r;e++)t[s*r+e]=n[e]}return t}const xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Mt(t,e,n){const r=new Uint8Array(t,e,n);return xt.decode(r)}const Pt={get:function(t,e={}){e||(e={});const n=new AbortController,r=n.signal,i=_t({},e);i.signal=r,i.method||(i.method="GET");const o=fetch(t,i).then(t=>{const n=this.t(t,e.responseType);return n.message?n:n.then(n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t})}).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t});return o.xhr=n,o},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",Pt.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?Pt.jsonp(t):((e=e||{}).responseType="json",Pt.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+ut++;t.match(/\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise(t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)})}};class Nt{constructor(t,e,n){this.i=t,this.decoders=e,this.o=n,this.images={},this.s={}}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],i=this.A(e,r);return this.getImageByBuffer(i,n)}if(this.s[t.id])return this.s[t.id].then(()=>{const r=this.buffers[t.id],i=this.A(e,r);return this.getImageByBuffer(i,n)});if(Ct(t.uri)){const r=this.buffers[t.id]=Tt(t.uri),i=this.A(e,r);return this.getImageByBuffer(i,n)}return this.s[t.id]=Pt.getArrayBuffer(t.uri,null).then(r=>{const i=this.buffers[t.id]=r.data,o=this.A(e,i);return this.getImageByBuffer(o,n)})}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;if(n[e.mimeType])return n[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const n=new Blob([t],{type:e.mimeType}),r=URL.createObjectURL(n);return this.l(e.id,r)}}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.s[t.id]?this.s[t.id].then(()=>this.images[t.id]):this.s[t.id]=this.l(t.id,e)}l(t,e){return new Promise((n,r)=>{this.i(e,(i,o)=>{i?r(i):(URL.revokeObjectURL(e),this.images[t]=o,n(this.images[t]))})})}}const Dt=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],St=[];class Ot{constructor(t,e,n){this.rootPath=t,this.gltf=e,this.h=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.u()}_(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.B(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const i=n.bufferViews[r.bufferView];return this.C(i).then(n=>{const{buffer:i,byteOffset:o}=n;return this.accessors[r.id]=this.B(t,e,i,o)})}C(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then(()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})});if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(Ct(e.uri)){const t=this.buffers[e.id]=Tt(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=Pt.getArrayBuffer(t,null).then(r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}B(t,e,n,r=0){const i=this.gltf,o=i.accessors[e],s=void 0!==o.bufferView?i.bufferViews[o.bufferView]:{},a=(s.byteOffset||0)+r,c=this.T(o.type),A=Bt(o.componentType),l=s.byteStride||0,f={array:void 0,name:t,accessorName:e,byteLength:o.count*c*A.BYTES_PER_ELEMENT,componentType:o.componentType,count:o.count,type:o.type,itemSize:c,max:o.max,min:o.min,extensions:o.extensions};if(o.min&&(f.min=o.min),o.max&&(f.max=o.max),n)if(this.h)f.byteStride=l,f.byteOffset=a+(o.byteOffset||0),!l||l===c*A.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(f.array=this.m(n,o.count,c,a+(o.byteOffset||0),A),f.array.buffer.byteLength===f.byteLength&&(f.byteOffset=0)):f.array=new Uint8Array(n,a,s.byteLength);else if(o.interleaved){f.byteStride=0,f.byteOffset=0;const t=new A(o.count*c);if(f.array=bt(t,n,o.count,c,l,a+(o.byteOffset||0),o.componentType),f.extensions&&f.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(f.array.length),{decodeMatrix:e}=f.extensions.WEB3D_quantized_attributes;for(let n=0;n<f.array.length;n+=c){St[0]=f.array[n],St[1]=f.array[n+1],St[2]=f.array[n+2],St[3]=1;const r=at(St,St,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}f.componentType=5126,f.array=t}}else f.byteStride=0,f.array=this.m(n,o.count,c,a+(o.byteOffset||0),A),f.byteOffset=f.array.byteOffset;else{f.array=new A(o.count);const t=f.min||f.max;t&&(f.array[0]=t[0],f.array[1]=t[1],f.array[2]=t[2])}return f}u(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}m(t,e,n,r,i){return r%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*i.BYTES_PER_ELEMENT),r=0),new i(t,r,n*e)}T(t){const e=Dt.indexOf(t);return Dt[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map(t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.C(e).then(r=>{const{buffer:i,byteOffset:o}=r,s=Mt(i,o+(e.byteOffset||0),n);return t.content=s,t})}if(t.uri){if(Ct(t.uri)){const e=Tt(t.uri),n=Mt(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return Pt.get(e).then(e=>(t.content=e,t))}}return Promise.resolve(t)});return Promise.all(n).then(()=>t)}}class Lt extends Nt{constructor(t,e,n,r,i,o){super(r,i,o),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new Ot(t,e,n)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(dt(t.name)&&(e.name=t.name),dt(t.children)&&(e.children=t.children),dt(t.jointName)&&(e.jointName=t.jointName),dt(t.matrix)&&(e.matrix=t.matrix),dt(t.rotation)&&(e.rotation=t.rotation),dt(t.scale)&&(e.scale=t.scale),dt(t.translation)&&(e.translation=t.translation),dt(t.extras)&&(e.extras=t.extras),dt(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const n=K(mt,e.translation||yt),r=X(gt,e.rotation||Rt),i=k(pt,e.scale||It);return V(i,r,i),V(t,n,i)}return H(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}g(t){const e={};for(const n in t){const r=t[n];let i,o;r.instanceTechnique&&r.instanceTechnique.values?(i=r.instanceTechnique,o=i.values.diffuse):(i=r,o=i.values.tex||i.values.diffuseTex||i.values.diffuse);const s={baseColorTexture:{index:o}};r.name&&(s.name=r.name),r.extensions&&(s.extensions=r.extensions),r.extras&&(s.extras=r.extras),e[n]=s}return e}p(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,i=n.byteLength,o=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,i);return this.getImageByBuffer(o,t)}return this.requestExternalImage(t)}R(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.p(n).then(t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}})}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const i=this.gltf.textures[r];if(!i)return null;const o=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:o,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}class Ft extends Nt{constructor(t,e,n,r,i,o){super(r,i,o),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new Ot(t,e,n)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return _t(e,t),!dt(t.weights)&&this.gltf.meshes&&dt(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}R(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!dt(n))return null;const r=this.gltf.images[n];return this.p(r).then(t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};_t(n,e);const i=dt(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i,n.sampler.magFilter=i.magFilter||9729,n.sampler.minFilter=i.minFilter||9729,n.sampler.wrapS=i.wrapS||10497,n.sampler.wrapT=i.wrapT||10497),t.format&&(n.format=t.format),n})}p(t){if(!dt(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.I(e,t)}return null}I(t,e){const n=this.A(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}A(t,e,n){n=n||0;const r=t.byteOffset+n,i=t.byteLength;return new Uint8Array(e,r,i)}M(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);return n.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)))}getAnimations(t){const e=[];return t.forEach(t=>{e.push(this.getSamplers(t.samplers))}),Promise.all(e).then(e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t})}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(dt(t[n].input)||dt(t[n].output))&&(e.push(this.accessor._("input",t[n].input)),e.push(this.accessor._("output",t[n].output)));return Promise.all(e).then(e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t})}}const wt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class vt{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),i=r.getUint32(4,!0);if(1===i)return vt.readV1(r,e);if(2===i)return vt.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const i=Ut(t.buffer,20+e,r);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,i;const o=new DataView(t,e+12);let s=0;for(;s<o.byteLength;){const a=o.getUint32(s,!0);s+=4;const c=o.getUint32(s,!0);if(s+=4,1313821514===c)n=Ut(t,e+12+s,a);else if(5130562===c){i=e+12+s,r=a;break}s+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:i,buffer:t,byteLength:r}}}}function Ut(t,e,n){if(wt){const r=new Uint8Array(t,e,n);return wt.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=Gt[i>>3&7];if(!(64&i)||!n||r+n>e)return null;for(i&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;i=i<<6|63&e}}n+=String.fromCharCode(i)}return n}(new Uint8Array(t,e,n))}const Gt=[1,1,1,1,2,2,3,0],Ht=[0,0,0],Vt=[0,0,0,1],Kt=[1,1,1],kt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},Xt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},zt={P(t,e,n,r,i,o,s,a){const c=dt(t)?e.animations:[e.animations[0]],A={};for(let e=0;e<c.length;e++){const l=c[e],f=l.name||e;if(dt(t)&&f!==t)continue;const h=l.channelsMap[n];if(h)for(let t=0;t<h.length;t++){const e=h[t];"translation"===e.target.path?(this.N(i,l.samplers[e.sampler],r,1),A.translation=Z(Ht,i)):"rotation"===e.target.path?(this.D(o,l.samplers[e.sampler],r,1),A.rotation=ht(Vt,o)):"scale"===e.target.path?(this.N(s,l.samplers[e.sampler],r,1),A.scale=Z(Kt,s)):"weights"===e.target.path&&a&&(this.N(a,l.samplers[e.sampler],r,a.length),A.weights=a)}}return A},N(t,e,n,r){switch(e.interpolation){case"LINEAR":{const i=this.S(Xt,e,n,1*r);i&&(t=function(t,e,n,r){for(let i=0;i<t.length;i++)t[i]=e[i]+r*(n[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.S(Xt,e,n,1*r);i&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.S(Xt,e,n,3*r);i&&(t=this.O(t,i,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.S(Xt,e,n,1);r&&lt(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.S(Xt,e,n,1);r&&(t=st(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.S(Xt,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.O(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},L(t,e){const n=t.length;let r,i,o,s=0,a=n-1,c=Math.floor((s+a)/2);for(;s<=n-1&&a>=0;){if(s===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,i=c+1,o=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:i,interpolation:o}}e<t[c]?(a=c,c=Math.floor((s+a)/2)):t[c+1]<e&&(s=c,c=Math.floor((s+a)/2))}return null},S(t,e,n,r){const i=e.input.array,o=e.output.array,s=e.output.itemSize;(n<i[0]||n>i[i.length-1])&&(n=Math.max(i[0],Math.min(i[i.length-1],n))),n===i[i.length-1]&&(n=i[0]);const a=this.L(i,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:A,interpolation:l}=a;t.PREINDEX=c,t.NEXTINDEX=A,t.INTERPOLATION=l;const f=s*r;return t.PREVIOUS=o.subarray(t.PREINDEX*f,(t.PREINDEX+1)*f),t.NEXT=o.subarray(t.NEXTINDEX*f,(t.NEXTINDEX+1)*f),t},O(t,e,n,r){const i=e.INTERPOLATION,o=n[e.PREINDEX],s=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(s-o)*e.PREVIOUS[2*r+n],A=e.NEXT[3+n],l=(s-o)*e.NEXT[n],f=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*A+(Math.pow(i,3)-Math.pow(i,2))*l;t[n]=f}return t},getAnimationClip(t,e,n,r){const i=t.nodes[e]&&t.nodes[e].weights;return W(Ht,...kt.TRANSLATION),st(Vt,...kt.ROTATION),W(Kt,...kt.SCALE),this.P(r,t,e,n,Ht,Vt,Kt,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach((e,n)=>{let r=-1/0,i=1/0;const o=e.channels;for(let t=0;t<o.length;t++){const n=o[t],s=e.samplers[n.sampler].input.array;s[s.length-1]>r&&(r=s[s.length-1]),s[0]<i&&(i=s[0])}const s=e.name||n;t.timeSpan[s]={max:r,min:i}}),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?dt(e)?n[e]:n[Object.keys(n)[0]]:null}};let Yt=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(jn){}t&&"undefined"!=typeof createImageBitmap&&(Yt=!0)}const Jt="undefined"==typeof document?null:document.createElement("canvas");class Zt{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=vt.read(e.buffer,e.byteOffset,e.byteLength);this.F(t,n,r)}else this.F(t,e);this.v=new Ot(this.rootPath,this.gltf,this.glbBuffer),this.U()}U(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}G(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.v.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then(e=>(t.KHR_techniques_webgl=e,t)):Promise.resolve(t)}load(t){t=t||{};const e=this.H(t),n=this.V(),r=this.K(),i=this.G();return Promise.all([e,n,r,i]).then(t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0]))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return zt.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return zt.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return Bt(t)}static readInterleavedArray(t,e,n,r,i,o,s){return bt(t,e,n,r,i,o,s)}F(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=Yt?qt.bind(this):this.options.requestImage||Wt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Ft(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate((t,e,n)=>{e.id="buffer_"+n},"buffers"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors")):(this.adapter=new Lt(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"))}k(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||function(t){return!Et(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const r=t.children.map(t=>{const n=e[t];return n.nodeIndex=t,this.k(n,e)});t.children=r}var n;return t}H(t){return this.X(t).then(t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.k(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate((r,i,o)=>{const s={};i.name&&(s.name=i.name),i.nodes&&(s.nodes=i.nodes.map(e=>t[e])),this.gltf.scene===r&&(n=o),e.push(s)},"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.g(this.gltf.materials);r.materials=t}return r})}X(t){return this.Y(t).then(()=>{const t=this.nodes={};return this.adapter.iterate((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r},"nodes"),t})}J(){this.skins=[];const t=[];return this.adapter.iterate((e,n,r)=>{t.push(this.Z(n).then(t=>{t.index=r,this.skins.push(t)}))},"skins"),t}Z(t){const e=t.inverseBindMatrices;return this.adapter.accessor._("inverseBindMatrices",e).then(e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t))}V(){const t=this.gltf.animations;return dt(t)?this.adapter.getAnimations(t):null}Y(t){this.meshes={};let e=[];return this.adapter.iterate((n,r,i)=>{e.push(this.W(r,t).then(t=>{t.index=i,this.meshes[n]=t}))},"meshes"),e=e.concat(this.J()),Promise.all(e)}W(t,e){const n=t.primitives.map(t=>this.j(t,e)).filter(t=>!!t);return Promise.all(n).then(e=>{const n={};return _t(n,t),n.primitives=e,n})}K(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.R(n));return Promise.all(e).then(e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t].image.array;if(e[t]&&n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e})}j(t,e){let n;const r=[],i=t.extensions;if(dt(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const i=this.adapter.accessor._(`morphTargets_${t}_${e}`,n[t]);i&&r.push(i)}}if(i&&i.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:o,attributes:s}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[o],c=this.v.C(a).then(n=>{const{buffer:r,byteOffset:i}=n;let{byteOffset:o}=a;const c=a.byteLength;o||(o=0);const A=new DataView(r,i+o,c),l={attributes:s,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(A,l).then(t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e})});r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor._(t,e[t]);n&&r.push(n)}if(dt(t.indices)){const e=this.adapter.accessor._("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then(e=>{if(i&&i.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const o={attributes:e.reduce((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:i}=e,o=i.length/r;for(let e=0;e<o;e++)for(let o=0;o<r;o++){const s=e*r+o;i[s]<t[o]&&(t[o]=i[s]),i[s]>n[o]&&(n[o]=i[s])}if(e.quantization){const r=e.quantization,i=r.range/(1<<r.quantizationBits),o=r.minValues;$(t,t,i),j(t,t,o),$(n,n,i),j(n,n,o)}e.min=t,e.max=n}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t},{}),material:t.material};return n&&(o.indices=n),r&&(o.morphTargets=r),o.mode=dt(t.mode)?t.mode:4,dt(t.extras)&&(o.extras=t.extras),o})}}function Wt(t,e){const n=new Image;n.crossOrigin="",n.onload=()=>{if(!Jt)return void e(new Error("There is no canvas to draw image!"));Jt.width=n.width,Jt.height=n.height;const t=Jt.getContext("2d",{willReadFrequently:!0});t.drawImage(n,0,0,n.width,n.height);const r=t.getImageData(0,0,n.width,n.height),i={width:n.width,height:n.height,data:new Uint8Array(r.data)};e(null,i)},n.onerror=function(t){e(t)},n.src=t}let jt,Qt;function qt(t,e){jt||(jt=new OffscreenCanvas(2,2),Qt=jt.getContext("2d",{willReadFrequently:!0})),fetch(t).then(t=>t.arrayBuffer()).then(t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(t=>{let{width:n,height:r}=t;$t(n)||(n=te(n)),$t(r)||(r=te(r));const i=this.options.maxTextureSize;i&&(n=Math.min(i,n),r=Math.min(i,r)),jt.width=n,jt.height=r,Qt.drawImage(t,0,0,n,r),t.close();const o=Qt.getImageData(0,0,n,r);e(null,{width:n,height:r,data:new Uint8Array(o.data)})}).catch(t=>{console.warn(t),e(t)})}function $t(t){return 0==(t&t-1)&&0!==t}function te(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const ee="undefined"==typeof document?null:document.createElement("canvas");class ne extends t.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!ee)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(re(t.width)&&re(t.height))return t;let e=t.width,n=t.height;re(e)||(e=ie(e));re(n)||(n=ie(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const i=t.src,o=i.lastIndexOf("/")+1,s=i.substring(o);return console.warn(`Texture(${s})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);ee.width=t.width,ee.height=t.height;const r=ee.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),o={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,o,[o.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function re(t){return 0==(t&t-1)&&0!==t}function ie(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class oe{constructor(t,e){this.max=t,this.currentSize=0,this.onRemove=e,this.reset()}reset(){if(this.data){const t=this.data.values();for(const e of t)this.onRemove(e)}return this.data=new Map,this.currentSize=0,this}clear(){this.reset(),delete this.onRemove}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){if(!this.data.get(e.value).current){const t=this.getAndRemove(e.value);t&&this.onRemove(t)}e=t.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e),this}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t){const e=this.data.values();for(const n of e)n.current=t}}function se(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,i=r.length;n<i;n++){const i=[];ue(r[n],i,t,e)}}}const ae=[],ce=[],Ae=[],le=[0,0,0],fe=At([]),he=[1,1,1];function ue(t,e,n,r){const i=e.slice(0);if(t.matrix)i.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=K(ae,t.translation||le),n=X(ce,t.rotation||fe),r=k(Ae,t.scale||he);V(r,n,r);const o=V([],e,r);i.push(o)}if(t.children&&t.children.length)for(let e=0,o=t.children.length;e<o;e++)ue(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,o=n.meshes[e];if(o){const t=i.slice(0),s=o.primitives;for(let i=0,o=s.length;i<o;i++){const o=s[i];o&&(o.matrices=t,r(o,e,i,n))}}}}function Ee(t,e,n){let{byteOffset:r,byteStride:i}=e;const{componentType:o,itemSize:s}=e,a=e.array.buffer,c=o?Zt.getTypedArrayCtor(o):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,i=i||0,!i||i===s*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*s*c.BYTES_PER_ELEMENT,s);return t.set(e),t}i||(i=s*c.BYTES_PER_ELEMENT);const A=new Uint8Array(a,i*n+r,s*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(A),t}function de(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}const _e=new Array(3),Be=new Array(3),Ce=[40680631590769,40680631590769,40408299984661.445];function Te(t,e,n,r){const i=Ce,o=Math.cos(n);_e[0]=o*Math.cos(e),_e[1]=o*Math.sin(e),_e[2]=Math.sin(n),Pe(_e,_e),q(Be,i,_e);const s=Math.sqrt(et(_e,Be));var a,c,A;return c=Be,A=s,(a=Be)[0]=c[0]/A,a[1]=c[1]/A,a[2]=c[2]/A,$(_e,_e,r),j(t,Be,_e)}const me=[1/6378137,1/6378137,1/6356752.314245179],ge=[1/40680631590769,1/40680631590769,1/40408299984661.445],pe=new Array(3),ye=new Array(3),Re=new Array(3);function Ie(t,e){const n=ge,r=function(t,e,n,r,i){const o=e[0],s=e[1],a=e[2],c=n[0],A=n[1],l=n[2],f=o*o*c*c,h=s*s*A*A,u=a*a*l*l,E=f+h+u,d=Math.sqrt(1/E),_=$(be,e,d);if(E<i)return isFinite(d)?_:void 0;const B=r[0],C=r[1],T=r[2],m=xe;m[0]=_[0]*B*2,m[1]=_[1]*C*2,m[2]=_[2]*T*2;let g,p,y,R,I,b,x,M,P,N,D,S=(1-d)*Me(e)/(.5*Me(m)),O=0;do{S-=O,y=1/(1+S*B),R=1/(1+S*C),I=1/(1+S*T),b=y*y,x=R*R,M=I*I,P=b*y,N=x*R,D=M*I,g=f*b+h*x+u*M-1,p=f*P*B+h*N*C+u*D*T;O=g/(-2*p)}while(Math.abs(g)>1e-12);return t[0]=o*y,t[1]=s*R,t[2]=a*I,t}(pe,e,me,n,.1);let i=it(ye,r,n);i=Pe(i,i);const o=rt(Re,e,r),s=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=P(et(o,e))*Me(o);return t[0]=x(s),t[1]=x(a),t[2]=c,t}const be=new Array(3),xe=new Array(3);function Me(t){return Y(t)}function Pe(t,e){const n=e[0],r=e[1],i=e[2];let o=n*n+r*r+i*i;return o>0&&(o=Math.sqrt(o),t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o),t}function Ne(t,e){return q(e,t,ge),tt(e,e)}function De(t,e){const n=t[0],r=t[1],i=Math.cos(r),o=i*Math.cos(n),s=i*Math.sin(n),a=Math.sin(r);return e.x=o,e.y=s,e.z=a,tt(e,e)}var Se=Object.freeze({__proto__:null,radianToCartesian3:Te,cartesian3ToDegree:Ie,normalizeCartesian:Pe,geodeticSurfaceNormal:Ne,geodeticSurfaceNormalCartographic:De});function Oe(t,e,n,r){n=n||0,r=r||n;const i=Math.abs(t-e);return i<=r||i<=n*Math.max(Math.abs(t),Math.abs(e))}function Le(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const Fe="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function we(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(D(r))}function ve(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(D(r))}function Ue(t,e,n){return{offset:e,byteLength:n}}function Ge(t,e,n,r){const{byteOffset:i,componentType:o,type:s}=t,{ctor:a,type:c}=ze(o||"UNSIGNED_SHORT"),A=ke(s);return{byteStride:0,byteOffset:i+n,itemSize:A,count:r*A,componentType:c,array:new a(e,n+i,r*A)}}function He(t,e,n,r){const i=Ge(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function Ve(t,e,n,r){const{byteOffset:i,componentType:o,type:s}=t,{ctor:a}=ze(o||"UNSIGNED_SHORT"),c=ke(s),A=new a(e,i,n*c);return 1===c?A[r]:A.subarray(r*c,r*c+c)}const Ke={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function ke(t){return t?Ke[t]:1}const Xe={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function ze(t){return Xe[t]}function Ye(t){for(const e in Xe)if(t===Xe[e].ctor)return Xe[e].type;throw new Error("unrecognized ctor:"+t)}function Je(t,e,n,r){const i=t,o=e.length/3;for(let t=0;t<o;t++)i[3*t]=e[3*t]/65535*r[0]+n[0],i[3*t+1]=e[3*t+1]/65535*r[1]+n[1],i[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return i}function Ze(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),o=t.getUint32(20,!0),s=t.getUint32(24,!0),a=t.buffer;let c,A={},l={},f=null;r>0&&(A=we(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),o>0&&(l=ve(a,e,o),e+=o);const h=Ue(0,e,s);return f=a.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:A,featureTableBin:c,batchTable:l,batchTableBin:f}}const We={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"}},je={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Qe={},qe={east:[],north:[],up:[],west:[],south:[],down:[]};let $e=[],tn=[],en=[];const nn=[0,0,0];function rn(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const on=function(t,e){const n=We[t][e];let r;const i=t+e;return Qe[i]?r=Qe[i]:(r=function(r,i,o){if(function(t,e){var n=t[0],r=t[1],i=t[2],o=e[0],s=e[1],a=e[2];return Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}(r,nn))Z($e,je[t]),Z(tn,je[e]),Z(en,je[n]);else if(Oe(r[0],0,1e-14)&&Oe(r[1],0,1e-14)){const i=P(r[2]);Z($e,je[t]),"east"!==t&&"west"!==t&&$($e,$e,i),Z(tn,je[e]),"east"!==e&&"west"!==e&&$(tn,tn,i),Z(en,je[n]),"east"!==n&&"west"!==n&&$(en,en,i)}else{Ne(r,qe.up);const i=qe.up,o=qe.east;o[0]=-r[1],o[1]=r[0],o[2]=0,tt(qe.east,o),nt(qe.north,i,o),$(qe.down,qe.up,-1),$(qe.west,qe.east,-1),$(qe.south,qe.north,-1),$e=qe[t],tn=qe[e],en=qe[n]}return o[0]=$e[0],o[1]=$e[1],o[2]=$e[2],o[3]=0,o[4]=tn[0],o[5]=tn[1],o[6]=tn[2],o[7]=0,o[8]=en[0],o[9]=en[1],o[10]=en[2],o[11]=0,o[12]=r[0],o[13]=r[1],o[14]=r[2],o[15]=1,o},Qe[i]=r),r}("east","north"),sn=[],an=[],cn=[],An=[],ln=[],fn=[],hn=[],un={x:0,y:0},En={x:0,y:0},dn=Math.PI/180;const _n={"programs":[{"attributes":["aPosition","instanceId","batchId","aTexCoord0","aTexCoord1","aNormal","aColor","uv2","uv3","uv4","secondary_colour","uv6"],"fragmentShader":1,"vertexShader":0}],"shaders":[{"type":35633,"content":"#include <gl2_vert>\n\nuniform mat4 czm_modelViewProjection;\n\nuniform mat4 czm_modelView;\n\nuniform mat3 czm_normal;\n\n\n\nattribute vec4 aPosition;\n\n\n\n#ifdef VertexColor\n\n attribute vec4 aColor;\n\n#endif\n\n#ifdef VertexNormal\n\n attribute vec3 aNormal;\n\n#endif\n\n#ifdef Instance\n\n attribute float instanceId;\n\n#else\n\n attribute float batchId;\n\n#endif\n\n\n\n#ifdef TexCoord\n\n attribute vec4 aTexCoord0;\n\n varying vec4 vTexCoord;\n\n uniform mat4 uTexMatrix;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform float uTexture0Width;\n\n varying vec4 vTexMatrix;\n\n varying vec4 vTexCoordTransform;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n#ifdef TexCoord2\n\n attribute vec4 aTexCoord1;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef InstanceBim\n\n attribute vec4 uv2;\n\n attribute vec4 uv3;\n\n attribute vec4 uv4;\n\n attribute vec4 secondary_colour;\n\n attribute vec4 uv6;\n\n#endif\n\n\n\n uniform vec4 uFillForeColor;\n\n uniform vec4 uSelectedColor;\n\n varying vec4 vSecondColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n varying vec4 vColor;\n\n\n\n const float SHIFT_LEFT8 = 256.0;\n\n const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\n const float SHIFT_RIGHT4 = 1.0 / 16.0;\n\n const float SHIFT_LEFT4 = 16.0;\n\n void getTextureMatrixFromZValue(in float nZ, inout float XTran, inout float YTran, inout float scale, inout float isRGBA)\n\n {\n\n if(nZ <= 0.0)\n\n {\n\n return;\n\n }\n\n float nDel8 = floor(nZ * SHIFT_RIGHT8);\n\n float nDel16 = floor(nDel8 * SHIFT_RIGHT8);\n\n float nDel20 = floor(nDel16 * SHIFT_RIGHT4);\n\n isRGBA = floor(nDel20);\n\n YTran = nZ - nDel8 * SHIFT_LEFT8;\n\n XTran = nDel8 - nDel16 * SHIFT_LEFT8;\n\n float nLevel = nDel16 - nDel20 * SHIFT_LEFT4;\n\n scale = 1.0 / pow(2.0, nLevel);\n\n }\n\n\n\n void operation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor)\n\n {\n\n float right_2 = operationType.x * 0.5;\n\n float right_4 = right_2 * 0.5;\n\n float right_8 = right_4 * 0.5;\n\n float right_16 = right_8 * 0.5;\n\n float isSetColor = fract(right_2);\n\n if(isSetColor > 0.1)\n\n {\n\n vertexColor *= color;\n\n }\n\n float isPicked = fract(floor(right_2)* 0.5);\n\n if(isPicked > 0.1)\n\n {\n\n vertexColor *= selectedColor;\n\n }\n\n float isHide = fract(floor(right_4)* 0.5);\n\n if(isHide > 0.1)\n\n {\n\n vertexColor.a = 0.0;\n\n }\n\n }\n\n\n\n void main()\n\n {\n\n #ifdef TexCoord\n\n vTexCoord.xy = aTexCoord0.xy;\n\n #ifdef COMPUTE_TEXCOORD\n\n vTexMatrix = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.x = 0.0;\n\n vTexCoordTransform.x = aTexCoord0.z;\n\n if(vTexCoordTransform.x < -90000.0)\n\n {\n\n vTexMatrix.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.x), vTexMatrix.x, vTexMatrix.y, vTexMatrix.z, vIsRGBA.x);\n\n vTexMatrix.w = log2(uTexture0Width * vTexMatrix.z);\n\n #endif\n\n #endif\n\n\n\n #ifdef TexCoord2\n\n vTexCoord.zw = aTexCoord1.xy;\n\n vTexMatrix2 = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.y = 0.0;\n\n vTexCoordTransform.y = aTexCoord1.z;\n\n if(vTexCoordTransform.y < -90000.0)\n\n {\n\n vTexMatrix2.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.y), vTexMatrix2.x, vTexMatrix2.y, vTexMatrix2.z, vIsRGBA.y);\n\n vTexMatrix2.w = log2(uTexture1Width * vTexMatrix.z);\n\n #endif\n\n\n\n vec4 vertexPos = aPosition;\n\n vec4 vertexColor = uFillForeColor;\n\n#ifdef VertexColor\n\n vertexColor *= aColor / 255.0;\n\n#endif\n\n#ifdef VertexNormal\n\n vec3 normal = aNormal;\n\n#endif\n\n #ifdef InstanceBim\n\n mat4 worldMatrix;\n\n worldMatrix[0] = uv2;\n\n worldMatrix[1] = uv3;\n\n worldMatrix[2] = uv4;\n\n worldMatrix[3] = vec4(0, 0, 0, 1);\n\n vertexPos = vec4(vertexPos.xyz,1.0) * worldMatrix;\n\n vertexColor *= secondary_colour;\n\n #endif\n\n\n\n\n\n #ifdef Instance\n\n float index = instanceId;\n\n #else\n\n float index = batchId;\n\n #endif\n\n vec4 positionMC = vec4(vertexPos.xyz, 1.0);\n\n vColor = vertexColor;\n\n #ifdef VertexNormal\n\n vNormalEC = czm_normal * normal;\n\n #endif\n\n vPositionMC = positionMC;\n\n vPositionEC = (czm_modelView * positionMC).xyz;\n\n gl_Position = czm_modelViewProjection * vec4(vertexPos.xyz, 1.0);\n\n }\n\n"},{"type":35632,"content":"#ifdef GL_OES_standard_derivatives\n\n #extension GL_OES_standard_derivatives : enable\n\n #define support_standard_derivatives 1\n\n#endif\n\n#ifdef GL_EXT_shader_texture_lod\n\n #extension GL_EXT_shader_texture_lod : enable\n\n #define support_shader_texture_lod 1\n\n#endif\n\n\n\nprecision highp float;\n\n\n\n#include <gl2_frag>\n\n\n\n#if __VERSION__ == 300\n\n #define support_standard_derivatives 1\n\n #define support_shader_texture_lod 1\n\n#endif\n\n\n\n uniform vec3 czm_lightDirectionEC;\n\n uniform vec4 uDiffuseColor;\n\n#ifdef TexCoord\n\n varying vec4 vTexCoord;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform sampler2D uTexture;\n\n uniform highp float uTexture0Width;\n\n varying vec4 vTexCoordTransform;\n\n varying vec4 vTexMatrix;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n varying vec4 vColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n#ifdef TexCoord2\n\n uniform sampler2D uTexture2;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef COMPUTE_TEXCOORD\n\n void calculateMipLevel(in vec2 inTexCoord, in float vecTile, in float fMaxMip, inout float mipLevel)\n\n {\n\n vec2 dx = dFdx(inTexCoord * vecTile);\n\n vec2 dy = dFdy(inTexCoord * vecTile);\n\n float dotX = dot(dx, dx);\n\n float dotY = dot(dy, dy);\n\n float dMax = max(dotX, dotY);\n\n float dMin = min(dotX, dotY);\n\n float offset = (dMax - dMin) / (dMax + dMin);\n\n offset = clamp(offset, 0.0, 1.0);\n\n float d = dMax * (1.0 - offset) + dMin * offset;\n\n mipLevel = 0.5 * log2(d);\n\n mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);\n\n }\n\n\n\n void calculateTexCoord(in vec3 inTexCoord, in float scale, in float XTran, in float YTran, in float fTile, in float mipLevel, inout vec2 outTexCoord)\n\n {\n\n if(inTexCoord.z < -9000.0)\n\n {\n\n outTexCoord = inTexCoord.xy;\n\n }\n\n else\n\n {\n\n vec2 fTexCoord = fract(inTexCoord.xy);\n\n float offset = 1.0 * pow(2.0, mipLevel) / fTile;\n\n fTexCoord = clamp(fTexCoord, offset, 1.0 - offset);\n\n outTexCoord.x = (fTexCoord.x + XTran) * scale;\n\n outTexCoord.y = (fTexCoord.y + YTran) * scale;\n\n }\n\n }\n\n\n\n vec4 getTexColorForS3M(sampler2D curTexture, vec3 oriTexCoord, float texTileWidth, float fMaxMipLev, float fTexCoordScale, vec2 vecTexCoordTranslate, float isRGBA)\n\n {\n\n vec4 color = vec4(1.0);\n\n float mipLevel = 0.0;\n\n #ifdef support_standard_derivatives\n\n calculateMipLevel(oriTexCoord.xy, texTileWidth, fMaxMipLev, mipLevel);\n\n #endif\n\n vec2 realTexCoord;\n\n calculateTexCoord(oriTexCoord, fTexCoordScale, vecTexCoordTranslate.x, vecTexCoordTranslate.y, texTileWidth, mipLevel, realTexCoord);\n\n if(isRGBA > 0.5)\n\n {\n\n vec2 rgbTexCoord;\n\n rgbTexCoord.x = (realTexCoord.x + vecTexCoordTranslate.x * fTexCoordScale) * 0.5;\n\n rgbTexCoord.y = (realTexCoord.y + vecTexCoordTranslate.y * fTexCoordScale) * 0.5;\n\n color = texture2D(curTexture, rgbTexCoord.xy, -10.0);\n\n vec2 vecAlphaTexCoord;\n\n vecAlphaTexCoord.x = rgbTexCoord.x;\n\n vecAlphaTexCoord.y = rgbTexCoord.y + fTexCoordScale * 0.5;\n\n color.a = texture2D(curTexture, vecAlphaTexCoord.xy, -10.0).r;\n\n }\n\n else\n\n {\n\n if(oriTexCoord.z < -9000.0)\n\n {\n\n color = texture2D(curTexture, realTexCoord.xy);\n\n }\n\n else\n\n {\n\n #ifdef support_shader_texture_lod\n\n color = texture2DLodEXT(curTexture, realTexCoord.xy, mipLevel);\n\n #else\n\n color = texture2D(curTexture, realTexCoord.xy, mipLevel);\n\n #endif\n\n }\n\n }\n\n\n\n return color;\n\n }\n\n\n\n vec4 getTextureColor()\n\n {\n\n if(vTexMatrix.z < 0.0)\n\n {\n\n return vec4(1.0);\n\n }\n\n float texTileWidth0 = vTexMatrix.z * uTexture0Width;\n\n vec3 realTexCoord = vec3(vTexCoord.xy, vTexCoordTransform.x);\n\n vec4 FColor = getTexColorForS3M(uTexture, realTexCoord, texTileWidth0, vTexMatrix.w, vTexMatrix.z, vTexMatrix.xy, vIsRGBA.x);\n\n #ifdef TexCoord2\n\n float texTileWidth1 = vTexMatrix2.z * uTexture1Width;\n\n realTexCoord = vec3(vTexCoord.zw, vTexCoordTransform.y);\n\n vec4 SColor = getTexColorForS3M(uTexture2, realTexCoord, texTileWidth1, vTexMatrix2.w, vTexMatrix2.z, vTexMatrix2.xy, vIsRGBA.y);\n\n SColor.r = clamp(SColor.r, 0.0, 1.0);\n\n SColor.g = clamp(SColor.g, 0.0, 1.0);\n\n SColor.b = clamp(SColor.b, 0.0, 1.0);\n\n return FColor * SColor;\n\n #else\n\n return FColor;\n\n #endif\n\n }\n\n#endif\n\n vec4 SRGBtoLINEAR4(vec4 srgbIn)\n\n {\n\n #ifndef HDR\n\n vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));\n\n return vec4(linearOut, srgbIn.a);\n\n #else\n\n return srgbIn;\n\n #endif\n\n }\n\n vec3 LINEARtoSRGB(vec3 linearIn)\n\n {\n\n #ifndef HDR\n\n return pow(linearIn, vec3(1.0/2.2));\n\n #else\n\n return linearIn;\n\n #endif\n\n }\n\n\n\n vec3 computeNormal(in vec3 oriVertex)\n\n {\n\n vec3 normal = cross(vec3(dFdx(oriVertex.x), dFdx(oriVertex.y), dFdx(oriVertex.z)), vec3(dFdy(oriVertex.x), dFdy(oriVertex.y), dFdy(oriVertex.z)));\n\n normal = normalize(normal);\n\n return normal;\n\n }\n\n\n\n void main()\n\n {\n\n if(vColor.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec4 baseColorWithAlpha = vColor;\n\n #ifdef COMPUTE_TEXCOORD\n\n baseColorWithAlpha *= SRGBtoLINEAR4(getTextureColor());\n\n #endif\n\n\n\n if(baseColorWithAlpha.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec3 normal = vec3(0.0);\n\n #ifdef VertexNormal\n\n normal = normalize(vNormalEC);\n\n #endif\n\n normal = length(normal) > 0.1 ? normal : computeNormal(vPositionMC.xyz);\n\n vec3 color = baseColorWithAlpha.rgb;\n\n vec3 dirVectorEC = normalize(czm_lightDirectionEC);\n\n float dotProduct = dot( normal, dirVectorEC );\n\n float dirDiffuseWeight = max( dotProduct, 0.0 );\n\n dirDiffuseWeight = dirDiffuseWeight * 0.5 + 0.5;\n\n color += color * uDiffuseColor.rgb * dirDiffuseWeight;\n\n #ifdef TexCoord\n\n color = LINEARtoSRGB(color);\n\n #endif\n\n glFragColor = vec4(color, baseColorWithAlpha.a);\n\n#if __VERSION__ == 100\n\n gl_FragColor = glFragColor;\n\n#endif\n\n }\n\n"}],"techniques":[{"attributes":{"aPosition":{"semantic":"POSITION","type":35666},"instanceId":{"semantic":"instanceId","type":5126},"batchId":{"semantic":"_BATCHID","type":5126},"aTexCoord0":{"semantic":"TEXCOORD_0","type":35664},"aTexCoord1":{"semantic":"aTexCoord1","type":35666},"aNormal":{"semantic":"aNormal","type":35665},"aColor":{"semantic":"COLOR_0","type":35666},"uv2":{"semantic":"uv2","type":35666},"uv3":{"semantic":"uv3","type":35666},"uv4":{"semantic":"uv4","type":35666},"secondary_colour":{"semantic":"secondary_colour","type":35666},"uv6":{"semantic":"uv6","type":35666},"TextureCoordMatrix":{"semantic":"TextureCoordMatrix","type":35664}},"program":0,"uniforms":{"czm_modelView":{"type":35676,"semantic":"MODELVIEW"},"czm_normal":{"type":35675,"semantic":"MODELINVERSETRANSPOSE"},"czm_modelViewProjection":{"type":35676,"semantic":"MODELVIEWPROJECTION"},"uTexMatrix":{"type":35676},"uTexture0Width":{"type":5126},"uFillForeColor":{"type":35666},"uSelectedColor":{"type":35666},"uDiffuseColor":{"type":35666},"uTexture":{"type":35678},"uTexture2":{"type":35678},"uTexture1Width":{"type":5126}}}]};const{getTextureMagFilter:Bn,getTextureMinFilter:Cn,getTextureWrap:Tn,getMaterialType:mn,getMaterialFormat:gn,getPrimitive:pn,getUniqueREGLBuffer:yn}=n.REGLHelper,Rn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],In=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:bn,logoutIBLResOnCanvas:xn,getIBLResOnCanvas:Mn,getPBRUniforms:Pn}=n.pbr.PBRUtils,Nn={factor:0,units:0},Dn={specularStrength:0,materialShininess:1},Sn=[1,1,1],On=r.identity([]),Ln=t=>t.material instanceof n.PhongMaterial,Fn=t=>t.material instanceof n.pbr.StandardMaterial,wn=[!0,!0,!0,!0],vn=[],Un=new t.Coordinate(0,0),Gn=new t.Point(0,0),Hn=new t.Point(0,0),Vn=new t.Point(0,0),Kn=[],kn=[],Xn=[],zn=[],Yn={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"};class Jn{constructor(e,r){this.q=r,this.$=r.getRenderer().canvas,this.pickingFBO=r.getRenderer().pickingFBO,this.tt=new t.SpatialReference,this.et=e,this.nt=new n.Renderer(e),this.rt={},this.it={},this.ot={},this.st={},this.ct={},this.At={},this.lt={},this.ft=new n.Scene,this.ht=new n.Scene,this.ut=new n.Scene,this.Et=new n.Scene,this.dt=new n.ResourceLoader(e.texture(2)),this._t=this.Bt.bind(this),this.Ct=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.Tt(),this.gt=new n.KHRTechniquesWebglManager(this.et,this.pt(),this.dt);const i=this.getMap();i.altitudeToPoint&&(this.yt=i.altitudeToPoint(100,i.getGLRes())/100)}getI3DMMeshes(){return this.ct}getPNTSMeshes(){return this.st}getB3DMMeshes(){return this.ot}getPaintedMeshes(){return this.Rt}getMap(){return this.q.getMap()}paint(t,e,n){const r=n&&n.renderTarget,o=n&&n.sceneFilter,s=this.getMap();if(!t.length||!s)return null;const a=this.It(),c=s.projViewMatrix,A=this.q.options.services,l=[],f=[],h=[],u=[],E=[],d=this.bt(t);for(let r=0,o=t.length;r<o;r++){const o=t[r].data.node;let s=this.xt(o);if(!s)continue;this.At[o.id]&&(s=this.At[o.id],s=O(s));let a=A[o.Mt].polygonOffset||Nn;y(a)&&(a=a()),Array.isArray(s)||(l[0]=s,s=l);for(let t=0,r=s.length;t<r;t++){const r=s[t].properties.magic;if("b3dm"===r){if(s[t].getBoundingBox&&!_(c,s[t].getBoundingBox()))continue;const{batchIdData:e,batchIdMap:r}=s[t].geometry.properties;if(e&&r){const e=s[t].properties.node.Mt;this.Pt&&this.Pt[e]&&i.highlightMesh(this.et,s[t],this.Pt[e],this.Nt,r),i.showOnly(this.et,s[t],this.Dt&&this.Dt[e],this.St,r)}n&&n.bloom&&s[t].properties.hlBloomMesh&&(s[t].properties.hlBloomMesh.properties.depthFunc="always",s[t].properties.hlBloomMesh.properties.polygonOffset=a,h.push(s[t].properties.hlBloomMesh)),h.push(s[t])}else"pnts"===r?u.push(s[t]):"i3dm"===r&&E.push(s[t]);s[t].properties.isLeaf=!!e[o.id],s[t].properties.level=d.get(o.Ot),s[t].properties.polygonOffset=a,s[t].Lt=o,e[o.id]||f.push(s[t]),this.Ft(s[t])}}let B=0;const C=this.gt.getExcludeFilter();B+=this.wt(this.vt,a,[o,Ln,C],r,f,h,E),B+=this.wt(this.Ut,a,[o,Fn,C],r,f,h,E),this.gt.forEachShader((t,e,n)=>{const i=this.It(n);B+=this.wt(t,i,[o,e],r,f,h,E)}),this.ht.setMeshes(u);const T=this.Gt();return B+=this.nt.render(this.Ht,T,this.ht,r&&r.fbo),this.Rt={pntsMeshes:u,i3dmMeshes:E,b3dmMeshes:h},B}wt(t,e,n,r,i,o,s){t.filter=n.filter(t=>!!t),e.debug=!1,e.stencilEnable=!0,e.debug=!1,e.cullFace="back",e.colorMask=wn;let a=0;return this.ft.setMeshes(o),a+=this.nt.render(t,e,this.ft,r&&r.fbo),e.stencilEnable=!0,this.ut.setMeshes(s),a+=this.nt.render(t,e,this.ut,r&&r.fbo),a}Vt(t,e){return e.Lt.Kt-t.Lt.Kt}paintRegion(t,e,n,r,i){const o=this.getMap();if(!t.length&&!e.length)return;const s=o.projViewMatrix,a=[];for(let n=0,r=(t=t.concat(e)).length;n<r;n++){const e=t[n].node,r=this.kt(e);r&&(r.getBoundingBox&&!_(s,r.getBoundingBox())||a.push(r))}this.Xt.filter=r,this.Et.setMeshes(a);const c=this.zt(n);this.nt.render(this.Xt,c,this.Et,i&&i.fbo)}deleteTile(t){const e=t.node.id;this.Yt(e)}Yt(t){const e=this.it[t];e&&(e.geometry.dispose(),e.dispose(),delete this.it[t]);const n=this.ot[t]||this.st[t]||this.ct[t]||this.At[t]||this.rt[t];this.At[t]?this.Jt(t):n&&(this.Zt(n),delete this.ot[t],delete this.st[t],delete this.ct[t],delete this.rt[t])}Jt(t){let e=this.At[t];e=O(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.Yt(n)}delete this.At[t]}Zt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.Zt(t[e]);else{i.showOnly(this.et,t),i.highlightMesh(this.et,t);const e=t.geometry.properties.url;if(e){const t=this.lt[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.lt[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.q;xn(t.getRenderer().canvas,t.getMap());for(const t in this.At)this.Jt(t);this.At={};for(const t in this.ot)this.Yt(t);this.ot={};for(const t in this.st)this.Yt(t);this.st={};for(const t in this.ct)this.Yt(t);this.ct={};for(const t in this.rt)this.Yt(t);this.rt={};for(const t in this.it)this.Yt(t);this.it={},this.vt&&(this.vt.dispose(),delete this.vt),this.Ut&&(this.Ut.dispose(),delete this.Ut),this.Ht&&(this.Ht.dispose(),delete this.Ht),this.Xt&&(this.Xt.dispose(),delete this.Xt),this.gt.dispose(),this.picking&&this.picking.dispose()}kt(e){if(!e.boundingVolume||!e.boundingVolume.region)return null;if(this.it[e.id])return this.it[e.id];const i=e.boundingVolume.region;let o=new t.Coordinate(x(i[0]),x(i[1])),s=new t.Coordinate(x(i[2]),x(i[3]));o=this.Wt(o),s=this.Wt(s);const a=o.add(s).jt(.5);o._sub(a),s._sub(a);const c=this.Qt(i[4],i[5]),A=c.x,l=c.y,f=[o.x,o.y,l,s.x,o.y,l,s.x,s.y,l,o.x,s.y,l,o.x,o.y,A,s.x,o.y,A,s.x,s.y,A,o.x,s.y,A],h=new n.Geometry({aPosition:f},[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],0,{primitive:"lines"});h.generateBuffers(this.et);const u=new n.Mesh(h),E=r.identity([]);return u.setLocalTransform(r.translate(E,E,[a.x,a.y,0])),this.it[e.id]=u,u}xt(t){return this.ot[t.id]||this.st[t.id]||this.ct[t.id]||this.At[t.id]}has(t){return this.xt(t)||this.rt[t.id]}createPntsMesh(t,e,i,o){if(this.st[e]){const t=this.st[e];return console.warn(`pnts mesh with id(${e}) was already created.`),o(null,{id:e,mesh:t}),t}const{pnts:s,featureTable:a,rootIdx:c}=t,A=this.q.options.services[c],l=a.POINTS_LENGTH,f=new n.Geometry(s,null,l,{primitive:"points",positionAttribute:"POSITION"});f.generateBuffers(this.et);const h={};s.POSITION?h.HAS_POSITION=1:s.POSITION_QUANTIZED&&(h.HAS_POSITION_QUANTIZED=1),s.RGB?h.HAS_RGB=1:s.RGBA?h.HAS_RGBA=1:s.RGB565&&(h.HAS_RGB565=1),(s.NORMAL||s.NORMAL_OCT16P)&&(h.HAS_NORMAL=1,s.NORMAL_OCT16P&&(h.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map(t=>t/255));const{rtcCenter:u,rtcCoord:E}=t,d=this.qt(Xn,E),_=this.$t([],i,u,E);r.multiply(_,_,d);const B=this.q.options.services[c],C=new n.Mesh(f);if(C.properties.magic="pnts",C.properties.id=e,C.properties.node=i,C.properties.count=l,C.properties.batchTable=t.batchTable,C.properties.batchTableBin=t.batchTableBin,C.properties.serviceIndex=c,C.setDefines(h),Object.defineProperty(C.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:B&&B.pointColor||[1,1,1,1]}}),Object.defineProperty(C.uniforms,"pointSize",{enumerable:!0,get:function(){return B&&B.pointSize||2}}),Object.defineProperty(C.uniforms,"pointOpacity",{enumerable:!0,get:function(){return B&&B.pointOpacity||1}}),A.coordOffset){const t=this.te(i.Mt,E);r.multiply(_,t,_)}return C.setLocalTransform(_),this.st[e]=C,o(null,{id:e,mesh:[C]}),[C]}createI3DMMesh(t,e,i,s){if(this.ct[e]){const t=this.ct[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.rt[e]||s(null,{id:e,mesh:t}),t}const a=this.q.options.services[i.Mt],A=this.ee(i.ne),{i3dm:l,featureTable:f,gltf:h,batchTable:u,batchTableBin:E,count:d}=t,_=f.INSTANCES_LENGTH,{rtcCenter:B,rtcCoord:C}=t,T=this.qt(Xn,C),m=this.$t(zn,i,B,C);r.multiply(T,m,T);const{POSITION:g,NORMAL_UP:p,NORMAL_RIGHT:y,SCALE:R,SCALE_NON_UNIFORM:I,INSTANCE_ROTATION:b}=l,x={"instance_vectorA":new Float32Array(4*_),"instance_vectorB":new Float32Array(4*_),"instance_vectorC":new Float32Array(4*_)},M=new Float32Array(3),P=new Float32Array(3),N=[],D=new Float32Array(1),O=new Float32Array(3),L=[],F=[],w=[],v=[],U=new Float32Array(9);!function(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:o,itemSize:s}=t,a=t.array.buffer,c=o?Zt.getTypedArrayCtor(o):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/s,(!r||r===s*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*s);for(let r=0;r<i*s;r+=s){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,s),r/s)}return}const A=new Uint8Array(s*c.BYTES_PER_ELEMENT);r||(r=s*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const i=new Uint8Array(a,r*t+n,s*c.BYTES_PER_ELEMENT);A.set(i);e(new c(A.buffer),t),i.set(A)}}(g,(t,e)=>{p?(Ee(P,y,e),Ee(M,p,e),o.cross(N,P,M),o.normalize(N,N),S(L,P,0),S(L,M,1),S(L,N,2),c.fromMat3(F,L)):b?(Ee(U,b,e),c.fromMat3(F,U)):c.identity(F),R?(Ee(D,R,e),o.set(w,D[0],D[0],D[0])):I?(Ee(O,I,e),o.set(w,...O)):o.set(w,1,1,1),r.fromRotationTranslationScale(v,F,t,w),de(x.instance_vectorA,e,v,0),de(x.instance_vectorB,e,v,1),de(x.instance_vectorC,e,v,2)});const G={};for(const t in x)G[t]={buffer:this.et.buffer({dimension:x[t].length/_,data:x[t]}),divisor:1};const H=a.shader||"phong";let V=0,K=!0;const k=[];return se(h,(t,o,s,c)=>{const{geometry:l,material:f}=this.re(t,o,s,c,i,!0,H);f&&!f.isReady()&&(K=!1,V++);const h=new n.InstancedMesh(G,_,l,f);h.properties.magic="i3dm",h.properties.id=e,h.properties.count=d,h.properties.batchTable=u,h.properties.batchTableBin=E,h.properties.serviceIndex=i.Mt;const B=this.ie(t,l,f,i.Mt,c);this.oe(h,t.attributes);const m=r.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(m,m,t.matrices[e]);let g;if(r.multiply(m,A,m),h.setPositionMatrix(m),a.coordOffset){const t=this.te(i.Mt,C);g=r.multiply([],t,T)}else g=r.copy([],T);h.setLocalTransform(g),h.setDefines(B),h.properties.polygonOffset={offset:0,factor:0},k.push(h),delete t.attributes}),K?(this.ct[e]=k,s(null,{id:e,mesh:k})):(this.rt[e]={meshes:k,count:V},k.se=s),k}createB3DMMesh(e,i,o,s){if(this.ot[i]||this.rt[i]){const t=this.ot[i];return console.warn(`mesh with id(${i}) was already created.`),this.rt[i]||s(null,{id:i,mesh:t}),t}let a;if(o.maxExtent){const e=new t.Extent(o.maxExtent).convertTo(t=>this._pointToPrj(t));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=e.gltf,{projCenter:A}=c.extensions.MAPTALKS_RTC,{rtcCoord:l,center:f}=c.extensions.CESIUM_RTC,h=this.ee(o.ne);let u;u=c.asset&&c.asset.sharePosition?this.qt(Xn,l):this.ae(Xn,l,A,o.Mt);const E=this.q.options.services[o.Mt];let d=E.shader||"pbr";if(c.materials)for(let t=0;t<c.materials.length;t++)if(c.materials[t]&&c.materials[t].extensions&&c.materials[t].extensions.KHR_materials_unlit){d=E.shader="phong";break}const _=[];let B=0,C=!0;return se(c,(t,s,c,A)=>{const{geometry:T,material:m}=this.re(t,s,c,A,o,!1,d);m&&!m.isReady()&&(C=!1,B++);const g=new n.Mesh(T,m);g.properties.magic="b3dm",g.properties.id=i,g.properties.node=o,g.properties.batchTable=e.batchTable,g.properties.batchTableBin=e.batchTableBin,g.properties.count=e.featureTable.BATCH_LENGTH,g.properties.serviceIndex=o.Mt;const p=this.ie(t,T,m,o.Mt,A);g.setDefines(p);const y=t.compressUniforms;if(y)for(const t in y)g.setUniform(t,y[t]);this.oe(g,t.attributes),a&&(p.USE_MAX_EXTENT=1,g.setUniform("maxPrjExtent",a)),Object.prototype.hasOwnProperty.call(g.uniforms,"polygonOpacity")||Object.defineProperty(g.uniforms,"polygonOpacity",{enumerable:!0,get:function(){return I(E.opacity)?E.opacity:1}});const R=r.identity([]);if(A.asset.sharePosition&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(R,R,t.matrices[e]);if(A.asset.sharePosition){const t=this.$t(zn,o,f,l);r.multiply(R,h,R),r.multiply(R,u,R),r.multiply(R,t,R)}else r.multiply(R,u,R);if(E.coordOffset){const t=this.te([],o.Mt,l);r.multiply(R,t,R)}g.setLocalTransform(R),_.push(g),delete t.attributes}),C?(this.ot[i]=_,s(null,{id:i,mesh:_})):(this.rt[i]={meshes:_,count:B},_.se=s),_}oe(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}$t(e,n,i,s){const a=this.getMap(),c=this.q.options.services[n.Mt].heightOffset||0,A=new t.Coordinate(s);let l;l=a.altitudeToPoint?this.yt:a.distanceToPointAtRes(100,100,a.getGLRes(),A).y/100;const f=n.matrix?r.copy(e,n.matrix):r.identity(e);if(i){rn(f,o.transformMat4(vn,i,f),f)}const h=function(t,e,n,r,i,o,s){e=Z(sn,e);const a=Te(sn,e[0]*dn,e[1]*dn,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(an,n),A=r.ellipsoid;let l;l=0===ot(c)?W(cn,0,0,-6378137):Ie(cn,c),un.x=l[0],un.y=l[1];const f=r.project(un,En);An[0]=f.x/i,An[1]=f.y/i,An[2]=(l[2]+s)*o;const h=on(a,A,ln),u=function(t,e,n){const r=t[0],i=t[1],o=t[2],s=t[4],a=t[5],c=t[6],A=t[8],l=t[9],f=t[10],h=e[0],u=e[1],E=e[2],d=e[3],_=e[4],B=e[5],C=e[6],T=e[7],m=e[8],g=r*h+s*u+A*E,p=i*h+a*u+l*E,y=o*h+c*u+f*E,R=r*d+s*_+A*B,I=i*d+a*_+l*B,b=o*d+c*_+f*B,x=r*C+s*T+A*m,M=i*C+a*T+l*m,P=o*C+c*T+f*m;return n[0]=g,n[1]=p,n[2]=y,n[3]=0,n[4]=R,n[5]=I,n[6]=b,n[7]=0,n[8]=x,n[9]=M,n[10]=P,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],s=e[4],a=e[5],c=e[6],A=e[7],l=e[8],f=e[9],h=e[10],u=e[11],E=e[12],d=e[13],_=e[14],B=e[15],C=n*a-r*s,T=n*c-i*s,m=n*A-o*s,g=r*c-i*a,p=r*A-o*a,y=i*A-o*c,R=l*d-f*E,I=l*_-h*E,b=l*B-u*E,x=f*_-h*d,M=f*B-u*d,P=h*B-u*_,N=C*P-T*M+m*x+g*b-p*I+y*R;return N?(N=1/N,t[0]=(a*P-c*M+A*x)*N,t[1]=(i*M-r*P-o*x)*N,t[2]=(d*y-_*p+B*g)*N,t[3]=(h*p-f*y-u*g)*N,t[4]=(c*b-s*P-A*I)*N,t[5]=(n*P-i*b+o*I)*N,t[6]=(_*m-E*y-B*T)*N,t[7]=(l*y-h*m+u*T)*N,t[8]=(s*M-a*b+A*R)*N,t[9]=(r*b-n*M-o*R)*N,t[10]=(E*p-d*m+B*C)*N,t[11]=(f*m-l*p-u*C)*N,t[12]=(a*I-s*x-c*R)*N,t[13]=(n*x-r*I+i*R)*N,t[14]=(d*T-E*g-_*C)*N,t[15]=(l*g-f*T+h*C)*N,t):null}(fn,h),function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(hn,n),t);return rn(t,An,u),t}(f,s,f,a.getProjection(),a.getGLRes(),l,c),u=function(t,e){return W(t,e[12],e[13],e[14]),t}(kn,h);let E=this.q.options.offset;if(y(E)){E=E(this.q.ce(n.id).center)}return o.set(Kn,E[0],E[1],0),o.sub(u,u,Kn),rn(h,u,h),h}te(t,e,n){const i=this.q.options.services[e];if(!i.coordOffset)return null;const s=this.getMap(),a=s.getGLRes();Un.set(n[0],n[1]);const c=s.coordToPointAtRes(Un,a,Hn),A=i.coordOffset,l=Un.set(n[0]+A[0],n[1]+A[1]),f=s.coordToPointAtRes(l,a,Vn),h=f.x-c.x,u=f.y-c.y,E=this.Ae(),d=o.set(Kn,h,u,(A[2]||0)*E);return r.fromTranslation(t,d)}Ae(){const t=this.getMap();let e;return e=t.altitudeToPoint?this.yt:t.distanceToPointAtRes(100,100,t.getGLRes(),Un).y/100,e}createCMPTMesh(t,e,n,r){if(this.At[e]){const t=this.At[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:i}=t,o=[];for(let t=0;t<i.length;t++){const{magic:r}=i[t],s=e+"."+t;"b3dm"===r?this.createB3DMMesh(i[t],s,n,(t,{mesh:e})=>{o.push(e)}):"i3dm"===r?this.createI3DMMesh(i[t],s,n,(t,{mesh:e})=>{o.push(e)}):"pnts"===r?this.createPntsMesh(i[t],s,n,(t,{mesh:e})=>{o.push(e)}):"cmpt"===r&&this.createCMPTMesh(i[t],s,n,(t,{mesh:e})=>{o.push(e)})}return this.At[e]=o,r(null,{id:e,mesh:o}),o}ie(t,e,n,r,i){const o=("phong"===(this.q.options.services[r].shader||"phong")?this.vt:this.Ut).getGeometryDefines(e);i.asset&&"S3M"===i.asset.generator&&this.le(o,e),e.data.uvRegion&&(o.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(o.VertexNormal=1),e.data[e.desc.color0Attribute]&&(o.VertexColor=1),e.data[e.desc.uv0Attribute]&&(o.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(o.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(o.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(o.TexCoord2=1),"MESHOPT"===this.q.fe&&(o.MeshOPT_Compress=1),this.hasIBL()&&(o.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(o.HAS_WEB3D_quantized_attributes_TEXCOORD=1);return p(o,t.compressDefines),o}Ft(t){const e=this.q.getRenderer();e&&e.updateMaskDefines(t)}le(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}re(t,e,n,r,i,o,s){let a=!1;r.asset&&"S3M"===r.asset.generator&&(a=!0,r.extensions=r.extensions||{},r.extensions.KHR_techniques_webgl=function(t){if(3===t){const t=JSON.parse(JSON.stringify(_n));return t.shaders[0].content="precision highp float;\n\n#include <gl2_vert>\n\n attribute vec4 aPosition;\n\n#ifdef VertexColor\n\n attribute vec4 aColor0;\n\n#endif\n\n#ifdef VertexNormal\n\n attribute vec3 aNormal;\n\n#endif\n\n#ifdef Instance\n\n attribute float instanceId;\n\n#else\n\n attribute float batchId;\n\n#endif \n\n\n\n#ifdef HAS_VertexWeight\n\n attribute float aVertexWeight;\n\n#endif\n\n\n\n#ifdef HAS_TextureCoordMatrix\n\n attribute vec2 aTextureCoordMatrix;\n\n#endif\n\n\n\n#ifdef TexCoord\n\n attribute vec4 aTexCoord;\n\n varying vec4 vTexCoord;\n\n uniform mat4 uTexMatrix;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform float uTexture0Width;\n\n varying vec4 vTexMatrix;\n\n varying vec4 vTexCoordTransform;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n#ifdef TexCoord2\n\n attribute vec4 aTexCoord1;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef InstanceBim\n\n attribute vec4 uv2;\n\n attribute vec4 uv3;\n\n attribute vec4 uv4;\n\n attribute vec4 secondary_colour;\n\n attribute vec4 uv6; \n\n#endif\n\n\n\n#ifdef InstancePipe\n\n attribute vec4 uv1;\n\n attribute vec4 uv2;\n\n attribute vec4 uv3;\n\n attribute vec4 uv4;\n\n attribute vec4 uv5;\n\n attribute vec4 uv6;\n\n attribute vec4 uv7;\n\n attribute vec4 secondary_colour;\n\n attribute vec4 uv9;\n\n#endif\n\n uniform vec4 uFillForeColor;\n\n uniform vec4 uSelectedColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n varying vec4 vColor;\n\n const float SHIFT_LEFT8 = 256.0;\n\n const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\n const float SHIFT_RIGHT4 = 1.0 / 16.0;\n\n const float SHIFT_LEFT4 = 16.0;\n\n void getTextureMatrixFromZValue(in float nZ, inout float XTran, inout float YTran, inout float scale, inout float isRGBA)\n\n {\n\n if(nZ <= 0.0)\n\n {\n\n return;\n\n }\n\n float nDel8 = floor(nZ * SHIFT_RIGHT8);\n\n float nDel16 = floor(nDel8 * SHIFT_RIGHT8);\n\n float nDel20 = floor(nDel16 * SHIFT_RIGHT4);\n\n isRGBA = floor(nDel20);\n\n YTran = nZ - nDel8 * SHIFT_LEFT8;\n\n XTran = nDel8 - nDel16 * SHIFT_LEFT8;\n\n float nLevel = nDel16 - nDel20 * SHIFT_LEFT4;\n\n scale = 1.0 / pow(2.0, nLevel);\n\n }\n\n \n\n void operation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor)\n\n {\n\n float right_2 = operationType.x * 0.5;\n\n float right_4 = right_2 * 0.5;\n\n float right_8 = right_4 * 0.5;\n\n float right_16 = right_8 * 0.5;\n\n float isSetColor = fract(right_2);\n\n if(isSetColor > 0.1)\n\n {\n\n vertexColor *= color;\n\n }\n\n float isPicked = fract(floor(right_2)* 0.5);\n\n if(isPicked > 0.1)\n\n {\n\n vertexColor *= selectedColor;\n\n }\n\n float isHide = fract(floor(right_4)* 0.5);\n\n if(isHide > 0.1)\n\n {\n\n vertexColor.a = 0.0;\n\n }\n\n }\n\n \n\n#ifdef COMPRESS_TEXCOORD\n\n#ifdef TexCoord\n\n uniform vec2 decode_texCoord0_min;\n\n#endif\n\n#ifdef TexCoord2\n\n uniform vec2 decode_texCoord1_min;\n\n#endif\n\n#ifdef MeshOPT_Compress\n\n uniform vec3 decode_texCoord0_vNormConstant;\n\n uniform vec3 decode_texCoord1_vNormConstant;\n\n#else\n\n uniform float decode_texCoord0_normConstant;\n\n uniform float decode_texCoord1_normConstant;\n\n#endif\n\n#endif\n\n\n\n#ifdef COMPRESS_VERTEX\n\n uniform vec4 decode_position_min;\n\n uniform float decode_position_normConstant;\n\n#endif\n\n\n\n#ifdef COMPRESS_NORMAL\n\n uniform float normal_rangeConstant;\n\n#endif\n\n\n\nuniform mat4 modelMatrix;\n\nuniform mat4 modelViewMatrix;\n\nuniform mat4 projMatrix;\n\nuniform mat3 modelNormalMatrix;\n\n\n\n\n\n\n\nfloat czm_signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n}\n\nvec2 czm_signNotZero(vec2 value) {\n\n return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));\n\n}\n\n\n\nvec3 czm_octDecode(vec2 encoded, float range) {\n\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n return vec3(0.0, 0.0, 0.0);\n\n }\n\n encoded = encoded / range * 2.0 - 1.0;\n\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n if (v.z < 0.0) {\n\n v.xy = (1.0 - abs(v.yx)) * czm_signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n}\n\n\n\nvec4 czm_updatePositionDepth(vec4 coords) {\n\n coords.z = clamp(coords.z / coords.w, -1.0, 1.0) * coords.w;\n\n return coords;\n\n}\n\n\n\nvoid main()\n\n{\n\n#ifdef COMPRESS_VERTEX\n\n vec4 vertexPos = vec4(1.0);\n\n vertexPos = vec4(aPosition.xyz, 1.0);\n\n#else\n\n vec4 vertexPos = aPosition;\n\n#endif\n\n#ifdef TexCoord\n\n\n\n#ifdef COMPRESS_TEXCOORD\n\n#ifdef MeshOPT_Compress\n\n vec2 texCoord0;\n\n texCoord0.x = aTexCoord.x * decode_texCoord0_vNormConstant.x;\n\n texCoord0.y = aTexCoord.y * decode_texCoord0_vNormConstant.y;\n\n vTexCoord.xy = decode_texCoord0_min + texCoord0.xy;\n\n#else\n\n vTexCoord.xy = decode_texCoord0_min.xy + aTexCoord.xy * decode_texCoord0_normConstant;\n\n#endif\n\n#else\n\n vTexCoord.xy = aTexCoord.xy;\n\n#endif\n\n\n\n#ifdef COMPUTE_TEXCOORD\n\n vTexMatrix = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.x = 0.0;\n\n vTexCoordTransform.x = aTexCoord.z;\n\n #ifdef HAS_TextureCoordMatrix\n\n vTexCoordTransform.x = aTextureCoordMatrix.x;\n\n #endif\n\n if(vTexCoordTransform.x < -90000.0)\n\n {\n\n vTexMatrix.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.x), vTexMatrix.x, vTexMatrix.y, vTexMatrix.z, vIsRGBA.x);\n\n vTexMatrix.w = log2(uTexture0Width * vTexMatrix.z);\n\n#endif\n\n#endif\n\n\n\n#ifdef TexCoord2\n\n\n\n #ifdef COMPRESS_TEXCOORD\n\n #ifdef MeshOPT_Compress\n\n vec2 texCoord1;\n\n texCoord1.x = aTexCoord1.x * decode_texCoord1_vNormConstant.x;\n\n texCoord1.y = aTexCoord1.y * decode_texCoord1_vNormConstant.y;\n\n vTexCoord.zw = decode_texCoord1_min + texCoord1.xy;\n\n #else\n\n vTexCoord.zw = decode_texCoord1_min.xy + aTexCoord1.xy * decode_texCoord1_normConstant;\n\n #endif\n\n #else\n\n vTexCoord.zw = aTexCoord1.xy;\n\n #endif\n\n\n\n vTexMatrix2 = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.y = 0.0;\n\n vTexCoordTransform.y = aTexCoord1.z;\n\n #ifdef HAS_TextureCoordMatrix\n\n vTexCoordTransform.y = aTextureCoordMatrix.y;\n\n #endif\n\n if(vTexCoordTransform.y < -90000.0)\n\n {\n\n vTexMatrix2.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.y), vTexMatrix2.x, vTexMatrix2.y, vTexMatrix2.z, vIsRGBA.y);\n\n vTexMatrix2.w = log2(uTexture1Width * vTexMatrix.z);\n\n#endif\n\n\n\n vec4 vertexColor = uFillForeColor;\n\n#ifdef VertexColor\n\n vertexColor *= aColor0 / 255.0;\n\n#endif\n\n#ifdef VertexNormal\n\n vec3 normal = aNormal;\n\n #ifdef COMPRESS_NORMAL\n\n #ifdef MeshOPT_Compress\n\n normal.x = aNormal.x / 127.0;\n\n normal.y = aNormal.y / 127.0;\n\n normal.z = 1.0 - abs(normal.x) - abs(normal.y);\n\n normal = normalize(normal);\n\n #else\n\n normal = czm_octDecode(aNormal.xy, normal_rangeConstant).zxy;\n\n #endif\n\n #endif\n\n#endif\n\n#ifdef InstanceBim\n\n mat4 worldMatrix;\n\n worldMatrix[0] = uv2;\n\n worldMatrix[1] = uv3;\n\n worldMatrix[2] = uv4;\n\n worldMatrix[3] = vec4(0, 0, 0, 1);\n\n vertexPos = vec4(vertexPos.xyz,1.0) * worldMatrix;\n\n vertexColor *= secondary_colour; \n\n#endif\n\n#ifdef InstancePipe\n\n mat4 worldMatrix;\n\n mat4 worldMatrix0;\n\n mat4 worldMatrix1;\n\n vec4 worldPos0;\n\n vec4 worldPos1;\n\n worldMatrix0[0] = uv1;\n\n worldMatrix0[1] = uv2;\n\n worldMatrix0[2] = uv3;\n\n worldMatrix0[3] = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n worldMatrix1[0] = uv4;\n\n worldMatrix1[1] = uv5;\n\n worldMatrix1[2] = uv6;\n\n worldMatrix1[3] = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n vec4 realVertex = vec4(vertexPos.xyz, 1.0);\n\n realVertex.x = realVertex.x * uv7.z;\n\n worldPos0 = realVertex * worldMatrix0;\n\n worldPos1 = realVertex * worldMatrix1;\n\n vertexColor *= secondary_colour; \n\n #ifdef TexCoord\n\n if(aTexCoord.y > 0.5)\n\n {\n\n vec4 tex4Vec = uTexMatrix * vec4(uv7.y, aTexCoord.x, 0.0, 1.0);\n\n vTexCoord.xy = tex4Vec.xy;\n\n vertexPos = worldPos1;\n\n worldMatrix = worldMatrix1;\n\n }\n\n else\n\n {\n\n vec4 tex4Vec = uTexMatrix * vec4(uv7.x, aTexCoord.x, 0.0, 1.0);\n\n vTexCoord.xy = tex4Vec.xy;\n\n vertexPos = worldPos0;\n\n worldMatrix = worldMatrix0;\n\n }\n\n #endif\n\n #ifdef VertexNormal\n\n normal.x = normal.x * uv7.z;\n\n #endif\n\n#endif\n\n#ifdef Instance \n\n float index = instanceId;\n\n#else\n\n float index = batchId;\n\n#endif \n\n vec4 positionMC = vec4(vertexPos.xyz, 1.0);\n\n vColor = vertexColor;\n\n#ifdef VertexNormal\n\n vNormalEC = modelNormalMatrix * normal;\n\n#endif\n\n vPositionMC = positionMC;\n\n vPositionEC = (modelViewMatrix * positionMC).xyz;\n\n gl_Position = projMatrix * modelViewMatrix * vec4(vertexPos.xyz, 1.0);\n\n}\n\n",t.shaders[1].content="#ifdef GL_OES_standard_derivatives\n\n #extension GL_OES_standard_derivatives : enable\n\n#endif\n\n#ifdef GL_EXT_shader_texture_lod\n\n #extension GL_EXT_shader_texture_lod : enable\n\n#endif\n\nprecision highp float;\n\n#include <gl2_frag>\n\n uniform vec4 uDiffuseColor;\n\n#ifdef TexCoord\n\n varying vec4 vTexCoord;\n\n #ifdef COMPUTE_TEXCOORD\n\n uniform sampler2D uTexture;\n\n uniform float uTexture0Width;\n\n varying vec4 vTexCoordTransform;\n\n varying vec4 vTexMatrix;\n\n varying vec2 vIsRGBA;\n\n #endif\n\n#endif\n\n\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n varying vec4 vColor;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n#ifdef TexCoord2\n\n uniform sampler2D uTexture2;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef COMPUTE_TEXCOORD\n\n void calculateMipLevel(in vec2 inTexCoord, in float vecTile, in float fMaxMip, inout float mipLevel)\n\n {\n\n vec2 dx = dFdx(inTexCoord * vecTile);\n\n vec2 dy = dFdy(inTexCoord * vecTile);\n\n float dotX = dot(dx, dx);\n\n float dotY = dot(dy, dy);\n\n float dMax = max(dotX, dotY);\n\n float dMin = min(dotX, dotY);\n\n float offset = (dMax - dMin) / (dMax + dMin);\n\n offset = clamp(offset, 0.0, 1.0);\n\n float d = dMax * (1.0 - offset) + dMin * offset;\n\n mipLevel = 0.5 * log2(d);\n\n mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);\n\n }\n\n \n\n void calculateTexCoord(in vec3 inTexCoord, in float scale, in float XTran, in float YTran, in float fTile, in float mipLevel, inout vec2 outTexCoord)\n\n {\n\n if(inTexCoord.z < -9000.0)\n\n {\n\n outTexCoord = inTexCoord.xy;\n\n }\n\n else\n\n {\n\n vec2 fTexCoord = fract(inTexCoord.xy);\n\n float offset = 1.0 * pow(2.0, mipLevel) / fTile;\n\n fTexCoord = clamp(fTexCoord, offset, 1.0 - offset);\n\n outTexCoord.x = (fTexCoord.x + XTran) * scale;\n\n outTexCoord.y = (fTexCoord.y + YTran) * scale;\n\n }\n\n }\n\n \n\n vec4 getTexColorForS3M(sampler2D curTexture, vec3 oriTexCoord, float texTileWidth, float fMaxMipLev, float fTexCoordScale, vec2 vecTexCoordTranslate, float isRGBA)\n\n {\n\n vec4 color = vec4(1.0);\n\n float mipLevel = 0.0;\n\n #ifdef GL_OES_standard_derivatives\n\n calculateMipLevel(oriTexCoord.xy, texTileWidth, fMaxMipLev, mipLevel);\n\n #endif\n\n vec2 realTexCoord;\n\n calculateTexCoord(oriTexCoord, fTexCoordScale, vecTexCoordTranslate.x, vecTexCoordTranslate.y, texTileWidth, mipLevel, realTexCoord);\n\n if(isRGBA > 0.5)\n\n {\n\n vec2 rgbTexCoord;\n\n rgbTexCoord.x = (realTexCoord.x + vecTexCoordTranslate.x * fTexCoordScale) * 0.5;\n\n rgbTexCoord.y = (realTexCoord.y + vecTexCoordTranslate.y * fTexCoordScale) * 0.5;\n\n color = texture2D(curTexture, rgbTexCoord.xy, -10.0);\n\n vec2 vecAlphaTexCoord;\n\n vecAlphaTexCoord.x = rgbTexCoord.x;\n\n vecAlphaTexCoord.y = rgbTexCoord.y + fTexCoordScale * 0.5;\n\n color.a = texture2D(curTexture, vecAlphaTexCoord.xy, -10.0).r;\n\n }\n\n else\n\n {\n\n if(oriTexCoord.z < -9000.0)\n\n {\n\n color = texture2D(curTexture, realTexCoord.xy);\n\n }\n\n else\n\n {\n\n #ifdef GL_EXT_shader_texture_lod\n\n color = texture2DLodEXT(curTexture, realTexCoord.xy, mipLevel);\n\n #else\n\n color = texture2D(curTexture, realTexCoord.xy, mipLevel);\n\n #endif\n\n }\n\n }\n\n \n\n return color;\n\n }\n\n \n\n vec4 getTextureColor()\n\n {\n\n if(vTexMatrix.z < 0.0)\n\n {\n\n return vec4(1.0);\n\n }\n\n float texTileWidth0 = vTexMatrix.z * uTexture0Width;\n\n vec3 realTexCoord = vec3(vTexCoord.xy, vTexCoordTransform.x);\n\n vec4 FColor = getTexColorForS3M(uTexture, realTexCoord, texTileWidth0, vTexMatrix.w, vTexMatrix.z, vTexMatrix.xy, vIsRGBA.x);\n\n #ifdef TexCoord2\n\n float texTileWidth1 = vTexMatrix2.z * uTexture1Width;\n\n realTexCoord = vec3(vTexCoord.zw, vTexCoordTransform.y);\n\n vec4 SColor = getTexColorForS3M(uTexture2, realTexCoord, texTileWidth1, vTexMatrix2.w, vTexMatrix2.z, vTexMatrix2.xy, vIsRGBA.y);\n\n SColor.r = clamp(SColor.r, 0.0, 1.0);\n\n SColor.g = clamp(SColor.g, 0.0, 1.0);\n\n SColor.b = clamp(SColor.b, 0.0, 1.0);\n\n return FColor * SColor;\n\n #else\n\n return FColor;\n\n #endif\n\n }\n\n#endif\n\n\n\n vec3 czm_acesTonemapping(vec3 color) {\n\n float g = 0.985;\n\n float a = 0.065;\n\n float b = 0.0001;\n\n float c = 0.433;\n\n float d = 0.238;\n\n\n\n color = (color * (color + a) - b) / (color * (g * color + c) + d);\n\n\n\n color = clamp(color, 0.0, 1.0);\n\n\n\n return color;\n\n }\n\n vec4 SRGBtoLINEAR4(vec4 srgbIn) {\n\n #ifndef HDR \n\n vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));\n\n return vec4(linearOut, srgbIn.a);\n\n #else\n\n return srgbIn;\n\n #endif\n\n }\n\n vec3 LINEARtoSRGB(vec3 linearIn) {\n\n #ifndef HDR \n\n return pow(linearIn, vec3(1.0/2.2));\n\n #else\n\n return linearIn;\n\n #endif\n\n }\n\n vec3 applyTonemapping(vec3 linearIn) {\n\n #ifndef HDR\n\n return czm_acesTonemapping(linearIn);\n\n #else\n\n return linearIn;\n\n #endif\n\n }\n\n \n\n vec3 computeNormal(in vec3 oriVertex)\n\n {\n\n vec3 normal = cross(vec3(dFdx(oriVertex.x), dFdx(oriVertex.y), dFdx(oriVertex.z)), vec3(dFdy(oriVertex.x), dFdy(oriVertex.y), dFdy(oriVertex.z)));\n\n normal = normalize(normal);\n\n return normal;\n\n }\n\n \n\n uniform vec3 light0_viewDirection;\n\n void main()\n\n {\n\n if(vColor.a < 0.1)\n\n {\n\n discard;\n\n } \n\n vec4 baseColorWithAlpha = vColor;\n\n #ifdef COMPUTE_TEXCOORD\n\n baseColorWithAlpha *= SRGBtoLINEAR4(getTextureColor());\n\n #endif\n\n \n\n if(baseColorWithAlpha.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec3 normal = vec3(0.0);\n\n #ifdef VertexNormal\n\n normal = normalize(vNormalEC);\n\n #endif\n\n normal = length(normal) > 0.1 ? normal : computeNormal(vPositionMC.xyz);\n\n vec3 color = baseColorWithAlpha.rgb;\n\n vec3 dirVectorEC = normalize(light0_viewDirection);\n\n float dotProduct = dot( normal, dirVectorEC );\n\n float dirDiffuseWeight = max( dotProduct, 0.0 );\n\n dirDiffuseWeight = dirDiffuseWeight * 0.5 + 0.5;\n\n color += color * uDiffuseColor.rgb * dirDiffuseWeight;\n\n #ifdef TexCoord\n\n color = LINEARtoSRGB(color);\n\n #endif\n\n glFragColor = vec4(color, baseColorWithAlpha.a);\n\n #if __VERSION__ == 100\n\n gl_FragColor = glFragColor;\n\n #endif\n\n}",t}return _n}(r.asset.s3mVersion));const c=r.url+"-"+e+"-"+n;if(this.lt[c])return this.lt[c].refCount++,this.lt[c];let A,l;const f=r.materials&&r.materials[t.material];if(r.extensions&&r.extensions.KHR_techniques_webgl&&f.extensions&&f.extensions.KHR_techniques_webgl){const e=this.he(t,r,o,a);A=e.material,l=e.geometry;this.q.options.services[i.Mt].fillEmptyDataInMissingAttribute&&(l.desc.fillEmptyDataInMissingAttribute=!0)}else{l=this.ue(t,o,Yn);const e=this.q.options.services[i.Mt],n=e.ambientLight;let a=e.environmentExposure;const c=e.material,f=this.getMap().getLightManager(),h=f&&f.getAmbientLight();if(n&&(!h||h.color)&&void 0===a){const t=h&&h.color?h.color[0]:.2;a=n[0]/t}A=this.Ee(t.material,r,s,c||Dn,a||1)}A&&!A.isReady()?A.de=i.id:A||(A=this.Ct);const h={refCount:1,geometry:l,material:A};return l.properties.url=c,this.lt[c]=h,h}he(t,e,n,r){const{geometry:i,material:o}=this.gt.createMesh(t,e,n,r);return{geometry:i,material:o}}ue(t,e,r){const i=t.attributes;let o=i._BATCHID&&i._BATCHID.array;if(o&&o.byteOffset&&(o=new o.constructor(o)),i.COLOR_0){const t=i.COLOR_0.array||i.COLOR_0;if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);i.COLOR_0.array?(i.COLOR_0.array=e,i.COLOR_0.componentType=5121):i.COLOR_0=e}}const s={};for(const t in i){const e=yn(this.et,i[t],{dimension:i[t].itemSize}),n=r[t]||t;s[n]={buffer:e},i[t].quantization&&(s[n].quantization=i[t].quantization),n===r.POSITION&&(s[n].array=i[t].array,s[n].min=i[t].min,s[n].max=i[t].max)}const a=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,c=new n.Geometry(s,a,0,{positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":pn(t.mode)});return o&&a&&(c.properties.batchIdData=o,c.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const i=e[r],o=t[i];let s=n.get(o);s||(s=[],n.set(o,s)),s.push(i)}return n}
18
+ let dt=0;function mt(t){return null==t}function pt(t){return!mt(t)}function yt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function bt(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+t)}function gt(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function Tt(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const wt=[],_t=[],At=[],Ot=[0,0,0],xt=ht([]),It=[1,1,1];function St(t,e,n,r,s,i,o){const a=bt(o);if((0===s||s===r*a.BYTES_PER_ELEMENT)&&i%a.BYTES_PER_ELEMENT==0){const s=new a(e,i,n*r);return t.set(s),t}0===s&&(s=r*a.BYTES_PER_ELEMENT);const c=new Uint8Array(r*a.BYTES_PER_ELEMENT);for(let o=0;o<n;o++){let n=null;const h=new Uint8Array(e,s*o+i,r*a.BYTES_PER_ELEMENT);c.set(h),n=new a(c.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const Mt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Et(t,e,n){const r=new Uint8Array(t,e,n);return Mt.decode(r)}const vt={get:function(t,e={}){e||(e={});const n=new AbortController,r=n.signal,s=yt({},e);s.signal=r,s.method||(s.method="GET");const i=fetch(t,s).then(t=>{const n=this.t(t,e.responseType);return n.message?n:n.then(n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t})}).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t});return i.xhr=n,i},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",vt.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?vt.jsonp(t):((e=e||{}).responseType="json",vt.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+dt++;t.match(/\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise(t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)})}};class Nt{constructor(t,e,n){this.s=t,this.decoders=e,this.i=n,this.images={},this.o={}}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.h(e,r);return this.getImageByBuffer(s,n)}if(this.o[t.id])return this.o[t.id].then(()=>{const r=this.buffers[t.id],s=this.h(e,r);return this.getImageByBuffer(s,n)});if(gt(t.uri)){const r=this.buffers[t.id]=Tt(t.uri),s=this.h(e,r);return this.getImageByBuffer(s,n)}return this.o[t.id]=vt.getArrayBuffer(t.uri,null).then(r=>{const s=this.buffers[t.id]=r.data,i=this.h(e,s);return this.getImageByBuffer(i,n)})}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;if(n[e.mimeType])return n[e.mimeType](t,{supportedFormats:this.i});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const n=new Blob([t],{type:e.mimeType}),r=URL.createObjectURL(n);return this.u(e.id,r)}}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.o[t.id]?this.o[t.id].then(()=>this.images[t.id]):this.o[t.id]=this.u(t.id,e)}u(t,e){return new Promise((n,r)=>{this.s(e,(s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))})})}}const Ct=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],Rt=[];class Bt{constructor(t,e,n){this.rootPath=t,this.gltf=e,this.l=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.m()}p(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.g(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this.T(s).then(n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this.g(t,e,s,i)})}T(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then(()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})});if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(gt(e.uri)){const t=this.buffers[e.id]=Tt(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=vt.getArrayBuffer(t,null).then(r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}g(t,e,n,r=0){const s=this.gltf,i=s.accessors[e],o=void 0!==i.bufferView?s.bufferViews[i.bufferView]:{},a=(o.byteOffset||0)+r,c=this._(i.type),h=bt(i.componentType),u=o.byteStride||0,f={array:void 0,name:t,accessorName:e,byteLength:i.count*c*h.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(f.min=i.min),i.max&&(f.max=i.max),n)if(this.l)f.byteStride=u,f.byteOffset=a+(i.byteOffset||0),!u||u===c*h.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(f.array=this.A(n,i.count,c,a+(i.byteOffset||0),h),f.array.buffer.byteLength===f.byteLength&&(f.byteOffset=0)):f.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){f.byteStride=0,f.byteOffset=0;const t=new h(i.count*c);if(f.array=St(t,n,i.count,c,u,a+(i.byteOffset||0),i.componentType),f.extensions&&f.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(f.array.length),{decodeMatrix:e}=f.extensions.WEB3D_quantized_attributes;for(let n=0;n<f.array.length;n+=c){Rt[0]=f.array[n],Rt[1]=f.array[n+1],Rt[2]=f.array[n+2],Rt[3]=1;const r=at(Rt,Rt,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}f.componentType=5126,f.array=t}}else f.byteStride=0,f.array=this.A(n,i.count,c,a+(i.byteOffset||0),h),f.byteOffset=f.array.byteOffset;else{f.array=new h(i.count);const t=f.min||f.max;t&&(f.array[0]=t[0],f.array[1]=t[1],f.array[2]=t[2])}return f}m(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}A(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}_(t){const e=Ct.indexOf(t);return Ct[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map(t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.T(e).then(r=>{const{buffer:s,byteOffset:i}=r,o=Et(s,i+(e.byteOffset||0),n);return t.content=o,t})}if(t.uri){if(gt(t.uri)){const e=Tt(t.uri),n=Et(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return vt.get(e).then(e=>(t.content=e,t))}}return Promise.resolve(t)});return Promise.all(n).then(()=>t)}}class Ut extends Nt{constructor(t,e,n,r,s,i){super(r,s,i),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new Bt(t,e,n)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(pt(t.name)&&(e.name=t.name),pt(t.children)&&(e.children=t.children),pt(t.jointName)&&(e.jointName=t.jointName),pt(t.matrix)&&(e.matrix=t.matrix),pt(t.rotation)&&(e.rotation=t.rotation),pt(t.scale)&&(e.scale=t.scale),pt(t.translation)&&(e.translation=t.translation),pt(t.extras)&&(e.extras=t.extras),pt(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const n=G(wt,e.translation||Ot),r=z(_t,e.rotation||xt),s=j(At,e.scale||It);return H(s,r,s),H(t,n,s)}return V(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}O(t){const e={};for(const n in t){const r=t[n];let s,i;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,i=s.values.diffuse):(s=r,i=s.values.tex||s.values.diffuseTex||s.values.diffuse);const o={baseColorTexture:{index:i}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}I(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}S(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.I(n).then(t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}})}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}class Pt extends Nt{constructor(t,e,n,r,s,i){super(r,s,i),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new Bt(t,e,n)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return yt(e,t),!pt(t.weights)&&this.gltf.meshes&&pt(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}S(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!pt(n))return null;const r=this.gltf.images[n];return this.I(r).then(t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};yt(n,e);const s=pt(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||9729,n.sampler.minFilter=s.minFilter||9729,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),t.format&&(n.format=t.format),n})}I(t){if(!pt(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.M(e,t)}return null}M(t,e){const n=this.h(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}h(t,e,n){n=n||0;const r=t.byteOffset+n,s=t.byteLength;return new Uint8Array(e,r,s)}v(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);return n.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)))}getAnimations(t){const e=[];return t.forEach(t=>{e.push(this.getSamplers(t.samplers))}),Promise.all(e).then(e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t})}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(pt(t[n].input)||pt(t[n].output))&&(e.push(this.accessor.p("input",t[n].input)),e.push(this.accessor.p("output",t[n].output)));return Promise.all(e).then(e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t})}}const Lt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class Dt{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return Dt.readV1(r,e);if(2===s)return Dt.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const s=Ft(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=Ft(t,e+12+o,a);else if(5130562===c){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function Ft(t,e,n){if(Lt){const r=new Uint8Array(t,e,n);return Lt.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=kt[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const kt=[1,1,1,1,2,2,3,0],Vt=[0,0,0],Ht=[0,0,0,1],Gt=[1,1,1],jt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},zt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},qt={N(t,e,n,r,s,i,o,a){const c=pt(t)?e.animations:[e.animations[0]],h={};for(let e=0;e<c.length;e++){const u=c[e],f=u.name||e;if(pt(t)&&f!==t)continue;const l=u.channelsMap[n];if(l)for(let t=0;t<l.length;t++){const e=l[t];"translation"===e.target.path?(this.C(s,u.samplers[e.sampler],r,1),h.translation=$(Vt,s)):"rotation"===e.target.path?(this.R(i,u.samplers[e.sampler],r,1),h.rotation=lt(Ht,i)):"scale"===e.target.path?(this.C(o,u.samplers[e.sampler],r,1),h.scale=$(Gt,o)):"weights"===e.target.path&&a&&(this.C(a,u.samplers[e.sampler],r,a.length),h.weights=a)}}return h},C(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.B(zt,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.B(zt,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.B(zt,e,n,3*r);s&&(t=this.U(t,s,e.input.array,3*r));break}}return t},R(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.B(zt,e,n,1);r&&ut(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.B(zt,e,n,1);r&&(t=ot(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.B(zt,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.U(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},P(t,e){const n=t.length;let r,s,i,o=0,a=n-1,c=Math.floor((o+a)/2);for(;o<=n-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,i=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:i}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},B(t,e,n,r){const s=e.input.array,i=e.output.array,o=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.P(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:h,interpolation:u}=a;t.PREINDEX=c,t.NEXTINDEX=h,t.INTERPOLATION=u;const f=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*f,(t.PREINDEX+1)*f),t.NEXT=i.subarray(t.NEXTINDEX*f,(t.NEXTINDEX+1)*f),t},U(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],h=e.NEXT[3+n],u=(o-i)*e.NEXT[n],f=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*h+(Math.pow(s,3)-Math.pow(s,2))*u;t[n]=f}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return W(Vt,...jt.TRANSLATION),ot(Ht,...jt.ROTATION),W(Gt,...jt.SCALE),this.N(r,t,e,n,Vt,Ht,Gt,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach((e,n)=>{let r=-1/0,s=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const n=i[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<s&&(s=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:s}}),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?pt(e)?n[e]:n[Object.keys(n)[0]]:null}};let Xt=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Wn){}t&&"undefined"!=typeof createImageBitmap&&(Xt=!0)}const Kt="undefined"==typeof document?null:document.createElement("canvas");class $t{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=Dt.read(e.buffer,e.byteOffset,e.byteLength);this.L(t,n,r)}else this.L(t,e);this.D=new Bt(this.rootPath,this.gltf,this.glbBuffer),this.F()}F(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}k(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.D.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then(e=>(t.KHR_techniques_webgl=e,t)):Promise.resolve(t)}load(t){t=t||{};const e=this.V(t),n=this.H(),r=this.G(),s=this.k();return Promise.all([e,n,r,s]).then(t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0]))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return qt.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return qt.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return bt(t)}static readInterleavedArray(t,e,n,r,s,i,o){return St(t,e,n,r,s,i,o)}L(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=Xt?Zt.bind(this):this.options.requestImage||Wt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Pt(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate((t,e,n)=>{e.id="buffer_"+n},"buffers"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors")):(this.adapter=new Ut(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"))}j(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||function(t){return!mt(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const r=t.children.map(t=>{const n=e[t];return n.nodeIndex=t,this.j(n,e)});t.children=r}var n;return t}V(t){return this.q(t).then(t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.j(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate((r,s,i)=>{const o={};s.name&&(o.name=s.name),s.nodes&&(o.nodes=s.nodes.map(e=>t[e])),this.gltf.scene===r&&(n=i),e.push(o)},"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.O(this.gltf.materials);r.materials=t}return r})}q(t){return this.X(t).then(()=>{const t=this.nodes={};return this.adapter.iterate((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r},"nodes"),t})}K(){this.skins=[];const t=[];return this.adapter.iterate((e,n,r)=>{t.push(this.$(n).then(t=>{t.index=r,this.skins.push(t)}))},"skins"),t}$(t){const e=t.inverseBindMatrices;return this.adapter.accessor.p("inverseBindMatrices",e).then(e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t))}H(){const t=this.gltf.animations;return pt(t)?this.adapter.getAnimations(t):null}X(t){this.meshes={};let e=[];return this.adapter.iterate((n,r,s)=>{e.push(this.W(r,t).then(t=>{t.index=s,this.meshes[n]=t}))},"meshes"),e=e.concat(this.K()),Promise.all(e)}W(t,e){const n=t.primitives.map(t=>this.Y(t,e)).filter(t=>!!t);return Promise.all(n).then(e=>{const n={};return yt(n,t),n.primitives=e,n})}G(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.S(n));return Promise.all(e).then(e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t].image.array;if(e[t]&&n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e})}Y(t,e){let n;const r=[],s=t.extensions;if(pt(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.p(`morphTargets_${t}_${e}`,n[t]);s&&r.push(s)}}if(s&&s.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:i,attributes:o}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[i],c=this.D.T(a).then(n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const h=new DataView(r,s+i,c),u={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(h,u).then(t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e})});r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.p(t,e[t]);n&&r.push(n)}if(pt(t.indices)){const e=this.adapter.accessor.p("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then(e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const i={attributes:e.reduce((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,i=s.length/r;for(let e=0;e<i;e++)for(let i=0;i<r;i++){const o=e*r+i;s[o]<t[i]&&(t[i]=s[o]),s[o]>n[i]&&(n[i]=s[o])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),i=r.minValues;Q(t,t,s),Y(t,t,i),Q(n,n,s),Y(n,n,i)}e.min=t,e.max=n}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t},{}),material:t.material};return n&&(i.indices=n),r&&(i.morphTargets=r),i.mode=pt(t.mode)?t.mode:4,pt(t.extras)&&(i.extras=t.extras),i})}}function Wt(t,e){const n=new Image;n.crossOrigin="",n.onload=()=>{if(!Kt)return void e(new Error("There is no canvas to draw image!"));Kt.width=n.width,Kt.height=n.height;const t=Kt.getContext("2d",{willReadFrequently:!0});t.drawImage(n,0,0,n.width,n.height);const r=t.getImageData(0,0,n.width,n.height),s={width:n.width,height:n.height,data:new Uint8Array(r.data)};e(null,s)},n.onerror=function(t){e(t)},n.src=t}let Yt,Jt;function Zt(t,e){Yt||(Yt=new OffscreenCanvas(2,2),Jt=Yt.getContext("2d",{willReadFrequently:!0})),fetch(t).then(t=>t.arrayBuffer()).then(t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(t=>{let{width:n,height:r}=t;Qt(n)||(n=te(n)),Qt(r)||(r=te(r));const s=this.options.maxTextureSize;s&&(n=Math.min(s,n),r=Math.min(s,r)),Yt.width=n,Yt.height=r,Jt.drawImage(t,0,0,n,r),t.close();const i=Jt.getImageData(0,0,n,r);e(null,{width:n,height:r,data:new Uint8Array(i.data)})}).catch(t=>{console.warn(t),e(t)})}function Qt(t){return 0==(t&t-1)&&0!==t}function te(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const ee="undefined"==typeof document?null:document.createElement("canvas");class ne extends t.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const s={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(s,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!ee)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(re(t.width)&&re(t.height))return t;let e=t.width,n=t.height;re(e)||(e=se(e));re(n)||(n=se(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const s=t.src,i=s.lastIndexOf("/")+1,o=s.substring(i);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);ee.width=t.width,ee.height=t.height;const r=ee.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const s=r.getImageData(0,0,t.width,t.height),i={width:t.width,height:t.height,data:new Uint8Array(s.data)};e(null,i,[i.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function re(t){return 0==(t&t-1)&&0!==t}function se(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class ie{constructor(t,e){this.max=t,this.currentSize=0,this.onRemove=e,this.reset()}reset(){if(this.data){const t=this.data.values();for(const e of t)this.onRemove(e)}return this.data=new Map,this.currentSize=0,this}clear(){this.reset(),delete this.onRemove}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){if(!this.data.get(e.value).current){const t=this.getAndRemove(e.value);t&&this.onRemove(t)}e=t.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e),this}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t){const e=this.data.values();for(const n of e)n.current=t}}function oe(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];de(r[n],s,t,e)}}}const ae=[],ce=[],he=[],ue=[0,0,0],fe=ht([]),le=[1,1,1];function de(t,e,n,r){const s=e.slice(0);if(t.matrix)s.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=G(ae,t.translation||ue),n=z(ce,t.rotation||fe),r=j(he,t.scale||le);H(r,n,r);const i=H([],e,r);s.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)de(t.children[e],s,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=s.slice(0),o=i.primitives;for(let s=0,i=o.length;s<i;s++){const i=o[s];i&&(i.matrices=t,r(i,e,s,n))}}}}function me(t,e,n){let{byteOffset:r,byteStride:s}=e;const{componentType:i,itemSize:o}=e,a=e.array.buffer,c=i?$t.getTypedArrayCtor(i):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,s*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function pe(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}const ye=new Array(3),be=new Array(3),ge=[40680631590769,40680631590769,40408299984661.445];function Te(t,e,n,r){const s=ge,i=Math.cos(n);ye[0]=i*Math.cos(e),ye[1]=i*Math.sin(e),ye[2]=Math.sin(n),ve(ye,ye),Z(be,s,ye);const o=Math.sqrt(et(ye,be));var a,c,h;return c=be,h=o,(a=be)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,Q(ye,ye,r),Y(t,be,ye)}const we=[1/6378137,1/6378137,1/6356752.314245179],_e=[1/40680631590769,1/40680631590769,1/40408299984661.445],Ae=new Array(3),Oe=new Array(3),xe=new Array(3);function Ie(t,e){const n=_e,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],h=n[1],u=n[2],f=i*i*c*c,l=o*o*h*h,d=a*a*u*u,m=f+l+d,p=Math.sqrt(1/m),y=Q(Se,e,p);if(m<s)return isFinite(p)?y:void 0;const b=r[0],g=r[1],T=r[2],w=Me;w[0]=y[0]*b*2,w[1]=y[1]*g*2,w[2]=y[2]*T*2;let _,A,O,x,I,S,M,E,v,N,C,R=(1-p)*Ee(e)/(.5*Ee(w)),B=0;do{R-=B,O=1/(1+R*b),x=1/(1+R*g),I=1/(1+R*T),S=O*O,M=x*x,E=I*I,v=S*O,N=M*x,C=E*I,_=f*S+l*M+d*E-1,A=f*v*b+l*N*g+d*C*T;B=_/(-2*A)}while(Math.abs(_)>1e-12);return t[0]=i*O,t[1]=o*x,t[2]=a*I,t}(Ae,e,we,n,.1);let s=st(Oe,r,n);s=ve(s,s);const i=rt(xe,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=v(et(i,e))*Ee(i);return t[0]=M(o),t[1]=M(a),t[2]=c,t}const Se=new Array(3),Me=new Array(3);function Ee(t){return X(t)}function ve(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function Ne(t,e){return Z(e,t,_e),tt(e,e)}function Ce(t,e){const n=t[0],r=t[1],s=Math.cos(r),i=s*Math.cos(n),o=s*Math.sin(n),a=Math.sin(r);return e.x=i,e.y=o,e.z=a,tt(e,e)}var Re=Object.freeze({__proto__:null,radianToCartesian3:Te,cartesian3ToDegree:Ie,normalizeCartesian:ve,geodeticSurfaceNormal:Ne,geodeticSurfaceNormalCartographic:Ce});function Be(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function Ue(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Pe="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Le(t,e,n){const r=new Uint8Array(t,e,n);return Pe?JSON.parse(Pe.decode(r)):JSON.parse(C(r))}function De(t,e,n){const r=new Uint8Array(t,e,n);return Pe?JSON.parse(Pe.decode(r)):JSON.parse(C(r))}function Fe(t,e,n){return{offset:e,byteLength:n}}function ke(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=qe(i||"UNSIGNED_SHORT"),h=je(o);return{byteStride:0,byteOffset:s+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+s,r*h)}}function Ve(t,e,n,r){const s=ke(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function He(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=qe(i||"UNSIGNED_SHORT"),c=je(o),h=new a(e,s,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const Ge={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function je(t){return t?Ge[t]:1}const ze={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function qe(t){return ze[t]}function Xe(t){for(const e in ze)if(t===ze[e].ctor)return ze[e].type;throw new Error("unrecognized ctor:"+t)}function Ke(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function $e(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,h={},u={},f=null;r>0&&(h=Le(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(u=De(a,e,i),e+=i);const l=Fe(0,e,o);return f=a.slice(l.offset,l.offset+l.byteLength),n.push(f),{featureTable:h,featureTableBin:c,batchTable:u,batchTableBin:f}}const We={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"}},Ye={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Je={},Ze={east:[],north:[],up:[],west:[],south:[],down:[]};let Qe=[],tn=[],en=[];const nn=[0,0,0];function rn(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const sn=function(t,e){const n=We[t][e];let r;const s=t+e;return Je[s]?r=Je[s]:(r=function(r,s,i){if(function(t,e){var n=t[0],r=t[1],s=t[2],i=e[0],o=e[1],a=e[2];return Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}(r,nn))$(Qe,Ye[t]),$(tn,Ye[e]),$(en,Ye[n]);else if(Be(r[0],0,1e-14)&&Be(r[1],0,1e-14)){const s=v(r[2]);$(Qe,Ye[t]),"east"!==t&&"west"!==t&&Q(Qe,Qe,s),$(tn,Ye[e]),"east"!==e&&"west"!==e&&Q(tn,tn,s),$(en,Ye[n]),"east"!==n&&"west"!==n&&Q(en,en,s)}else{Ne(r,Ze.up);const s=Ze.up,i=Ze.east;i[0]=-r[1],i[1]=r[0],i[2]=0,tt(Ze.east,i),nt(Ze.north,s,i),Q(Ze.down,Ze.up,-1),Q(Ze.west,Ze.east,-1),Q(Ze.south,Ze.north,-1),Qe=Ze[t],tn=Ze[e],en=Ze[n]}return i[0]=Qe[0],i[1]=Qe[1],i[2]=Qe[2],i[3]=0,i[4]=tn[0],i[5]=tn[1],i[6]=tn[2],i[7]=0,i[8]=en[0],i[9]=en[1],i[10]=en[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},Je[s]=r),r}("east","north"),on=[],an=[],cn=[],hn=[],un=[],fn=[],ln=[],dn={x:0,y:0},mn={x:0,y:0},pn=Math.PI/180;const{getTextureMagFilter:yn,getTextureMinFilter:bn,getTextureWrap:gn,getMaterialType:Tn,getMaterialFormat:wn,getPrimitive:_n,getUniqueREGLBuffer:An}=n.REGLHelper,On=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],xn=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:In,logoutIBLResOnCanvas:Sn,getIBLResOnCanvas:Mn,getPBRUniforms:En}=n.pbr.PBRUtils,vn={factor:0,units:0},Nn={specularStrength:0,materialShininess:1},Cn=[1,1,1],Rn=r.identity([]),Bn=t=>t.material instanceof n.PhongMaterial,Un=t=>t.material instanceof n.pbr.StandardMaterial,Pn=[!0,!0,!0,!0],Ln=[],Dn=new t.Coordinate(0,0),Fn=new t.Point(0,0),kn=new t.Point(0,0),Vn=new t.Point(0,0),Hn=[],Gn=[],jn=[],zn=[],qn={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"};class Xn{constructor(e,r){this.J=r,this.Z=r.getRenderer().canvas,this.pickingFBO=r.getRenderer().pickingFBO,this.tt=new t.SpatialReference,this.et=e,this.nt=new n.Renderer(e),this.rt={},this.st={},this.it={},this.ot={},this.ct={},this.ht={},this.ut={},this.ft=new n.Scene,this.lt=new n.Scene,this.dt=new n.Scene,this.pt=new n.Scene,this.yt=new n.ResourceLoader(e.texture(2)),this.bt=this.gt.bind(this),this.Tt=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.wt(),this._t=new n.KHRTechniquesWebglManager(this.et,this.At(),this.yt);const s=this.getMap();s.altitudeToPoint&&(this.Ot=s.altitudeToPoint(100,s.getGLRes())/100)}getI3DMMeshes(){return this.ct}getPNTSMeshes(){return this.ot}getB3DMMeshes(){return this.it}getPaintedMeshes(){return this.xt}getMap(){return this.J.getMap()}paint(t,e,n){const r=n&&n.renderTarget,i=n&&n.sceneFilter,o=this.getMap();if(!t.length||!o)return null;const a=this.It(),c=o.projViewMatrix,h=this.J.options.services,u=[],f=[],l=[],d=[],m=[],p=this.St(t);for(let r=0,i=t.length;r<i;r++){const i=t[r].data.node;let o=this.Mt(i);if(!o)continue;this.ht[i.id]&&(o=this.ht[i.id],o=B(o));let a=h[i.Et].polygonOffset||vn;O(a)&&(a=a()),Array.isArray(o)||(u[0]=o,o=u);for(let t=0,r=o.length;t<r;t++){const r=o[t].properties.magic;if("b3dm"===r){if(o[t].getBoundingBox&&!y(c,o[t].getBoundingBox()))continue;const{batchIdData:e,batchIdMap:r}=o[t].geometry.properties;if(e&&r){const e=o[t].properties.node.Et;this.vt&&this.vt[e]?s.highlightMesh(this.et,o[t],this.vt[e],this.Nt,r):this.vt&&this.vt[e]||s.highlightMesh(this.et,o[t],null,this.Nt,r),s.showOnly(this.et,o[t],this.Ct&&this.Ct[e],this.Rt,r)}n&&n.bloom&&o[t].properties.hlBloomMesh&&(o[t].properties.hlBloomMesh.properties.depthFunc="always",o[t].properties.hlBloomMesh.properties.polygonOffset=a,l.push(o[t].properties.hlBloomMesh)),l.push(o[t])}else"pnts"===r?d.push(o[t]):"i3dm"===r&&m.push(o[t]);o[t].properties.isLeaf=!!e[i.id],o[t].properties.level=p.get(i.Bt),o[t].properties.polygonOffset=a,o[t].Ut=i,e[i.id]||f.push(o[t]),this.Pt(o[t])}}let b=0;const g=this._t.getExcludeFilter();b+=this.Lt(this.Dt,a,[i,Bn,g],r,f,l,m),b+=this.Lt(this.Ft,a,[i,Un,g],r,f,l,m),this._t.forEachShader((t,e,n)=>{const s=this.It(n);b+=this.Lt(t,s,[i,e],r,f,l,m)}),this.lt.setMeshes(d);const T=this.kt();return b+=this.nt.render(this.Vt,T,this.lt,r&&r.fbo),this.xt={pntsMeshes:d,i3dmMeshes:m,b3dmMeshes:l},b}Lt(t,e,n,r,s,i,o){t.filter=n.filter(t=>!!t),e.debug=!1,e.stencilEnable=!0,e.debug=!1,e.cullFace="back",e.colorMask=Pn;let a=0;return this.ft.setMeshes(i),a+=this.nt.render(t,e,this.ft,r&&r.fbo),e.stencilEnable=!0,this.dt.setMeshes(o),a+=this.nt.render(t,e,this.dt,r&&r.fbo),a}Ht(t,e){return e.Ut.Gt-t.Ut.Gt}paintRegion(t,e,n,r,s){const i=this.getMap();if(!t.length&&!e.length)return;const o=i.projViewMatrix,a=[];for(let n=0,r=(t=t.concat(e)).length;n<r;n++){const e=t[n].node,r=this.jt(e);r&&(r.getBoundingBox&&!y(o,r.getBoundingBox())||a.push(r))}this.zt.filter=r,this.pt.setMeshes(a);const c=this.qt(n);this.nt.render(this.zt,c,this.pt,s&&s.fbo)}deleteTile(t){const e=t.node.id;this.Xt(e)}Xt(t){const e=this.st[t];e&&(e.geometry.dispose(),e.dispose(),delete this.st[t]);const n=this.it[t]||this.ot[t]||this.ct[t]||this.ht[t]||this.rt[t];this.ht[t]?this.Kt(t):n&&(this.$t(n),delete this.it[t],delete this.ot[t],delete this.ct[t],delete this.rt[t])}Kt(t){let e=this.ht[t];e=B(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.Xt(n)}delete this.ht[t]}$t(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.$t(t[e]);else{s.showOnly(this.et,t),s.highlightMesh(this.et,t);const e=t.geometry.properties.url;if(e){const t=this.ut[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.ut[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.J;Sn(t.getRenderer().canvas,t.getMap());for(const t in this.ht)this.Kt(t);this.ht={};for(const t in this.it)this.Xt(t);this.it={};for(const t in this.ot)this.Xt(t);this.ot={};for(const t in this.ct)this.Xt(t);this.ct={};for(const t in this.rt)this.Xt(t);this.rt={};for(const t in this.st)this.Xt(t);this.st={},this.Dt&&(this.Dt.dispose(),delete this.Dt),this.Ft&&(this.Ft.dispose(),delete this.Ft),this.Vt&&(this.Vt.dispose(),delete this.Vt),this.zt&&(this.zt.dispose(),delete this.zt),this._t.dispose(),this.picking&&this.picking.dispose()}jt(e){if(!e.boundingVolume||!e.boundingVolume.region)return null;if(this.st[e.id])return this.st[e.id];const s=e.boundingVolume.region;let i=new t.Coordinate(M(s[0]),M(s[1])),o=new t.Coordinate(M(s[2]),M(s[3]));i=this.Wt(i),o=this.Wt(o);const a=i.add(o).Yt(.5);i._sub(a),o._sub(a);const c=this.Jt(s[4],s[5]),h=c.x,u=c.y,f=[i.x,i.y,u,o.x,i.y,u,o.x,o.y,u,i.x,o.y,u,i.x,i.y,h,o.x,i.y,h,o.x,o.y,h,i.x,o.y,h],l=new n.Geometry({aPosition:f},[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],0,{primitive:"lines"});l.generateBuffers(this.et);const d=new n.Mesh(l),m=r.identity([]);return d.setLocalTransform(r.translate(m,m,[a.x,a.y,0])),this.st[e.id]=d,d}Mt(t){return this.it[t.id]||this.ot[t.id]||this.ct[t.id]||this.ht[t.id]}has(t){return this.Mt(t)||this.rt[t.id]}createPntsMesh(t,e,s,i){if(this.ot[e]){const t=this.ot[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c}=t,h=this.J.options.services[c],u=a.POINTS_LENGTH,f=new n.Geometry(o,null,u,{primitive:"points",positionAttribute:"POSITION"});f.generateBuffers(this.et);const l={};o.POSITION?l.HAS_POSITION=1:o.POSITION_QUANTIZED&&(l.HAS_POSITION_QUANTIZED=1),o.RGB?l.HAS_RGB=1:o.RGBA?l.HAS_RGBA=1:o.RGB565&&(l.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(l.HAS_NORMAL=1,o.NORMAL_OCT16P&&(l.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map(t=>t/255));const{rtcCenter:d,rtcCoord:m}=t,p=this.Zt(jn,m),y=this.Qt([],s,d,m);r.multiply(y,y,p);const b=this.J.options.services[c],g=new n.Mesh(f);if(g.properties.magic="pnts",g.properties.id=e,g.properties.node=s,g.properties.count=u,g.properties.batchTable=t.batchTable,g.properties.batchTableBin=t.batchTableBin,g.properties.serviceIndex=c,g.setDefines(l),Object.defineProperty(g.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:b&&b.pointColor||[1,1,1,1]}}),Object.defineProperty(g.uniforms,"pointSize",{enumerable:!0,get:function(){return b&&b.pointSize||2}}),Object.defineProperty(g.uniforms,"pointOpacity",{enumerable:!0,get:function(){return b&&b.pointOpacity||1}}),h.coordOffset){const t=this.te(s.Et,m);r.multiply(y,t,y)}return g.setLocalTransform(y),this.ot[e]=g,i(null,{id:e,mesh:[g]}),[g]}createI3DMMesh(t,e,s,o){if(this.ct[e]){const t=this.ct[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.rt[e]||o(null,{id:e,mesh:t}),t}const a=this.J.options.services[s.Et],h=this.ee(s.ne),{i3dm:u,featureTable:f,gltf:l,batchTable:d,batchTableBin:m,count:p}=t,y=f.INSTANCES_LENGTH,{rtcCenter:b,rtcCoord:g}=t,T=this.Zt(jn,g),w=this.Qt(zn,s,b,g);r.multiply(T,w,T);const{POSITION:_,NORMAL_UP:A,NORMAL_RIGHT:O,SCALE:x,SCALE_NON_UNIFORM:I,INSTANCE_ROTATION:S}=u,M={"instance_vectorA":new Float32Array(4*y),"instance_vectorB":new Float32Array(4*y),"instance_vectorC":new Float32Array(4*y)},E=new Float32Array(3),v=new Float32Array(3),N=[],C=new Float32Array(1),B=new Float32Array(3),U=[],P=[],L=[],D=[],F=new Float32Array(9);!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?$t.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o)}return}const h=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);h.set(s);e(new c(h.buffer),t),s.set(h)}}(_,(t,e)=>{A?(me(v,O,e),me(E,A,e),i.cross(N,v,E),i.normalize(N,N),R(U,v,0),R(U,E,1),R(U,N,2),c.fromMat3(P,U)):S?(me(F,S,e),c.fromMat3(P,F)):c.identity(P),x?(me(C,x,e),i.set(L,C[0],C[0],C[0])):I?(me(B,I,e),i.set(L,...B)):i.set(L,1,1,1),r.fromRotationTranslationScale(D,P,t,L),pe(M.instance_vectorA,e,D,0),pe(M.instance_vectorB,e,D,1),pe(M.instance_vectorC,e,D,2)});const k={};for(const t in M)k[t]={buffer:this.et.buffer({dimension:M[t].length/y,data:M[t]}),divisor:1};const V=a.shader||"pbr";let H=0,G=!0;const j=[];return oe(l,(t,i,o,c)=>{const{geometry:u,material:f}=this.re(t,i,o,c,s,!0,V);f&&!f.isReady()&&(G=!1,H++);const l=new n.InstancedMesh(k,y,u,f);l.properties.magic="i3dm",l.properties.id=e,l.properties.count=p,l.properties.batchTable=d,l.properties.batchTableBin=m,l.properties.serviceIndex=s.Et;const b=this.se(t,u,f,s.Et,c);this.ie(l,t.attributes);const w=r.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(w,w,t.matrices[e]);let _;if(r.multiply(w,h,w),l.setPositionMatrix(w),a.coordOffset){const t=this.te(s.Et,g);_=r.multiply([],t,T)}else _=r.copy([],T);l.setLocalTransform(_),l.setDefines(b),l.properties.polygonOffset={offset:0,factor:0},j.push(l),delete t.attributes}),G?(this.ct[e]=j,o(null,{id:e,mesh:j})):(this.rt[e]={meshes:j,count:H},j.oe=o),j}createB3DMMesh(e,s,i,o){if(this.it[s]||this.rt[s]){const t=this.it[s];return console.warn(`mesh with id(${s}) was already created.`),this.rt[s]||o(null,{id:s,mesh:t}),t}let a;if(i.maxExtent){const e=new t.Extent(i.maxExtent).convertTo(t=>this._pointToPrj(t));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=e.gltf,{projCenter:h}=c.extensions.MAPTALKS_RTC,{rtcCoord:u,center:f}=c.extensions.CESIUM_RTC,l=this.ee(i.ne);let d;d=c.asset&&c.asset.sharePosition?this.Zt(jn,u):this.ae(jn,u,h,i.Et);const m=this.J.options.services[i.Et];let p=m.shader||"pbr";if(c.materials)for(let t=0;t<c.materials.length;t++)if(c.materials[t]&&c.materials[t].extensions&&c.materials[t].extensions.KHR_materials_unlit){p=m.shader="phong";break}const y=[];let b=0,g=!0;return oe(c,(t,o,c,h)=>{const{geometry:T,material:w}=this.re(t,o,c,h,i,!1,p);w&&!w.isReady()&&(g=!1,b++);const _=new n.Mesh(T,w);_.properties.magic="b3dm",_.properties.id=s,_.properties.node=i,_.properties.batchTable=e.batchTable,_.properties.batchTableBin=e.batchTableBin,_.properties.count=e.featureTable.BATCH_LENGTH,_.properties.serviceIndex=i.Et;const A=this.se(t,T,w,i.Et,h);_.setDefines(A);const O=t.compressUniforms;if(O)for(const t in O)_.setUniform(t,O[t]);this.ie(_,t.attributes),a&&(A.USE_MAX_EXTENT=1,_.setUniform("maxPrjExtent",a)),Object.prototype.hasOwnProperty.call(_.uniforms,"polygonOpacity")||Object.defineProperty(_.uniforms,"polygonOpacity",{enumerable:!0,get:function(){return I(m.opacity)?m.opacity:1}});const x=r.identity([]);if(h.asset.sharePosition&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(x,x,t.matrices[e]);if(h.asset.sharePosition){const t=this.Qt(zn,i,f,u);r.multiply(x,l,x),r.multiply(x,d,x),r.multiply(x,t,x)}else r.multiply(x,d,x);if(m.coordOffset){const t=this.te([],i.Et,u);r.multiply(x,t,x)}_.setLocalTransform(x),y.push(_),delete t.attributes}),g?(this.it[s]=y,o(null,{id:s,mesh:y})):(this.rt[s]={meshes:y,count:b},y.oe=o),y}ie(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}Qt(e,n,s,o){const a=this.getMap(),c=this.J.options.services[n.Et].heightOffset||0,h=new t.Coordinate(o);let u;u=a.altitudeToPoint?this.Ot:a.distanceToPointAtRes(100,100,a.getGLRes(),h).y/100;const f=n.matrix?r.copy(e,n.matrix):r.identity(e);if(s){rn(f,i.transformMat4(Ln,s,f),f)}const l=function(t,e,n,r,s,i,o){e=$(on,e);const a=Te(on,e[0]*pn,e[1]*pn,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(an,n),h=r.ellipsoid;let u;u=0===it(c)?W(cn,0,0,-6378137):Ie(cn,c),dn.x=u[0],dn.y=u[1];const f=r.project(dn,mn);hn[0]=f.x/s,hn[1]=f.y/s,hn[2]=(u[2]+o)*i;const l=sn(a,h,un),d=function(t,e,n){const r=t[0],s=t[1],i=t[2],o=t[4],a=t[5],c=t[6],h=t[8],u=t[9],f=t[10],l=e[0],d=e[1],m=e[2],p=e[3],y=e[4],b=e[5],g=e[6],T=e[7],w=e[8],_=r*l+o*d+h*m,A=s*l+a*d+u*m,O=i*l+c*d+f*m,x=r*p+o*y+h*b,I=s*p+a*y+u*b,S=i*p+c*y+f*b,M=r*g+o*T+h*w,E=s*g+a*T+u*w,v=i*g+c*T+f*w;return n[0]=_,n[1]=A,n[2]=O,n[3]=0,n[4]=x,n[5]=I,n[6]=S,n[7]=0,n[8]=M,n[9]=E,n[10]=v,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],h=e[7],u=e[8],f=e[9],l=e[10],d=e[11],m=e[12],p=e[13],y=e[14],b=e[15],g=n*a-r*o,T=n*c-s*o,w=n*h-i*o,_=r*c-s*a,A=r*h-i*a,O=s*h-i*c,x=u*p-f*m,I=u*y-l*m,S=u*b-d*m,M=f*y-l*p,E=f*b-d*p,v=l*b-d*y,N=g*v-T*E+w*M+_*S-A*I+O*x;return N?(N=1/N,t[0]=(a*v-c*E+h*M)*N,t[1]=(s*E-r*v-i*M)*N,t[2]=(p*O-y*A+b*_)*N,t[3]=(l*A-f*O-d*_)*N,t[4]=(c*S-o*v-h*I)*N,t[5]=(n*v-s*S+i*I)*N,t[6]=(y*w-m*O-b*T)*N,t[7]=(u*O-l*w+d*T)*N,t[8]=(o*E-a*S+h*x)*N,t[9]=(r*S-n*E-i*x)*N,t[10]=(m*A-p*w+b*g)*N,t[11]=(f*w-u*A-d*g)*N,t[12]=(a*I-o*M-c*x)*N,t[13]=(n*M-r*I+s*x)*N,t[14]=(p*T-m*_-y*g)*N,t[15]=(u*_-f*T+l*g)*N,t):null}(fn,l),function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(ln,n),t);return rn(t,hn,d),t}(f,o,f,a.getProjection(),a.getGLRes(),u,c),d=function(t,e){return W(t,e[12],e[13],e[14]),t}(Gn,l);let m=this.J.options.offset;if(O(m)){m=m(this.J.ce(n.id).center)}return i.set(Hn,m[0],m[1],0),i.sub(d,d,Hn),rn(l,d,l),l}te(t,e,n){const s=this.J.options.services[e];if(!s.coordOffset)return null;const o=this.getMap(),a=o.getGLRes();Dn.set(n[0],n[1]);const c=o.coordToPointAtRes(Dn,a,kn),h=s.coordOffset,u=Dn.set(n[0]+h[0],n[1]+h[1]),f=o.coordToPointAtRes(u,a,Vn),l=f.x-c.x,d=f.y-c.y,m=this.he(),p=i.set(Hn,l,d,(h[2]||0)*m);return r.fromTranslation(t,p)}he(){const t=this.getMap();let e;return e=t.altitudeToPoint?this.Ot:t.distanceToPointAtRes(100,100,t.getGLRes(),Dn).y/100,e}createCMPTMesh(t,e,n,r){if(this.ht[e]){const t=this.ht[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:s}=t,i=[];for(let t=0;t<s.length;t++){const{magic:r}=s[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(s[t],o,n,(t,{mesh:e})=>{i.push(e)}):"i3dm"===r?this.createI3DMMesh(s[t],o,n,(t,{mesh:e})=>{i.push(e)}):"pnts"===r?this.createPntsMesh(s[t],o,n,(t,{mesh:e})=>{i.push(e)}):"cmpt"===r&&this.createCMPTMesh(s[t],o,n,(t,{mesh:e})=>{i.push(e)})}return this.ht[e]=i,r(null,{id:e,mesh:i}),i}se(t,e,n,r,s){const i=("phong"===(this.J.options.services[r].shader||"pbr")?this.Dt:this.Ft).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this.ue(i,e),e.data.uvRegion&&(i.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(i.VertexNormal=1),e.data[e.desc.color0Attribute]&&(i.VertexColor=1),e.data[e.desc.uv0Attribute]&&(i.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(i.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(i.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(i.TexCoord2=1),"MESHOPT"===this.J.fe&&(i.MeshOPT_Compress=1),this.hasIBL()&&(i.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(i.HAS_WEB3D_quantized_attributes_TEXCOORD=1);return A(i,t.compressDefines),i}Pt(t){const e=this.J.getRenderer();e&&e.updateMaskDefines(t)}ue(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}re(t,e,n,r,s,i,o){let a=!1;r.asset&&"S3M"===r.asset.generator&&(a=!0,r.extensions=r.extensions||{});const c=r.url+"-"+e+"-"+n;if(this.ut[c])return this.ut[c].refCount++,this.ut[c];let h,u;const f=r.materials&&r.materials[t.material];if(r.extensions&&r.extensions.KHR_techniques_webgl&&f.extensions&&f.extensions.KHR_techniques_webgl){const e=this.le(t,r,i,a);h=e.material,u=e.geometry;this.J.options.services[s.Et].fillEmptyDataInMissingAttribute&&(u.desc.fillEmptyDataInMissingAttribute=!0)}else{u=this.de(t,i,qn);const e=this.J.options.services[s.Et],n=e.ambientLight;let a=e.environmentExposure;const c=e.material,f=this.getMap().getLightManager(),l=f&&f.getAmbientLight();if(n&&(!l||l.color)&&void 0===a){const t=l&&l.color?l.color[0]:.2;a=n[0]/t}h=this.me(t.material,r,o,c||Nn,a||1)}h&&!h.isReady()?h.pe=s.id:h||(h=this.Tt);const l={refCount:1,geometry:u,material:h};return u.properties.url=c,this.ut[c]=l,l}le(t,e,n,r){const{geometry:s,material:i}=this._t.createMesh(t,e,n,r);return{geometry:s,material:i}}de(t,e,r){const s=t.attributes;let i=s._BATCHID&&s._BATCHID.array;if(i&&i.byteOffset&&(i=new i.constructor(i)),s.COLOR_0){const t=s.COLOR_0.array||s.COLOR_0;if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);s.COLOR_0.array?(s.COLOR_0.array=e,s.COLOR_0.componentType=5121):s.COLOR_0=e}}const o={};for(const t in s){const e=An(this.et,s[t],{dimension:s[t].itemSize}),n=r[t]||t;o[n]={buffer:e},s[t].quantization&&(o[n].quantization=s[t].quantization),n===r.POSITION&&(o[n].array=s[t].array,o[n].min=s[t].min,o[n].max=s[t].max)}const a=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,c=new n.Geometry(o,a,0,{positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":_n(t.mode)});return i&&a&&(c.properties.batchIdData=i,c.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const s=e[r],i=t[s];let o=n.get(i);o||(o=[],n.set(i,o)),o.push(s)}return n}
19
19
  /*!
20
- * @maptalks/gl v0.83.1
20
+ * @maptalks/gl v0.84.0
21
21
  * LICENSE : UNLICENSED
22
22
  * (c) 2016-2023 maptalks.com
23
- */(o,a)),c.generateBuffers(this.et,{excludeElementsInVAO:e}),c}ae(t,e,n,i){const s=r.identity(t),a=this.getMap();Un.x=n[0],Un.y=n[1];const c=this._prjToPoint(Un),A=this._e(),l=1/(a.getGLZoom?a.getResolution(a.getGLZoom()):a.getGLRes());Un.x=e[0],Un.y=e[1];const f=this.Ae();let h=this.q.options.offset;y(h)&&(h=h(Un));const u=this.q.options.services[i].heightOffset||0;return o.set(kn,c.x-h[0],c.y-h[1],f*n[2]+f*u),r.translate(s,s,kn),o.set(A,l,l,f),r.scale(s,s,A),s}qt(t,e){const n=r.identity(t),i=this.getMap(),s=this._e();Un.x=e[0],Un.y=e[1];const a=i.distanceToPointAtRes(100,100,i.getGLRes(),Un);let c;return c=i.altitudeToPoint?this.yt:a.y/100,o.set(s,a.x/100*1.01,a.y/100*1.01,c),r.scale(n,n,s),n}Tt(){const t={x:0,y:0,width:()=>this.$?this.$.width:1,height:()=>this.$?this.$.height:1};this.Xt=new n.MeshShader({vert:"attribute vec3 aPosition;\n\n\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main() {\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n}\n\n",frag:"precision mediump float;\nuniform vec3 color;\nvoid main() {\n gl_FragColor = vec4(color, 1.0);\n}\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply([],e.projViewMatrix,e.modelMatrix)}],extraCommandProps:{viewport:t}});const e=[],i=[];this.Ht=new n.MeshShader({vert:"const float SHIFT_RIGHT_11 = 1.0 / 2048.0;\n\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\n\nconst float SHIFT_LEFT_11 = 2048.0;\n\nconst float SHIFT_LEFT_5 = 32.0;\n\nconst float NORMALIZE_6 = 1.0 / 64.0;\n\nconst float NORMALIZE_5 = 1.0 / 32.0;\n\n\n\n#ifdef HAS_POSITION\n\n attribute vec3 POSITION;\n\n#endif\n\n\n\n#if defined(HAS_RGB)\n\n attribute vec3 RGB;\n\n#elif defined(HAS_RGBA)\n\n attribute vec4 RGBA;\n\n#elif defined(HAS_RGB565)\n\n attribute float RGB565;\n\n#endif\n\n\n\nuniform vec4 pointColor;\n\nuniform float pointSize;\n\n\n\nuniform mat4 projViewModelMatrix;\n\nuniform float pointOpacity;\n\n\n\nvarying vec4 vColor;\n\n\n\n#ifdef HAS_NORMAL\n\n #ifdef HAS_NORMAL_OCT16P\n\n attribute vec2 NORMAL_OCT16P;\n\n float signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n }\n\n vec2 signNotZero(vec2 value) {\n\n return vec2(signNotZero(value.x), signNotZero(value.y));\n\n }\n\n vec3 octDecode(vec2 encoded, float range) {\n\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n return vec3(0.0, 0.0, 0.0);\n\n }\n\n encoded = encoded / range * 2.0 - 1.0;\n\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n if (v.z < 0.0) {\n\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n }\n\n vec3 octDecode(vec2 encoded) {\n\n return octDecode(encoded, 255.0);\n\n }\n\n #else\n\n attribute vec3 NORMAL;\n\n #endif\n\n uniform vec3 lightDir;\n\n uniform mat3 modelNormalMatrix;\n\n uniform mat4 positionMatrix;\n\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n\n return max(dot(-lightDir, normal), 0.0);\n\n }\n\n#endif\n\n\n\nvoid main() {\n\n #if defined(HAS_RGB)\n\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n\n #elif defined(HAS_RGBA)\n\n vColor = RGBA / 255.0 * pointOpacity;\n\n #elif defined(HAS_RGB565)\n\n float compressed = RGB565;\n\n float r = floor(compressed * SHIFT_RIGHT_11);\n\n compressed -= r * SHIFT_LEFT_11;\n\n float g = floor(compressed * SHIFT_RIGHT_5);\n\n compressed -= g * SHIFT_LEFT_5;\n\n float b = compressed;\n\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n\n vColor = vec4(rgb, 1.0);\n\n #else\n\n vColor = pointColor;\n\n #endif\n\n\n\n #ifdef HAS_POSITION\n\n vec3 localPos = POSITION;\n\n #endif\n\n\n\n #ifdef HAS_NORMAL\n\n mat3 positionNormalMatrix = mat3(positionMatrix);\n\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n\n #ifdef HAS_NORMAL_OCT16P\n\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n\n #else\n\n vec3 localNormal = NORMAL;\n\n #endif\n\n vec3 normal = normalize(normalMatrix * localNormal);\n\n float colorStrength = getLambertDiffuse(lightDir, normal);\n\n colorStrength = max(colorStrength, 0.5);\n\n vColor *= colorStrength;\n\n #endif\n\n\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n}\n\n",frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n gl_FragColor = vColor;\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(i,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,n)=>s.fromMat4(e,n.modelMatrix)}],extraCommandProps:{viewport:t,blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const o=this.pt();this.vt=new n.PhongShader({extraCommandProps:o}),this.Ut=new n.pbr.StandardShader({extraCommandProps:o});const a=this.q;bn(a.getRenderer().canvas,this.et,a.getMap()),this.picking=new n.FBORayPicking(this.nt,{vert:this.Ut.vert,extraCommandProps:o,uniforms:this.Ut.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}pt(){return{viewport:{x:0,y:0,width:()=>this.$?this.$.width:1,height:()=>this.$?this.$.height:1},colorMask:(t,e)=>e.colorMask||wn,cull:{enable:!0,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>!0===e.stencilEnable,func:{cmp:(t,e)=>e.meshProperties.isLeaf?"always":">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}zt(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}Gt(t){const e=this.getMap(),n=e.getLightManager(),r=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:o.normalize(r,r)}}It(){const t=this.getMap(),e=this.q.getRenderer().canvas,{iblTexes:n,dfgLUT:r}=Mn(e),i=Pn(t,n,r),o=this.q.getRenderer().getMaskUniforms();return p(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[e.width,e.height],polygonFill:[1,1,1,1],polygonOpacity:1}),p(i,o),i}Ee(t,e,r,i,o){const s=e.materials&&e.materials[t];if(!s||!s.baseColorTexture&&!s.pbrMetallicRoughness)return null;const c=p({},i);if(s.baseColorTexture){const t=e.textures[s.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.R(t)),c.baseColorFactor=t&&t.image.color||s.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(s.normalTexture){const t=this.R(e.textures[s.normalTexture.index]),n=s.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=n}if(s.occlusionTexture){const t=this.R(e.textures[s.occlusionTexture.index]),n=s.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=n}if(s.emissiveTexture){const t=this.R(e.textures[s.emissiveTexture.index]);c.emissiveTexture=t}s.emissiveFactor&&(c.emissiveFactor=s.emissiveFactor);const t=s.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];n.image&&n.image.color?c.baseColorFactor=c.baseColorFactor?a.multiply(c.baseColorFactor,c.baseColorFactor,n.image.color):n.image.color:(c.baseColorTexture=this.R(n),c.baseColorTexture.getREGLTexture(this.et))}if(g(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),g(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),s.metallicRoughnessTexture){const t=this.R(e.textures[s.metallicRoughnessTexture.index]);c.metallicRoughnessTexture=t}}}if(s.s3mMaterial)return new n.Material(c);if(c.environmentExposure=o,s.extensions&&s.extensions.KHR_materials_unlit)return c.environmentExposure=1,c.ambientColor=[1,1,1],c.light0_diffuse=[0,0,0,0],c.lightSpecular=[0,0,0],new n.PhongMaterial(c);let A=new n.pbr.StandardMaterial(c);"phong"===r&&(A=n.PhongMaterial.convertFrom(A));const l=s.pbrMetallicRoughness,f=l&&l.baseColorTexture&&l.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(A.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),A.set("khr_rotation",f.KHR_texture_transform.rotation||0),A.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),A.once("complete",this._t),A}R(t){const e={type:t.type?mn(t.type):"uint8",format:t.format?gn(t.format):"rgba",flipY:!!t.flipY},r=t.image;r.array?e.data=r.array:r.mipmap&&(e.mipmap=r.mipmap),e.width=r.width,e.height=r.height;const i=t.sampler||t.texture&&t.texture.sampler;return i&&(i.magFilter&&(e.mag=Bn(i.magFilter)),i.minFilter&&(e.min=Cn(i.minFilter)),i.wrapS&&(e.wrapS=Tn(i.wrapS)),i.wrapT&&(e.wrapT=Tn(i.wrapT))),new n.Texture2D(e,this.dt)}Be(t){const e=t.image,n=window.URL||window.webkitURL,r=new Blob([e.array],{type:e.mimeType});return n.createObjectURL(r)}Bt({target:t}){const e=t.de,n=this.rt[e];if(n.count--,!n.count){const t=n.meshes;this.ot[e]=t,delete this.rt[e];const r=t.se;delete t.se,r(null,{mesh:n.meshes,id:e})}}_e(){return Sn}Wt(t){return this.q.Wt(t)}Qt(t,e){const n=this.getMap();return n.getGLZoom?n.distanceToPoint(t,e,n.getGLZoom()):n.distanceToPointAtRes(t,e,n.getGLRes())}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),Gn)}ee(t){return"Y"===t?Rn:"X"===t?In:On}pick(t,e,n=3){const r=this.q;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=this.getMap(),o=this.It(),s=this.picking;s.render(this.ft.getMeshes().filter(t=>!t.bloom),o,!0);let a={};s.getRenderedMeshes().length&&(a=s.pick(t,e,n,o,{viewMatrix:i.viewMatrix,projMatrix:i.projMatrix,returnPoint:r.options.pickingPoint}));const{meshId:c,pickingId:A,point:l,coordinate:f}=a,h=(0===c||c)&&s.getMeshAt(c);if(!h||!h.geometry)return[];const u=h.properties;l&&l.length&&(l[0]=Math.round(1e5*l[0])/1e5,l[1]=Math.round(1e5*l[1])/1e5,l[2]=Math.round(1e5*l[2])/1e5);const E={batchId:A};if(r.options.debug&&(E.debugInfo=u),u&&u.batchTable){const{batchTable:t,batchTableBin:e,count:n}=u,r=A;for(const i in t)void 0!==t[i].byteOffset?E[i]=Ve(t[i],e,n,r):E[i]=t[i][r]}return[{service:h.properties.serviceIndex,data:E,point:l,coordinate:f}]}bt(t){let e=new Set;for(let n=0,r=t.length;n<r;n++){const r=t[n].data.node;this.xt(r)&&e.add(r.Ot)}e=Array.from(e),e.sort();const n=new Map,r=e.length;for(let t=0;t<r;t++)n.set(e[t],t);return n}highlight(t){this.Pt=t;const e=this.q.getRenderer();this.Nt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Pt=null;const t=this.q.getRenderer();this.Nt=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Dt=t;const e=this.q.getRenderer();this.St=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Dt=null;const t=this.q.getRenderer();this.St=t.getFrameTimestamp(),t.setToRedraw(!0)}Ce(){if(!this.Rt)return[];const t={},e=[];for(const n in this.Rt){const r=this.Rt[n];if(r)for(let n=0;n<r.length;n++){const i=r[n],o=i&&i.geometry;if(!i||!o)continue;const s=i.properties.serviceIndex;t[s]||(t[s]=new Set);const a=o.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[s].has(a[n])||(e.push({id:a[n],service:s}),t[s].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}const Zn=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},Wn=Zn(),jn=Wn.gl_trans__coders=Wn.gl_trans__coders||{};function Qn(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}jn.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=Wn.gl_trans__coders=Wn.gl_trans__coders||{};let o=`${r}\n const _____getGlobal = ${Zn.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(o+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return o+="\n"+e.substring(r.length),o},jn.registerTranscoder=function(t,e){jn[t]=e},jn.getTranscoder=function(t){return jn[t]};const qn=[];class $n{constructor(t,e,n,r){this.Te=t,this.Mt=e,this.me=r,this.ge=n.version,t.indexOf("i3s:tileset:")<0?(this.ge<=1.6?this.pe="root":this.pe=0,n.version=this.ge):(this.pe=t.substring("i3s:tileset:".length),this.ge>1.6&&(this.pe=parseInt(this.pe))),this.Te=t,this.ye=n}load(){const t=this.ye,e=t.layerScene.baseUrl;if(this.ge<=1.6)return t[this.pe]&&t[this.pe].lodSelection?(this.Re=t[this.pe],this.Ie()):new Promise(n=>{let r=e+"/nodes/"+this.pe;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.me(this.Mt,r,()=>{this.Re=t[this.pe],n(this.Ie())})});if(this.ge>=1.7){if(t[this.pe])return this.Re=t[this.pe],this.Ie();const n=Math.floor(this.pe/t.nodesPerPage);return new Promise(r=>{let i=e+"/nodepages/"+n;t.layerScene.eslpk&&(i+=".json"),this.me(this.Mt,i,()=>{this.Re=t[this.pe],r(this.Ie())})})}return null}getTileset(){return this.be}getChildrenURL(){return this.xe}Ie(){const t=this.ye,e=t.layerScene.baseUrl,n=this.Re.children,r=[],i={};if(n)for(let o=0;o<n.length;o++)if(this.ge<=1.6){const s=n[o].id;if(t[s])continue;const a=s;i[a]||(i[a]=new Promise(n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.me(this.Mt,r,()=>{n()})}),r.push(i[a]))}else{const s=n[o];if(t[s])continue;const a=Math.floor(s/t.nodesPerPage);i[a]||(i[a]=new Promise(n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.me(this.Mt,r,()=>{n()})}),r.push(i[a]))}return r.length?Promise.all(r).then(()=>this.Me()):this.Me()}Me(){return Promise.resolve(this.Pe())}Ne(t){Qn(this.ye,t)}Pe(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.De(this.Re,!0)}}De(t){const e=this.ge,n=this.ye,r=t,i=r.obb,o=r.mbs,s={};let a;if(o)a=tr([],o[0],o[1],o[2]),s.sphere=[...a,o[3]];else if(i){a=tr([],i.center[0],i.center[1],i.center[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],s=n+n,a=r+r,c=i+i,A=n*s,l=r*s,f=r*a,h=i*s,u=i*a,E=i*c,d=o*s,_=o*a,B=o*c;return t[0]=1-f-E,t[3]=l-B,t[6]=h+_,t[1]=l+B,t[4]=1-A-E,t[7]=u-d,t[2]=h-_,t[5]=u+d,t[8]=1-A-f,t}([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(a,i.halfSize,i.quaternion),e=t[3]+t[6]+t[9],n=t[4]+t[7]+t[10],r=t[5]+t[8]+t[11];W(qn,e,n,r);const o=ot(qn);s.sphere=[...a,o]}let c=1/0,A=0;if(r.mbs?A=r.mbs[3]:r.obb&&(A=Math.max(Math.max(r.obb.halfSize[0],r.obb.halfSize[1]),r.obb.halfSize[2])),void 0!==r.lodThreshold)if("maxScreenThresholdSQ"===n.lodSelectionMetricType){c=A/(Math.sqrt(r.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==r.lodSelection)for(let t=0;t<r.lodSelection.length;t++)"maxScreenThreshold"===r.lodSelection[t].metricType&&(c=A/r.lodSelection[t].maxError);(c===1/0||isNaN(c))&&(c=1e5);const l=16*c,f=H([]),h=r.children;let u;if(h){u=[];const t=this.ye;for(let n=0;n<h.length;n++){const r=e<=1.6?h[n].id:h[n];if(!t[r]){u=null;break}u.push(this.De(t[r]))}}const E={refine:"REPLACE",boundingVolume:s,transform:f,geometricError:l};return e<=1.6?t.lodSelection?t.geometryData&&(E.content={uri:"i3s:mesh:"+(t.id||t.index)}):E.content={uri:"i3s:tileset:"+(t.id||t.index)}:h&&h.length&&!u?E.content={uri:"i3s:tileset:"+(t.id||t.index)}:r.mesh&&(E.content={uri:"i3s:mesh:"+(t.id||t.index)}),u&&u.length&&(E.children=u),E}getJSON(){return this.Re}}function tr(t,e,n,r){return Te(t,b(e),b(n),r)}const er=!!jn.ktx2,nr=r.identity([]),rr=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function ir(t){return t.indexOf("i3s:mesh")>=0}const or="i3s:mesh:".length;function sr(t,e,n,r,i){const o=e.layerScene.eslpk,s=function(t,e){const n=e.substring(or);return t>=1.7?parseInt(n):n}(e.version,t),a=e[s],c=e.layerScene.baseUrl,A=[];let l=!1;const f=nr;let h,u;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;o&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",o&&(i+="."+n);const s={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=s}A.push(r)}else{h=a.mesh.geometry,u=a.mesh.material;const t=e.layerScene.geometryDefinitions[h.definition],{geometryBuffers:s}=t;l=r&&2===s.length;const f=jn.draco&&l?s[1]:s[0],E=jn.draco&&l?1:0;let d=c+`/nodes/${h.resource}/geometries/`+E;o&&(d+=".bin");const _={geometry:{url:d,info:f}};if(i&&rr&&l&&!jn.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const B=e.layerScene.materialDefinitions,C=e.layerScene.textureSetDefinitions;let T,m=0;if(u&&(m=B[u.definition]),B){T=function(t,e,n,r,i,o){const s=JSON.parse(JSON.stringify(t));return function t(e,n,r,i,o,s){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const t=n[e[a].textureSetDefinitionId],c="images/"+t.formats[0].format,A=ar(t.formats,o),l={url:r+`/nodes/${i}/textures/${A.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:A.format,mimeType:c};if(s){let t="";switch(A.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=A.format}l.url+="."+t}e[a]=l}else R(e[a])&&t(e[a],n,r,i,o,s)}(s,e,n,r,i,o),s}(m,C,c,u.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};_.material=T,A.push(_)}return{dracoCompression:l,meshes:A,nodeIndex:s,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:f}}function ar(t,e){for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&er)return t[n]}return null}const cr=[];class Ar extends(A(t.renderer.CanvasRenderer)){constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new oe(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.Se={},this.Oe=[],this.me=this.Le.bind(this)}getAnalysisMeshes(){if(!this.painter)return cr;const t=this.painter.getPaintedMeshes();if(!t)return cr;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:i}=t;return n.length&&v(e,n),r.length&&v(e,r),i.length&&v(e,i),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Oe.length||super.needToRedraw())}getFrameTimestamp(){return this.Fe}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.Fe=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:i}=this.layer.getTiles(),o=i.length;if(!i||!o)return void this.completeRender();this.we(),this.ve();const{selectedTiles:s,leaves:a,requests:c}=this.Ue(r,i);c.length&&this.loadTiles(c),this.Ge(s,a,e),this.He(),c.length||this.completeRender()}Ue(t,e){const n=this.layer.getRootTiles();let r=[];this.Ve();let i=0;const o=this.Ke(),s={};let a=!1,c=!1;for(let t=0;t<e.length;t++){const o=e[t],A=o.node;if(s[A.id])continue;const l=n[A.Mt];s[A.id]=1;let f=!1;const h=this.getCachedTile(A.id);if(this.ke(A.id)?(i++,f=c=!0,this.tilesLoading[A.id].current=!0):h?(this.getTileOpacity(h)<1&&(f=c=!0),(!o.node.Xe||l.isS3M||!o.node.children||o.node.Xe<=500)&&(a=!0,o.selected=!0,o.data=h)):this.painter.has(A)||(f=c=!0,r.push(A)),!f)continue;if(this.ze(o))a=!0;else{this.Ye(o).length&&(a=!0)}}let A=[],l={};if(a&&({selectedTiles:A,leaves:l}=this.Je(t)),r.length>1&&(r.sort(lr),o)){const t=o-i;r=t>0?r.slice(0,t):[]}return{loading:c,requests:r,selectedTiles:A,leaves:l}}Je(t){const e=[],n={};let r;const i=[t],o=[];for(;i.length>0||o.length>0;){if(o.length>0){const t=o[o.length-1];if(t.Ze===i.length){o.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=i.pop(),s=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=o.length,e.push(t);else{if(t.selectionDepth=o.length,r=t,0===s.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}o.push(t),t.Ze=i.length}for(let t=0;t<s.length;t++)i.push(s[t])}return{selectedTiles:e,leaves:n}}ze(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Ye(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.Ot+1,r=[t.node];for(;r.length>0;){const i=r.pop().children;for(let o=0,s=i.length;o<s;o++){if((!i[o].content||!i[o].content.url)&&i[o].children&&i[o].children.length){r.push(i[o]);continue}const s=i[o].id;if(this.tileCache.has(s)){const n=this.layer.We(i[o],t);n.selected=!0,n.data=this.tileCache.get(s),t.children.push(n),e.push(n)}else i[o].Ot<=n&&r.push(i[o])}}return e}Ge(t,e,n){this.tileCache.markAll(!1);for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,this.tileCache.add(t[e].node.id,n)}this.tileCache.shrink();const r={tiles:t,leaves:e};this.onDrawTileStart(r);const i=this.painter.paint(t,e,n);this.onDrawTileEnd(r),i&&this.layer.fire("canvasisdirty",{renderCount:i})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(F(e)){const n=w(e);return this.je(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.Mt,r=this.Qe[n];return new $n(e,n,r,this.me).load().then(n=>{this.onTilesetLoad(n,t,e)})}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&!ir(e)&&(e=t.baseUrl+e);const n=this.layer.options.services[t.Mt];if(n.ajaxInMainThread){let r=n.urlParams;r&&(r=(e.indexOf("?")>0?"&":"?")+r);let i=Pt.getArrayBuffer(e+(r||""),n.fetchOptions);const o=i.xhr;i=i.then(n=>{delete this.Se[e],n?this.je(e,n.data,t):this.onTileError(null,t)}).catch(n=>{delete this.Se[e],this.onTileError(n,t)}),this.Se[e]=o}else this.je(e,null,t);return null}je(t,e,r){let i=this.o;i||(i=n.Util.getSupportedFormats(this.gl.gl||this.gl),this.o=i);const o=this.layer.options.services[r.Mt];o.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length).split("/"),r=[];for(let t=0;t<n.length;t++)r.push(encodeURIComponent(n[t]));return e+r.join("/")}(t,r.baseUrl));const s={url:t=this.layer.getTileUrl(t,r.baseUrl,o),arraybuffer:e,rootIdx:r.Mt,upAxis:r.ne,transform:r.matrix,supportedFormats:i};if(ir(t)){const e=this.Qe[r.Mt];if(s.i3sInfo=sr(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!s.i3sInfo)return void this.onTileError({status:404},r)}this.workerConn.loadTile(this.layer.getId(),s,(e,n)=>{if(e)return void this.onTileError(e,r);const{magic:i}=n;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i?this.Oe.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)})}ve(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.Oe.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.Oe.shift(),{magic:r}=t;"b3dm"===r?this.painter.createB3DMMesh(t,e.id,e,(n,{mesh:r})=>{this.qe(t,e,n,r)}):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,(n,{mesh:r})=>{this.qe(t,e,n,r)}):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,(n,{mesh:r})=>{this.qe(t,e,n,r)}):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,(n,{mesh:r})=>{this.qe(t,e,n,r)}),n++}}qe(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.$e(r);e.memorySize=n,this.onTileLoad(t,e)}}$e(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.$e(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.tn(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.fe=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.en(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e){if(!this.layer)return;const n=e.content.url;console.warn("failed to load 3d tile: "+n),console.warn(t),delete this.tilesLoading[e.id],this.nn(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}nn(e,n){const r={loadTime:t.Util.now(),current:!0,error:n,node:e};this.tileCache.add(e.id,r)}tn(e){const n={loadTime:t.Util.now(),current:!0,node:e};this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;if(this.layer.options.services[t.node.Mt].ajaxInMainThread){const t=this.Se[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.Se[e]}Ve(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias},n=this.canvas.gl&&this.canvas.gl.wrap;n?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.rn(this.canvas,e)),this.regl=this.regl||l({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),n&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Jn(this.regl,t),this.layer.in()}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new ne("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let n=this.layer.options||{};n=p({},n),delete n.offset,n.projection=t.getSpatialReference().getProjection().code;const r=this.layer.getId();e.addLayer(r,n,t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))})}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),t=>{if(t)throw t}),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.He(!0),this.tileCache.reset(),this.tilesLoading={},super.clear()}clearCanvas(){this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas()}getTileOpacity(){return 1}getStencilValue(){return 0}He(t){this.sn||(this.sn=Date.now());const e=Date.now();if(t||!(e-this.sn<this.layer.options.retireInterval)){this.sn=e;for(const e in this.tilesLoading){const n=this.tilesLoading[e];!t&&n.current||this.abortTileLoading(n)}}}Ke(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}rn(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let i=0;i<n.length;++i){try{r=t.getContext(n[i],e)}catch(t){}if(r)break}return r}ke(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return Ge(t,e,0,n)}we(){if(!this.an)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.an){const i=this.an[r];if("pending"===i.status)continue;i.status="pending";const o=i.rootIdx;if(n.push(Pt.getJSON(r).then(t=>{delete this.an[r];const e=this.Qe[o];if(e){t.nodes?Qn(e,t.nodes):(e[t.id]=t,Qn(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()})),e++,e>=t)break}n.length&&Promise.all(n)}Le(t,e,n){this.an||(this.an={}),this.an[e]=this.an[e]||[],this.an[e].rootIdx=t,this.an[e].push(n),this.setToRedraw()}en(t,e,n){this.Qe||(this.Qe=[]);const r=e.Mt;this.Qe[r]||(this.Qe[r]={});const i=this.Qe[r],o=this.layer.options.services[r];t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),i.version=+(o.i3sVersion||t.store.version),function(t,e,n,r,i,o){if(!i.layerScene){i.layerScene=t,i.nodesPerPage=t.nodePages&&t.nodePages.nodesPerPage||64,i.lodSelectionMetricType=t.nodePages&&t.nodePages.lodSelectionMetricType;let e=r;i.layerScene.eslpk=e.indexOf("3dSceneLayer.json")>=0;if(e.endsWith(".json")){const t=r.lastIndexOf("/");e=t<0?"./":r.substring(0,t)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(e)}return new $n(r,e,i,o).load()}(t,r,0,n,i,this.me).then(t=>{this.onTilesetLoad(t,e,n)})}pick(t,e,n){return this.painter?this.painter.pick(t,e,n&&n.tolerance):[]}highlight(t){if(this.Pt||(this.Pt=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Pt[n];r||(r=this.Pt[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Pt[e];n||(n=this.Pt[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.Pt)}cancelHighlight(t,e){if(!this.Pt)return;const n=this.Pt[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);this.painter.highlight(this.Pt)}}cancelAllHighlight(){delete this.Pt,this.painter.cancelAllHighlight()}showOnly(t){if(this.Dt||(this.Dt=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Dt[n];r||(r=this.Dt[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Dt[e];n||(n=this.Dt[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Dt)}cancelShowOnly(){delete this.Dt,this.painter.cancelShowOnly()}Ce(){return this.painter?this.painter.Ce():[]}}function lr(t,e){return t.Kt-e.Kt}function fr(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function hr(t,e,n){return Math.sqrt(function(t,e,n){const r=Q(ur,n,t),i=fr(Er,e,0),o=fr(dr,e,1),s=fr(_r,e,2),a=ot(i),c=ot(o),A=ot(s);tt(i,i),tt(o,o),tt(s,s);const l=Br;l[0]=et(r,i),l[1]=et(r,o),l[2]=et(r,s);let f,h=0;l[0]<-a?(f=l[0]+a,h+=f*f):l[0]>a&&(f=l[0]-a,h+=f*f);l[1]<-c?(f=l[1]+c,h+=f*f):l[1]>c&&(f=l[1]-c,h+=f*f);l[2]<-A?(f=l[2]+A,h+=f*f):l[2]>A&&(f=l[2]-A,h+=f*f);return h}(t,e,n))}const ur=[],Er=[],dr=[],_r=[],Br=[];const Cr=2*Math.PI;class Tr{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],i=t.west;let o=t.east;return o<i&&(o+=Cr,n<0&&(n+=Cr)),(n>i||Oe(n,i,1e-14))&&(n<o||Oe(n,o,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const mr=[0,0,1];function gr(t,e){return Te(e,t[0],t[1],t[2])}class pr{constructor(t,e){this.normal=o.copy([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-o.dot(e,t);return o.copy(n.normal,e),n.distance=r,n}}const yr=[],Rr=[],Ir=[],br=[],xr=[],Mr=[],Pr=[],Nr=[],Dr=[],Sr=[],Or=new pr([1,0,0],0),Lr=[];class Fr{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new Tr(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!Tr.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,r=this.northeastCornerCartesian,i=this.westNormal,s=this.southNormal,a=this.eastNormal,c=this.northNormal,A=o.subtract(Lr,t,e),l=o.dot(A,i),f=o.dot(A,s),h=o.subtract(Lr,t,r),u=o.dot(h,a),E=o.dot(h,c);l>0?n+=l*l:u>0&&(n+=u*u),f>0?n+=f*f:E>0&&(n+=E*E)}const r=e[2],i=this.minimumHeight,s=this.maximumHeight;if(r>s){const t=r-s;n+=t*t}else if(r<i){const t=i-r;n+=t*t}return Math.sqrt(n)}computeBox(t){const e=this;gr(Tr.southwest(t,Rr),e.southwestCornerCartesian),gr(Tr.northeast(t,Rr),e.northeastCornerCartesian),yr[0]=t.west,yr[1]=.5*(t.south+t.north),yr[2]=0;const n=gr(yr,Ir),r=o.cross(xr,n,mr);o.normalize(e.westNormal,r),yr[0]=t.east;const i=gr(yr,Nr),s=o.cross(xr,mr,i);o.normalize(e.eastNormal,s);const a=o.subtract(xr,n,i),c=o.normalize(br,a),A=t.south;let l;if(A>0){yr[0]=.5*(t.west+t.east),yr[1]=A;const n=gr(yr,Dr);o.copy(Sr,c);const r=pr.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Or);wr(Dr,Sr,r,e.southwestCornerCartesian),l=Ne(n,Mr)}else l=De(Tr.southeast(t,Rr),Mr);const f=o.cross(Pr,l,a);o.normalize(e.southNormal,f);const h=t.north;let u;if(h<0){yr[0]=.5*(t.west+t.east),yr[1]=h;const n=gr(yr,Dr);o.scale(Sr,c,-1);const r=pr.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Or);wr(Dr,Sr,r,e.northeastCornerCartesian),u=Ne(n,Mr)}else u=De(Tr.northwest(t,Rr),Mr);const E=o.cross(Pr,a,u);o.normalize(e.northNormal,E)}}function wr(t,e,n,r){const i=t,s=e,a=n.normal,c=o.dot(a,s);if(Math.abs(c)<1e-15)return;const A=(-n.distance-o.dot(a,i))/c;return A<0?void 0:(r=o.scale(r,s,A),o.add(r,i,r))}const vr=new t.Extent(0,0,0,0),Ur=new t.Extent(0,0,0,0),Gr=[],Hr=[],Vr=[],Kr=[],kr=new t.Point(0,0),Xr=[],zr=new t.Coordinate(0,0),Yr=r.identity([]),Jr=[0,0];class Zr extends(f(t.Layer)){constructor(t,e){super(t,e),this.cn(),this.Se={},this.An=[]}cn(){const t=this.options.services.map(t=>t.url);this.ln=t.map((t,e)=>function(t,e){t=M(t);return{visible:1,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([]),Mt:e,Ot:0}}(t,e)),this.fire("rootready",{roots:this.ln.slice(0)})}showService(t){return this.hn(t,1),this}hideService(t){return this.hn(t,0),this}setToRedraw(){const t=this.getRenderer();t&&t.setToRedraw()}hn(t,e){const n=this.ln[t];if(!n)return;n.visible=e;const r=this.getRenderer();r&&r.setToRedraw()}getTileUrl(t){return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.ln.length;t++)if(this.ln[t].boundingVolume){const n=this.boundingVolumeToExtent(this.ln[t]);e._combine(n)}return e}return this.ln[e]&&this.ln[e].boundingVolume?this.boundingVolumeToExtent(this.ln[e]):null}boundingVolumeToExtent(e){const n=e.boundingVolume.un?Yr:e.matrix,r=this.getMap();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(x(n[0]),x(n[1]),x(n[2]),x(n[3]))}if(e.boundingVolume.sphere){const i=e.boundingVolume.sphere,s=Ie([],o.transformMat4([],i,n)),a=i[3],c=r.locate(s,-a,a),A=r.locate(s,a,-a);return new t.Extent(c,A)}if(e.boundingVolume.box){const i=e.boundingVolume.box,a=o.transformMat4([],i,n),c=new t.Coordinate(Ie([],a)),A=i.slice(3);s.multiply(A,s.fromMat4([],e.matrix),A);const l=o.length(A.slice(0,3)),f=o.length(A.slice(3,6)),h=o.length(A.slice(6,9)),u=Math.max(l,f,h),E=r.locate(c,-u,u),d=r.locate(c,u,-u);return new t.Extent(E,d)}return null}getRootTiles(){return this.ln}getTiles(){const t=this.getRenderer();if(!t.ready)return this.En(),{tiles:Kr};const e=this.getMap(),n=e.cameraPosition;let r,i;if(e.getGLZoom)i=e.pointToDistance(n[2],0,e.getGLZoom()),zr.set(n[0],n[1]),r=e.pointToCoord(zr,e.getGLZoom());else{const t=e.getGLRes();i=e.pointAtResToDistance(n[2],0,t),zr.set(n[0],n[1]),r=e.pointAtResToCoord(zr,t)}this.dn=this.dn||[],o.set(this.dn,b(r.x),b(r.y),i),this._n=Te(this._n||[],this.dn[0],this.dn[1],this.dn[2]),this.Bn=2*Math.tan(.5*b(e.getFov()));const s=e.projViewMatrix,a={children:[],level:-1};let c=a;const A=[];for(let e=0;e<this.ln.length;e++){const n=this.ln[e];if(!n.visible)continue;let r=1/0;const i=[n],o=this.Cn(e);for(;i.length>0;){const e=i.pop();for(e.id||this.Tn(e);c.level>=e.Ot;)c=c.parent;const n=this.mn(e,o,s);if(n<1){let t=c;for(;t&&!t.content;)t=t.parent;0===n&&t&&t.content&&this.gn(A,t);if(!1===this.options.services[e.Mt].alwaysShow)continue;if(!(0===n&&e.Ot<=r))continue;e.content&&(r=e.Ot)}e.Kt<1/0&&this.pn(e);const a=this.We(e,c);c.children.push(a);const l=e.children,f=l&&l.length,h=a.content;if(!f&&h&&this.gn(A,a),f){h&&"add"===e.refine&&this.gn(A,a),c=a;const n=l[0].parent;let r=!1;for(let o=0,s=l.length;o<s;o++){if(n){const e=t.getCachedTile(l[o].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,l[o].parent=e,l[o].ne=e.ne,l[o].baseUrl=e.baseUrl;const t=l[o].content&&(l[o].content.url||l[o].content.uri);t&&(F(t)||t.indexOf("i3s:")>=0?l[o].baseUrl=e.baseUrl:-1===t.indexOf("http://")&&-1===t.indexOf("https://")?l[o].content.url=e.baseUrl+t:l[o].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}i.push(l[o])}!r&&h&&this.gn(A,a)}}}return{root:a,tiles:A}}gn(t,e){const{viewerRequestVolume:n}=e.node;n&&!function(t,e,n){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return Wr(n,e);if(n.box)return 0===jr(n,e)}return!1}(this.dn,this._n,n)||t.push(e)}We(t,e){return{id:t.id,node:t,children:[],level:t.Ot,parent:e,content:t.content&&t.content.url}}Tn(e){e.id=t.Util.GUID(),e.matrix=e.transform||r.identity([]),e.yn=this.Rn(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=r.multiply(e.matrix,e.parent.matrix,e.matrix)),e.Mt=e.parent.Mt,void 0===e.Ot&&(e.Ot=e.parent.Ot+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri),this.In(e)}In(t){const e=t.boundingVolume;if(!e||e.un)return;const n=this.options.services[t.Mt],i=n.heightOffset||0,s=this.options.offset,a=y(s)||s[0]||s[1],c=n.coordOffset||Jr;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!t.boundingVolume||!i&&r.exactEquals(t.matrix,Yr)&&!a&&c===Jr)return;const{region:A,box:l,sphere:f}=e;if(A){const t=this.bn([x(A[0]),x(A[1])]);A[0]=b(t.x+c[0]),A[1]=b(t.y+c[1]);const e=this.bn([x(A[2]),x(A[3])]);A[2]=b(e.x+c[0]),A[3]=b(e.y+c[1]),A[4]+=i+(c[2]||0),A[5]+=i+(c[2]||0)}else if(l||f){const e=l||f,n=o.transformMat4(Gr,e,t.matrix),r=Ie(Hr,n),s=this.bn([r[0]+c[0],r[1]+c[1]]);r[0]=s.x,r[1]=s.y,r[2]+=i+(c[2]||0),Te(e,b(r[0]),b(r[1]),r[2])}e.un=!0}Rn(t){return void 0===t.geometricError||!t.boundingVolume}pn(t){let e=t.parent;for(;e&&e.yn&&!(e.Kt<=t.Kt);)e.Kt=t.Kt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const r=this.getRenderer();r&&r.setToRedraw()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const i=this.options.services[e.Mt],o=(t.asset&&t.asset.gltfUpAxis||e&&e.ne||i.upAxis||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const s=n.indexOf("realspace/")>-1;0===e.Ot&&(t.asset&&t.asset.s3mType&&s||i.isSuperMapiServer)&&(t.root.baseUrl+="data/path/");const a=t.asset.i3s,c=!!t.asset.s3mType;if(t.root.ne=o,e){const n=e.Mt,i=this.ln[n];c&&!i.isS3M&&(i.isS3M=c);const o=e.boundingVolume;p(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",o&&(e.boundingVolume=o);const s=t.root.transform;s&&(e.parent?a||(e.matrix=r.multiply([],e.parent.matrix,s)):e.matrix=s),this.In(e),e.xn=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.yn=this.Rn(e);const A=e.content&&(e.content.url||e.content.uri);A&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),a||!A||F(A)||-1!==A.indexOf("http://")||-1!==A.indexOf("https://")||(e.content.url=e.baseUrl+A)}this.En(),this.fire("loadtileset",{tileset:t,index:e&&e.Mt,url:n})}mn(t,e,n){if(t.Kt=1/0,0===t.Ot||t.yn)return 1;if(!this.Mn(t,e,n))return-1;if(0===t.geometricError)return 1;let r=this.options.services[t.Mt].maximumScreenSpaceError;null==r&&(r=16);let i=this.Pn(t);return 0===i&&t.parent&&(i=.5*(t.parent.Xe||0)),i>=r?1:0}Wt(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.getGLZoom?r.coordToPoint(e,r.getGLZoom(),n):r.coordToPointAtRes(e,r.getGLRes(),n)}Mn(e,n,i){const a=e.id;let c=this.An[a];const{boundingVolume:A}=e,l=A.sphere;let f=A.region;const h=A.box;if(!c){let n,i,u;if(h&&(f=function(t,e){for(let e=0;e<9;e++)t[e+3]!==1/0&&t[e+3]!==-1/0||(t[e+3]=6378137*Math.sign(t[e+3])*3),si[e]=t[e+3];const n=si;r.exactEquals(e,Yr)||s.multiply(n,s.fromMat4(Xr,e),n);const i=o.copy(Qr,t),a=o.set(qr,n[0],n[1],n[2]),c=o.set($r,n[3],n[4],n[5]),A=o.set(ti,n[6],n[7],n[8]);ei[0]=ei[0]||[];const l=o.copy(ei[0],i);o.sub(l,l,a),o.sub(l,l,c),o.sub(l,l,A),ei[1]=ei[1]||[];const f=o.copy(ei[1],i);o.sub(f,f,a),o.sub(f,f,c),o.add(f,f,A),ei[2]=ei[2]||[];const h=o.copy(ei[2],i);o.sub(h,h,a),o.add(h,h,c),o.sub(h,h,A),ei[3]=ei[3]||[];const u=o.copy(ei[3],i);o.sub(u,u,a),o.add(u,u,c),o.add(u,u,A),ei[4]=ei[4]||[];const E=o.copy(ei[4],i);o.add(E,E,a),o.sub(E,E,c),o.sub(E,E,A),ei[5]=ei[5]||[];const d=o.copy(ei[5],i);o.add(d,d,a),o.sub(d,d,c),o.add(d,d,A),ei[6]=ei[6]||[];const _=o.copy(ei[6],i);o.add(_,_,a),o.add(_,_,c),o.sub(_,_,A),ei[7]=ei[7]||[];const B=o.copy(ei[7],i);o.add(B,B,a),o.add(B,B,c),o.add(B,B,A);for(let t=0;t<ei.length;t++)ni[t]=ni[t]||[],Ie(ni[t],ei[t]),ri[t]=ni[t][0],ii[t]=ni[t][1],oi[t]=ni[t][2];return[b(Math.min(...ri)),b(Math.min(...ii)),b(Math.max(...ri)),b(Math.max(...ii)),Math.min(...oi),Math.max(...oi)]}(h,e.matrix),A.region=f),f){n=vr.set(x(f[0]),x(f[1]),x(f[2]),x(f[3]));const t=n.getCenter(),e=this.Nn(t);n=n.convertTo(t=>this.Wt(t,kr),Ur),u=f[4],i=f[5],c=this.An[a]=[[n.xmin,n.ymin,u*e[2]],[n.xmax,n.ymax,i*e[2]]],c.center=t}else if(l){const e=Ie(Gr,l),n=new t.Coordinate(e),r=this.Wt(n,kr).toArray(),i=this.Nn(n);r.push(e[2]*i[2]),c=this.An[a]=[r,l[3]*i[2]],c.center=n}}if(n){if(f)vr.xmin=c[0][0],vr.ymin=c[0][1],vr.xmax=c[1][0],vr.ymax=c[1][1];else if(l){const t=c[2];vr.xmin=c[0][0]-t,vr.ymin=c[0][1]-t,vr.xmax=c[0][0]+t,vr.ymax=c[0][1]+t}else if(h){const t=c[1],e=c[2];vr.xmin=c[0][0]-t,vr.ymin=c[0][1]-e,vr.xmax=c[0][0]+t,vr.ymax=c[0][1]+e}if(!n.intersects(vr))return!1}return f?_(i,c):l?function(t,e,n){C(t);for(var r=e[0],i=-e[1],o=0;o<6;o++){if(!n||"0"!==n.charAt(o))if(m(u[o],r)<i)return!1}return!0}(i,c):!!h&&function(t,e,n){C(t);for(var r=0;r<6;r++){if(!n||"0"!==n.charAt(r))if(!B(u[r],e))return!1}return!0}(i,c)}Nn(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let r;return r=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:n.y/100,o.set(Vr,n.x/100*1.01,n.y/100*1.01,r),Vr}bn(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(y(n)&&(n=n(Array.isArray(e)?new t.Coordinate(e):e)),n[0]||n[1]){const t=this.getMap(),r=t.getGLRes(),i=t.coordToPointAtRes(e,r);return i._sub(n),t.pointAtResToCoord(i,r)}return e}Cn(e){const n=this.options.services[e].maxExtent;if(!n)return null;const r=this.ln[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo(t=>this.Wt(t))),r.maxExtent}Pn(t){const e=this.Bn,n=t.geometricError;if(0===n)return t.Xe=0,0;const r=this.getMap();let i;t.boundingVolume.region?i=function(t,e,n){t.Dn||(t.Dn=new Fr(t.boundingVolume.region));return t.Dn.distanceToCamera(e,n)}(t,this._n,this.dn):t.boundingVolume.sphere?i=Wr(t.boundingVolume,this._n):t.boundingVolume.box&&(i=jr(t.boundingVolume,this._n));const o=Math.max(Math.abs(i),1e-7),s=n*r.height/(o*e);return t.Kt=i,t.Xe=s,s}En(){const t=this.getRenderer();t&&t.setToRedraw()}ce(t){return this.An[t]}identify(e,n={}){const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];const o=r.coordToContainerPoint(new t.Coordinate(e));return this.identifyAtPoint(o,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&v(n,r)}const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];const o=r.getDevicePixelRatio();return v(n,i.pick(t.x*o,t.y*o,e)),n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Ce():[]}highlight(t){const e=this.getRenderer();return e?(e.highlight(t),this):(this.Pt||(this.Pt=[]),this.Pt.push(t),this)}in(){if(this.Pt){for(let t=0;t<this.Pt.length;t++)this.highlight(this.Pt[t]);delete this.Pt}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Dt||(this.Dt=[]),this.Dt.push(t),this)}Sn(){if(this.Dt){for(let t=0;t<this.Dt.length;t++)this.showOnly(this.Dt[t]);delete this.Dt}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);const r=this.getRenderer();return r?(r.setToRedraw(),this):this}}function Wr(t,e){const n=t.sphere,r=o.dist(n,e),i=t.sphere[3];return r<i?0:r-i}function jr(t,e){const n=t.box;return hr(o.set(Gr,n[0],n[1],n[2]),s.set(Xr,n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]),e)}Zr.mergeOptions({"maxGPUMemory":512,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":0,"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"debug":!1,"debugOutline":[0,1,0],"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"antialias":!1,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"],"offset":[0,0]}),Zr.registerRenderer("gl",Ar),Zr.registerJSONType("Geo3DTilesLayer");const Qr=[],qr=[],$r=[],ti=[],ei=[],ni=[],ri=[],ii=[],oi=[],si=[];let ai=null;function ci(){return ai||(ai={"image/crn":jn.crn&&jn.crn(),"image/ktx2":jn.ktx2&&jn.ktx2(),"image/cttf":jn.ktx2&&jn.ktx2(),"draco":jn.draco&&jn.draco()}),ai}class Ai{constructor(t,e,n){this.i=t,this.On=e||Zt,this.o=n,this.Ln=ci()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.Fn(t,e,n,r,i)):Pt.getArrayBuffer(t,{}).then(e=>{const i=e.data;return r||(r=i.byteLength),this.Fn(t,i,n,r)})}Fn(t,e,n,r,i){const o=i&&i.maxTextureSize,s=this.wn(e,n,r,t);if(s.error)return Promise.resolve(s);const a=t.substring(0,t.lastIndexOf("/")),c=new this.On(a,s.glb,{transferable:!0,requestImage:this.i,decoders:this.Ln,supportedFormats:this.o,maxTextureSize:o});return c.load({skipAttributeTransform:!1}).then(e=>{e.url=`${t}-${n}-${r}`;const i=c.transferables;for(let t=0;t<s.transferables.length;t++)i.indexOf(s.transferables[t])<0&&i.push(s.transferables[t]);return{magic:"b3dm",count:s.count,transferables:i,featureTable:s.featureTable,batchTable:s.batchTable,batchTableBin:s.batchTableBin,gltf:e}})}wn(t,e,n,r){const i=new DataView(t,e,n),o=i.getUint32(4,!0);if(1!==o){const t="Unsupported b3dm version: "+o+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let s,a=i.getUint32(12,!0),c=i.getUint32(16,!0),A=i.getUint32(20,!0),l=i.getUint32(24,!0),f=28+e;A>=570425344?(f-=8,s=a,A=c,l=0,a=0,c=0):l>=570425344&&(f-=4,s=A,A=a,l=c,a=0,c=0);const h=[t];let u,E,d;if(a>0?(u=we(t,f,a),f+=a,s=u.BATCH_LENGTH):u={"BATCH_LENGTH":s},c>0&&(f+=c),A>0&&(E=ve(t,f,A),f+=A,l>0)){const e=Ue(0,f,l);d=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(d)}const _=u.BATCH_LENGTH,B={};if(u&&u.BATCH_ID){B.BATCH_ID=He(u.BATCH_ID,t,(void 0).offset,_);const e=B.BATCH_ID.array&&B.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:s,transferables:h,featureTable:u,batchTable:E,batchTableBin:d,b3dm:B,glb:{buffer:t,byteOffset:f,byteLength:i.byteLength+i.byteOffset-f}}}vn(){return null}}class li{constructor(t,e,n,r){this.i=t,this.On=e||Zt,this.o=n,this.Ln=ci(),this.Un=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.Fn(t,e,n,r,i)):Pt.getArrayBuffer(t,{}).then(e=>{const i=e.data;return r||(r=i.byteLength),this.Fn(t,i,n,r)})}Fn(t,e,n,r,i){return this.Gn(t,e,n,r,i).then(({gltf:i,transferables:o})=>{const s=this.Hn(e,n,r,t);if(s.error)return Promise.resolve(s);for(let t=0;t<o.length;t++)-1===s.transferables.indexOf(o[t])&&s.transferables.push(o[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:s.count,transferables:s.transferables,featureTable:s.featureTable,batchTable:s.batchTable,batchTableBin:s.batchTableBin,i3dm:s.i3dm,gltf:i})})}Gn(t,e,n,r,i){const o=i&&i.maxTextureSize,s={transferable:!0,requestImage:this.i,decoders:this.Ln,supportedFormats:this.o,maxTextureSize:o},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=D(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Pt.getArrayBuffer(r,{}).then(t=>this.Vn(r,{buffer:t.data,byteOffset:0},s)):Pt.getJSON(r,{}).then(t=>this.Vn(r,t,s))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Vn(t,r,s)}}Vn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.On(r,e,n);return i.load({skipAttributeTransform:!0}).then(n=>{let r=0,o=0;return e.buffer&&(r=e.byteOffset||0,o=e.byteLength||0),n.url=`${t}-${r}-${o}`,{transferables:i.transferables,gltf:n}})}Hn(t,e,n,r){const i=new DataView(t,e,n),o=i.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const s=[t],{featureTable:a,featureTableBin:c,batchTable:A,batchTableBin:l}=Ze(i,32+e,s),f={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},s.push(f.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.Kn(new Uint16Array(t,r+c.offset,3*h),e,n)},s.push(f.POSITION.array.buffer)}if(a.BATCH_ID){f.BATCH_ID=He(a.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&s.indexOf(e)<0&&s.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},s.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},s.push(f.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.kn(new Uint16Array(t,e+c.offset,2*h))},s.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.kn(new Uint16Array(t,e+c.offset,2*h))},s.push(f.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},s.push(f.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},s.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:A,batchTableBin:l,featureTable:a,i3dm:f,transferables:s}}kn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)fi(r,t[2*i],t[2*i+1],65535),n[3*i]=r[0],n[3*i+1]=r[1],n[3*i+2]=r[2];return n}Kn(t,e,n){return Je(new Float32Array(t.length),t,e,n)}vn(){return null}}function fi(t,e,n,r){if(t[0]=hi(e,r),t[1]=hi(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*ui(e),t[1]=(1-Math.abs(e))*ui(t[1])}return tt(t,t)}function hi(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function ui(t){return t<0?-1:1}class Ei{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Fn(t,e,n,r)):Pt.getArrayBuffer(t,{}).then(e=>{const i=e.data;return r||(r=i.byteLength),this.Fn(t,i,n,r)})}Fn(t,e,n,r){return this.Xn(e,n,r,t).then(t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts})}Xn(t,e,n,r){const i=new DataView(t,e,n),o=i.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const s=[t],{featureTable:a,featureTableBin:c,batchTable:A,batchTableBin:l}=Ze(i,e+28,s),f=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,u=a.POINTS_LENGTH;let E,d={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){d=a.extensions["3DTILES_draco_point_compression"],E=new DataView(t,d.byteOffset+c.offset,d.byteLength);const e={attributes:d.properties,useUniqueIDs:!1};return this.zn||(this.zn=ci().draco),this.zn(E,e).then(e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.Yn(t,e.attributes,c.offset,u,s,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Ye(t.constructor),array:t},s.push(t.buffer)}else if(a.BATCH_ID||Object.keys(A).length){a.BATCH_ID?r.BATCH_ID=He(a.BATCH_ID,t,c.offset,u):r.BATCH_ID=di(u);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&s.indexOf(e)<0&&s.push(e)}return{count:u,batchTable:A,batchTableBin:l,featureTable:a,pnts:r,transferables:s}})}const _=this.Yn(t,a,c.offset,u,s,f,h);if(a.BATCH_ID||Object.keys(A).length){a.BATCH_ID?_.BATCH_ID=He(a.BATCH_ID,t,c.offset,u):_.BATCH_ID=di(u);const e=_.BATCH_ID.array&&_.BATCH_ID.array.buffer;e&&s.indexOf(e)<0&&s.push(e)}return Promise.resolve({count:u,batchTable:A,batchTableBin:l,featureTable:a,pnts:_,transferables:s})}Yn(t,e,n,r,i,o,s){const a={};if(e.POSITION){let{byteOffset:o,array:s}=e.POSITION;o=o||0;const c=s?0:n;if(!s){const e=t.slice(o+c,o+c+3*r*4);s=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:s},i.push(s.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:A}=e.POSITION_QUANTIZED;c=c||0;const l=A?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Kn(A||new Uint16Array(t,c+l,3*r),o,s)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:o,array:s}=e.RGBA;o=o||0;const c=s?0:n;if(!s){const e=t.slice(o+c,o+c+4*r);s=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:s},i.push(s.buffer)}else if(e.RGB){let{byteOffset:o,array:s}=e.RGB;o=o||0;const c=s?0:n;if(!s){const e=t.slice(o+c,o+c+3*r);s=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:s},i.push(s.buffer)}else if(e.RGB565){let{byteOffset:o,array:s}=e.RGB565;o=o||0;const c=s?0:n;if(!s){const e=t.slice(o+c,o+c+2*r);s=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:s},i.push(s.buffer)}if(e.NORMAL){let{byteOffset:o,array:s}=e.NORMAL;o=o||0;const c=s?0:n;if(!s){const e=t.slice(o+c,o+c+3*r*4);s=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:s},i.push(s.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:o,array:s}=e.NORMAL_OCT16P;o=o||0;const c=s?0:n;if(!s){const e=t.slice(o+c,o+c+2*r);s=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:s},i.push(s.buffer)}return a}Kn(t,e,n){return Je(new Float32Array(t.length),t,e,n)}vn(){return null}}function di(t){const e=L(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Ye(e),array:n}}class _i{constructor(t,e,n,r){this.o=n,this.i=t,this.On=e||Zt,this.Un=r}load(t,e,n=0,r=0,i){return e?this.Fn(t,e,n,r,i):Pt.getArrayBuffer(t,{}).then(e=>{const i=e.data;return this.Fn(t,i,n,r)})}Fn(t,e,n,r,i){r||(r=e.byteLength);const o=this.Jn(e,t,n,r),s=[];for(let n=0;n<o.length;n++){let r;if("b3dm"===o[n].magic)r=new Ai(this.i,this.On,this.o);else if("i3dm"===o[n].magic)r=new li(this.i,this.On,this.o,this.Un);else if("pnts"===o[n].magic)r=new Ei;else{if("cmpt"!==o[n].magic){console.warn("Unsupported magic in CMPT tile:",o[n].magic);continue}r=new _i(this.i,this.On,this.o,this.Un)}s.push(r.load(t,e,o[n].offset,o[n].byteLength,i).then(t=>t))}return Promise.all(s).then(t=>({magic:"cmpt",tiles:t}))}Jn(t,e,n,r){const i=new DataView(t,n,r),o=i.getUint32(4,!0);if(1!==o){const t="Unsupported cmpt version: "+o+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const s=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Le(i,c),r=i.getUint32(c+8,!0);s.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return s}}if(e.transcoders){const n=t.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=e.transcoders.inject(h);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(h)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",h);export{Ai as B3DMLoader,_i as CMPTLoader,Zr as Geo3DTilesLayer,U as Geo3DTilesUtil,Se as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.83.1");
23
+ */(i,a)),c.generateBuffers(this.et,{excludeElementsInVAO:e}),c}ae(t,e,n,s){const o=r.identity(t),a=this.getMap();Dn.x=n[0],Dn.y=n[1];const c=this._prjToPoint(Dn),h=this.ye(),u=1/(a.getGLZoom?a.getResolution(a.getGLZoom()):a.getGLRes());Dn.x=e[0],Dn.y=e[1];const f=this.he();let l=this.J.options.offset;O(l)&&(l=l(Dn));const d=this.J.options.services[s].heightOffset||0;return i.set(Gn,c.x-l[0],c.y-l[1],f*n[2]+f*d),r.translate(o,o,Gn),i.set(h,u,u,f),r.scale(o,o,h),o}Zt(t,e){const n=r.identity(t),s=this.getMap(),o=this.ye();Dn.x=e[0],Dn.y=e[1];const a=s.distanceToPointAtRes(100,100,s.getGLRes(),Dn);let c;return c=s.altitudeToPoint?this.Ot:a.y/100,i.set(o,a.x/100*1.01,a.y/100*1.01,c),r.scale(n,n,o),n}wt(){const t={x:0,y:0,width:()=>this.Z?this.Z.width:1,height:()=>this.Z?this.Z.height:1};this.zt=new n.MeshShader({vert:"attribute vec3 aPosition;\n\n\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main() {\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n}\n\n",frag:"precision mediump float;\n\n\n\nuniform vec3 color;\n\n\n\nvoid main() {\n\n gl_FragColor = vec4(color, 1.0);\n\n}\n\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply([],e.projViewMatrix,e.modelMatrix)}],extraCommandProps:{viewport:t}});const e=[],s=[];this.Vt=new n.MeshShader({vert:"const float SHIFT_RIGHT_11 = 1.0 / 2048.0;\n\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\n\nconst float SHIFT_LEFT_11 = 2048.0;\n\nconst float SHIFT_LEFT_5 = 32.0;\n\nconst float NORMALIZE_6 = 1.0 / 64.0;\n\nconst float NORMALIZE_5 = 1.0 / 32.0;\n\n\n\n#ifdef HAS_POSITION\n\n attribute vec3 POSITION;\n\n#endif\n\n\n\n#if defined(HAS_RGB)\n\n attribute vec3 RGB;\n\n#elif defined(HAS_RGBA)\n\n attribute vec4 RGBA;\n\n#elif defined(HAS_RGB565)\n\n attribute float RGB565;\n\n#endif\n\n\n\nuniform vec4 pointColor;\n\nuniform float pointSize;\n\n\n\nuniform mat4 projViewModelMatrix;\n\nuniform float pointOpacity;\n\n\n\nvarying vec4 vColor;\n\n\n\n#ifdef HAS_NORMAL\n\n #ifdef HAS_NORMAL_OCT16P\n\n attribute vec2 NORMAL_OCT16P;\n\n float signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n }\n\n vec2 signNotZero(vec2 value) {\n\n return vec2(signNotZero(value.x), signNotZero(value.y));\n\n }\n\n vec3 octDecode(vec2 encoded, float range) {\n\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n return vec3(0.0, 0.0, 0.0);\n\n }\n\n encoded = encoded / range * 2.0 - 1.0;\n\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n if (v.z < 0.0) {\n\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n }\n\n vec3 octDecode(vec2 encoded) {\n\n return octDecode(encoded, 255.0);\n\n }\n\n #else\n\n attribute vec3 NORMAL;\n\n #endif\n\n uniform vec3 lightDir;\n\n uniform mat3 modelNormalMatrix;\n\n uniform mat4 positionMatrix;\n\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n\n return max(dot(-lightDir, normal), 0.0);\n\n }\n\n#endif\n\n\n\nvoid main() {\n\n #if defined(HAS_RGB)\n\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n\n #elif defined(HAS_RGBA)\n\n vColor = RGBA / 255.0 * pointOpacity;\n\n #elif defined(HAS_RGB565)\n\n float compressed = RGB565;\n\n float r = floor(compressed * SHIFT_RIGHT_11);\n\n compressed -= r * SHIFT_LEFT_11;\n\n float g = floor(compressed * SHIFT_RIGHT_5);\n\n compressed -= g * SHIFT_LEFT_5;\n\n float b = compressed;\n\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n\n vColor = vec4(rgb, 1.0);\n\n #else\n\n vColor = pointColor;\n\n #endif\n\n\n\n #ifdef HAS_POSITION\n\n vec3 localPos = POSITION;\n\n #endif\n\n\n\n #ifdef HAS_NORMAL\n\n mat3 positionNormalMatrix = mat3(positionMatrix);\n\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n\n #ifdef HAS_NORMAL_OCT16P\n\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n\n #else\n\n vec3 localNormal = NORMAL;\n\n #endif\n\n vec3 normal = normalize(normalMatrix * localNormal);\n\n float colorStrength = getLambertDiffuse(lightDir, normal);\n\n colorStrength = max(colorStrength, 0.5);\n\n vColor *= colorStrength;\n\n #endif\n\n\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n}\n\n",frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n gl_FragColor = vColor;\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(s,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,n)=>o.fromMat4(e,n.modelMatrix)}],extraCommandProps:{viewport:t,blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const i=this.At();this.Dt=new n.PhongShader({extraCommandProps:i}),this.Ft=new n.pbr.StandardShader({extraCommandProps:i});const a=this.J;In(a.getRenderer().canvas,this.et,a.getMap()),this.picking=new n.FBORayPicking(this.nt,{vert:this.Ft.vert,extraCommandProps:i,uniforms:this.Ft.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}At(){return{viewport:{x:0,y:0,width:()=>this.Z?this.Z.width:1,height:()=>this.Z?this.Z.height:1},colorMask:(t,e)=>e.colorMask||Pn,cull:{enable:!0,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>!0===e.stencilEnable,func:{cmp:(t,e)=>e.meshProperties.isLeaf?"always":">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}qt(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}kt(t){const e=this.getMap(),n=e.getLightManager(),r=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:i.normalize(r,r)}}It(){const t=this.getMap(),e=this.J.getRenderer().canvas,{iblTexes:n,dfgLUT:r}=Mn(e),s=En(t,n,r),i=this.J.getRenderer().getMaskUniforms();return A(s,{czm_lightDirectionEC:s.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[e.width,e.height],polygonFill:[1,1,1,1],polygonOpacity:1}),A(s,i),s}me(t,e,r,s,i){const o=e.materials&&e.materials[t];if(!o||!o.baseColorTexture&&!o.pbrMetallicRoughness)return null;const c=A({},s);if(o.baseColorTexture){const t=e.textures[o.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.S(t)),c.baseColorFactor=t&&t.image.color||o.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(o.normalTexture){const t=this.S(e.textures[o.normalTexture.index]),n=o.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=n}if(o.occlusionTexture){const t=this.S(e.textures[o.occlusionTexture.index]),n=o.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=n}if(o.emissiveTexture){const t=this.S(e.textures[o.emissiveTexture.index]);c.emissiveTexture=t}o.emissiveFactor&&(c.emissiveFactor=o.emissiveFactor);const t=o.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];n.image&&n.image.color?c.baseColorFactor=c.baseColorFactor?a.multiply(c.baseColorFactor,c.baseColorFactor,n.image.color):n.image.color:(c.baseColorTexture=this.S(n),c.baseColorTexture.getREGLTexture(this.et))}if(_(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),_(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),o.metallicRoughnessTexture){const t=this.S(e.textures[o.metallicRoughnessTexture.index]);c.metallicRoughnessTexture=t}}}if(o.s3mMaterial)return new n.Material(c);if(c.environmentExposure=i,o.extensions&&o.extensions.KHR_materials_unlit)return c.environmentExposure=1,c.ambientColor=[1,1,1],c.light0_diffuse=[0,0,0,0],c.lightSpecular=[0,0,0],new n.PhongMaterial(c);c.alphaTest=.99;let h=new n.pbr.StandardMaterial(c);"phong"===r&&(h=n.PhongMaterial.convertFrom(h));const u=o.pbrMetallicRoughness,f=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(h.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),h.set("khr_rotation",f.KHR_texture_transform.rotation||0),h.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),h.once("complete",this.bt),h}S(t){const e={type:t.type?Tn(t.type):"uint8",format:t.format?wn(t.format):"rgba",flipY:!!t.flipY},r=t.image;r.array?e.data=r.array:r.mipmap&&(e.mipmap=r.mipmap),e.width=r.width,e.height=r.height;const s=t.sampler||t.texture&&t.texture.sampler;return s&&(s.magFilter&&(e.mag=yn(s.magFilter)),s.minFilter&&(e.min=bn(s.minFilter)),s.wrapS&&(e.wrapS=gn(s.wrapS)),s.wrapT&&(e.wrapT=gn(s.wrapT))),new n.Texture2D(e,this.yt)}be(t){const e=t.image,n=window.URL||window.webkitURL,r=new Blob([e.array],{type:e.mimeType});return n.createObjectURL(r)}gt({target:t}){const e=t.pe,n=this.rt[e];if(n.count--,!n.count){const t=n.meshes;this.it[e]=t,delete this.rt[e];const r=t.oe;delete t.oe,r(null,{mesh:n.meshes,id:e})}}ye(){return Cn}Wt(t){return this.J.Wt(t)}Jt(t,e){const n=this.getMap();return n.getGLZoom?n.distanceToPoint(t,e,n.getGLZoom()):n.distanceToPointAtRes(t,e,n.getGLRes())}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),Fn)}ee(t){return"Y"===t?On:"X"===t?xn:Rn}pick(t,e,n=3){const r=this.J;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=this.getMap(),i=this.It(),o=this.picking;o.render(this.ft.getMeshes().filter(t=>!t.bloom),i,!0);let a={};o.getRenderedMeshes().length&&(a=o.pick(t,e,n,i,{viewMatrix:s.viewMatrix,projMatrix:s.projMatrix,returnPoint:r.options.pickingPoint}));const{meshId:c,pickingId:h,point:u,coordinate:f}=a,l=(0===c||c)&&o.getMeshAt(c);if(!l||!l.geometry)return[];const d=l.properties;u&&u.length&&(u[0]=Math.round(1e5*u[0])/1e5,u[1]=Math.round(1e5*u[1])/1e5,u[2]=Math.round(1e5*u[2])/1e5);const m={batchId:h};if(r.options.debug&&(m.debugInfo=d),d&&d.batchTable){const{batchTable:t,batchTableBin:e,count:n}=d,r=h;for(const s in t)void 0!==t[s].byteOffset?m[s]=He(t[s],e,n,r):m[s]=t[s][r]}return[{service:l.properties.serviceIndex,data:m,point:u,coordinate:f}]}St(t){let e=new Set;for(let n=0,r=t.length;n<r;n++){const r=t[n].data.node;this.Mt(r)&&e.add(r.Bt)}e=Array.from(e),e.sort();const n=new Map,r=e.length;for(let t=0;t<r;t++)n.set(e[t],t);return n}highlight(t){this.vt=t;const e=this.J.getRenderer();this.Nt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.vt=null;const t=this.J.getRenderer();this.Nt=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Ct=t;const e=this.J.getRenderer();this.Rt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Ct=null;const t=this.J.getRenderer();this.Rt=t.getFrameTimestamp(),t.setToRedraw(!0)}ge(){if(!this.xt)return[];const t={},e=[];for(const n in this.xt){const r=this.xt[n];if(r)for(let n=0;n<r.length;n++){const s=r[n],i=s&&s.geometry;if(!s||!i)continue;const o=s.properties.serviceIndex;t[o]||(t[o]=new Set);const a=i.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}const Kn=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},$n=Kn(),Wn=$n.gl_trans__coders=$n.gl_trans__coders||{};function Yn(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}Wn.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=$n.gl_trans__coders=$n.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${Kn.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\n;");return i+="\n"+e.substring(r.length),i},Wn.registerTranscoder=function(t,e){Wn[t]=e},Wn.getTranscoder=function(t){return Wn[t]};const Jn=[];class Zn{constructor(t,e,n,r){this.Te=t,this.Et=e,this.we=r,this._e=n.version,t.indexOf("i3s:tileset:")<0?(this._e<=1.6?this.Ae="root":this.Ae=0,n.version=this._e):(this.Ae=t.substring("i3s:tileset:".length),this._e>1.6&&(this.Ae=parseInt(this.Ae))),this.Te=t,this.Oe=n}load(){const t=this.Oe,e=t.layerScene.baseUrl;if(this._e<=1.6)return t[this.Ae]&&t[this.Ae].lodSelection?(this.xe=t[this.Ae],this.Ie()):new Promise(n=>{let r=e+"/nodes/"+this.Ae;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.we(this.Et,r,()=>{this.xe=t[this.Ae],n(this.Ie())})});if(this._e>=1.7){if(t[this.Ae])return this.xe=t[this.Ae],this.Ie();const n=Math.floor(this.Ae/t.nodesPerPage);return new Promise(r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.we(this.Et,s,()=>{this.xe=t[this.Ae],r(this.Ie())})})}return null}getTileset(){return this.Se}getChildrenURL(){return this.Me}Ie(){const t=this.Oe,e=t.layerScene.baseUrl,n=this.xe.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this._e<=1.6){const o=n[i].id;if(t[o])continue;const a=o;s[a]||(s[a]=new Promise(n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.we(this.Et,r,()=>{n()})}),r.push(s[a]))}else{const o=n[i];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);s[a]||(s[a]=new Promise(n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.we(this.Et,r,()=>{n()})}),r.push(s[a]))}return r.length?Promise.all(r).then(()=>this.Ee()):this.Ee()}Ee(){return Promise.resolve(this.ve())}Ne(t){Yn(this.Oe,t)}ve(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.Ce(this.xe,!0)}}Ce(t){const e=this._e,n=this.Oe,r=t,s=r.obb,i=r.mbs,o={};let a;if(i)a=Qn([],i[0],i[1],i[2]),o.sphere=[...a,i[3]];else if(s){a=Qn([],s.center[0],s.center[1],s.center[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,f=r*a,l=s*o,d=s*a,m=s*c,p=i*o,y=i*a,b=i*c;return t[0]=1-f-m,t[3]=u-b,t[6]=l+y,t[1]=u+b,t[4]=1-h-m,t[7]=d-p,t[2]=l-y,t[5]=d+p,t[8]=1-h-f,t}([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(a,s.halfSize,s.quaternion),e=t[3]+t[6]+t[9],n=t[4]+t[7]+t[10],r=t[5]+t[8]+t[11];W(Jn,e,n,r);const i=it(Jn);o.sphere=[...a,i]}let c=1/0,h=0;if(r.mbs?h=r.mbs[3]:r.obb&&(h=Math.max(Math.max(r.obb.halfSize[0],r.obb.halfSize[1]),r.obb.halfSize[2])),void 0!==r.lodThreshold)if("maxScreenThresholdSQ"===n.lodSelectionMetricType){c=h/(Math.sqrt(r.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==r.lodSelection)for(let t=0;t<r.lodSelection.length;t++)"maxScreenThreshold"===r.lodSelection[t].metricType&&(c=h/r.lodSelection[t].maxError);(c===1/0||isNaN(c))&&(c=1e5);const u=16*c,f=V([]),l=r.children;let d;if(l){d=[];const t=this.Oe;for(let n=0;n<l.length;n++){const r=e<=1.6?l[n].id:l[n];if(!t[r]){d=null;break}d.push(this.Ce(t[r]))}}const m={refine:"REPLACE",boundingVolume:o,transform:f,geometricError:u};return e<=1.6?t.lodSelection?t.geometryData&&(m.content={uri:"i3s:mesh:"+(t.id||t.index)}):m.content={uri:"i3s:tileset:"+(t.id||t.index)}:l&&l.length&&!d?m.content={uri:"i3s:tileset:"+(t.id||t.index)}:r.mesh&&(m.content={uri:"i3s:mesh:"+(t.id||t.index)}),d&&d.length&&(m.children=d),m}getJSON(){return this.xe}}function Qn(t,e,n,r){return Te(t,S(e),S(n),r)}const tr=!!Wn.ktx2,er=r.identity([]),nr=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function rr(t){return t.indexOf("i3s:mesh")>=0}const sr="i3s:mesh:".length;function ir(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(sr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let u=!1;const f=er;let l,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;i&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let s=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(s){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",i&&(s+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+s,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}h.push(r)}else{l=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions[l.definition],{geometryBuffers:o}=t;u=r&&2===o.length;const f=Wn.draco&&u?o[1]:o[0],m=Wn.draco&&u?1:0;let p=c+`/nodes/${l.resource}/geometries/`+m;i&&(p+=".bin");const y={geometry:{url:p,info:f}};if(s&&nr&&u&&!Wn.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const b=e.layerScene.materialDefinitions,g=e.layerScene.textureSetDefinitions;let T,w=0;if(d&&(w=b[d.definition]),b){T=function(t,e,n,r,s,i){const o=JSON.parse(JSON.stringify(t));return function t(e,n,r,s,i,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const t=n[e[a].textureSetDefinitionId],c="images/"+t.formats[0].format,h=or(t.formats,i),u={url:r+`/nodes/${s}/textures/${h.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:h.format,mimeType:c};if(o){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}u.url+="."+t}e[a]=u}else x(e[a])&&t(e[a],n,r,s,i,o)}(o,e,n,r,s,i),o}(w,g,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};y.material=T,h.push(y)}return{dracoCompression:u,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:f}}function or(t,e){for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&tr)return t[n]}return null}const ar=[];class cr extends(h(t.renderer.CanvasRenderer)){constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new ie(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.Re={},this.Be=[],this.we=this.Ue.bind(this)}getAnalysisMeshes(){if(!this.painter)return ar;const t=this.painter.getPaintedMeshes();if(!t)return ar;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&D(e,n),r.length&&D(e,r),s.length&&D(e,s),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Be.length||super.needToRedraw())}getFrameTimestamp(){return this.Pe}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.Pe=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:s}=this.layer.getTiles(),i=s.length;if(!s||!i)return void this.completeRender();this.Le(),this.De();const{selectedTiles:o,leaves:a,requests:c}=this.Fe(r,s);c.length&&this.loadTiles(c),this.ke(o,a,e),this.Ve(),c.length||this.completeRender()}Fe(t,e){const n=this.layer.getRootTiles();let r=[];this.He();let s=0;const i=this.Ge(),o={};let a=!1,c=!1;for(let t=0;t<e.length;t++){const i=e[t],h=i.node;if(o[h.id])continue;const u=n[h.Et];o[h.id]=1;let f=!1;const l=this.getCachedTile(h.id);if(this.je(h.id)?(s++,f=c=!0,this.tilesLoading[h.id].current=!0):l?(this.getTileOpacity(l)<1&&(f=c=!0),(!i.node.ze||u.isS3M||!i.node.children||i.node.ze<=500)&&(a=!0,i.selected=!0,i.data=l)):this.painter.has(h)||(f=c=!0,r.push(h)),!f)continue;if(this.qe(i))a=!0;else{this.Xe(i).length&&(a=!0)}}let h=[],u={};if(a&&({selectedTiles:h,leaves:u}=this.Ke(t)),r.length>1&&(r.sort(hr),i)){const t=i-s;r=t>0?r.slice(0,t):[]}return{loading:c,requests:r,selectedTiles:h,leaves:u}}Ke(t){const e=[],n={};let r;const s=[t],i=[];for(;s.length>0||i.length>0;){if(i.length>0){const t=i[i.length-1];if(t.$e===s.length){i.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=s.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=i.length,e.push(t);else{if(t.selectionDepth=i.length,r=t,0===o.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}i.push(t),t.$e=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return{selectedTiles:e,leaves:n}}qe(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Xe(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.Bt+1,r=[t.node];for(;r.length>0;){const s=r.pop().children;for(let i=0,o=s.length;i<o;i++){if((!s[i].content||!s[i].content.url)&&s[i].children&&s[i].children.length){r.push(s[i]);continue}const o=s[i].id;if(this.tileCache.has(o)){const n=this.layer.We(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].Bt<=n&&r.push(s[i])}}return e}ke(t,e,n){this.tileCache.markAll(!1);for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,this.tileCache.add(t[e].node.id,n)}this.tileCache.shrink();const r={tiles:t,leaves:e};this.onDrawTileStart(r);const s=this.painter.paint(t,e,n);this.onDrawTileEnd(r),s&&this.layer.fire("canvasisdirty",{renderCount:s})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(P(e)){const n=L(e);return this.Ye(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.Et,r=this.Je[n];return new Zn(e,n,r,this.we).load().then(n=>{this.onTilesetLoad(n,t,e)})}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&!rr(e)&&(e=t.baseUrl+e);const n=this.layer.options.services[t.Et];if(n.ajaxInMainThread){let r=n.urlParams;r&&(r=(e.indexOf("?")>0?"&":"?")+r);let s=vt.getArrayBuffer(e+(r||""),n.fetchOptions);const i=s.xhr;s=s.then(n=>{delete this.Re[e],n?this.Ye(e,n.data,t):this.onTileError(null,t)}).catch(n=>{delete this.Re[e],this.onTileError(n,t)}),this.Re[e]=i}else this.Ye(e,null,t);return null}Ye(t,e,r){let s=this.i;s||(s=n.Util.getSupportedFormats(this.gl.gl||this.gl),this.i=s);const i=this.layer.options.services[r.Et];i.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length).split("/"),r=[];for(let t=0;t<n.length;t++)r.push(encodeURIComponent(n[t]));return e+r.join("/")}(t,r.baseUrl));const o={url:t=this.layer.getTileUrl(t,r.baseUrl,i),arraybuffer:e,rootIdx:r.Et,upAxis:r.ne,transform:r.matrix,supportedFormats:s};if(rr(t)){const e=this.Je[r.Et];if(o.i3sInfo=ir(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r)}this.workerConn.loadTile(this.layer.getId(),o,(e,n)=>{if(e)return void this.onTileError(e,r);const{magic:s}=n;"b3dm"===s||"pnts"===s||"i3dm"===s||"cmpt"===s?this.Be.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)})}De(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.Be.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.Be.shift(),{magic:r}=t;"b3dm"===r?this.painter.createB3DMMesh(t,e.id,e,(n,{mesh:r})=>{this.Ze(t,e,n,r)}):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,(n,{mesh:r})=>{this.Ze(t,e,n,r)}):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,(n,{mesh:r})=>{this.Ze(t,e,n,r)}):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,(n,{mesh:r})=>{this.Ze(t,e,n,r)}),n++}}Ze(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.Qe(r);e.memorySize=n,this.onTileLoad(t,e)}}Qe(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Qe(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.tn(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.fe=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.en(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e){if(!this.layer)return;const n=e.content.url;console.warn("failed to load 3d tile: "+n),console.warn(t),delete this.tilesLoading[e.id],this.nn(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}nn(e,n){const r={loadTime:t.Util.now(),current:!0,error:n,node:e};this.tileCache.add(e.id,r)}tn(e){const n={loadTime:t.Util.now(),current:!0,node:e};this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;if(this.layer.options.services[t.node.Et].ajaxInMainThread){const t=this.Re[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.Re[e]}He(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias},n=this.canvas.gl&&this.canvas.gl.wrap;n?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.rn(this.canvas,e)),this.regl=this.regl||u({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),n&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Xn(this.regl,t),this.layer.sn()}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new ne("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let n=this.layer.options||{};n=A({},n),delete n.offset,n.projection=t.getSpatialReference().getProjection().code;const r=this.layer.getId();e.addLayer(r,n,t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))})}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),t=>{if(t)throw t}),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.Ve(!0),this.tileCache.reset(),this.tilesLoading={},super.clear()}clearCanvas(){this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas()}getTileOpacity(){return 1}getStencilValue(){return 0}Ve(t){this.in||(this.in=Date.now());const e=Date.now();if(t||!(e-this.in<this.layer.options.retireInterval)){this.in=e;for(const e in this.tilesLoading){const n=this.tilesLoading[e];!t&&n.current||this.abortTileLoading(n)}}}Ge(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}rn(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let s=0;s<n.length;++s){try{r=t.getContext(n[s],e)}catch(t){}if(r)break}return r}je(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return ke(t,e,0,n)}Le(){if(!this.an)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.an){const s=this.an[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx;if(n.push(vt.getJSON(r).then(t=>{delete this.an[r];const e=this.Je[i];if(e){t.nodes?Yn(e,t.nodes):(e[t.id]=t,Yn(e,t.children));for(let t=0;t<s.length;t++)s[t]();this.setToRedraw()}else this.setToRedraw()})),e++,e>=t)break}n.length&&Promise.all(n)}Ue(t,e,n){this.an||(this.an={}),this.an[e]=this.an[e]||[],this.an[e].rootIdx=t,this.an[e].push(n),this.setToRedraw()}en(t,e,n){this.Je||(this.Je=[]);const r=e.Et;this.Je[r]||(this.Je[r]={});const s=this.Je[r],i=this.layer.options.services[r];t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),s.version=+(i.i3sVersion||t.store.version),function(t,e,n,r,s,i){if(!s.layerScene){s.layerScene=t,s.nodesPerPage=t.nodePages&&t.nodePages.nodesPerPage||64,s.lodSelectionMetricType=t.nodePages&&t.nodePages.lodSelectionMetricType;let e=r;s.layerScene.eslpk=e.indexOf("3dSceneLayer.json")>=0;if(e.endsWith(".json")){const t=r.lastIndexOf("/");e=t<0?"./":r.substring(0,t)}s.layerScene.baseUrl=function(t){return t.split("?")[0]}(e)}return new Zn(r,e,s,i).load()}(t,r,0,n,s,this.we).then(t=>{this.onTilesetLoad(t,e,n)})}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:s,height:i}=this.canvas;return!this.pickingFBO||r.width===s&&r.height===i||r.resize(s,i),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.vt||(this.vt=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.vt[n];r||(r=this.vt[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.vt[e];n||(n=this.vt[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.vt)}cancelHighlight(t,e){if(!this.vt)return;const n=this.vt[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.vt[t]=null),this.painter.highlight(this.vt)}}cancelAllHighlight(){delete this.vt,this.painter.cancelAllHighlight()}showOnly(t){if(this.Ct||(this.Ct=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Ct[n];r||(r=this.Ct[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Ct[e];n||(n=this.Ct[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Ct)}cancelShowOnly(){delete this.Ct,this.painter.cancelShowOnly()}ge(){return this.painter?this.painter.ge():[]}}function hr(t,e){return t.Gt-e.Gt}function ur(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function fr(t,e,n){return Math.sqrt(function(t,e,n){const r=J(lr,n,t),s=ur(dr,e,0),i=ur(mr,e,1),o=ur(pr,e,2),a=it(s),c=it(i),h=it(o);tt(s,s),tt(i,i),tt(o,o);const u=yr;u[0]=et(r,s),u[1]=et(r,i),u[2]=et(r,o);let f,l=0;u[0]<-a?(f=u[0]+a,l+=f*f):u[0]>a&&(f=u[0]-a,l+=f*f);u[1]<-c?(f=u[1]+c,l+=f*f):u[1]>c&&(f=u[1]-c,l+=f*f);u[2]<-h?(f=u[2]+h,l+=f*f):u[2]>h&&(f=u[2]-h,l+=f*f);return l}(t,e,n))}const lr=[],dr=[],mr=[],pr=[],yr=[];const br=2*Math.PI;class gr{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],s=t.west;let i=t.east;return i<s&&(i+=br,n<0&&(n+=br)),(n>s||Be(n,s,1e-14))&&(n<i||Be(n,i,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const Tr=[0,0,1];function wr(t,e){return Te(e,t[0],t[1],t[2])}class _r{constructor(t,e){this.normal=i.copy([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-i.dot(e,t);return i.copy(n.normal,e),n.distance=r,n}}const Ar=[],Or=[],xr=[],Ir=[],Sr=[],Mr=[],Er=[],vr=[],Nr=[],Cr=[],Rr=new _r([1,0,0],0),Br=[];class Ur{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new gr(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!gr.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,r=this.northeastCornerCartesian,s=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,h=i.subtract(Br,t,e),u=i.dot(h,s),f=i.dot(h,o),l=i.subtract(Br,t,r),d=i.dot(l,a),m=i.dot(l,c);u>0?n+=u*u:d>0&&(n+=d*d),f>0?n+=f*f:m>0&&(n+=m*m)}const r=e[2],s=this.minimumHeight,o=this.maximumHeight;if(r>o){const t=r-o;n+=t*t}else if(r<s){const t=s-r;n+=t*t}return Math.sqrt(n)}computeBox(t){const e=this;wr(gr.southwest(t,Or),e.southwestCornerCartesian),wr(gr.northeast(t,Or),e.northeastCornerCartesian),Ar[0]=t.west,Ar[1]=.5*(t.south+t.north),Ar[2]=0;const n=wr(Ar,xr),r=i.cross(Sr,n,Tr);i.normalize(e.westNormal,r),Ar[0]=t.east;const s=wr(Ar,vr),o=i.cross(Sr,Tr,s);i.normalize(e.eastNormal,o);const a=i.subtract(Sr,n,s),c=i.normalize(Ir,a),h=t.south;let u;if(h>0){Ar[0]=.5*(t.west+t.east),Ar[1]=h;const n=wr(Ar,Nr);i.copy(Cr,c);const r=_r.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Rr);Pr(Nr,Cr,r,e.southwestCornerCartesian),u=Ne(n,Mr)}else u=Ce(gr.southeast(t,Or),Mr);const f=i.cross(Er,u,a);i.normalize(e.southNormal,f);const l=t.north;let d;if(l<0){Ar[0]=.5*(t.west+t.east),Ar[1]=l;const n=wr(Ar,Nr);i.scale(Cr,c,-1);const r=_r.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Rr);Pr(Nr,Cr,r,e.northeastCornerCartesian),d=Ne(n,Mr)}else d=Ce(gr.northwest(t,Or),Mr);const m=i.cross(Er,a,d);i.normalize(e.northNormal,m)}}function Pr(t,e,n,r){const s=t,o=e,a=n.normal,c=i.dot(a,o);if(Math.abs(c)<1e-15)return;const h=(-n.distance-i.dot(a,s))/c;return h<0?void 0:(r=i.scale(r,o,h),i.add(r,s,r))}const Lr=new t.Extent(0,0,0,0),Dr=new t.Extent(0,0,0,0),Fr=[],kr=[],Vr=[],Hr=[],Gr=new t.Point(0,0),jr=[],zr=new t.Coordinate(0,0),qr=r.identity([]),Xr=[0,0];class Kr extends(f(t.Layer)){constructor(t,e){super(t,e),this.cn(),this.Re={},this.hn=[]}cn(){const t=this.options.services.map(t=>t.url);this.un=t.map((t,e)=>function(t,e){t=E(t);return{visible:1,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([]),Et:e,Bt:0}}(t,e)),this.fire("rootready",{roots:this.un.slice(0)})}showService(t){return this.ln(t,1),this}hideService(t){return this.ln(t,0),this}setToRedraw(){const t=this.getRenderer();t&&t.setToRedraw()}ln(t,e){const n=this.un[t];if(!n)return;n.visible=e;const r=this.getRenderer();r&&r.setToRedraw()}getTileUrl(t){return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.un.length;t++)if(this.un[t].boundingVolume){const n=this.boundingVolumeToExtent(this.un[t]);e._combine(n)}return e}return this.un[e]&&this.un[e].boundingVolume?this.boundingVolumeToExtent(this.un[e]):null}boundingVolumeToExtent(e){const n=e.boundingVolume.dn?qr:e.matrix,r=this.getMap();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(M(n[0]),M(n[1]),M(n[2]),M(n[3]))}if(e.boundingVolume.sphere){const s=e.boundingVolume.sphere,o=Ie([],i.transformMat4([],s,n)),a=s[3],c=r.locate(o,-a,a),h=r.locate(o,a,-a);return new t.Extent(c,h)}if(e.boundingVolume.box){const s=e.boundingVolume.box,a=i.transformMat4([],s,n),c=new t.Coordinate(Ie([],a)),h=s.slice(3);o.multiply(h,o.fromMat4([],e.matrix),h);const u=i.length(h.slice(0,3)),f=i.length(h.slice(3,6)),l=i.length(h.slice(6,9)),d=Math.max(u,f,l),m=r.locate(c,-d,d),p=r.locate(c,d,-d);return new t.Extent(m,p)}return null}getRootTiles(){return this.un}getTiles(){const t=this.getRenderer();if(!t.ready)return this.mn(),{tiles:Hr};const e=this.getMap(),n=e.cameraPosition;let r,s;if(e.getGLZoom)s=e.pointToDistance(n[2],0,e.getGLZoom()),zr.set(n[0],n[1]),r=e.pointToCoord(zr,e.getGLZoom());else{const t=e.getGLRes();s=e.pointAtResToDistance(n[2],0,t),zr.set(n[0],n[1]),r=e.pointAtResToCoord(zr,t)}this.pn=this.pn||[],i.set(this.pn,S(r.x),S(r.y),s),this.yn=Te(this.yn||[],this.pn[0],this.pn[1],this.pn[2]),this.bn=2*Math.tan(.5*S(e.getFov()));const o=e.projViewMatrix,a={children:[],level:-1};let c=a;const h=[];for(let e=0;e<this.un.length;e++){const n=this.un[e];if(!n.visible)continue;let r=1/0;const s=[n],i=this.gn(e);for(;s.length>0;){const e=s.pop();for(e.id||this.Tn(e);c.level>=e.Bt;)c=c.parent;const n=this.wn(e,i,o);if(n<1){let t=c;for(;t&&!t.content;)t=t.parent;0===n&&t&&t.content&&this._n(h,t);if(!1===this.options.services[e.Et].alwaysShow)continue;if(!(0===n&&e.Bt<=r))continue;e.content&&(r=e.Bt)}e.Gt<1/0&&this.An(e);const a=this.We(e,c);c.children.push(a);const u=e.children,f=u&&u.length,l=a.content;if(!f&&l&&this._n(h,a),f){l&&"add"===e.refine&&this._n(h,a),c=a;const n=u[0].parent;let r=!1;for(let i=0,o=u.length;i<o;i++){if(n){const e=t.getCachedTile(u[i].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,u[i].parent=e,u[i].ne=e.ne,u[i].baseUrl=e.baseUrl;const t=u[i].content&&(u[i].content.url||u[i].content.uri);t&&(P(t)||t.indexOf("i3s:")>=0?u[i].baseUrl=e.baseUrl:-1===t.indexOf("http://")&&-1===t.indexOf("https://")?u[i].content.url=e.baseUrl+t:u[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}s.push(u[i])}!r&&l&&this._n(h,a)}}}return{root:a,tiles:h}}_n(t,e){const{viewerRequestVolume:n}=e.node;n&&!function(t,e,n){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return $r(n,e);if(n.box)return 0===Wr(n,e)}return!1}(this.pn,this.yn,n)||t.push(e)}We(t,e){return{id:t.id,node:t,children:[],level:t.Bt,parent:e,content:t.content&&t.content.url}}Tn(e){e.id=t.Util.GUID(),e.matrix=e.transform||r.identity([]),e.On=this.xn(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=r.multiply(e.matrix,e.parent.matrix,e.matrix)),e.Et=e.parent.Et,void 0===e.Bt&&(e.Bt=e.parent.Bt+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri),this.In(e)}In(t){const e=t.boundingVolume;if(!e||e.dn)return;const n=this.options.services[t.Et],s=n.heightOffset||0,o=this.options.offset,a=O(o)||o[0]||o[1],c=n.coordOffset||Xr;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!t.boundingVolume||!s&&r.exactEquals(t.matrix,qr)&&!a&&c===Xr)return;const{region:h,box:u,sphere:f}=e;if(h){const t=this.Sn([M(h[0]),M(h[1])]);h[0]=S(t.x+c[0]),h[1]=S(t.y+c[1]);const e=this.Sn([M(h[2]),M(h[3])]);h[2]=S(e.x+c[0]),h[3]=S(e.y+c[1]),h[4]+=s+(c[2]||0),h[5]+=s+(c[2]||0)}else if(u||f){const e=u||f,n=i.transformMat4(Fr,e,t.matrix),r=Ie(kr,n),o=this.Sn([r[0]+c[0],r[1]+c[1]]);r[0]=o.x,r[1]=o.y,r[2]+=s+(c[2]||0),Te(e,S(r[0]),S(r[1]),r[2])}e.dn=!0}xn(t){return void 0===t.geometricError||!t.boundingVolume}An(t){let e=t.parent;for(;e&&e.On&&!(e.Gt<=t.Gt);)e.Gt=t.Gt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const r=this.getRenderer();r&&r.setToRedraw()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const s=this.options.services[e.Et],i=(t.asset&&t.asset.gltfUpAxis||e&&e.ne||s.upAxis||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const o=n.indexOf("realspace/")>-1;0===e.Bt&&(t.asset&&t.asset.s3mType&&o||s.isSuperMapiServer)&&(t.root.baseUrl+="data/path/");const a=t.asset.i3s,c=!!t.asset.s3mType;if(t.root.ne=i,e){const n=e.Et,s=this.un[n];c&&!s.isS3M&&(s.isS3M=c);const i=e.boundingVolume;A(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",i&&(e.boundingVolume=i);const o=t.root.transform;o&&(e.parent?a||(e.matrix=r.multiply([],e.parent.matrix,o)):e.matrix=o),this.In(e),e.Mn=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.On=this.xn(e);const h=e.content&&(e.content.url||e.content.uri);h&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),a||!h||P(h)||-1!==h.indexOf("http://")||-1!==h.indexOf("https://")||(e.content.url=e.baseUrl+h)}this.mn(),this.fire("loadtileset",{tileset:t,index:e&&e.Et,url:n})}wn(t,e,n){if(t.Gt=1/0,0===t.Bt||t.On)return 1;if(!this.En(t,e,n))return-1;if(0===t.geometricError)return 1;let r=this.options.services[t.Et].maximumScreenSpaceError;null==r&&(r=16);let s=this.vn(t);return 0===s&&t.parent&&(s=.5*(t.parent.ze||0)),s>=r?1:0}Wt(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.getGLZoom?r.coordToPoint(e,r.getGLZoom(),n):r.coordToPointAtRes(e,r.getGLRes(),n)}En(e,n,s){const a=e.id;let c=this.hn[a];const{boundingVolume:h}=e,u=h.sphere;let f=h.region;const l=h.box;if(!c){let n,s,d;if(l&&(f=function(t,e){for(let e=0;e<9;e++)t[e+3]!==1/0&&t[e+3]!==-1/0||(t[e+3]=6378137*Math.sign(t[e+3])*3),is[e]=t[e+3];const n=is;r.exactEquals(e,qr)||o.multiply(n,o.fromMat4(jr,e),n);const s=i.copy(Yr,t),a=i.set(Jr,n[0],n[1],n[2]),c=i.set(Zr,n[3],n[4],n[5]),h=i.set(Qr,n[6],n[7],n[8]);ts[0]=ts[0]||[];const u=i.copy(ts[0],s);i.sub(u,u,a),i.sub(u,u,c),i.sub(u,u,h),ts[1]=ts[1]||[];const f=i.copy(ts[1],s);i.sub(f,f,a),i.sub(f,f,c),i.add(f,f,h),ts[2]=ts[2]||[];const l=i.copy(ts[2],s);i.sub(l,l,a),i.add(l,l,c),i.sub(l,l,h),ts[3]=ts[3]||[];const d=i.copy(ts[3],s);i.sub(d,d,a),i.add(d,d,c),i.add(d,d,h),ts[4]=ts[4]||[];const m=i.copy(ts[4],s);i.add(m,m,a),i.sub(m,m,c),i.sub(m,m,h),ts[5]=ts[5]||[];const p=i.copy(ts[5],s);i.add(p,p,a),i.sub(p,p,c),i.add(p,p,h),ts[6]=ts[6]||[];const y=i.copy(ts[6],s);i.add(y,y,a),i.add(y,y,c),i.sub(y,y,h),ts[7]=ts[7]||[];const b=i.copy(ts[7],s);i.add(b,b,a),i.add(b,b,c),i.add(b,b,h);for(let t=0;t<ts.length;t++)es[t]=es[t]||[],Ie(es[t],ts[t]),ns[t]=es[t][0],rs[t]=es[t][1],ss[t]=es[t][2];return[S(Math.min(...ns)),S(Math.min(...rs)),S(Math.max(...ns)),S(Math.max(...rs)),Math.min(...ss),Math.max(...ss)]}(l,e.matrix),h.region=f),f){n=Lr.set(M(f[0]),M(f[1]),M(f[2]),M(f[3]));const t=n.getCenter(),e=this.Nn(t);n=n.convertTo(t=>this.Wt(t,Gr),Dr),d=f[4],s=f[5],c=this.hn[a]=[[n.xmin,n.ymin,d*e[2]],[n.xmax,n.ymax,s*e[2]]],c.center=t}else if(u){const e=Ie(Fr,u),n=new t.Coordinate(e),r=this.Wt(n,Gr).toArray(),s=this.Nn(n);r.push(e[2]*s[2]),c=this.hn[a]=[r,u[3]*s[2]],c.center=n}}if(n){if(f)Lr.xmin=c[0][0],Lr.ymin=c[0][1],Lr.xmax=c[1][0],Lr.ymax=c[1][1];else if(u){const t=c[2];Lr.xmin=c[0][0]-t,Lr.ymin=c[0][1]-t,Lr.xmax=c[0][0]+t,Lr.ymax=c[0][1]+t}else if(l){const t=c[1],e=c[2];Lr.xmin=c[0][0]-t,Lr.ymin=c[0][1]-e,Lr.xmax=c[0][0]+t,Lr.ymax=c[0][1]+e}if(!n.intersects(Lr))return!1}return f?y(s,c):u?function(t,e,n){g(t);for(var r=e[0],s=-e[1],i=0;i<6;i++){if(!n||"0"!==n.charAt(i))if(w(d[i],r)<s)return!1}return!0}(s,c):!!l&&function(t,e,n){g(t);for(var r=0;r<6;r++){if(!n||"0"!==n.charAt(r))if(!b(d[r],e))return!1}return!0}(s,c)}Nn(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let r;return r=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:n.y/100,i.set(Vr,n.x/100*1.01,n.y/100*1.01,r),Vr}Sn(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(O(n)&&(n=n(Array.isArray(e)?new t.Coordinate(e):e)),n[0]||n[1]){const t=this.getMap(),r=t.getGLRes(),s=t.coordToPointAtRes(e,r);return s._sub(n),t.pointAtResToCoord(s,r)}return e}gn(e){const n=this.options.services[e].maxExtent;if(!n)return null;const r=this.un[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo(t=>this.Wt(t))),r.maxExtent}vn(t){const e=this.bn,n=t.geometricError;if(0===n)return t.ze=0,0;const r=this.getMap();let s;t.boundingVolume.region?s=function(t,e,n){t.Cn||(t.Cn=new Ur(t.boundingVolume.region));return t.Cn.distanceToCamera(e,n)}(t,this.yn,this.pn):t.boundingVolume.sphere?s=$r(t.boundingVolume,this.yn):t.boundingVolume.box&&(s=Wr(t.boundingVolume,this.yn));const i=Math.max(Math.abs(s),1e-7),o=n*r.height/(i*e);return t.Gt=s,t.ze=o,o}mn(){const t=this.getRenderer();t&&t.setToRedraw()}ce(t){return this.hn[t]}identify(e,n={}){const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.coordToContainerPoint(new t.Coordinate(e));return this.identifyAtPoint(i,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&D(n,r)}const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.getDevicePixelRatio();return D(n,s.pick(t.x*i,t.y*i,e)),n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.ge():[]}highlight(t){const e=this.getRenderer();return e?(e.highlight(t),this):(this.vt||(this.vt=[]),this.vt.push(t),this)}sn(){if(this.vt){for(let t=0;t<this.vt.length;t++)this.highlight(this.vt[t]);delete this.vt}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Ct||(this.Ct=[]),this.Ct.push(t),this)}Rn(){if(this.Ct){for(let t=0;t<this.Ct.length;t++)this.showOnly(this.Ct[t]);delete this.Ct}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);const r=this.getRenderer();return r?(r.setToRedraw(),this):this}}function $r(t,e){const n=t.sphere,r=i.dist(n,e),s=t.sphere[3];return r<s?0:r-s}function Wr(t,e){const n=t.box;return fr(i.set(Fr,n[0],n[1],n[2]),o.set(jr,n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]),e)}Kr.mergeOptions({"maxGPUMemory":512,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":0,"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"debug":!1,"debugOutline":[0,1,0],"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"antialias":!1,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"],"offset":[0,0]}),Kr.registerRenderer("gl",cr),Kr.registerJSONType("Geo3DTilesLayer");const Yr=[],Jr=[],Zr=[],Qr=[],ts=[],es=[],ns=[],rs=[],ss=[],is=[];let os=null;function as(){return os||(os={"image/crn":Wn.crn&&Wn.crn(),"image/ktx2":Wn.ktx2&&Wn.ktx2(),"image/cttf":Wn.ktx2&&Wn.ktx2(),"draco":Wn.draco&&Wn.draco()}),os}class cs{constructor(t,e,n){this.s=t,this.Bn=e||$t,this.i=n,this.Un=as()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Pn(t,e,n,r,s)):vt.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.Pn(t,s,n,r)})}Pn(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.Ln(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.Bn(a,o.glb,{transferable:!0,requestImage:this.s,decoders:this.Un,supportedFormats:this.i,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then(e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}})}Ln(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),h=s.getUint32(20,!0),u=s.getUint32(24,!0),f=28+e;h>=570425344?(f-=8,o=a,h=c,u=0,a=0,c=0):u>=570425344&&(f-=4,o=h,h=a,u=c,a=0,c=0);const l=[t];let d,m,p;if(a>0?(d=Le(t,f,a),f+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(f+=c),h>0&&(m=De(t,f,h),f+=h,u>0)){const e=Fe(0,f,u);p=t.slice(e.offset,e.offset+e.byteLength),f+=u,l.push(p)}const y=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Ve(d.BATCH_ID,t,(void 0).offset,y);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&l.indexOf(e)<0&&l.push(e)}return{count:o,transferables:l,featureTable:d,batchTable:m,batchTableBin:p,b3dm:b,glb:{buffer:t,byteOffset:f,byteLength:s.byteLength+s.byteOffset-f}}}Dn(){return null}}class hs{constructor(t,e,n,r){this.s=t,this.Bn=e||$t,this.i=n,this.Un=as(),this.Fn=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Pn(t,e,n,r,s)):vt.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.Pn(t,s,n,r)})}Pn(t,e,n,r,s){return this.kn(t,e,n,r,s).then(({gltf:s,transferables:i})=>{const o=this.Vn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})})}kn(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.s,decoders:this.Un,supportedFormats:this.i,maxTextureSize:i},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=C(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?vt.getArrayBuffer(r,{}).then(t=>this.Hn(r,{buffer:t.data,byteOffset:0},o)):vt.getJSON(r,{}).then(t=>this.Hn(r,t,o))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Hn(t,r,o)}}Hn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.Bn(r,e,n);return s.load({skipAttributeTransform:!0}).then(n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}})}Vn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:u}=$e(s,32+e,o),f={},l=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(f.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.Gn(new Uint16Array(t,r+c.offset,3*l),e,n)},o.push(f.POSITION.array.buffer)}if(a.BATCH_ID){f.BATCH_ID=Ve(a.BATCH_ID,t,c.offset,l);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(f.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.jn(new Uint16Array(t,e+c.offset,2*l))},o.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.jn(new Uint16Array(t,e+c.offset,2*l))},o.push(f.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,l).slice()},o.push(f.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:l,batchTable:h,batchTableBin:u,featureTable:a,i3dm:f,transferables:o}}jn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)us(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}Gn(t,e,n){return Ke(new Float32Array(t.length),t,e,n)}Dn(){return null}}function us(t,e,n,r){if(t[0]=fs(e,r),t[1]=fs(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*ls(e),t[1]=(1-Math.abs(e))*ls(t[1])}return tt(t,t)}function fs(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function ls(t){return t<0?-1:1}class ds{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Pn(t,e,n,r)):vt.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.Pn(t,s,n,r)})}Pn(t,e,n,r){return this.zn(e,n,r,t).then(t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts})}zn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:u}=$e(s,e+28,o),f=a.QUANTIZED_VOLUME_OFFSET,l=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.qn||(this.qn=as().draco),this.qn(m,e).then(e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.Xn(t,e.attributes,c.offset,d,o,f,l);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Xe(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=Ve(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=ms(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:r,transferables:o}})}const y=this.Xn(t,a,c.offset,d,o,f,l);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?y.BATCH_ID=Ve(a.BATCH_ID,t,c.offset,d):y.BATCH_ID=ms(d);const e=y.BATCH_ID.array&&y.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:y,transferables:o})}Xn(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:h}=e.POSITION_QUANTIZED;c=c||0;const u=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Gn(h||new Uint16Array(t,c+u,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}Gn(t,e,n){return Ke(new Float32Array(t.length),t,e,n)}Dn(){return null}}function ms(t){const e=U(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Xe(e),array:n}}class ps{constructor(t,e,n,r){this.i=n,this.s=t,this.Bn=e||$t,this.Fn=r}load(t,e,n=0,r=0,s){return e?this.Pn(t,e,n,r,s):vt.getArrayBuffer(t,{}).then(e=>{const s=e.data;return this.Pn(t,s,n,r)})}Pn(t,e,n,r,s){r||(r=e.byteLength);const i=this.Kn(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new cs(this.s,this.Bn,this.i);else if("i3dm"===i[n].magic)r=new hs(this.s,this.Bn,this.i,this.Fn);else if("pnts"===i[n].magic)r=new ds;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new ps(this.s,this.Bn,this.i,this.Fn)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then(t=>t))}return Promise.all(o).then(t=>({magic:"cmpt",tiles:t}))}Kn(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Ue(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(e.transcoders){const n=t.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=e.transcoders.inject(l);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(l)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",l);export{cs as B3DMLoader,ps as CMPTLoader,Kr as Geo3DTilesLayer,F as Geo3DTilesUtil,Re as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.84.0");