@maptalks/3dtiles 0.102.0 → 0.102.2

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,12 +1,12 @@
1
1
  /*!
2
- * @maptalks/3dtiles v0.102.0
2
+ * @maptalks/3dtiles v0.102.2
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2024 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,ContextUtil as s,quat as o,vec3 as a,mat3 as c,vec4 as h,MaskRendererMixin as l,createREGL as u,MaskLayerMixin as f,ClipOutsideMask as d,vec2 as m}from"@maptalks/gl";import{intersectsBox as p,intersectsOrientedBox as g,intersectsSphere as b}from"frustum-intersects";import{GLTFLoader as y,Ajax as w}from"@maptalks/gltf-loader";import{quat as v,mat4 as T,vec3 as _,mat3 as M}from"gl-matrix";const O="${",A=`function(t){\n/*!\n * @maptalks/gltf-loader v0.98.3\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.org\n */\nvar e="undefined"!=typeof Float32Array?Float32Array:Array;function n(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=e[8],h=e[9],d=e[10],y=e[11],m=e[12],b=e[13],p=e[14],g=e[15],w=n[0],v=n[1],M=n[2],A=n[3];return t[0]=w*r+v*a+M*l+A*m,t[1]=w*i+v*c+M*h+A*b,t[2]=w*s+v*u+M*d+A*p,t[3]=w*o+v*f+M*y+A*g,w=n[4],v=n[5],M=n[6],A=n[7],t[4]=w*r+v*a+M*l+A*m,t[5]=w*i+v*c+M*h+A*b,t[6]=w*s+v*u+M*d+A*p,t[7]=w*o+v*f+M*y+A*g,w=n[8],v=n[9],M=n[10],A=n[11],t[8]=w*r+v*a+M*l+A*m,t[9]=w*i+v*c+M*h+A*b,t[10]=w*s+v*u+M*d+A*p,t[11]=w*o+v*f+M*y+A*g,w=n[12],v=n[13],M=n[14],A=n[15],t[12]=w*r+v*a+M*l+A*m,t[13]=w*i+v*c+M*h+A*b,t[14]=w*s+v*u+M*d+A*p,t[15]=w*o+v*f+M*y+A*g,t}function r(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function i(t,n,r){var i=new e(3);return i[0]=t,i[1]=n,i[2]=r,i}function s(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function o(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function a(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function c(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function u(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function f(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*s+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*s+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*s+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*s+n[15]*o,t}function l(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),r(),function(){var t;t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var h,d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};r(),i(1,0,0),i(0,1,0),l(),l(),h=new e(9),e!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[5]=0,h[6]=0,h[7]=0),h[0]=1,h[4]=1,h[8]=1;let y=0;function m(t){return null==t}function b(t){return!m(t)}function p(t){return!m(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function g(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 w(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 v(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function M(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 A=[],T=[],_=[],k=[0,0,0],O=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),x=[1,1,1];function S(t,e,n,r,i,s,o){const a=w(o),c=a.BYTES_PER_ELEMENT;if((0===i||i===r*c)&&s%c==0){const i=new a(e,s,n*r);return t.set(i),t}0===i&&(i=r*c);const u=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const f=new Uint8Array(e,i*o+s,r*c);u.set(f),n=new a(u.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const I="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function E(t,e,n){const r=new Uint8Array(t,e,n);return I.decode(r)}const C={get:function(t,e={},n){e||(e={});const r=new AbortController,i=r.signal,s=g({},e);s.signal=i,s.method||(s.method="GET"),s.referrerPolicy=s.referrerPolicy||"origin","undefined"==typeof window||s.referrer||(s.referrer=window.location.href),n&&(t=n(t));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=r,o},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${O}t.status}): ${O}t.statusText}\`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={},n)=>(e||(e={}),e.responseType="arraybuffer",C.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?C.jsonp(t):((e=e||{}).responseType="json",C.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+y++;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 U{constructor(t,e,n,r,i){this.i=t,this.decoders=e,this.o=n,this.images={},this.u={},this.h=r||{},this.m=i}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}if(this.u[t.id])return this.u[t.id].then((()=>{const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}));if(v(t.uri)){const r=this.buffers[t.id]=M(t.uri),i=this.p(e,r);return this.getImageByBuffer(i,n)}let r;const i=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||i?t.uri:this.rootPath+"/"+t.uri,this.u[t.id]=C.getArrayBuffer(r,this.h,this.m).then((r=>{const i=this.buffers[t.id]=r.data,s=this.p(e,i);return this.getImageByBuffer(s,n)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.o}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.v(e.id,t)}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.u[t.id]?this.u[t.id].then((()=>this.images[t.id])):this.u[t.id]=this.v(t.id,e)}v(t,e){return new Promise(((n,r)=>{let i=e;this.m&&(i=this.m(e)),this.i(i,this.h,((i,s)=>{i?r(i):(URL.revokeObjectURL(e),this.images[t]=s,n(this.images[t]))}))}))}}const F=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],N=[];class P{constructor(t,e,n,r,i){this.rootPath=t,this.gltf=e,this.M=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.A(),this.h=r,this.m=i}T(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this._(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.k(i).then((n=>{const{buffer:i,byteOffset:s}=n;return this.accessors[r.id]=this._(t,e,i,s)}))}k(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(v(e.uri)){const t=this.buffers[e.id]=M(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]=C.getArrayBuffer(t,this.h,!n&&this.m).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})}_(t,e,n,r=0){const i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+r,c=this.O(s.type),u=w(s.componentType),l=o.byteStride||0,h={array:void 0,name:t,accessorName:e,byteLength:s.count*c*u.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c,max:s.max,min:s.min,extensions:s.extensions};if(s.min&&(h.min=s.min),s.max&&(h.max=s.max),n)if(this.M)h.byteStride=l,h.byteOffset=a+(s.byteOffset||0),!l||l===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(h.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),h.array.buffer.byteLength===h.byteLength&&(h.byteOffset=0)):h.array=new Uint8Array(n,a,o.byteLength);else if(s.interleaved){h.byteStride=0,h.byteOffset=0;const t=new u(s.count*c);if(h.array=S(t,n,s.count,c,l,a+(s.byteOffset||0),s.componentType),h.extensions&&h.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(h.array.length),{decodeMatrix:e}=h.extensions.WEB3D_quantized_attributes;for(let n=0;n<h.array.length;n+=c){N[0]=h.array[n],N[1]=h.array[n+1],N[2]=h.array[n+2],N[3]=1;const r=f(N,N,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}h.componentType=5126,h.array=t}}else h.byteStride=0,h.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),h.byteOffset=h.array.byteOffset;else{h.array=new u(s.count);const t=h.min||h.max;t&&(h.array[0]=t[0],h.array[1]=t[1],h.array[2]=t[2])}return h}A(){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)}S(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)}O(t){const e=F.indexOf(t);return F[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.k(e).then((r=>{const{buffer:i,byteOffset:s}=r,o=E(i,s+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(v(t.uri)){const e=M(t.uri),n=E(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return C.get(e,this.h,this.m).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class B extends U{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new P(t,e,n,o,a)}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 r=function(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}(A,e.translation||k),i=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,y=i*c,m=s*o,b=s*a,p=s*c;return t[0]=1-l-y,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-p,t[5]=1-u-y,t[6]=d+m,t[7]=0,t[8]=h+b,t[9]=d-m,t[10]=1-u-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(T,e.rotation||O),s=function(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}(_,e.scale||x);return n(s,i,s),n(t,r,s)}return function(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}(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}I(t){const e={};for(const n in t){const r=t[n];let i,s;r.instanceTechnique&&r.instanceTechnique.values?(i=r.instanceTechnique,s=i.values.diffuse):(i=r,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}C(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,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}U(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.C(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 s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}const D=9729;class R extends U{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new P(t,e,n,o,a)}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 g(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}U(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.C(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}};g(n,e);const i=b(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(i&&(n.sampler=i,n.sampler.magFilter=i.magFilter||D,n.sampler.minFilter=i.minFilter||9987,n.sampler.wrapS=i.wrapS||10497,n.sampler.wrapT=i.wrapT||10497),"image/ktx2"===n.image.mimeType&&!n.image.mipmap&&n.sampler&&n.sampler.minFilter!==D&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:D}return t.format&&(n.format=t.format),n}))}C(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.F(e,t)}return null}F(t,e){const n=this.p(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}p(t,e,n){n=n||0;const r=(t.byteOffset||0)+n,i=t.byteLength;return new Uint8Array(e,r,i)}N(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);n.join("");const r="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)));return r}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.T("input",t[n].input)),e.push(this.accessor.T("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 L="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class j{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 j.readV1(r,e);if(2===i)return j.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=z(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 s=new DataView(t,e+12);let o=0;for(;o<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)n=z(t,e+12+o,a);else if(5130562===c){i=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:i,buffer:t,byteLength:r}}}}function z(t,e,n){if(L){const r=new Uint8Array(t,e,n);return L.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=q[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 q=[1,1,1,1,2,2,3,0],V=[0,0,0],G=[0,0,0,1],$=[1,1,1],X={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},H={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},J={P(t,e,n,r,i,o,a,c){const u=b(t)?e.animations:[e.animations[0]],f={};for(let e=0;e<u.length;e++){const l=u[e],h=l.name||e;if(b(t)&&h!==t)continue;const y=l.channelsMap[n];if(y)for(let t=0;t<y.length;t++){const e=y[t];"translation"===e.target.path?(this.B(i,l.samplers[e.sampler],r,1),f.translation=s(V,i)):"rotation"===e.target.path?(this.D(o,l.samplers[e.sampler],r,1),f.rotation=d(G,o)):"scale"===e.target.path?(this.B(a,l.samplers[e.sampler],r,1),f.scale=s($,a)):"weights"===e.target.path&&c&&(this.B(c,l.samplers[e.sampler],r,c.length),f.weights=c)}}return f},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const i=this.R(H,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.R(H,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.R(H,e,n,3*r);i&&(t=this.L(t,i,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.R(H,e,n,1);r&&function(t,e,n,r){var i,s,o,a,c,u=e[0],f=e[1],l=e[2],h=e[3],d=n[0],y=n[1],m=n[2],b=n[3];(s=u*d+f*y+l*m+h*b)<0&&(s=-s,d=-d,y=-y,m=-m,b=-b),1-s>1e-6?(i=Math.acos(s),o=Math.sin(i),a=Math.sin((1-r)*i)/o,c=Math.sin(r*i)/o):(a=1-r,c=r),t[0]=a*u+c*d,t[1]=a*f+c*y,t[2]=a*l+c*m,t[3]=a*h+c*b}(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.R(H,e,n,1);r&&(t=u(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.R(H,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.L(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},j(t,e){const n=t.length;let r,i,s,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,i=c+1,s=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:i,interpolation:s}}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},R(t,e,n,r){const i=e.input.array,s=e.output.array,o=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.j(i,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=o*r;return t.PREVIOUS=s.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=s.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},L(t,e,n,r){const i=e.INTERPOLATION,s=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-s)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(o-s)*e.NEXT[n],l=(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))*u+(Math.pow(i,3)-Math.pow(i,2))*f;t[n]=l}return t},getAnimationClip(t,e,n,r){const i=t.nodes[e]&&t.nodes[e].weights;return o(V,...X.TRANSLATION),u(G,...X.ROTATION),o($,...X.SCALE),this.P(r,t,e,n,V,G,$,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 s=e.channels;for(let t=0;t<s.length;t++){const n=s[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?b(e)?n[e]:n[Object.keys(n)[0]]:null}};let K=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Je){}t&&"undefined"!=typeof createImageBitmap&&(K=!0)}const Y="undefined"==typeof document?null:document.createElement("canvas");class Q{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.h=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=j.read(e.buffer,e.byteOffset,e.byteLength);this.q(t,n,r)}else this.q(t,e);this.V=new P(this.rootPath,this.gltf,this.glbBuffer,this.h,this.options.urlModifier),this.G()}G(){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["image/ktx2"])throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded");if(t.indexOf("EXT_meshopt_compression")>=0)throw new Error("EXT_meshopt_compression extension is not supported yet.")}}$(){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.X(t),n=this.H(),r=this.J(),i=this.$();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 J.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return J.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return w(t)}static readInterleavedArray(t,e,n,r,i,s,o){return S(t,e,n,r,i,s,o)}q(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=K?it.bind(this):this.options.requestImage||W,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new R(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.h,this.options.urlModifier),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 B(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.h,this.options.urlModifier),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)||p(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}X(t){return this.Y(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,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===r&&(n=s),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.I(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r}))}Y(t){return this.W(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}))}Z(){this.skins=[];const t=[];return this.adapter.iterate(((e,n,r)=>{t.push(this.tt(n).then((t=>{t.index=r,this.skins.push(t)})))}),"skins"),t}tt(t){const e=t.inverseBindMatrices;return this.adapter.accessor.T("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 b(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,i)=>{e.push(this.et(r,t).then((t=>{t.index=i,this.meshes[n]=t})))}),"meshes"),e=e.concat(this.Z()),Promise.all(e)}et(t,e){const n=t.primitives.map((t=>this.nt(t,e))).filter((t=>!!t));return Promise.all(n).then((e=>{const n={};return g(n,t),n.primitives=e,n}))}J(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.U(n));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image.array;if(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}))}nt(t,e){let n;const r=[],i=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 i=this.adapter.accessor.T(\`morphTargets_${O}t}_${O}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:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.V.k(a).then((n=>{const{buffer:r,byteOffset:i}=n;let{byteOffset:s}=a;const c=a.byteLength;s||(s=0);const u=new DataView(r,i+s,c),f={attributes:o,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.T(t,e[t]);n&&r.push(n)}if(b(t.indices)){const e=this.adapter.accessor.T("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 s={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,s=i.length/r;for(let e=0;e<s;e++)for(let s=0;s<r;s++){const o=e*r+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>n[s]&&(n[s]=i[o])}if(e.quantization){const r=e.quantization,i=r.range/(1<<r.quantizationBits),s=r.minValues;c(t,t,i),a(t,t,s),c(n,n,i),a(n,n,s)}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&&(s.indices=n),r&&(s.morphTargets=r),s.mode=b(t.mode)?t.mode:4,b(t.extras)&&(s.extras=t.extras),s}))}}function W(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Y)return void n(new Error("There is no canvas to draw image!"));Y.width=r.width,Y.height=r.height;const t=Y.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,i)},r.onerror=function(t){n(t)},r.src=t}const Z=[],tt=[],et=30;let nt,rt;function it(t,e,n){nt||(nt=new OffscreenCanvas(2,2),rt=nt.getContext("2d",{willReadFrequently:!0}));let r=null;if(p(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),Z.push([t,e,n,this]),st();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(ot.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function st(){if(!Z.length||tt.length>et)return;const t=Z.shift(),[e,n,r,i]=t;tt.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(ot.bind(i)).then((e=>{r.call(i,null,e);const n=tt.indexOf(t);tt.splice(n,1),st()})).catch((e=>{console.warn(e),r.call(i,e);const n=tt.indexOf(t);tt.splice(n,1),st()}))}function ot(t){let{width:e,height:n}=t;at(e)||(e=ct(e)),at(n)||(n=ct(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),nt.width=e,nt.height=n,rt.drawImage(t,0,0,e,n),t.close();const i=rt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(i.data)}}function at(t){return!(t&t-1)&&0!==t}function ct(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var ut="undefined"!=typeof Float32Array?Float32Array:Array;function ft(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 lt(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=e[8],h=e[9],d=e[10],y=e[11],m=e[12],b=e[13],p=e[14],g=e[15],w=n[0],v=n[1],M=n[2],A=n[3];return t[0]=w*r+v*a+M*l+A*m,t[1]=w*i+v*c+M*h+A*b,t[2]=w*s+v*u+M*d+A*p,t[3]=w*o+v*f+M*y+A*g,w=n[4],v=n[5],M=n[6],A=n[7],t[4]=w*r+v*a+M*l+A*m,t[5]=w*i+v*c+M*h+A*b,t[6]=w*s+v*u+M*d+A*p,t[7]=w*o+v*f+M*y+A*g,w=n[8],v=n[9],M=n[10],A=n[11],t[8]=w*r+v*a+M*l+A*m,t[9]=w*i+v*c+M*h+A*b,t[10]=w*s+v*u+M*d+A*p,t[11]=w*o+v*f+M*y+A*g,w=n[12],v=n[13],M=n[14],A=n[15],t[12]=w*r+v*a+M*l+A*m,t[13]=w*i+v*c+M*h+A*b,t[14]=w*s+v*u+M*d+A*p,t[15]=w*o+v*f+M*y+A*g,t}function ht(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 dt(){var t=new ut(3);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function yt(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function mt(t,e,n){var r=new ut(3);return r[0]=t,r[1]=e,r[2]=n,r}function bt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function pt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function gt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function wt(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function vt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Mt(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[3]*r+n[7]*i+n[11]*s+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*i+n[8]*s+n[12])/o,t[1]=(n[1]*r+n[5]*i+n[9]*s+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*s+n[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var At=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},Tt=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},_t=yt;function kt(){var t=new ut(4);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}dt(),function(){var t,e=(t=new ut(4),ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var Ot;function xt(t){return t&&t.rt&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}dt(),mt(1,0,0),mt(0,1,0),kt(),kt(),Ot=new ut(9),ut!=Float32Array&&(Ot[1]=0,Ot[2]=0,Ot[3]=0,Ot[5]=0,Ot[6]=0,Ot[7]=0),Ot[0]=1,Ot[4]=1,Ot[8]=1;var St={exports:{}},It={exports:{}},Et=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},Ct=Array.prototype.concat,Ut=Array.prototype.slice,Ft=It.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];Et(i)?e=Ct.call(e,Ut.call(i)):e.push(i)}return e};Ft.wrap=function(t){return function(){return t(Ft(arguments))}};var Nt=It.exports,Pt={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},Bt=Nt,Dt=Object.hasOwnProperty,Rt=Object.create(null);for(var Lt in Pt)Dt.call(Pt,Lt)&&(Rt[Pt[Lt]]=Lt);var jt=St.exports={to:{},get:{}};function zt(t,e,n){return Math.min(Math.max(e,t),n)}function qt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}jt.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=jt.get.hsl(t),n="hsl";break;case"hwb":e=jt.get.hwb(t),n="hwb";break;default:e=jt.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},jt.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var s=2*n;i[n]=parseInt(e.slice(s,s+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:Dt.call(Pt,e[1])?((i=Pt[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=zt(i[n],0,255);return i[3]=zt(i[3],0,1),i},jt.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,zt(parseFloat(e[2]),0,100),zt(parseFloat(e[3]),0,100),zt(isNaN(n)?1:n,0,1)]}return null},jt.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,zt(parseFloat(e[2]),0,100),zt(parseFloat(e[3]),0,100),zt(isNaN(n)?1:n,0,1)]}return null},jt.to.hex=function(){var t=Bt(arguments);return"#"+qt(t[0])+qt(t[1])+qt(t[2])+(t[3]<1?qt(Math.round(255*t[3])):"")},jt.to.rgb=function(){var t=Bt(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},jt.to.rgb.percent=function(){var t=Bt(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},jt.to.hsl=function(){var t=Bt(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},jt.to.hwb=function(){var t=Bt(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},jt.to.keyword=function(t){return Rt[t.slice(0,3)]};var Vt=St.exports,Gt={exports:{}},$t={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},Xt={};for(var Ht in $t)$t.hasOwnProperty(Ht)&&(Xt[$t[Ht]]=Ht);var Jt=Gt.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var Kt in Jt)if(Jt.hasOwnProperty(Kt)){if(!("channels"in Jt[Kt]))throw new Error("missing channels property: "+Kt);if(!("labels"in Jt[Kt]))throw new Error("missing channel labels property: "+Kt);if(Jt[Kt].labels.length!==Jt[Kt].channels)throw new Error("channel and label counts mismatch: "+Kt);var Yt=Jt[Kt].channels,Qt=Jt[Kt].labels;delete Jt[Kt].channels,delete Jt[Kt].labels,Object.defineProperty(Jt[Kt],"channels",{value:Yt}),Object.defineProperty(Jt[Kt],"labels",{value:Qt})}function Wt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}Jt.rgb.hsl=function(t){var e,n,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),c=a-o;return a===o?e=0:r===a?e=(i-s)/c:i===a?e=2+(s-r)/c:s===a&&(e=4+(r-i)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},Jt.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),f=u-Math.min(o,a,c),l=function(t){return(u-t)/6/f+.5};return 0===f?i=s=0:(s=f/u,e=l(o),n=l(a),r=l(c),o===u?i=r-n:a===u?i=1/3+e-r:c===u&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*u]},Jt.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[Jt.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},Jt.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-i)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-i-e)/(1-e)||0),100*e]},Jt.rgb.keyword=function(t){var e=Xt[t];if(e)return e;var n,r=1/0;for(var i in $t)if($t.hasOwnProperty(i)){var s=Wt(t,$t[i]);s<r&&(r=s,n=i)}return n},Jt.keyword.rgb=function(t){return $t[t]},Jt.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},Jt.rgb.lab=function(t){var e=Jt.rgb.xyz(t),n=e[0],r=e[1],i=e[2];return r/=100,i/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},Jt.hsl.rgb=function(t){var e,n,r,i,s,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[s=255*c,s,s];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),i=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,s=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,i[u]=255*s;return i},Jt.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,i=n,s=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[e,100*(0===r?2*i/(s+i):2*n/(r+n)),100*((r+n)/2)]},Jt.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),c=255*r*(1-n*(1-s));switch(r*=255,i){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},Jt.hsv.hsl=function(t){var e,n,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,n=s*a,[i,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(r/=2)]},Jt.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,u=t[1]/100,f=t[2]/100,l=u+f;switch(l>1&&(u/=l,f/=l),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=u+r*((n=1-f)-u),e){default:case 6:case 0:s=n,o=i,a=u;break;case 1:s=i,o=n,a=u;break;case 2:s=u,o=n,a=i;break;case 3:s=u,o=i,a=n;break;case 4:s=i,o=u,a=n;break;case 5:s=n,o=u,a=i}return[255*s,255*o,255*a]},Jt.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},Jt.xyz.rgb=function(t){var e,n,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,e=(e=3.2406*i+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},Jt.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},Jt.lab.xyz=function(t){var e,n,r,i=t[0];e=t[1]/500+(n=(i+16)/116),r=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=s>.008856?s:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},Jt.lab.lch=function(t){var e,n=t[0],r=t[1],i=t[2];return(e=360*Math.atan2(i,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+i*i),e]},Jt.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},Jt.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:Jt.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===i&&(s+=60),s},Jt.hsv.ansi16=function(t){return Jt.rgb.ansi16(Jt.hsv.rgb(t),t[2])},Jt.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},Jt.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},Jt.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},Jt.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},Jt.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},Jt.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,r),i),o=Math.min(Math.min(n,r),i),a=s-o;return e=a<=0?0:s===n?(r-i)/a%6:s===r?2+(i-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},Jt.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,i=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},Jt.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},Jt.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var i,s=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=c,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=c,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=c}return i=(1-n)*r,[255*(n*s[0]+i),255*(n*s[1]+i),255*(n*s[2]+i)]},Jt.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},Jt.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},Jt.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},Jt.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},Jt.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},Jt.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},Jt.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},Jt.gray.hsl=Jt.gray.hsv=function(t){return[0,0,t[0]]},Jt.gray.hwb=function(t){return[0,100,t[0]]},Jt.gray.cmyk=function(t){return[0,0,0,t[0]]},Jt.gray.lab=function(t){return[t[0],0,0]},Jt.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},Jt.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Zt=Gt.exports,te=Zt;function ee(t){var e=function(){for(var t={},e=Object.keys(te),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(te[r]),s=i.length,o=0;o<s;o++){var a=i[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function ne(t,e){return function(n){return e(t(n))}}function re(t,e){for(var n=[e[t].parent,t],r=te[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=ne(te[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var ie=Zt,se=function(t){for(var e=ee(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=re(o,e))}return n},oe={};Object.keys(ie).forEach((function(t){oe[t]={},Object.defineProperty(oe[t],"channels",{value:ie[t].channels}),Object.defineProperty(oe[t],"labels",{value:ie[t].labels});var e=se(t);Object.keys(e).forEach((function(n){var r=e[n];oe[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,i=0;i<r;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),oe[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var ae=Vt,ce=oe,ue=[].slice,fe=["keyword","gray","hex"],le={};Object.keys(ce).forEach((function(t){le[ue.call(ce[t].labels).sort().join("")]=t}));var he={};function de(t,e){if(!(this instanceof de))return new de(t,e);if(e&&e in fe&&(e=null),e&&!(e in ce))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof de)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=ae.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=ce[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=ce[this.model].channels;var s=ue.call(t,0,r);this.color=be(s,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in le))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=le[a];var c=ce[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=be(u)}if(he[this.model])for(r=ce[this.model].channels,n=0;n<r;n++){var f=he[this.model][n];f&&(this.color[n]=f(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ye(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(he[t]||(he[t]=[]))[e]=n})),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),(i=this[t]()).color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function me(t){return function(e){return Math.max(0,Math.min(t,e))}}function be(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function pe(t){return null==t}function ge(t){return"object"==typeof t&&!!t}function we(t){return t/Math.PI*180}de.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in ae.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return ae.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return ae.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ce[this.model].channels,n=ce[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new de(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new de(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ye("rgb",0,me(255)),green:ye("rgb",1,me(255)),blue:ye("rgb",2,me(255)),hue:ye(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ye("hsl",1,me(100)),lightness:ye("hsl",2,me(100)),saturationv:ye("hsv",1,me(100)),value:ye("hsv",2,me(100)),chroma:ye("hcg",1,me(100)),gray:ye("hcg",2,me(100)),white:ye("hwb",1,me(100)),wblack:ye("hwb",2,me(100)),cyan:ye("cmyk",0,me(100)),magenta:ye("cmyk",1,me(100)),yellow:ye("cmyk",2,me(100)),black:ye("cmyk",3,me(100)),x:ye("xyz",0,me(100)),y:ye("xyz",1,me(100)),z:ye("xyz",2,me(100)),l:ye("lab",0,me(100)),a:ye("lab",1),b:ye("lab",2),keyword:function(t){return arguments.length?new de(t):ce[this.model].keyword(this.color)},hex:function(t){return arguments.length?new de(t):ae.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return de.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,c=1-a;return de.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}},Object.keys(ce).forEach((function(t){if(-1===fe.indexOf(t)){var e=ce[t].channels;de.prototype[t]=function(){if(this.model===t)return new de(this);if(arguments.length)return new de(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new de((n=ce[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},de[t]=function(n){return"number"==typeof n&&(n=be(ue.call(arguments),e)),new de(n,t)}}}));const ve=[1,1,1,1,2,2,3,0];function Me(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=ve[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 Array(3),new Array(3);const Ae=[1/6378137,1/6378137,1/6356752.314245179],Te=[1/40680631590769,1/40680631590769,1/40408299984661.445],_e=new Array(3),ke=new Array(3),Oe=new Array(3);function xe(t,e){const n=Te,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],u=n[1],f=n[2],l=s*s*c*c,h=o*o*u*u,d=a*a*f*f,y=l+h+d,m=Math.sqrt(1/y),b=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(Se,e,m);if(y<i)return isFinite(m)?b:void 0;const p=r[0],g=r[1],w=r[2],v=Ie;v[0]=b[0]*p*2,v[1]=b[1]*g*2,v[2]=b[2]*w*2;let M,A,T,_,k,O,x,S,I,E,C,U=(1-m)*Ce(e)/(.5*Ce(v)),F=0;do{U-=F,T=1/(1+U*p),_=1/(1+U*g),k=1/(1+U*w),O=T*T,x=_*_,S=k*k,I=O*T,E=x*_,C=S*k,M=l*O+h*x+d*S-1,A=l*I*p+h*E*g+d*C*w;F=M/(-2*A)}while(Math.abs(M)>Ee);return t[0]=s*T,t[1]=o*_,t[2]=a*k,t}(_e,e,Ae,n,.1);let i=Tt(ke,r,n);i=function(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s);return t}(i,i);const s=At(Oe,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=function(t){return Math.sign?Math.sign(t):0==(t=+t)||isNaN(t)?Number(t):t>0?1:-1}(vt(s,e))*Ce(s);return t[0]=we(o),t[1]=we(a),t[2]=c,t}const Se=new Array(3),Ie=new Array(3),Ee=1e-12;function Ce(t){return yt(t)}function Ue(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 Ne(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(Me(r))}function Pe(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(Me(r))}function Be(t,e,n){return{offset:e,byteLength:n}}function De(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return je[t]}(s||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Le[t]}(o);return{byteStride:0,byteOffset:i+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+i,r*u)}}function Re(t,e,n,r){const i=De(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const Le={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const je={"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){for(const e in je)if(t===je[e].ctor)return je[e].type;throw new Error("unrecognized ctor:"+t)}function qe(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;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 Ve(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,u={},f={},l=null;r>0&&(u=Ne(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(f=Pe(a,e,s),e+=s);const h=Be(0,e,o);return l=a.slice(h.offset,h.offset+h.byteLength),n.push(l),{featureTable:u,featureTableBin:c,batchTable:f,batchTableBin:l}}const Ge={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function $e(t){for(const e in Ge)if(t===Ge[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n * @maptalks/gl v0.102.0\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.com\n */const Xe=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")},He=Xe(),Je=He.gl_trans__coders=He.gl_trans__coders||{};Je.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=He.gl_trans__coders=He.gl_trans__coders||{};let s=\`${O}r}\\n const _____getGlobal = ${O}Xe.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&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\\n;");return s+="\\n"+e.substring(r.length),s},Je.registerTranscoder=function(t,e){Je[t]=e},Je.getTranscoder=function(t){return Je[t]};let Ke=null;function Ye(){return Ke||(Ke={"image/crn":Je.crn&&Je.crn(),"image/ktx2":Je.ktx2&&Je.ktx2(),"image/cttf":Je.ktx2&&Je.ktx2(),"draco":Je.draco&&Je.draco()}),Ke}class Qe{constructor(t,e,n){this.i=t,this.it=e||Q,this.o=n,this.st=Ye()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.ct(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.it(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${O}t}-${O}n}-${O}r}\`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}ct(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", 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 o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),u=i.getUint32(20,!0),f=i.getUint32(24,!0),l=28+e;u>=570425344?(l-=8,o=a,u=c,f=0,a=0,c=0):f>=570425344&&(l-=4,o=u,u=a,f=c,a=0,c=0);const h=[t];let d,y,m;if(a>0?(d=Ne(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),u>0&&(y=Pe(t,l,u),l+=u,f>0)){const e=Be(0,l,f);m=t.slice(e.offset,e.offset+e.byteLength),l+=f,h.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Re(d.BATCH_ID,t,undefined.offset,b);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:d,batchTable:y,batchTableBin:m,b3dm:p,glb:{buffer:t,byteOffset:l,byteLength:i.byteLength+i.byteOffset-l}}}ut(){return null}}class We{constructor(t,e,n,r){this.i=t,this.it=e||Q,this.o=n,this.st=Ye(),this.ft=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){return this.lt(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.ht(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}lt(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,maxTextureSize:s},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=Me(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?C.getArrayBuffer(r,{}).then((t=>this.dt(r,{buffer:t.data,byteOffset:0},o))):C.getJSON(r,{}).then((t=>this.dt(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.dt(t,r,o)}}dt(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.it(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=\`${O}t}-${O}r}-${O}s}\`,{transferables:i.transferables,gltf:n}}))}ht(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", 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 o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=Ve(i,32+e,o),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()},o.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.yt(new Uint16Array(t,r+c.offset,3*h),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Re(a.BATCH_ID,t,c.offset,h);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.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()},o.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()},o.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.bt(new Uint16Array(t,e+c.offset,2*h))},o.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.bt(new Uint16Array(t,e+c.offset,2*h))},o.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()},o.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()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:f,featureTable:a,i3dm:l,transferables:o}}bt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Ze(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}yt(t,e,n){return qe(new Float32Array(t.length),t,e,n)}ut(){return null}}function Ze(t,e,n,r){if(t[0]=tn(e,r),t[1]=tn(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]))*en(e),t[1]=(1-Math.abs(e))*en(t[1])}return wt(t,t)}function tn(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,n){return t<e?e:t>n?n:t}(t,0,e)/e*2-1}function en(t){return t<0?-1:1}class nn{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.ot(t,e,n,r)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r){return this.gt(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}))}gt(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", 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 o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=Ve(i,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let y,m={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){m=a.extensions["3DTILES_draco_point_compression"],y=new DataView(t,m.byteOffset+c.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.wt||(this.wt=Ye().draco),this.wt(y,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.vt(t,e.attributes,c.offset,d,o,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:ze(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Re(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=rn(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:u,batchTableBin:f,featureTable:a,pnts:r,transferables:o}}))}const b=this.vt(t,a,c.offset,d,o,l,h);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Re(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=rn(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:u,batchTableBin:f,featureTable:a,pnts:b,transferables:o})}vt(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.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.yt(u||new Uint16Array(t,c+f,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}yt(t,e,n){return qe(new Float32Array(t.length),t,e,n)}ut(){return null}}function rn(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:ze(e),array:r}}class sn{constructor(t,e,n,r){this.o=n,this.i=t,this.it=e||Q,this.ft=r}load(t,e,n=0,r=0,i){return e?this.ot(t,e,n,r,i):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.ot(t,i,n,r)}))}ot(t,e,n,r,i){r||(r=e.byteLength);const s=this.Mt(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new Qe(this.i,this.it,this.o);else if("i3dm"===s[n].magic)r=new We(this.i,this.it,this.o,this.ft);else if("pnts"===s[n].magic)r=new nn;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new sn(this.i,this.it,this.o,this.ft)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Mt(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Ue(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function on(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=[];dn(r[n],i,t,e)}}}const an=[],cn=[],un=[],fn=[0,0,0],ln=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),hn=[1,1,1];function dn(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=function(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}(an,t.translation||fn),n=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,y=i*c,m=s*o,b=s*a,p=s*c;return t[0]=1-l-y,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-p,t[5]=1-u-y,t[6]=d+m,t[7]=0,t[8]=h+b,t[9]=d-m,t[10]=1-u-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(cn,t.rotation||ln),r=function(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}(un,t.scale||hn);lt(r,n,r);const s=lt([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)dn(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,r(s,e,i,n))}}}}function yn(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?Q.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*o;r+=o){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o)}return}const u=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);u.set(i);e(new c(u.buffer),t),i.set(u)}}var mn=vn("DXT1"),bn=vn("DXT3"),pn=vn("DXT5"),gn=vn("DX10"),wn=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 i=r[21];switch(i){case mn:e=8,n="dxt1";break;case bn:e=16,n="dxt3";break;case pn:e=16,n="dxt5";break;case 116:n="rgba32f";break;case gn:var s=new Uint32Array(t.slice(128,148));n=s[0];var o=s[1];if(s[2],s[3],s[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=i,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],d=r[3],y=r[1]+4,m=h,b=d,p=[];i===gn&&(y+=20);if(f)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=m,d=b;for(var w=Math.log(h)/Math.log(2)+1,v=0;v<w;v++)l=h*d*16,p.push({offset:y,length:l,shape:[h,d]}),v<u&&(y+=l),h=Math.floor(h/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)l=Math.max(4,h)/4*Math.max(4,d)/4*e,p.push({offset:y,length:l,shape:[h,d]}),y+=l,h=Math.floor(h/2),d=Math.floor(d/2);return{shape:[m,b],images:p,format:n,flags:c,cubemap:f}};function vn(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var Mn=xt(wn),An=Math.abs,Tn=Math.sin,_n=Math.cos,kn=Math.tan,On=Math.atan,xn=Math.atan2,Sn=Math.sqrt,In=Math.log,En=Math.hypot,Cn=Math.sinh,Un=Math.cosh,Fn=1/0;function Nn(t){var e,n,r,i,s,o,a=[],c=[],u=[],f=[];function l(t,e){for(var n,r=2*_n(2*e),i=t.length-1,s=t[i],o=0;--i>=0;)n=r*s-o+t[i],o=s,s=n;return e+n*Tn(2*e)}function h(t,e,n){for(var r,i,s=Tn(e),o=_n(e),a=Cn(n),c=Un(n),u=2*o*c,f=-2*s*a,l=t.length-1,h=t[l],d=0,y=0,m=0;--l>=0;)r=y,i=d,h=u*(y=h)-r-f*(d=m)+t[l],m=f*y-i+u*d;return[(u=s*c)*h-(f=o*a)*m,u*m+f*h]}t.es,s=i=(r=t.es/(1+Sn(1-t.es)))/(2-r),a[0]=i*(2+i*(-2/3+i*(i*(116/45+i*(26/45+i*(-2854/675)))-2))),c[0]=i*(i*(2/3+i*(4/3+i*(-82/45+i*(32/45+i*(4642/4725)))))-2),s*=i,a[1]=s*(7/3+i*(i*(-227/45+i*(2704/315+i*(2323/945)))-1.6)),c[1]=s*(5/3+i*(-16/15+i*(-13/9+i*(904/315+i*(-1522/945))))),s*=i,a[2]=s*(56/15+i*(-136/35+i*(-1262/105+i*(73814/2835)))),c[2]=s*(-26/15+i*(34/21+i*(1.6+i*(-12686/2835)))),s*=i,a[3]=s*(4279/630+i*(-332/35+i*(-399572/14175))),c[3]=s*(1237/630+i*(i*(-24832/14175)-2.4)),s*=i,a[4]=s*(4174/315+i*(-144838/6237)),c[4]=s*(-734/315+i*(109598/31185)),s*=i,a[5]=s*(601676/22275),c[5]=s*(444337/155925),s=i*i,e=t.k0/(1+i)*(1+s*(1/4+s*(1/64+s/256))),u[0]=i*(i*(2/3+i*(-37/96+i*(1/360+i*(81/512+i*(-96199/604800)))))-.5),f[0]=i*(.5+i*(-2/3+i*(5/16+i*(41/180+i*(-127/288+i*(7891/37800)))))),u[1]=s*(-1/48+i*(-1/15+i*(437/1440+i*(-46/105+i*(1118711/3870720))))),f[1]=s*(13/48+i*(i*(557/1440+i*(281/630+i*(-1983433/1935360)))-.6)),s*=i,u[2]=s*(-17/480+i*(37/840+i*(209/4480+i*(-5569/90720)))),f[2]=s*(61/240+i*(-103/140+i*(15061/26880+i*(167603/181440)))),s*=i,u[3]=s*(-4397/161280+i*(11/504+i*(830251/7257600))),f[3]=s*(49561/161280+i*(-179/168+i*(6601661/7257600))),s*=i,u[4]=s*(-4583/161280+i*(108847/3991680)),f[4]=s*(34729/80640+i*(-3418889/1995840)),s*=i,u[5]=s*(-20648693/638668800),f[5]=.6650675310896665*s,o=l(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*_n(e),i=t.length-1,s=t[i],o=0;for(;--i>=0;)n=r*s-o+t[i],o=s,s=n;return Tn(e)*n}(f,2*o)),t.fwd=function(t,r){var i,s,o,a,u,d=t.phi,y=t.lam;d=l(c,d),i=Tn(d),s=_n(d),a=Tn(y),o=_n(y),d=xn(i,o*s),y=xn(a*s,En(i,s*o)),y=function(t){var e=An(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*In(e)/n}(e*(1+e/(En(1,e)+1))),t<0?-e:e}(kn(y)),u=h(f,2*d,2*y),d+=u[0],y+=u[1],An(y)<=2.623395162778?(r.y=e*d+n,r.x=e*y):r.x=r.y=Fn},t.inv=function(t,r){var i,s,o,c,f,d=t.y,y=t.x;d=(d-n)/e,An(y/=e)<=2.623395162778?(d+=(f=h(u,2*d,2*y))[0],y+=f[1],y=On(Cn(y)),i=Tn(d),s=_n(d),c=Tn(y),o=_n(y),y=xn(c,o*s),d=xn(i*o,En(c,o*s)),r.phi=l(a,d),r.lam=y):r.phi=r.lam=Fn}}const Pn=Math.PI/180,Bn=6378137*Math.PI/180,Dn=85.0511287798,Rn={};function Ln(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Dn,r=e[0],i=Math.max(Math.min(n,e[1]),-n);let s;s=0===i?0:Math.log(Math.tan((90+i)*Pn/2))/Pn;return t[0]=r*Bn,t[1]=s*Bn,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return jn(t,e);if("baidu"===n)return jn(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const i=JSON.stringify(n);let s=Rn[i];return s||(s=Rn[i]=function(t){const e={a:qn,es:Vn,x0:pe(t.falseEasting)?5e5:t.falseEasting,y0:pe(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*zn,phi0:(t.latitudeOfOrigin||0)*zn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Nn(e);const n={lam:0,phi:0},r={};let i=0,s=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*zn-e.lam0,n.phi=e.originPhi0*zn,e.fwd(n,r),i=e.a*r.x+e.x0,s=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*zn-e.lam0,n.phi=t[1]*zn,e.fwd(n,r);const a=e.a*r.x+e.x0-i,c=e.a*r.y+e.y0-s;return o[0]=a,o[1]=c,o}}}(n)),s.project(e,t)}}function jn(t,e){return t[0]=e[0],t[1]=e[1],t}const zn=.017453292519943295,qn=6378137,Vn=.0066943799901413165;const Gn=ft([]),$n=Ye().draco,Xn=Ye().ktx2,Hn={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Jn={"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 Kn(t,e,n,r,i,s){const o=[],a=[],c=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],i=C.getArrayBuffer(n.url,s);i.xhr.url=n.url,c.push(i.xhr);const u=i.then((t=>({buffer:t})));o.push(u);const f=[];if(rr(r,f),f.length){const t=f.map((t=>{const e=C.getArrayBuffer(t.url,s);return e.xhr.url=t.url,c.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));o.push(...t)}a[e]=f.length}const u=Promise.all(o).then((s=>{for(let t=0;t<s.length;t++)if(!s[t]||!s[t].buffer)return Promise.resolve(null);const o=[];let c=0;for(let t=0;t<a.length;t++){const e=a[t];o.push({geoBuffer:{data:s[c].buffer.data},textureBuffers:s.slice(c+1,e+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+e}const u=function(t,e,n,r,i,s){const o={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;l=ur(h)?Qn(o,c,f,h,t.transform,t.center,i,s):Zn(o,c,f,h,t.transform,t.center,i,s),a.push(l),o.nodes[c]={mesh:c,nodeIndex:c,matrix:ft([])},o.scenes[0].nodes[c]=o.nodes[c],u||(u=Hn);const d=er(c,o,u,e[c].textureBuffers,n,r);a.push(d)}return Promise.all(a).then((()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables})))}(t,o,e,i,n,r);return u}));return u.xhr=c,u}const Yn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Qn(t,e,n,r,i,s,o,a){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=Jn[e];if(!r)return t;return t[r.name||e]=n,t}),{});return $n(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>tr(n,t,e,i,s,o,a)))}const Wn={position:function(t,e,n){const r=3*t.vertexCount,i=new Float32Array(e,n,r);return t.position={array:i,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,i=new Float32Array(e,n,r);return t.normal={array:i,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,i=new Float32Array(e,n,r);return t.uv0={array:i,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,i=new Uint8Array(e,n,r);return t.color={array:i,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,i=new Uint32Array(e,n,r);return t.faceRange={array:i,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Zn(t,e,n,r,i,s,o,a){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.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++)Wn[n[e]]?t=Wn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let i=e.ordering,s=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<i.length;e++){const n=Wn[i[e]];n||console.log(i[e]),t=n(c,r,t)}for(let e=0;e<s.length;e++){const n=Wn[s[e]];n||console.log(s[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const f={};for(const t in c){const e=Jn[t]&&Jn[t].name;e&&(f[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(l=e)<=255?Uint8Array:l<=65535?Uint16Array:Uint32Array,r=new n(f.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,i=t[e],s=t[e+1];for(let t=i;t<=s;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}f._BATCHID={componentType:$e(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var l;return tr({attributes:f},t,e,i,s,o,a)}function tr(t,e,n,r,i,s,o){const a={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 c=function(t,e,n,r,i){let s,o=[0,0,0,1];const a=[0,0],c=Ln([],n,r,i);c[2]=n[2];const u=e&&ht(Gn,e);return yn(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],u||(o=Mt(o,o,e)),n&&gt(o,o,n),Ln(a,o,r,i),s=o[2],t[0]=a[0]-c[0],t[1]=a[1]-c[1],t[2]=s-c[2],t))),c}(t.attributes.POSITION,r,i,s,o);e.meshes[n]={primitives:[a],index:n},e.extensions.MAPTALKS_RTC={projCenter:c},e.extensions.CESIUM_RTC={rtcCoord:i};for(const n in t.attributes)cr(e.transferables,t.attributes[n].array.buffer);return t.indices&&cr(e.transferables,t.indices.array.buffer),a}function er(t,e,n,r,i,s){const o=r.map((t=>function(t,e,n,r,i){if("dds"===e){const e=Mn(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),i="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Yn,format:i})}if("png"===e||"jpg"===e)return function(t,e){ir||(ir=new OffscreenCanvas(2,2),sr=ir.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;or(n)||(n=ar(n)),or(r)||(r=ar(r));const i=e;i&&(n=Math.min(i,n),r=Math.min(i,r)),ir.width=n,ir.height=r,sr.drawImage(t,0,0,n,r),t.close();const s=sr.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(s.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,i).then((t=>{t.mimeType=n;return{image:t,sampler:Yn,format:6408}}));if("ktx2"===e)return Xn(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Yn,format:t.format})));return null}(t.data,t.format,t.mimeType,i,s).then((t=>{if(t.image)if(t.image.array)cr(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cr(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{nr(t,e,n,r)}))}function nr(t,e,n,r){const i=JSON.parse(JSON.stringify(n)),s=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(s.push(r[r.ptr++]),i[t]={index:s.length-1},void 0!==n[t].factor&&(i[t].scale=n[t].factor)):ge(n[t])&&(i[t]=nr(-1,e,n[t],r));return t>=0&&(e.materials[t]=i),i}function rr(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}):ge(t[n])&&rr(t[n],e)}let ir,sr;function or(t){return!(t&t-1)&&0!==t}function ar(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cr(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function ur(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()}var fr="undefined"!=typeof Float32Array?Float32Array:Array;function lr(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hr=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new fr(3);return fr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const dr=[];const yr=[],mr=[],br=[],pr=[],gr=[],wr=[],vr=[];function Mr(t,e,n,r,i,s){lr(pr,t[3*e],t[3*e+1],t[3*e+2]),lr(gr,t[3*n],t[3*n+1],t[3*n+2]),lr(wr,t[3*r],t[3*r+1],t[3*r+2]);const o=hr(yr,wr,gr),a=hr(mr,pr,gr),c=function(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],c=n[2];return t[0]=i*c-s*a,t[1]=s*o-r*c,t[2]=r*a-i*o,t}(br,o,a);!function(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s)}(vr,c),i[3*e]=i[3*e]||0,i[3*n]=i[3*n]||0,i[3*r]=i[3*r]||0,i[3*e+1]=i[3*e+1]||0,i[3*n+1]=i[3*n+1]||0,i[3*r+1]=i[3*r+1]||0,i[3*e+2]=i[3*e+2]||0,i[3*n+2]=i[3*n+2]||0,i[3*r+2]=i[3*r+2]||0,i[3*e]+=vr[0],i[3*n]+=vr[0],i[3*r]+=vr[0],i[3*e+1]+=vr[1],i[3*n+1]+=vr[1],i[3*r+1]+=vr[1],i[3*e+2]+=vr[2],i[3*n+2]+=vr[2],i[3*r+2]+=vr[2],s[e]+=1,s[n]+=1,s[r]+=1}const Ar=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Tr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],_r=2*Math.PI*6378137/360,kr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Or,xr,Sr=!1;if("undefined"!=typeof OffscreenCanvas){try{xr=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}xr&&"undefined"!=typeof createImageBitmap&&(Sr=!0)}const Ir=ft([]),Er=[0,0,0],Cr=[],Ur=[],Fr=[],Nr=[],Pr={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Br={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Dr;class Rr{constructor(t,e,n,r){this.id=t,this.options=e,this.At=(...t)=>this.requestImage.call(this,...t),this.Tt=n,this._t={},r(null,{},[])}kt(t){this.Ot||(this.o=t,this.xt=new nn,this.Ot=new Qe(this.At,Q,t),this.St=new We(this.At,Q,t))}requestImage(t,e){Sr?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{Or.width=t.width,Or.height=t.height,xr.drawImage(t,0,0);const n=xr.getImageData(0,0,Or.width,Or.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.Tt("requestImage",{url:t},null,e)}loadTile(t,e){this.kt(t.supportedFormats);const{service:n,url:r,arraybuffer:i}=t,s=n.fetchOptions||{};if(s.referrer=t.referrer,s.referrerPolicy=s.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const i=t.i3sInfo,o=n.maxTextureSize||0,a=Kn(i,t.supportedFormats,this.options.projection,t.projection,o,s);return a.then((t=>{if(delete this._t[r],!t)return void e({status:404,url:r,i3sInfo:i});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:i});t.gltf.url=r;const{transferables:s}=t;t.magic="b3dm",n.createNormalIfMissed&&this.It(t.gltf),n.compressGeometry&&this.Et(t.gltf),e(null,t,s)})),void(this._t[r]=a.xhr)}if(i){delete this._t[r];const n=Ue(new DataView(i),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(kr){const r=new Uint8Array(t,e,n);return kr.decode(r)}return Me(new Uint8Array(t,e,n))}(i,0,i.byteLength),s=JSON.parse(n);s.accessors?this.Ct(s,r,t,"gltf",e):this.Ut(t.rootIdx,s,i,r,e)}else this.Ct(i,r,t,n,e)}else{let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);const o=r.replace(/\\+/g,"%2B");let a=C.getArrayBuffer(o+(i||""),s);const c=a.xhr;a=a.then((n=>{delete this._t[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this._t[r],e(t)})),this._t[r]=c}}Ct(t,e,n,r,i){r=r&&r.toLowerCase();const{service:s}=n;if("b3dm"===r){this.Ot.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:r}=this.Ft(t,n);s.createNormalIfMissed&&this.It(e.gltf),s.compressGeometry&&this.Et(e.gltf),i(null,e,r)})).catch((t=>{i(t)}))}else if("pnts"===r){const r=n.transform||Ir;this.xt.load(e,t).then((t=>{const{content:e,transferables:s}=this.Nt(t,r,n.rootIdx);this.Pt(e),i(null,e,s)}))}else if("i3dm"===r){const r=n.transform||Ir;this.St.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:o}=this.Bt(t,r,n.rootIdx);s.createNormalIfMissed&&this.It(e.gltf),s.compressGeometry&&this.Et(e.gltf),i(null,e,o)}))}else if("cmpt"===r){new sn(this.At,Q,this.o,s.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Dt(t,n);this.Rt(e,s),s.compressGeometry&&this.Lt(e),i(null,e,r)})).catch((t=>{i(t)}))}else if("gltf"===r){this.st||(this.st=Ye());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t,a=new Q(r,o,{transferable:!0,requestImage:this.At,decoders:this.st,supportedFormats:this.o,maxTextureSize:s.maxTextureSize||0});a.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.jt(t,null,n),s.createNormalIfMissed&&this.It(t),s.compressGeometry&&this.Et(t),i(null,{magic:"gltf",gltf:t},a.transferables)}))}else i(new Error("unsupported tile format: "+r))}Rt(t,e){t.content?t.content.forEach((t=>{this.Rt(t,e)})):e.createNormalIfMissed&&this.It(t.gltf)}Lt(t){t.content?t.content.forEach((t=>{this.Lt(t)})):this.Et(t.gltf)}zt(t,e){if(this.qt(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.Vt()?Dr.subarray(0,n):e,i=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const i=dr;i.length<t.length/3&&(i.length=t.length/3),i.fill(0,0,t.length/3);const s=void 0===e.length?e:e.length;for(let n=0;n<s/3;n++)void 0===e.length?Mr(t,3*n,3*n+1,3*n+2,r,i):Mr(t,e[3*n],e[3*n+1],e[3*n+2],r,i);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=i[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:i,byteLength:i.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:i.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}Et(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(Pr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=_r,t.compressed_int16_params.compressed_ratio=r);const i=Gr(e[n].array,r,e[n].min,e[n].max,n);if(!i)continue;const{array:s,range:o}=i;e[n].componentType=5124,e[n].array=s,t.compressed_int16_params[n]=o}}))}}It(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.zt(e,t)}))}}Pt(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(Pr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=_r,t.compressed_int16_params.compressed_ratio=r);const{array:i,range:s}=Gr(e[n].array,r,e[n].min,e[n].max,n);e[n].array=i,t.compressed_int16_params[n]=s}}Gt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const i={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(i)}return e}Ut(t,e,n,r,i){return e.capabilities,void i(null,e)}Dt(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},i=[];for(let t=0;t<n.length;t++){const{magic:s}=n[t];if("b3dm"===s){const{content:s,transferables:o}=this.Ft(n[t],e);qr(i,o),r.content.push(s)}else if("i3dm"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Bt(n[t],s,o);qr(i,c),r.content.push(a)}else if("pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Nt(n[t],s,o);qr(i,c),r.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Dt(n[t],e);qr(i,o),r.content.push(s)}}return{content:r,transferables:i}}Ft(t,e){const{gltf:n,transferables:r,featureTable:i}=t;return this.jt(n,i,e),delete t.transferables,{content:t,transferables:r}}jt(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;const e="visited";let n=1;const r=[];for(const i in t.meshes){const s=t.meshes[i],{primitives:o}=s;if(o)for(let t=0;t<o.length;t++){const i=o[t].attributes&&o[t].attributes.POSITION;if(!i||!i.array)continue;i.array.buffer[e]||(i.array.buffer[e]=n++);const s=n-1+"-"+(i.byteOffset||0);if(r.indexOf(s)>=0)return!0;r.push(s)}}return!1}(t);this.$t(t);n.service.createNormalIfMissed||this.Xt(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.Ht(t,e,n.upAxis,n.transform)):this.Jt(t,e,n.upAxis,n.transform)}Bt(t,e,n){const{featureTable:r}=t,i=t.i3dm,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&ht(Ir,e),c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};jr(i.POSITION.array,3,s,Ir,c);const u=zr(c);e&&!a&&Mt(u,u,e);const f=this.Kt(u),l=[];Ln(l,f,o),l[2]=f[2];const h=bt([],u),d=[0,0,0],y=[0,0,0],m=[0,0],b=[1/0,1/0,1/0],p=[-1/0,-1/0,-1/0];yn(i.POSITION,(t=>{d[0]=t[0]+s[0],d[1]=t[1]+s[1],d[2]=t[2]+s[2],e&&!a&&Mt(d,d,e),0===_t(d)?pt(y,0,0,-6378137):xe(y,d),Ln(m,y,o),t[0]=m[0]-l[0],t[1]=m[1]-l[1],t[2]=y[2]-l[2],t[0]<b[0]&&(b[0]=t[0]),t[1]<b[1]&&(b[1]=t[1]),t[2]<b[2]&&(b[2]=t[2]),t[0]>p[0]&&(p[0]=t[0]),t[1]>p[1]&&(p[1]=t[1]),t[2]>p[2]&&(p[2]=t[2])})),i.POSITION.min=b,i.POSITION.max=p,e&&Mt(u,u,e),t.rtcCenter=h,t.rtcCoord=f,t.projCenter=l,t.rootIdx=n;const g=t.transferables;return delete t.transferables,{content:t,transferables:g}}Nt(t,e,n){const{featureTable:r}=t,i=t.pnts,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&ht(Ir,e),c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};jr(i.POSITION.array,3,s,e,c);const u=zr(c),f=this.Yt(u),l=bt([],u),h=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];let y=[0,0,0,1];const m=[0,0,0],b=[0,0];yn(i.POSITION,(t=>(y[0]=t[0]+s[0],y[1]=t[1]+s[1],y[2]=t[2]+s[2],e&&!a&&(y=Mt(y,y,e)),0===_t(y)?pt(m,0,0,-6378137):xe(m,y),Ln(b,m,o),t[0]=b[0]-f[0],t[1]=b[1]-f[1],t[2]=m[2]-f[2],t[0]<h[0]&&(h[0]=t[0]),t[1]<h[1]&&(h[1]=t[1]),t[2]<h[2]&&(h[2]=t[2]),t[0]>d[0]&&(d[0]=t[0]),t[1]>d[1]&&(d[1]=t[1]),t[2]>d[2]&&(d[2]=t[2]),t))),i.POSITION.min=h,i.POSITION.max=d,e&&Mt(u,u,e);const p=this.Kt(u);t.rtcCenter=l,t.projCenter=f,t.rtcCoord=p,t.rootIdx=n;const g=t.transferables;return delete t.transferables,{content:t,transferables:g}}$t(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],i=n[1],s=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==i||n[t+2]!==s||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,i/255,s/255,o/255],delete e[t].image.array)}}}Xt(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const i=r.primitives;if(i)for(let e=0;e<i.length;e++){if(!i[e])continue;if(!i[e].attributes||i[e].attributes.NORMAL)continue;const n=i[e].material;if(!pe(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}abortTileLoading(t,e){const n=this._t[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._t[t.url],e(null)}Qt(t,e,n,r){const i=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let s=Ar;"X"===(n=n&&n.toUpperCase())?s=Tr:"Z"===n&&(s=Ir),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),i&&(t.extensions.CESIUM_RTC.center=i),t.extensions.MAPTALKS_RTC={};const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};on(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=ft(Cr);t.matrices&&Vr(e,t.matrices);const n=t.attributes.POSITION.array,a=t.attributes.POSITION.itemSize;lt(e,s,e),r&&lt(e,r,e),jr(n,a,i||Er,e,o,t.compressUniforms)}));const a=zr(o);return{rtcCenter:i,modelCenter:a,upAxisTransform:s}}Ht(t,e,n,r){const{modelCenter:i,upAxisTransform:s,rtcCenter:o}=this.Qt(t,e,n),a=this.Yt(i);t.extensions.MAPTALKS_RTC.projCenter=a,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i);const c=bt([],i);r&&Mt(i,i,r),t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i),o||(on(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=ft(Cr);t.matrices&&Vr(n,t.matrices),lt(n,s,n);const r=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],u=e[7],f=e[8],l=e[9],h=e[10],d=e[11],y=e[12],m=e[13],b=e[14],p=e[15],g=n*a-r*o,w=n*c-i*o,v=n*u-s*o,M=r*c-i*a,A=r*u-s*a,T=i*u-s*c,_=f*m-l*y,k=f*b-h*y,O=f*p-d*y,x=l*b-h*m,S=l*p-d*m,I=h*p-d*b,E=g*I-w*S+v*x+M*O-A*k+T*_;return E?(E=1/E,t[0]=(a*I-c*S+u*x)*E,t[1]=(i*S-r*I-s*x)*E,t[2]=(m*T-b*A+p*M)*E,t[3]=(h*A-l*T-d*M)*E,t[4]=(c*O-o*I-u*k)*E,t[5]=(n*I-i*O+s*k)*E,t[6]=(b*v-y*T-p*w)*E,t[7]=(f*T-h*v+d*w)*E,t[8]=(o*S-a*O+u*_)*E,t[9]=(r*O-n*S-s*_)*E,t[10]=(y*A-m*v+p*g)*E,t[11]=(l*v-f*A-d*g)*E,t[12]=(a*k-o*x-c*_)*E,t[13]=(n*x-r*k+i*_)*E,t[14]=(m*w-y*M-b*g)*E,t[15]=(f*M-l*w+h*g)*E,t):null}(Ur,n),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];yn(e,(t=>{Mt(t,t,n),t[0]=t[0]-c[0],t[1]=t[1]-c[1],t[2]=t[2]-c[2],Mt(t,t,r),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]>o[0]&&(o[0]=t[0]),t[1]>o[1]&&(o[1]=t[1]),t[2]>o[2]&&(o[2]=t[2])})),e.min=i,e.max=o,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=c)}Jt(t,e,n,r){const{modelCenter:i,rtcCenter:s}=this.Qt(t,e,n,r),o=this.Yt(i);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i),on(t,(e=>{if(e.attributes&&e.attributes.POSITION){const i=this.qt(e,t);if(i){const t=e.attributes.POSITION.array.length;(!Dr||Dr.length<t)&&(Dr=new Float32Array(t))}e.attributes.NORMAL&&this.Wt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.Wt(e.attributes.TANGENT,e.matrices,n);const{newPositions:o}=this.Zt(e.attributes.POSITION,e.matrices,s,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,i),{componentType:a}=e.attributes.POSITION;5126!==a&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=Ir}}Yt(t){const e=this.options.projection;"identity"===e?bt(Fr,t):0===_t(t)?pt(Fr,0,0,-6378137):xe(Fr,t),Ln(Nr,Fr,e);const n=Fr[2],r=[];return r[0]=Nr[0],r[1]=Nr[1],r[2]=n,r}Wt(t,e,n){let r;r="Y"===n?Ar:"X"===n?Tr:Ir;const i=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}([],r);if(Vr(i,e),ht(i,Ir))return;const s=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}([],i),o=[];yn(t,(t=>(function(t,e,n){var r=e[0],i=e[1],s=e[2];t[0]=r*n[0]+i*n[3]+s*n[6],t[1]=r*n[1]+i*n[4]+s*n[7],t[2]=r*n[2]+i*n[5]+s*n[8]}(o,t,s),wt(o,o),bt(t,o),o)))}Zt(t,e,n,r,i,s,o,a){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const c=ft([]);Vr(c,e);const u=this.options.projection;i=i&&i.toUpperCase();const f=n;let l=null;"Y"===i?l=Ar:"X"===i&&(l=Tr);let h=[0,0,0,1];const d=[0,0,0],y=[0,0],m=r.projCenter,b=Ln([],r.rtcCoord,"EPSG:3857"),p=s&&ht(Ir,s),g=t.min=t.min||[],w=t.max=t.max||[];pt(g,1/0,1/0,1/0),pt(w,-1/0,-1/0,-1/0);const v=o||{},{decode_position_min:M,decode_position_normConstant:A}=v;let T=[0,0,0,0],_=1;M&&(T=M),A&&(_=A);const k=[];return yn(t,((e,n)=>{if(h[0]=e[0]*_+T[0],h[1]=e[1]*_+T[1],h[2]=e[2]*_+T[2],h=Mt(h,h,c),l&&(h=Mt(h,h,l)),f&&gt(h,h,f),s&&!p&&(h=Mt(h,h,s)),0===_t(h)?pt(d,0,0,-6378137):xe(d,h),a){const t=Dr;Ln(y,d,u),t[3*n]=y[0]-b[0],t[3*n+1]=y[0]-b[1],t[3*n+2]=y[0]-b[2]}if(Ln(y,d,u),e instanceof Float32Array)e[0]=y[0]-m[0],e[1]=y[1]-m[1],e[2]=d[2]-m[2];else{const n=y[0]-m[0],r=y[1]-m[1],i=d[2]-m[2];5126!==t.componentType&&(k.push(n),k.push(r),k.push(i),k.push(e[3]))}return e[0]<g[0]&&(g[0]=e[0]),e[1]<g[1]&&(g[1]=e[1]),e[2]<g[2]&&(g[2]=e[2]),e[0]>w[0]&&(w[0]=e[0]),e[1]>w[1]&&(w[1]=e[1]),e[2]>w[2]&&(w[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:m,newPositions:k}}Kt(t){return 0===_t(t)?pt([],0,0,-6378137):xe([],t)}onRemove(){}Vt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}qt(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;return!t.attributes.TANGENT}}const Lr=[];function jr(t,e,n,r,i,s){const o=s||{},{decode_position_min:a,decode_position_normConstant:c}=o;let u=[0,0,0,0],f=1;a&&(u=a),c&&(f=c);for(let s=0,o=t.length;s<o;s+=e){const{xmin:o,ymin:a,xmax:c,ymax:l,hmin:h,hmax:d}=i;pt(Lr,t[s]*f+u[0],t[s+1]*f+u[1],t[s+2]*f+u[2]),Mt(Lr,Lr,r);const y=gt(Lr,n,Lr);y[0]<o&&(i.xmin=y[0]),y[0]>c&&(i.xmax=y[0]),y[1]<a&&(i.ymin=y[1]),y[1]>l&&(i.ymax=y[1]),e>2&&(y[2]<h&&(i.hmin=y[2]),y[2]>d&&(i.hmax=y[2]))}}function zr(t){const{xmax:e,ymax:n,xmin:r,ymin:i,hmin:s,hmax:o}=t,a=[(r+e)/2,(i+n)/2,(s+o)/2];return e===-1/0&&(a[0]=0),n===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function qr(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Vr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)lt(n,e[t],n);return n}function Gr(t,e,n,r,i){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let s,o;if(n&&r&&1===e)s=Math.min(...n),o=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);s=e,o=n}return!function(t,e,n,r){for(let i=0;i<t.length;i++){const s=$r(Xr(t[i],e,n),e,n);if(Math.abs(s-t[i])>Br[r])return!1}return!0}(t,s,o,i)&&Br[i]?null:function(t,e,n){const r=new Int16Array(t.length);for(let i=0;i<t.length;i++)r[i]=Xr(t[i],e,n);return{array:r,range:[e,n]}}(t,s,o)}function $r(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Xr(t,e,n){const r=2*(t-e)/(n-e)-1,i=Math.max(-1,Math.min(1,r));return i<0?32768*i:32767*i}let Hr=0;class Jr{constructor(t){this.workerId=t,this.workers={},this.te={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},i){if(this.ee(e,n))return;const s=this.ne(e,n),o=r.options;this.workers[s]=new Rr(n,o,((...e)=>this.send.call(this,t,...e)),i)}removeLayer({mapId:t,layerId:e},n){const r=this.ee(t,e),i=this.ne(t,e);delete this.workers[i],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const i=this.ee(t,e);i&&i.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const i=this.ee(t,e);i&&i.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.te[e];delete this.te[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,i){const s=i?\`${O}t}-${O}Hr++}\`:null;i&&(this.te[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(s)},r||[])}ne(t,e){return\`${O}t}-${O}e}\`}ee(t,e){const n=this.ne(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Jr(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&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`;function x(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var I={exports:{}},S={exports:{}},E=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},C=Array.prototype.concat,N=Array.prototype.slice,k=S.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];E(i)?e=C.call(e,N.call(i)):e.push(i)}return e};k.wrap=function(t){return function(){return t(k(arguments))}};var R=S.exports,L={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},P=R,B=Object.hasOwnProperty,U=Object.create(null);for(var D in L)B.call(L,D)&&(U[L[D]]=D);var F=I.exports={to:{},get:{}};function j(t,e,n){return Math.min(Math.max(e,t),n)}function z(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}F.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=F.get.hsl(t),n="hsl";break;case"hwb":e=F.get.hwb(t),n="hwb";break;default:e=F.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},F.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var s=2*n;i[n]=parseInt(e.slice(s,s+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:B.call(L,e[1])?((i=L[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=j(i[n],0,255);return i[3]=j(i[3],0,1),i},F.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},F.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},F.to.hex=function(){var t=P(arguments);return"#"+z(t[0])+z(t[1])+z(t[2])+(t[3]<1?z(Math.round(255*t[3])):"")},F.to.rgb=function(){var t=P(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},F.to.rgb.percent=function(){var t=P(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},F.to.hsl=function(){var t=P(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},F.to.hwb=function(){var t=P(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},F.to.keyword=function(t){return U[t.slice(0,3)]};var q=I.exports,G={exports:{}},H={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},V={};for(var J in H)H.hasOwnProperty(J)&&(V[H[J]]=J);var $=G.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var K in $)if($.hasOwnProperty(K)){if(!("channels"in $[K]))throw new Error("missing channels property: "+K);if(!("labels"in $[K]))throw new Error("missing channel labels property: "+K);if($[K].labels.length!==$[K].channels)throw new Error("channel and label counts mismatch: "+K);var X=$[K].channels,Y=$[K].labels;delete $[K].channels,delete $[K].labels,Object.defineProperty($[K],"channels",{value:X}),Object.defineProperty($[K],"labels",{value:Y})}$.rgb.hsl=function(t){var e,n,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),c=a-o;return a===o?e=0:r===a?e=(i-s)/c:i===a?e=2+(s-r)/c:s===a&&(e=4+(r-i)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},$.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,h=Math.max(o,a,c),l=h-Math.min(o,a,c),u=function(t){return(h-t)/6/l+.5};return 0===l?i=s=0:(s=l/h,e=u(o),n=u(a),r=u(c),o===h?i=r-n:a===h?i=1/3+e-r:c===h&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*h]},$.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[$.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},$.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-i)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-i-e)/(1-e)||0),100*e]},$.rgb.keyword=function(t){var e=V[t];if(e)return e;var n,r,i,s=1/0;for(var o in H)if(H.hasOwnProperty(o)){var a=H[o],c=(r=t,i=a,Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2)+Math.pow(r[2]-i[2],2));c<s&&(s=c,n=o)}return n},$.keyword.rgb=function(t){return H[t]},$.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},$.rgb.lab=function(t){var e=$.rgb.xyz(t),n=e[0],r=e[1],i=e[2];return r/=100,i/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},$.hsl.rgb=function(t){var e,n,r,i,s,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[s=255*c,s,s];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),i=[0,0,0];for(var h=0;h<3;h++)(r=o+1/3*-(h-1))<0&&r++,r>1&&r--,s=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,i[h]=255*s;return i},$.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,i=n,s=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[e,100*(0===r?2*i/(s+i):2*n/(r+n)),100*((r+n)/2)]},$.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),c=255*r*(1-n*(1-s));switch(r*=255,i){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},$.hsv.hsl=function(t){var e,n,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,n=s*a,[i,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(r/=2)]},$.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,h=t[1]/100,l=t[2]/100,u=h+l;switch(u>1&&(h/=u,l/=u),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=h+r*((n=1-l)-h),e){default:case 6:case 0:s=n,o=i,a=h;break;case 1:s=i,o=n,a=h;break;case 2:s=h,o=n,a=i;break;case 3:s=h,o=i,a=n;break;case 4:s=i,o=h,a=n;break;case 5:s=n,o=h,a=i}return[255*s,255*o,255*a]},$.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},$.xyz.rgb=function(t){var e,n,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,e=(e=3.2406*i+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},$.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},$.lab.xyz=function(t){var e,n,r,i=t[0];e=t[1]/500+(n=(i+16)/116),r=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=s>.008856?s:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},$.lab.lch=function(t){var e,n=t[0],r=t[1],i=t[2];return(e=360*Math.atan2(i,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+i*i),e]},$.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},$.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:$.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===i&&(s+=60),s},$.hsv.ansi16=function(t){return $.rgb.ansi16($.hsv.rgb(t),t[2])},$.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},$.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},$.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},$.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},$.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},$.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,r),i),o=Math.min(Math.min(n,r),i),a=s-o;return e=a<=0?0:s===n?(r-i)/a%6:s===r?2+(i-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},$.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,i=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},$.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},$.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var i,s=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=c,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=c,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=c}return i=(1-n)*r,[255*(n*s[0]+i),255*(n*s[1]+i),255*(n*s[2]+i)]},$.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},$.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},$.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},$.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},$.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},$.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},$.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},$.gray.hsl=$.gray.hsv=function(t){return[0,0,t[0]]},$.gray.hwb=function(t){return[0,100,t[0]]},$.gray.cmyk=function(t){return[0,0,0,t[0]]},$.gray.lab=function(t){return[t[0],0,0]},$.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},$.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Z=G.exports,W=Z;function Q(t){var e=function(){for(var t={},e=Object.keys(W),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(W[r]),s=i.length,o=0;o<s;o++){var a=i[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function tt(t,e){return function(n){return e(t(n))}}function et(t,e){for(var n=[e[t].parent,t],r=W[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=tt(W[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var nt=Z,rt=function(t){for(var e=Q(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=et(o,e))}return n},it={};Object.keys(nt).forEach((function(t){it[t]={},Object.defineProperty(it[t],"channels",{value:nt[t].channels}),Object.defineProperty(it[t],"labels",{value:nt[t].labels});var e=rt(t);Object.keys(e).forEach((function(n){var r=e[n];it[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,i=0;i<r;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),it[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var st=q,ot=it,at=[].slice,ct=["keyword","gray","hex"],ht={};Object.keys(ot).forEach((function(t){ht[at.call(ot[t].labels).sort().join("")]=t}));var lt={};function ut(t,e){if(!(this instanceof ut))return new ut(t,e);if(e&&e in ct&&(e=null),e&&!(e in ot))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ut)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=st.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=ot[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=ot[this.model].channels;var s=at.call(t,0,r);this.color=mt(s,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ht[a];var c=ot[this.model].labels,h=[];for(n=0;n<c.length;n++)h.push(t[c[n]]);this.color=mt(h)}if(lt[this.model])for(r=ot[this.model].channels,n=0;n<r;n++){var l=lt[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ft(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(lt[t]||(lt[t]=[]))[e]=n})),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),(i=this[t]()).color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function dt(t){return function(e){return Math.max(0,Math.min(t,e))}}function mt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ut.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in st.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return st.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return st.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ot[this.model].channels,n=ot[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ut(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ut(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ft("rgb",0,dt(255)),green:ft("rgb",1,dt(255)),blue:ft("rgb",2,dt(255)),hue:ft(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ft("hsl",1,dt(100)),lightness:ft("hsl",2,dt(100)),saturationv:ft("hsv",1,dt(100)),value:ft("hsv",2,dt(100)),chroma:ft("hcg",1,dt(100)),gray:ft("hcg",2,dt(100)),white:ft("hwb",1,dt(100)),wblack:ft("hwb",2,dt(100)),cyan:ft("cmyk",0,dt(100)),magenta:ft("cmyk",1,dt(100)),yellow:ft("cmyk",2,dt(100)),black:ft("cmyk",3,dt(100)),x:ft("xyz",0,dt(100)),y:ft("xyz",1,dt(100)),z:ft("xyz",2,dt(100)),l:ft("lab",0,dt(100)),a:ft("lab",1),b:ft("lab",2),keyword:function(t){return arguments.length?new ut(t):ot[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ut(t):st.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ut.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,c=1-a;return ut.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}},Object.keys(ot).forEach((function(t){if(-1===ct.indexOf(t)){var e=ot[t].channels;ut.prototype[t]=function(){if(this.model===t)return new ut(this);if(arguments.length)return new ut(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ut((n=ot[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ut[t]=function(n){return"number"==typeof n&&(n=mt(at.call(arguments),e)),new ut(n,t)}}}));var pt=x(ut);function gt(t){return null==t}function bt(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 yt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function wt(t){return"object"==typeof t&&!!t}function vt(t){return"number"==typeof t&&!isNaN(t)}function Tt(t){return t*Math.PI/180}function _t(t){return t/Math.PI*180}function Mt(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function Ot(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const At=[1,1,1,1,2,2,3,0];function xt(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=At[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 It(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function St(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function Et(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Ct(t){return 0===t.indexOf("data:")}function Nt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),i=r.length,s=new Uint8Array(i);for(let t=0;t<i;t++)s[t]=r.charCodeAt(t);return s.buffer}function kt(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}const Rt={};function Lt(t,e){if(!Array.isArray(e)){const t=e;e=Rt[t]=Rt[t]||pt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Pt=Object.freeze({__proto__:null,base64URLToArrayBuffer:Nt,extend:bt,flatArr:St,getAbsoluteURL:Mt,getBatchIdArrayType:Et,isBase64:Ct,isFunction:yt,isNil:gt,isNumber:vt,isObject:wt,normalizeColor:Lt,pushIn:kt,setColumn3:It,sign:Ot,stringFromUTF8Array:xt,toDegree:_t,toRadian:Tt});function Bt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Ut(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Dt="undefined"==typeof document?null:document.createElement("canvas");class Ft extends t.worker.Actor{constructor(t,e,n){super(t),this.mapId=e,this.i=n}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(!Dt)return void e(new Error("There is no canvas to draw image!"));const t=this.i?n:function(t){if(jt(t.width)&&jt(t.height))return t;let e=t.width,n=t.height;jt(e)||(e=zt(e));jt(n)||(n=zt(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,s=i.lastIndexOf("/")+1,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);Dt.width=t.width,Dt.height=t.height;const r=Dt.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function jt(t){return!(t&t-1)&&0!==t}function zt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function qt(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=[];Xt(r[n],i,t,e)}}}const Gt=[],Ht=[],Vt=[],Jt=[0,0,0],$t=v.identity([]),Kt=[1,1,1];function Xt(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=T.fromTranslation(Gt,t.translation||Jt),n=T.fromQuat(Ht,t.rotation||$t),r=T.fromScaling(Vt,t.scale||Kt);T.multiply(r,n,r);const s=T.multiply([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)Xt(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,r(s,e,i,n))}}}}function Yt(t,e,n){let{byteOffset:r,byteStride:i}=e;const{componentType:s,itemSize:o}=e,a=e.array.buffer,c=s?y.getTypedArrayCtor(s):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,i=i||0,!i||i===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}i||(i=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,i*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function Zt(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]}var Wt="#include <gl2_vert>\n\nconst 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#ifdef PICKING_MODE\n\n #include <fbo_picking_vert>\n\n#endif\n\n#include <draco_decode_vert>\n\nvoid main() {\n\n #ifdef HAS_POSITION\n\n vec3 localPos = decode_getPosition(POSITION);\n\n #endif\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n\n\n #ifdef PICKING_MODE\n\n fbo_picking_setData(gl_Position.w, true);\n\n #else\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_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 #endif\n\n\n\n\n\n\n\n\n\n}\n\n";const Qt=new Array(3),te=new Array(3),ee=[40680631590769,40680631590769,40408299984661.445];function ne(t,e,n,r){const i=ee,s=Math.cos(n);Qt[0]=s*Math.cos(e),Qt[1]=s*Math.sin(e),Qt[2]=Math.sin(n),de(Qt,Qt),_.multiply(te,i,Qt);const o=Math.sqrt(_.dot(Qt,te));var a,c,h;return c=te,h=o,(a=te)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,_.scale(Qt,Qt,r),_.add(t,te,Qt)}const re=[1/6378137,1/6378137,1/6356752.314245179],ie=[1/40680631590769,1/40680631590769,1/40408299984661.445],se=new Array(3),oe=new Array(3),ae=new Array(3);function ce(t,e){const n=ie,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],h=n[1],l=n[2],u=s*s*c*c,f=o*o*h*h,d=a*a*l*l,m=u+f+d,p=Math.sqrt(1/m),g=_.scale(he,e,p);if(m<i)return isFinite(p)?g:void 0;const b=r[0],y=r[1],w=r[2],v=le;v[0]=g[0]*b*2,v[1]=g[1]*y*2,v[2]=g[2]*w*2;let T,M,O,A,x,I,S,E,C,N,k,R=(1-p)*fe(e)/(.5*fe(v)),L=0;do{R-=L,O=1/(1+R*b),A=1/(1+R*y),x=1/(1+R*w),I=O*O,S=A*A,E=x*x,C=I*O,N=S*A,k=E*x,T=u*I+f*S+d*E-1,M=u*C*b+f*N*y+d*k*w;L=T/(-2*M)}while(Math.abs(T)>ue);return t[0]=s*O,t[1]=o*A,t[2]=a*x,t}(se,e,re,n,.1);let i=_.mul(oe,r,n);i=de(i,i);const s=_.sub(ae,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=Ot(_.dot(s,e))*fe(s);return t[0]=_t(o),t[1]=_t(a),t[2]=c,t}const he=new Array(3),le=new Array(3),ue=1e-12;function fe(t){return _.length(t)}function de(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function me(t,e){return _.multiply(e,t,ie),_.normalize(e,e)}function pe(t,e){const n=t[0],r=t[1],i=Math.cos(r),s=i*Math.cos(n),o=i*Math.sin(n),a=Math.sin(r);return e.x=s,e.y=o,e.z=a,_.normalize(e,e)}var ge=Object.freeze({__proto__:null,cartesian3ToDegree:ce,geodeticSurfaceNormal:me,geodeticSurfaceNormalCartographic:pe,normalizeCartesian:de,radianToCartesian3:ne});function be(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 ye(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const we="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function ve(t,e,n){const r=new Uint8Array(t,e,n);return we?JSON.parse(we.decode(r)):JSON.parse(xt(r))}function Te(t,e,n){const r=new Uint8Array(t,e,n);return we?JSON.parse(we.decode(r)):JSON.parse(xt(r))}function _e(t,e,n){return{offset:e,byteLength:n}}function Me(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=Ee(s||"UNSIGNED_SHORT"),h=Ie(o);return{byteStride:0,byteOffset:i+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+i,r*h)}}function Oe(t,e,n,r){const i=Me(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function Ae(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=Ee(s||"UNSIGNED_SHORT"),c=Ie(o),h=new a(e,i,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const xe={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ie(t){return t?xe[t]:1}const Se={"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 Ee(t){return Se[t]}function Ce(t){for(const e in Se)if(t===Se[e].ctor)return Se[e].type;throw new Error("unrecognized ctor:"+t)}function Ne(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;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 ke(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,h={},l={},u=null;r>0&&(h=ve(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(l=Te(a,e,s),e+=s);const f=_e(0,e,o);return u=a.slice(f.offset,f.offset+f.byteLength),n.push(u),{featureTable:h,featureTableBin:c,batchTable:l,batchTableBin:u}}const Re={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"}},Le={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Pe={},Be={east:[],north:[],up:[],west:[],south:[],down:[]};let Ue=[],De=[],Fe=[];const je=[0,0,0];function ze(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 qe=function(t,e){const n=Re[t][e];let r;const i=t+e;return Pe[i]?r=Pe[i]:(r=function(r,i,s){if(_.equals(r,je))_.copy(Ue,Le[t]),_.copy(De,Le[e]),_.copy(Fe,Le[n]);else if(be(r[0],0,1e-14)&&be(r[1],0,1e-14)){const i=Ot(r[2]);_.copy(Ue,Le[t]),_.copy(De,Le[e]),_.scale(De,De,i),_.copy(Fe,Le[n]),_.scale(Fe,Fe,i)}else{me(r,Be.up);const i=Be.up,s=Be.east;s[0]=-r[1],s[1]=r[0],s[2]=0,_.normalize(Be.east,s),_.cross(Be.north,i,s),_.scale(Be.down,Be.up,-1),_.scale(Be.west,Be.east,-1),_.scale(Be.south,Be.north,-1),Ue=Be[t],De=Be[e],Fe=Be[n]}return s[0]=Ue[0],s[1]=Ue[1],s[2]=Ue[2],s[3]=0,s[4]=De[0],s[5]=De[1],s[6]=De[2],s[7]=0,s[8]=Fe[0],s[9]=Fe[1],s[10]=Fe[2],s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s},Pe[i]=r),r}("east","north"),Ge=[],He=[],Ve=[],Je=[],$e=[],Ke=[],Xe=[],Ye={x:0,y:0},Ze={x:0,y:0},We=Math.PI/180;let Qe;const tn={width:100,height:10};let en=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),en=!0}catch(t){en=!1}function nn(){if(!Qe){const{width:t,height:e}=tn;en?Qe=new OffscreenCanvas(t,e):(Qe=document.createElement("canvas"),Qe.width=t,Qe.height=e)}return Qe}class rn{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e][0];n=Math.min(i,n),r=Math.max(i,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},tn,e),this.o()}getImageData(){return this.imgData}o(){const t=nn(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const i=r.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:o}=this;for(let t=0,e=s.length;t<e;t++){const[e,n]=s[t],r=(e-this.min)/o;i.addColorStop(r,n)}r.fillStyle=i,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var sn;function on(t,e){var n,r,i;if(gn(t)){var s,o=t.stops&&"object"==typeof t.stops[0][0],a=o||void 0!==t.property,c=o||!a,h=t.type||e||"exponential";if("exponential"===h)s=hn;else if("interval"===h)s=cn;else if("categorical"===h)s=an;else if("identity"===h)s=fn;else if("color-interpolate"===h)s=un;else{if("calculate-expression"!==h)throw new Error('Unknown function type "'+h+'"');s=dn}if(o){var l={},u=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===l[f[0].zoom]&&(l[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),l[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in l)u.push([l[t].zoom,on(l[t])]);n=function(e,n){const r=hn({stops:u,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,i=!1}else c?(n=function(e){const n=s(t,e);return"function"==typeof n?n(e):n},r=!0,i=!1):(n=function(e,n){const r=s(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,i=!0)}else n=function(){return t},r=!0,i=!0;return n.isZoomConstant=i,n.isFeatureConstant=r,n}function an(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function cn(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function hn(t,e){for(var n=void 0!==t.base?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:mn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(sn=new Map);const ln={width:100,height:1};function un(t,e){const n=t.stops;if(n&&n.length>1){let t;if(sn){const e=JSON.stringify(n);if(!sn.has(e)){const t=new rn(n,ln);sn.set(e,t)}t=sn.get(e)}else t=new rn(n,ln);const[r,i,s,o]=t.getColor(e);return[r/255,i/255,s/255,o/255]}return n&&1===n.length?n[0][1]:null}function fn(t,e){return n=e,r=t.default,void 0!==n?n:void 0!==r?r:null;var n,r}function dn(t,e){const n=String(t.property),r=t.expression,i=e;function s(e){return null==e||""===e||isNaN(e)?t.default:e}if(null==e||""===e||isNaN(e)||e<0)return s(t.default);{const e=function t(e,n,r){const i=Number(r),s=String(n);return Array.isArray(e)?e.map((e=>t(e,s,i))):e===s?i:e}(r,n,i);return s(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(`Unknown operator: ${r}`);const i=n.slice(1).map((t=>e(t)));switch(r){case"+":return i.reduce(((t,e)=>t+e),0);case"-":return i.reduce(((t,e)=>t-e));case"*":return i.reduce(((t,e)=>t*e),1);case"/":return i.some((t=>0===t))?t.default:i.reduce(((t,e)=>t/e));default:throw new Error(`Unsupported operator: ${r}`)}}}(e))}}function mn(t,e,n,r,i,s){return"function"==typeof i?function(){var o=i.apply(void 0,arguments),a=s.apply(void 0,arguments);return mn(t,e,n,r,o,a)}:i.length?function(t,e,n,r,i,s){var o=[];for(let a=0;a<i.length;a++)o[a]=pn(t,e,n,r,i[a],s[a]);return o}(t,e,n,r,i,s):pn(t,e,n,r,i,s)}function pn(t,e,n,r,i,s){var o,a=r-n,c=t-n;return i*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+s*o}function gn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function bn(t){return yn(t,"exponential")}function yn(t,e){if(!gn(t))return function(){return t};let n=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(gn(i[t][1])){const s=yn(i[t][1],e);n=n&&s.isZoomConstant,r=r&&s.isFeatureConstant,i[t]=[i[t][0],s]}const s=on(t,e);return s.isZoomConstant=n&&s.isZoomConstant,s.isFeatureConstant=r&&s.isFeatureConstant,s}const{getTextureMagFilter:wn,getTextureMinFilter:vn,getTextureWrap:Tn,getMaterialType:_n,getMaterialFormat:Mn,getPrimitive:On,getUniqueREGLBuffer:An}=n.REGLHelper,xn=[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:Sn,logoutIBLResOnCanvas:En,getIBLResOnCanvas:Cn,getPBRUniforms:Nn}=n.pbr.PBRUtils,kn={factor:0,units:0},Rn=[1,1,1,1],Ln=[0,0,0],Pn={specularStrength:0,materialShininess:1},Bn=[1,1,1],Un=r.identity([]),Dn=[0,0,0],Fn=[0,0],jn=[],zn=t=>t.material instanceof n.PhongMaterial,qn=t=>t.material instanceof n.pbr.StandardMaterial,Gn=[],Hn=new t.Coordinate(0,0),Vn=new t.Point(0,0),Jn=new t.Point(0,0),$n=new t.Point(0,0),Kn=[],Xn=[],Yn=[],Zn=[],Wn=[],Qn=[],tr=[],er=[],nr=[],rr=[],ir=[],sr=[],or=[],ar=[],cr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},hr=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],lr=function(t,e){const n=2*Math.PI/t,r=[],i=[];for(let i=0;i<=t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=s,r[3*i+2]=o}for(let i=t;i<=2*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=o,r[3*i+1]=t,r[3*i+2]=s}for(let i=2*t;i<=3*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=o,r[3*i+2]=s}const s=r.length/3-1;for(let e=0;e<s;e++)e!==t-1&&e!==2*t-1&&(i[2*e]=e,i[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),i.push(s+1,s+2),i.push(s+1,s+3),i.push(s+1,s+4),{vertices:r,indices:i}}
6
+ import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as n,mat4 as r,HighlightUtil as i,ContextUtil as s,quat as o,vec3 as a,mat3 as c,vec4 as h,MaskRendererMixin as l,createREGL as u,MaskLayerMixin as f,ClipOutsideMask as d,vec2 as m}from"@maptalks/gl";import{intersectsBox as p,intersectsOrientedBox as g,intersectsSphere as b}from"frustum-intersects";import{GLTFLoader as y,Ajax as w}from"@maptalks/gltf-loader";import{quat as v,mat4 as T,vec3 as _,mat3 as M}from"gl-matrix";const O="${",A=`function(t){\n/*!\n * @maptalks/gltf-loader v0.98.4\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.org\n */\nvar e="undefined"!=typeof Float32Array?Float32Array:Array;function n(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=e[8],h=e[9],d=e[10],y=e[11],m=e[12],b=e[13],p=e[14],g=e[15],w=n[0],v=n[1],M=n[2],A=n[3];return t[0]=w*r+v*a+M*l+A*m,t[1]=w*i+v*c+M*h+A*b,t[2]=w*s+v*u+M*d+A*p,t[3]=w*o+v*f+M*y+A*g,w=n[4],v=n[5],M=n[6],A=n[7],t[4]=w*r+v*a+M*l+A*m,t[5]=w*i+v*c+M*h+A*b,t[6]=w*s+v*u+M*d+A*p,t[7]=w*o+v*f+M*y+A*g,w=n[8],v=n[9],M=n[10],A=n[11],t[8]=w*r+v*a+M*l+A*m,t[9]=w*i+v*c+M*h+A*b,t[10]=w*s+v*u+M*d+A*p,t[11]=w*o+v*f+M*y+A*g,w=n[12],v=n[13],M=n[14],A=n[15],t[12]=w*r+v*a+M*l+A*m,t[13]=w*i+v*c+M*h+A*b,t[14]=w*s+v*u+M*d+A*p,t[15]=w*o+v*f+M*y+A*g,t}function r(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function i(t,n,r){var i=new e(3);return i[0]=t,i[1]=n,i[2]=r,i}function s(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function o(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function a(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function c(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function u(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function f(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*s+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*s+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*s+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*s+n[15]*o,t}function l(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),r(),function(){var t;t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var h,d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};r(),i(1,0,0),i(0,1,0),l(),l(),h=new e(9),e!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[5]=0,h[6]=0,h[7]=0),h[0]=1,h[4]=1,h[8]=1;let y=0;function m(t){return null==t}function b(t){return!m(t)}function p(t){return!m(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function g(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 w(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 v(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function M(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 A=[],T=[],_=[],k=[0,0,0],O=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),x=[1,1,1];function S(t,e,n,r,i,s,o){const a=w(o),c=a.BYTES_PER_ELEMENT;if((0===i||i===r*c)&&s%c==0){const i=new a(e,s,n*r);return t.set(i),t}0===i&&(i=r*c);const u=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const f=new Uint8Array(e,i*o+s,r*c);u.set(f),n=new a(u.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const I="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function E(t,e,n){const r=new Uint8Array(t,e,n);return I.decode(r)}const C={get:function(t,e={},n){e||(e={});const r=new AbortController,i=r.signal,s=g({},e);s.signal=i,s.method||(s.method="GET"),s.referrerPolicy=s.referrerPolicy||"origin","undefined"==typeof window||s.referrer||(s.referrer=window.location.href),n&&(t=n(t));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=r,o},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${O}t.status}): ${O}t.statusText}\`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={},n)=>(e||(e={}),e.responseType="arraybuffer",C.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?C.jsonp(t):((e=e||{}).responseType="json",C.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+y++;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 U{constructor(t,e,n,r,i){this.i=t,this.decoders=e,this.o=n,this.images={},this.u={},this.h=r||{},this.m=i}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}if(this.u[t.id])return this.u[t.id].then((()=>{const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}));if(v(t.uri)){const r=this.buffers[t.id]=M(t.uri),i=this.p(e,r);return this.getImageByBuffer(i,n)}let r;const i=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||i?t.uri:this.rootPath+"/"+t.uri,this.u[t.id]=C.getArrayBuffer(r,this.h,this.m).then((r=>{const i=this.buffers[t.id]=r.data,s=this.p(e,i);return this.getImageByBuffer(s,n)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.o}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.v(e.id,t)}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.u[t.id]?this.u[t.id].then((()=>this.images[t.id])):this.u[t.id]=this.v(t.id,e)}v(t,e){return new Promise(((n,r)=>{let i=e;this.m&&(i=this.m(e)),this.i(i,this.h,((i,s)=>{i?r(i):(URL.revokeObjectURL(e),this.images[t]=s,n(this.images[t]))}))}))}}const F=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],N=[];class P{constructor(t,e,n,r,i){this.rootPath=t,this.gltf=e,this.M=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.A(),this.h=r,this.m=i}T(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this._(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.k(i).then((n=>{const{buffer:i,byteOffset:s}=n;return this.accessors[r.id]=this._(t,e,i,s)}))}k(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(v(e.uri)){const t=this.buffers[e.id]=M(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]=C.getArrayBuffer(t,this.h,!n&&this.m).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})}_(t,e,n,r=0){const i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+r,c=this.O(s.type),u=w(s.componentType),l=o.byteStride||0,h={array:void 0,name:t,accessorName:e,byteLength:s.count*c*u.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c,max:s.max,min:s.min,extensions:s.extensions};if(s.min&&(h.min=s.min),s.max&&(h.max=s.max),n)if(this.M)h.byteStride=l,h.byteOffset=a+(s.byteOffset||0),!l||l===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(h.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),h.array.buffer.byteLength===h.byteLength&&(h.byteOffset=0)):h.array=new Uint8Array(n,a,o.byteLength);else if(s.interleaved){h.byteStride=0,h.byteOffset=0;const t=new u(s.count*c);if(h.array=S(t,n,s.count,c,l,a+(s.byteOffset||0),s.componentType),h.extensions&&h.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(h.array.length),{decodeMatrix:e}=h.extensions.WEB3D_quantized_attributes;for(let n=0;n<h.array.length;n+=c){N[0]=h.array[n],N[1]=h.array[n+1],N[2]=h.array[n+2],N[3]=1;const r=f(N,N,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}h.componentType=5126,h.array=t}}else h.byteStride=0,h.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),h.byteOffset=h.array.byteOffset;else{h.array=new u(s.count);const t=h.min||h.max;t&&(h.array[0]=t[0],h.array[1]=t[1],h.array[2]=t[2])}return h}A(){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)}S(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)}O(t){const e=F.indexOf(t);return F[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.k(e).then((r=>{const{buffer:i,byteOffset:s}=r,o=E(i,s+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(v(t.uri)){const e=M(t.uri),n=E(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return C.get(e,this.h,this.m).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class B extends U{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new P(t,e,n,o,a)}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 r=function(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}(A,e.translation||k),i=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,y=i*c,m=s*o,b=s*a,p=s*c;return t[0]=1-l-y,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-p,t[5]=1-u-y,t[6]=d+m,t[7]=0,t[8]=h+b,t[9]=d-m,t[10]=1-u-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(T,e.rotation||O),s=function(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}(_,e.scale||x);return n(s,i,s),n(t,r,s)}return function(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}(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}I(t){const e={};for(const n in t){const r=t[n];let i,s;r.instanceTechnique&&r.instanceTechnique.values?(i=r.instanceTechnique,s=i.values.diffuse):(i=r,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}C(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,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}U(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.C(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 s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}const D=9729;class R extends U{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new P(t,e,n,o,a)}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 g(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}U(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.C(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}};g(n,e);const i=b(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(i&&(n.sampler=i,n.sampler.magFilter=i.magFilter||D,n.sampler.minFilter=i.minFilter||9987,n.sampler.wrapS=i.wrapS||10497,n.sampler.wrapT=i.wrapT||10497),"image/ktx2"===n.image.mimeType&&!n.image.mipmap&&n.sampler&&n.sampler.minFilter!==D&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:D}return t.format&&(n.format=t.format),n}))}C(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.F(e,t)}return null}F(t,e){const n=this.p(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}p(t,e,n){n=n||0;const r=(t.byteOffset||0)+n,i=t.byteLength;return new Uint8Array(e,r,i)}N(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);n.join("");const r="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)));return r}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.T("input",t[n].input)),e.push(this.accessor.T("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 L="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class j{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 j.readV1(r,e);if(2===i)return j.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=z(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 s=new DataView(t,e+12);let o=0;for(;o+8<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)n=z(t,e+12+o,a);else if(5130562===c){i=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:i,buffer:t,byteLength:r}}}}function z(t,e,n){if(L){const r=new Uint8Array(t,e,n);return L.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=q[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 q=[1,1,1,1,2,2,3,0],V=[0,0,0],G=[0,0,0,1],$=[1,1,1],X={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},H={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},J={P(t,e,n,r,i,o,a,c){const u=b(t)?e.animations:[e.animations[0]],f={};for(let e=0;e<u.length;e++){const l=u[e],h=l.name||e;if(b(t)&&h!==t)continue;const y=l.channelsMap[n];if(y)for(let t=0;t<y.length;t++){const e=y[t];"translation"===e.target.path?(this.B(i,l.samplers[e.sampler],r,1),f.translation=s(V,i)):"rotation"===e.target.path?(this.D(o,l.samplers[e.sampler],r,1),f.rotation=d(G,o)):"scale"===e.target.path?(this.B(a,l.samplers[e.sampler],r,1),f.scale=s($,a)):"weights"===e.target.path&&c&&(this.B(c,l.samplers[e.sampler],r,c.length),f.weights=c)}}return f},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const i=this.R(H,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.R(H,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.R(H,e,n,3*r);i&&(t=this.L(t,i,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.R(H,e,n,1);r&&function(t,e,n,r){var i,s,o,a,c,u=e[0],f=e[1],l=e[2],h=e[3],d=n[0],y=n[1],m=n[2],b=n[3];(s=u*d+f*y+l*m+h*b)<0&&(s=-s,d=-d,y=-y,m=-m,b=-b),1-s>1e-6?(i=Math.acos(s),o=Math.sin(i),a=Math.sin((1-r)*i)/o,c=Math.sin(r*i)/o):(a=1-r,c=r),t[0]=a*u+c*d,t[1]=a*f+c*y,t[2]=a*l+c*m,t[3]=a*h+c*b}(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.R(H,e,n,1);r&&(t=u(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.R(H,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.L(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},j(t,e){const n=t.length;let r,i,s,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,i=c+1,s=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:i,interpolation:s}}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},R(t,e,n,r){const i=e.input.array,s=e.output.array,o=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.j(i,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=o*r;return t.PREVIOUS=s.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=s.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},L(t,e,n,r){const i=e.INTERPOLATION,s=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-s)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(o-s)*e.NEXT[n],l=(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))*u+(Math.pow(i,3)-Math.pow(i,2))*f;t[n]=l}return t},getAnimationClip(t,e,n,r){const i=t.nodes[e]&&t.nodes[e].weights;return o(V,...X.TRANSLATION),u(G,...X.ROTATION),o($,...X.SCALE),this.P(r,t,e,n,V,G,$,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 s=e.channels;for(let t=0;t<s.length;t++){const n=s[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?b(e)?n[e]:n[Object.keys(n)[0]]:null}};let K=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Je){}t&&"undefined"!=typeof createImageBitmap&&(K=!0)}const Y="undefined"==typeof document?null:document.createElement("canvas");class Q{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.h=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=j.read(e.buffer,e.byteOffset,e.byteLength);this.q(t,n,r)}else this.q(t,e);this.V=new P(this.rootPath,this.gltf,this.glbBuffer,this.h,this.options.urlModifier),this.G()}G(){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["image/ktx2"])throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded");if(t.indexOf("EXT_meshopt_compression")>=0)throw new Error("EXT_meshopt_compression extension is not supported yet.")}}$(){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.X(t),n=this.H(),r=this.J(),i=this.$();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 J.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return J.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return w(t)}static readInterleavedArray(t,e,n,r,i,s,o){return S(t,e,n,r,i,s,o)}q(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=K?it.bind(this):this.options.requestImage||W,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new R(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.h,this.options.urlModifier),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 B(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.h,this.options.urlModifier),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)||p(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}X(t){return this.Y(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,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===r&&(n=s),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.I(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r}))}Y(t){return this.W(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}))}Z(){this.skins=[];const t=[];return this.adapter.iterate(((e,n,r)=>{t.push(this.tt(n).then((t=>{t.index=r,this.skins.push(t)})))}),"skins"),t}tt(t){const e=t.inverseBindMatrices;return this.adapter.accessor.T("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 b(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,i)=>{e.push(this.et(r,t).then((t=>{t.index=i,this.meshes[n]=t})))}),"meshes"),e=e.concat(this.Z()),Promise.all(e)}et(t,e){const n=t.primitives.map((t=>this.nt(t,e))).filter((t=>!!t));return Promise.all(n).then((e=>{const n={};return g(n,t),n.primitives=e,n}))}J(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.U(n));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image.array;if(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}))}nt(t,e){let n;const r=[],i=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 i=this.adapter.accessor.T(\`morphTargets_${O}t}_${O}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:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.V.k(a).then((n=>{const{buffer:r,byteOffset:i}=n;let{byteOffset:s}=a;const c=a.byteLength;s||(s=0);const u=new DataView(r,i+s,c),f={attributes:o,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.T(t,e[t]);n&&r.push(n)}if(b(t.indices)){const e=this.adapter.accessor.T("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 s={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,s=i.length/r;for(let e=0;e<s;e++)for(let s=0;s<r;s++){const o=e*r+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>n[s]&&(n[s]=i[o])}if(e.quantization){const r=e.quantization,i=r.range/(1<<r.quantizationBits),s=r.minValues;c(t,t,i),a(t,t,s),c(n,n,i),a(n,n,s)}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&&(s.indices=n),r&&(s.morphTargets=r),s.mode=b(t.mode)?t.mode:4,b(t.extras)&&(s.extras=t.extras),s}))}}function W(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Y)return void n(new Error("There is no canvas to draw image!"));Y.width=r.width,Y.height=r.height;const t=Y.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,i)},r.onerror=function(t){n(t)},r.src=t}const Z=[],tt=[],et=30;let nt,rt;function it(t,e,n){nt||(nt=new OffscreenCanvas(2,2),rt=nt.getContext("2d",{willReadFrequently:!0}));let r=null;if(p(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),Z.push([t,e,n,this]),st();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(ot.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function st(){if(!Z.length||tt.length>et)return;const t=Z.shift(),[e,n,r,i]=t;tt.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(ot.bind(i)).then((e=>{r.call(i,null,e);const n=tt.indexOf(t);tt.splice(n,1),st()})).catch((e=>{console.warn(e),r.call(i,e);const n=tt.indexOf(t);tt.splice(n,1),st()}))}function ot(t){let{width:e,height:n}=t;at(e)||(e=ct(e)),at(n)||(n=ct(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),nt.width=e,nt.height=n,rt.drawImage(t,0,0,e,n),t.close();const i=rt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(i.data)}}function at(t){return!(t&t-1)&&0!==t}function ct(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var ut="undefined"!=typeof Float32Array?Float32Array:Array;function ft(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 lt(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=e[8],h=e[9],d=e[10],y=e[11],m=e[12],b=e[13],p=e[14],g=e[15],w=n[0],v=n[1],M=n[2],A=n[3];return t[0]=w*r+v*a+M*l+A*m,t[1]=w*i+v*c+M*h+A*b,t[2]=w*s+v*u+M*d+A*p,t[3]=w*o+v*f+M*y+A*g,w=n[4],v=n[5],M=n[6],A=n[7],t[4]=w*r+v*a+M*l+A*m,t[5]=w*i+v*c+M*h+A*b,t[6]=w*s+v*u+M*d+A*p,t[7]=w*o+v*f+M*y+A*g,w=n[8],v=n[9],M=n[10],A=n[11],t[8]=w*r+v*a+M*l+A*m,t[9]=w*i+v*c+M*h+A*b,t[10]=w*s+v*u+M*d+A*p,t[11]=w*o+v*f+M*y+A*g,w=n[12],v=n[13],M=n[14],A=n[15],t[12]=w*r+v*a+M*l+A*m,t[13]=w*i+v*c+M*h+A*b,t[14]=w*s+v*u+M*d+A*p,t[15]=w*o+v*f+M*y+A*g,t}function ht(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 dt(){var t=new ut(3);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function yt(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function mt(t,e,n){var r=new ut(3);return r[0]=t,r[1]=e,r[2]=n,r}function bt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function pt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function gt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function wt(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function vt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Mt(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[3]*r+n[7]*i+n[11]*s+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*i+n[8]*s+n[12])/o,t[1]=(n[1]*r+n[5]*i+n[9]*s+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*s+n[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var At=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},Tt=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},_t=yt;function kt(){var t=new ut(4);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}dt(),function(){var t,e=(t=new ut(4),ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var Ot;function xt(t){return t&&t.rt&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}dt(),mt(1,0,0),mt(0,1,0),kt(),kt(),Ot=new ut(9),ut!=Float32Array&&(Ot[1]=0,Ot[2]=0,Ot[3]=0,Ot[5]=0,Ot[6]=0,Ot[7]=0),Ot[0]=1,Ot[4]=1,Ot[8]=1;var St={exports:{}},It={exports:{}},Et=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},Ct=Array.prototype.concat,Ut=Array.prototype.slice,Ft=It.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];Et(i)?e=Ct.call(e,Ut.call(i)):e.push(i)}return e};Ft.wrap=function(t){return function(){return t(Ft(arguments))}};var Nt=It.exports,Pt={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},Bt=Nt,Dt=Object.hasOwnProperty,Rt=Object.create(null);for(var Lt in Pt)Dt.call(Pt,Lt)&&(Rt[Pt[Lt]]=Lt);var jt=St.exports={to:{},get:{}};function zt(t,e,n){return Math.min(Math.max(e,t),n)}function qt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}jt.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=jt.get.hsl(t),n="hsl";break;case"hwb":e=jt.get.hwb(t),n="hwb";break;default:e=jt.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},jt.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var s=2*n;i[n]=parseInt(e.slice(s,s+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:Dt.call(Pt,e[1])?((i=Pt[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=zt(i[n],0,255);return i[3]=zt(i[3],0,1),i},jt.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,zt(parseFloat(e[2]),0,100),zt(parseFloat(e[3]),0,100),zt(isNaN(n)?1:n,0,1)]}return null},jt.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,zt(parseFloat(e[2]),0,100),zt(parseFloat(e[3]),0,100),zt(isNaN(n)?1:n,0,1)]}return null},jt.to.hex=function(){var t=Bt(arguments);return"#"+qt(t[0])+qt(t[1])+qt(t[2])+(t[3]<1?qt(Math.round(255*t[3])):"")},jt.to.rgb=function(){var t=Bt(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},jt.to.rgb.percent=function(){var t=Bt(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},jt.to.hsl=function(){var t=Bt(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},jt.to.hwb=function(){var t=Bt(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},jt.to.keyword=function(t){return Rt[t.slice(0,3)]};var Vt=St.exports,Gt={exports:{}},$t={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},Xt={};for(var Ht in $t)$t.hasOwnProperty(Ht)&&(Xt[$t[Ht]]=Ht);var Jt=Gt.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var Kt in Jt)if(Jt.hasOwnProperty(Kt)){if(!("channels"in Jt[Kt]))throw new Error("missing channels property: "+Kt);if(!("labels"in Jt[Kt]))throw new Error("missing channel labels property: "+Kt);if(Jt[Kt].labels.length!==Jt[Kt].channels)throw new Error("channel and label counts mismatch: "+Kt);var Yt=Jt[Kt].channels,Qt=Jt[Kt].labels;delete Jt[Kt].channels,delete Jt[Kt].labels,Object.defineProperty(Jt[Kt],"channels",{value:Yt}),Object.defineProperty(Jt[Kt],"labels",{value:Qt})}function Wt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}Jt.rgb.hsl=function(t){var e,n,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),c=a-o;return a===o?e=0:r===a?e=(i-s)/c:i===a?e=2+(s-r)/c:s===a&&(e=4+(r-i)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},Jt.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),f=u-Math.min(o,a,c),l=function(t){return(u-t)/6/f+.5};return 0===f?i=s=0:(s=f/u,e=l(o),n=l(a),r=l(c),o===u?i=r-n:a===u?i=1/3+e-r:c===u&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*u]},Jt.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[Jt.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},Jt.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-i)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-i-e)/(1-e)||0),100*e]},Jt.rgb.keyword=function(t){var e=Xt[t];if(e)return e;var n,r=1/0;for(var i in $t)if($t.hasOwnProperty(i)){var s=Wt(t,$t[i]);s<r&&(r=s,n=i)}return n},Jt.keyword.rgb=function(t){return $t[t]},Jt.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},Jt.rgb.lab=function(t){var e=Jt.rgb.xyz(t),n=e[0],r=e[1],i=e[2];return r/=100,i/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},Jt.hsl.rgb=function(t){var e,n,r,i,s,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[s=255*c,s,s];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),i=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,s=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,i[u]=255*s;return i},Jt.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,i=n,s=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[e,100*(0===r?2*i/(s+i):2*n/(r+n)),100*((r+n)/2)]},Jt.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),c=255*r*(1-n*(1-s));switch(r*=255,i){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},Jt.hsv.hsl=function(t){var e,n,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,n=s*a,[i,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(r/=2)]},Jt.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,u=t[1]/100,f=t[2]/100,l=u+f;switch(l>1&&(u/=l,f/=l),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=u+r*((n=1-f)-u),e){default:case 6:case 0:s=n,o=i,a=u;break;case 1:s=i,o=n,a=u;break;case 2:s=u,o=n,a=i;break;case 3:s=u,o=i,a=n;break;case 4:s=i,o=u,a=n;break;case 5:s=n,o=u,a=i}return[255*s,255*o,255*a]},Jt.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},Jt.xyz.rgb=function(t){var e,n,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,e=(e=3.2406*i+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},Jt.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},Jt.lab.xyz=function(t){var e,n,r,i=t[0];e=t[1]/500+(n=(i+16)/116),r=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=s>.008856?s:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},Jt.lab.lch=function(t){var e,n=t[0],r=t[1],i=t[2];return(e=360*Math.atan2(i,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+i*i),e]},Jt.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},Jt.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:Jt.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===i&&(s+=60),s},Jt.hsv.ansi16=function(t){return Jt.rgb.ansi16(Jt.hsv.rgb(t),t[2])},Jt.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},Jt.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},Jt.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},Jt.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},Jt.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},Jt.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,r),i),o=Math.min(Math.min(n,r),i),a=s-o;return e=a<=0?0:s===n?(r-i)/a%6:s===r?2+(i-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},Jt.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,i=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},Jt.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},Jt.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var i,s=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=c,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=c,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=c}return i=(1-n)*r,[255*(n*s[0]+i),255*(n*s[1]+i),255*(n*s[2]+i)]},Jt.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},Jt.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},Jt.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},Jt.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},Jt.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},Jt.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},Jt.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},Jt.gray.hsl=Jt.gray.hsv=function(t){return[0,0,t[0]]},Jt.gray.hwb=function(t){return[0,100,t[0]]},Jt.gray.cmyk=function(t){return[0,0,0,t[0]]},Jt.gray.lab=function(t){return[t[0],0,0]},Jt.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},Jt.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Zt=Gt.exports,te=Zt;function ee(t){var e=function(){for(var t={},e=Object.keys(te),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(te[r]),s=i.length,o=0;o<s;o++){var a=i[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function ne(t,e){return function(n){return e(t(n))}}function re(t,e){for(var n=[e[t].parent,t],r=te[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=ne(te[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var ie=Zt,se=function(t){for(var e=ee(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=re(o,e))}return n},oe={};Object.keys(ie).forEach((function(t){oe[t]={},Object.defineProperty(oe[t],"channels",{value:ie[t].channels}),Object.defineProperty(oe[t],"labels",{value:ie[t].labels});var e=se(t);Object.keys(e).forEach((function(n){var r=e[n];oe[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,i=0;i<r;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),oe[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var ae=Vt,ce=oe,ue=[].slice,fe=["keyword","gray","hex"],le={};Object.keys(ce).forEach((function(t){le[ue.call(ce[t].labels).sort().join("")]=t}));var he={};function de(t,e){if(!(this instanceof de))return new de(t,e);if(e&&e in fe&&(e=null),e&&!(e in ce))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof de)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=ae.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=ce[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=ce[this.model].channels;var s=ue.call(t,0,r);this.color=be(s,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in le))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=le[a];var c=ce[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=be(u)}if(he[this.model])for(r=ce[this.model].channels,n=0;n<r;n++){var f=he[this.model][n];f&&(this.color[n]=f(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ye(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(he[t]||(he[t]=[]))[e]=n})),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),(i=this[t]()).color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function me(t){return function(e){return Math.max(0,Math.min(t,e))}}function be(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function pe(t){return null==t}function ge(t){return"object"==typeof t&&!!t}function we(t){return t/Math.PI*180}de.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in ae.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return ae.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return ae.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ce[this.model].channels,n=ce[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new de(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new de(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ye("rgb",0,me(255)),green:ye("rgb",1,me(255)),blue:ye("rgb",2,me(255)),hue:ye(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ye("hsl",1,me(100)),lightness:ye("hsl",2,me(100)),saturationv:ye("hsv",1,me(100)),value:ye("hsv",2,me(100)),chroma:ye("hcg",1,me(100)),gray:ye("hcg",2,me(100)),white:ye("hwb",1,me(100)),wblack:ye("hwb",2,me(100)),cyan:ye("cmyk",0,me(100)),magenta:ye("cmyk",1,me(100)),yellow:ye("cmyk",2,me(100)),black:ye("cmyk",3,me(100)),x:ye("xyz",0,me(100)),y:ye("xyz",1,me(100)),z:ye("xyz",2,me(100)),l:ye("lab",0,me(100)),a:ye("lab",1),b:ye("lab",2),keyword:function(t){return arguments.length?new de(t):ce[this.model].keyword(this.color)},hex:function(t){return arguments.length?new de(t):ae.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return de.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,c=1-a;return de.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}},Object.keys(ce).forEach((function(t){if(-1===fe.indexOf(t)){var e=ce[t].channels;de.prototype[t]=function(){if(this.model===t)return new de(this);if(arguments.length)return new de(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new de((n=ce[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},de[t]=function(n){return"number"==typeof n&&(n=be(ue.call(arguments),e)),new de(n,t)}}}));const ve=[1,1,1,1,2,2,3,0];function Me(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=ve[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 Array(3),new Array(3);const Ae=[1/6378137,1/6378137,1/6356752.314245179],Te=[1/40680631590769,1/40680631590769,1/40408299984661.445],_e=new Array(3),ke=new Array(3),Oe=new Array(3);function xe(t,e){const n=Te,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],u=n[1],f=n[2],l=s*s*c*c,h=o*o*u*u,d=a*a*f*f,y=l+h+d,m=Math.sqrt(1/y),b=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(Se,e,m);if(y<i)return isFinite(m)?b:void 0;const p=r[0],g=r[1],w=r[2],v=Ie;v[0]=b[0]*p*2,v[1]=b[1]*g*2,v[2]=b[2]*w*2;let M,A,T,_,k,O,x,S,I,E,C,U=(1-m)*Ce(e)/(.5*Ce(v)),F=0;do{U-=F,T=1/(1+U*p),_=1/(1+U*g),k=1/(1+U*w),O=T*T,x=_*_,S=k*k,I=O*T,E=x*_,C=S*k,M=l*O+h*x+d*S-1,A=l*I*p+h*E*g+d*C*w;F=M/(-2*A)}while(Math.abs(M)>Ee);return t[0]=s*T,t[1]=o*_,t[2]=a*k,t}(_e,e,Ae,n,.1);let i=Tt(ke,r,n);i=function(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s);return t}(i,i);const s=At(Oe,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=function(t){return Math.sign?Math.sign(t):0==(t=+t)||isNaN(t)?Number(t):t>0?1:-1}(vt(s,e))*Ce(s);return t[0]=we(o),t[1]=we(a),t[2]=c,t}const Se=new Array(3),Ie=new Array(3),Ee=1e-12;function Ce(t){return yt(t)}function Ue(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 Ne(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(Me(r))}function Pe(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(Me(r))}function Be(t,e,n){return{offset:e,byteLength:n}}function De(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return je[t]}(s||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Le[t]}(o);return{byteStride:0,byteOffset:i+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+i,r*u)}}function Re(t,e,n,r){const i=De(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const Le={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const je={"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){for(const e in je)if(t===je[e].ctor)return je[e].type;throw new Error("unrecognized ctor:"+t)}function qe(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;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 Ve(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,u={},f={},l=null;r>0&&(u=Ne(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(f=Pe(a,e,s),e+=s);const h=Be(0,e,o);return l=a.slice(h.offset,h.offset+h.byteLength),n.push(l),{featureTable:u,featureTableBin:c,batchTable:f,batchTableBin:l}}const Ge={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function $e(t){for(const e in Ge)if(t===Ge[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n * @maptalks/gl v0.102.2\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.com\n */const Xe=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")},He=Xe(),Je=He.gl_trans__coders=He.gl_trans__coders||{};Je.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=He.gl_trans__coders=He.gl_trans__coders||{};let s=\`${O}r}\\n const _____getGlobal = ${O}Xe.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&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\\n;");return s+="\\n"+e.substring(r.length),s},Je.registerTranscoder=function(t,e){Je[t]=e},Je.getTranscoder=function(t){return Je[t]};let Ke=null;function Ye(){return Ke||(Ke={"image/crn":Je.crn&&Je.crn(),"image/ktx2":Je.ktx2&&Je.ktx2(),"image/cttf":Je.ktx2&&Je.ktx2(),"draco":Je.draco&&Je.draco()}),Ke}class Qe{constructor(t,e,n){this.i=t,this.it=e||Q,this.o=n,this.st=Ye()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.ct(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.it(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,maxTextureSize:s})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${O}t}-${O}n}-${O}r}\`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}ct(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", 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 o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),u=i.getUint32(20,!0),f=i.getUint32(24,!0),l=28+e;u>=570425344?(l-=8,o=a,u=c,f=0,a=0,c=0):f>=570425344&&(l-=4,o=u,u=a,f=c,a=0,c=0);const h=[t];let d,y,m;if(a>0?(d=Ne(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),u>0&&(y=Pe(t,l,u),l+=u,f>0)){const e=Be(0,l,f);m=t.slice(e.offset,e.offset+e.byteLength),l+=f,h.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Re(d.BATCH_ID,t,undefined.offset,b);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:d,batchTable:y,batchTableBin:m,b3dm:p,glb:{buffer:t,byteOffset:l,byteLength:i.byteLength+i.byteOffset-l}}}ut(){return null}}class We{constructor(t,e,n,r){this.i=t,this.it=e||Q,this.o=n,this.st=Ye(),this.ft=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){return this.lt(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.ht(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}lt(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,maxTextureSize:s},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=Me(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?C.getArrayBuffer(r,{}).then((t=>this.dt(r,{buffer:t.data,byteOffset:0},o))):C.getJSON(r,{}).then((t=>this.dt(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.dt(t,r,o)}}dt(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.it(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=\`${O}t}-${O}r}-${O}s}\`,{transferables:i.transferables,gltf:n}}))}ht(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", 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 o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=Ve(i,32+e,o),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()},o.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.yt(new Uint16Array(t,r+c.offset,3*h),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Re(a.BATCH_ID,t,c.offset,h);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.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()},o.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()},o.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.bt(new Uint16Array(t,e+c.offset,2*h))},o.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.bt(new Uint16Array(t,e+c.offset,2*h))},o.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()},o.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()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:f,featureTable:a,i3dm:l,transferables:o}}bt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Ze(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}yt(t,e,n){return qe(new Float32Array(t.length),t,e,n)}ut(){return null}}function Ze(t,e,n,r){if(t[0]=tn(e,r),t[1]=tn(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]))*en(e),t[1]=(1-Math.abs(e))*en(t[1])}return wt(t,t)}function tn(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,n){return t<e?e:t>n?n:t}(t,0,e)/e*2-1}function en(t){return t<0?-1:1}class nn{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.ot(t,e,n,r)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r){return this.gt(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}))}gt(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", 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 o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=Ve(i,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let y,m={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){m=a.extensions["3DTILES_draco_point_compression"],y=new DataView(t,m.byteOffset+c.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.wt||(this.wt=Ye().draco),this.wt(y,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.vt(t,e.attributes,c.offset,d,o,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:ze(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Re(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=rn(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:u,batchTableBin:f,featureTable:a,pnts:r,transferables:o}}))}const b=this.vt(t,a,c.offset,d,o,l,h);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Re(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=rn(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:u,batchTableBin:f,featureTable:a,pnts:b,transferables:o})}vt(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.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.yt(u||new Uint16Array(t,c+f,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}yt(t,e,n){return qe(new Float32Array(t.length),t,e,n)}ut(){return null}}function rn(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:ze(e),array:r}}class sn{constructor(t,e,n,r){this.o=n,this.i=t,this.it=e||Q,this.ft=r}load(t,e,n=0,r=0,i){return e?this.ot(t,e,n,r,i):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.ot(t,i,n,r)}))}ot(t,e,n,r,i){r||(r=e.byteLength);const s=this.Mt(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new Qe(this.i,this.it,this.o);else if("i3dm"===s[n].magic)r=new We(this.i,this.it,this.o,this.ft);else if("pnts"===s[n].magic)r=new nn;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new sn(this.i,this.it,this.o,this.ft)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Mt(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Ue(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function on(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=[];dn(r[n],i,t,e)}}}const an=[],cn=[],un=[],fn=[0,0,0],ln=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),hn=[1,1,1];function dn(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=function(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}(an,t.translation||fn),n=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,y=i*c,m=s*o,b=s*a,p=s*c;return t[0]=1-l-y,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-p,t[5]=1-u-y,t[6]=d+m,t[7]=0,t[8]=h+b,t[9]=d-m,t[10]=1-u-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(cn,t.rotation||ln),r=function(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}(un,t.scale||hn);lt(r,n,r);const s=lt([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)dn(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,r(s,e,i,n))}}}}function yn(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?Q.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*o;r+=o){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o)}return}const u=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);u.set(i);e(new c(u.buffer),t),i.set(u)}}var mn=vn("DXT1"),bn=vn("DXT3"),pn=vn("DXT5"),gn=vn("DX10"),wn=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 i=r[21];switch(i){case mn:e=8,n="dxt1";break;case bn:e=16,n="dxt3";break;case pn:e=16,n="dxt5";break;case 116:n="rgba32f";break;case gn:var s=new Uint32Array(t.slice(128,148));n=s[0];var o=s[1];if(s[2],s[3],s[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=i,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],d=r[3],y=r[1]+4,m=h,b=d,p=[];i===gn&&(y+=20);if(f)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=m,d=b;for(var w=Math.log(h)/Math.log(2)+1,v=0;v<w;v++)l=h*d*16,p.push({offset:y,length:l,shape:[h,d]}),v<u&&(y+=l),h=Math.floor(h/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)l=Math.max(4,h)/4*Math.max(4,d)/4*e,p.push({offset:y,length:l,shape:[h,d]}),y+=l,h=Math.floor(h/2),d=Math.floor(d/2);return{shape:[m,b],images:p,format:n,flags:c,cubemap:f}};function vn(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var Mn=xt(wn),An=Math.abs,Tn=Math.sin,_n=Math.cos,kn=Math.tan,On=Math.atan,xn=Math.atan2,Sn=Math.sqrt,In=Math.log,En=Math.hypot,Cn=Math.sinh,Un=Math.cosh,Fn=1/0;function Nn(t){var e,n,r,i,s,o,a=[],c=[],u=[],f=[];function l(t,e){for(var n,r=2*_n(2*e),i=t.length-1,s=t[i],o=0;--i>=0;)n=r*s-o+t[i],o=s,s=n;return e+n*Tn(2*e)}function h(t,e,n){for(var r,i,s=Tn(e),o=_n(e),a=Cn(n),c=Un(n),u=2*o*c,f=-2*s*a,l=t.length-1,h=t[l],d=0,y=0,m=0;--l>=0;)r=y,i=d,h=u*(y=h)-r-f*(d=m)+t[l],m=f*y-i+u*d;return[(u=s*c)*h-(f=o*a)*m,u*m+f*h]}t.es,s=i=(r=t.es/(1+Sn(1-t.es)))/(2-r),a[0]=i*(2+i*(-2/3+i*(i*(116/45+i*(26/45+i*(-2854/675)))-2))),c[0]=i*(i*(2/3+i*(4/3+i*(-82/45+i*(32/45+i*(4642/4725)))))-2),s*=i,a[1]=s*(7/3+i*(i*(-227/45+i*(2704/315+i*(2323/945)))-1.6)),c[1]=s*(5/3+i*(-16/15+i*(-13/9+i*(904/315+i*(-1522/945))))),s*=i,a[2]=s*(56/15+i*(-136/35+i*(-1262/105+i*(73814/2835)))),c[2]=s*(-26/15+i*(34/21+i*(1.6+i*(-12686/2835)))),s*=i,a[3]=s*(4279/630+i*(-332/35+i*(-399572/14175))),c[3]=s*(1237/630+i*(i*(-24832/14175)-2.4)),s*=i,a[4]=s*(4174/315+i*(-144838/6237)),c[4]=s*(-734/315+i*(109598/31185)),s*=i,a[5]=s*(601676/22275),c[5]=s*(444337/155925),s=i*i,e=t.k0/(1+i)*(1+s*(1/4+s*(1/64+s/256))),u[0]=i*(i*(2/3+i*(-37/96+i*(1/360+i*(81/512+i*(-96199/604800)))))-.5),f[0]=i*(.5+i*(-2/3+i*(5/16+i*(41/180+i*(-127/288+i*(7891/37800)))))),u[1]=s*(-1/48+i*(-1/15+i*(437/1440+i*(-46/105+i*(1118711/3870720))))),f[1]=s*(13/48+i*(i*(557/1440+i*(281/630+i*(-1983433/1935360)))-.6)),s*=i,u[2]=s*(-17/480+i*(37/840+i*(209/4480+i*(-5569/90720)))),f[2]=s*(61/240+i*(-103/140+i*(15061/26880+i*(167603/181440)))),s*=i,u[3]=s*(-4397/161280+i*(11/504+i*(830251/7257600))),f[3]=s*(49561/161280+i*(-179/168+i*(6601661/7257600))),s*=i,u[4]=s*(-4583/161280+i*(108847/3991680)),f[4]=s*(34729/80640+i*(-3418889/1995840)),s*=i,u[5]=s*(-20648693/638668800),f[5]=.6650675310896665*s,o=l(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*_n(e),i=t.length-1,s=t[i],o=0;for(;--i>=0;)n=r*s-o+t[i],o=s,s=n;return Tn(e)*n}(f,2*o)),t.fwd=function(t,r){var i,s,o,a,u,d=t.phi,y=t.lam;d=l(c,d),i=Tn(d),s=_n(d),a=Tn(y),o=_n(y),d=xn(i,o*s),y=xn(a*s,En(i,s*o)),y=function(t){var e=An(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*In(e)/n}(e*(1+e/(En(1,e)+1))),t<0?-e:e}(kn(y)),u=h(f,2*d,2*y),d+=u[0],y+=u[1],An(y)<=2.623395162778?(r.y=e*d+n,r.x=e*y):r.x=r.y=Fn},t.inv=function(t,r){var i,s,o,c,f,d=t.y,y=t.x;d=(d-n)/e,An(y/=e)<=2.623395162778?(d+=(f=h(u,2*d,2*y))[0],y+=f[1],y=On(Cn(y)),i=Tn(d),s=_n(d),c=Tn(y),o=_n(y),y=xn(c,o*s),d=xn(i*o,En(c,o*s)),r.phi=l(a,d),r.lam=y):r.phi=r.lam=Fn}}const Pn=Math.PI/180,Bn=6378137*Math.PI/180,Dn=85.0511287798,Rn={};function Ln(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Dn,r=e[0],i=Math.max(Math.min(n,e[1]),-n);let s;s=0===i?0:Math.log(Math.tan((90+i)*Pn/2))/Pn;return t[0]=r*Bn,t[1]=s*Bn,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return jn(t,e);if("baidu"===n)return jn(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const i=JSON.stringify(n);let s=Rn[i];return s||(s=Rn[i]=function(t){const e={a:qn,es:Vn,x0:pe(t.falseEasting)?5e5:t.falseEasting,y0:pe(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*zn,phi0:(t.latitudeOfOrigin||0)*zn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Nn(e);const n={lam:0,phi:0},r={};let i=0,s=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*zn-e.lam0,n.phi=e.originPhi0*zn,e.fwd(n,r),i=e.a*r.x+e.x0,s=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*zn-e.lam0,n.phi=t[1]*zn,e.fwd(n,r);const a=e.a*r.x+e.x0-i,c=e.a*r.y+e.y0-s;return o[0]=a,o[1]=c,o}}}(n)),s.project(e,t)}}function jn(t,e){return t[0]=e[0],t[1]=e[1],t}const zn=.017453292519943295,qn=6378137,Vn=.0066943799901413165;const Gn=ft([]),$n=Ye().draco,Xn=Ye().ktx2,Hn={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Jn={"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 Kn(t,e,n,r,i,s){const o=[],a=[],c=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],i=C.getArrayBuffer(n.url,s);i.xhr.url=n.url,c.push(i.xhr);const u=i.then((t=>({buffer:t})));o.push(u);const f=[];if(rr(r,f),f.length){const t=f.map((t=>{const e=C.getArrayBuffer(t.url,s);return e.xhr.url=t.url,c.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));o.push(...t)}a[e]=f.length}const u=Promise.all(o).then((s=>{for(let t=0;t<s.length;t++)if(!s[t]||!s[t].buffer)return Promise.resolve(null);const o=[];let c=0;for(let t=0;t<a.length;t++){const e=a[t];o.push({geoBuffer:{data:s[c].buffer.data},textureBuffers:s.slice(c+1,e+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+e}const u=function(t,e,n,r,i,s){const o={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;l=ur(h)?Qn(o,c,f,h,t.transform,t.center,i,s):Zn(o,c,f,h,t.transform,t.center,i,s),a.push(l),o.nodes[c]={mesh:c,nodeIndex:c,matrix:ft([])},o.scenes[0].nodes[c]=o.nodes[c],u||(u=Hn);const d=er(c,o,u,e[c].textureBuffers,n,r);a.push(d)}return Promise.all(a).then((()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables})))}(t,o,e,i,n,r);return u}));return u.xhr=c,u}const Yn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Qn(t,e,n,r,i,s,o,a){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=Jn[e];if(!r)return t;return t[r.name||e]=n,t}),{});return $n(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>tr(n,t,e,i,s,o,a)))}const Wn={position:function(t,e,n){const r=3*t.vertexCount,i=new Float32Array(e,n,r);return t.position={array:i,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,i=new Float32Array(e,n,r);return t.normal={array:i,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,i=new Float32Array(e,n,r);return t.uv0={array:i,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,i=new Uint8Array(e,n,r);return t.color={array:i,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,i=new Uint32Array(e,n,r);return t.faceRange={array:i,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Zn(t,e,n,r,i,s,o,a){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.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++)Wn[n[e]]?t=Wn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let i=e.ordering,s=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<i.length;e++){const n=Wn[i[e]];n||console.log(i[e]),t=n(c,r,t)}for(let e=0;e<s.length;e++){const n=Wn[s[e]];n||console.log(s[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const f={};for(const t in c){const e=Jn[t]&&Jn[t].name;e&&(f[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(l=e)<=255?Uint8Array:l<=65535?Uint16Array:Uint32Array,r=new n(f.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,i=t[e],s=t[e+1];for(let t=i;t<=s;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}f._BATCHID={componentType:$e(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var l;return tr({attributes:f},t,e,i,s,o,a)}function tr(t,e,n,r,i,s,o){const a={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 c=function(t,e,n,r,i){let s,o=[0,0,0,1];const a=[0,0],c=Ln([],n,r,i);c[2]=n[2];const u=e&&ht(Gn,e);return yn(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],u||(o=Mt(o,o,e)),n&&gt(o,o,n),Ln(a,o,r,i),s=o[2],t[0]=a[0]-c[0],t[1]=a[1]-c[1],t[2]=s-c[2],t))),c}(t.attributes.POSITION,r,i,s,o);e.meshes[n]={primitives:[a],index:n},e.extensions.MAPTALKS_RTC={projCenter:c},e.extensions.CESIUM_RTC={rtcCoord:i};for(const n in t.attributes)cr(e.transferables,t.attributes[n].array.buffer);return t.indices&&cr(e.transferables,t.indices.array.buffer),a}function er(t,e,n,r,i,s){const o=r.map((t=>function(t,e,n,r,i){if("dds"===e){const e=Mn(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),i="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Yn,format:i})}if("png"===e||"jpg"===e)return function(t,e){ir||(ir=new OffscreenCanvas(2,2),sr=ir.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;or(n)||(n=ar(n)),or(r)||(r=ar(r));const i=e;i&&(n=Math.min(i,n),r=Math.min(i,r)),ir.width=n,ir.height=r,sr.drawImage(t,0,0,n,r),t.close();const s=sr.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(s.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,i).then((t=>{t.mimeType=n;return{image:t,sampler:Yn,format:6408}}));if("ktx2"===e)return Xn(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Yn,format:t.format})));return null}(t.data,t.format,t.mimeType,i,s).then((t=>{if(t.image)if(t.image.array)cr(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cr(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{nr(t,e,n,r)}))}function nr(t,e,n,r){const i=JSON.parse(JSON.stringify(n)),s=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(s.push(r[r.ptr++]),i[t]={index:s.length-1},void 0!==n[t].factor&&(i[t].scale=n[t].factor)):ge(n[t])&&(i[t]=nr(-1,e,n[t],r));return t>=0&&(e.materials[t]=i),i}function rr(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}):ge(t[n])&&rr(t[n],e)}let ir,sr;function or(t){return!(t&t-1)&&0!==t}function ar(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cr(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function ur(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()}var fr="undefined"!=typeof Float32Array?Float32Array:Array;function lr(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hr=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new fr(3);return fr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const dr=[];const yr=[],mr=[],br=[],pr=[],gr=[],wr=[],vr=[];function Mr(t,e,n,r,i,s){lr(pr,t[3*e],t[3*e+1],t[3*e+2]),lr(gr,t[3*n],t[3*n+1],t[3*n+2]),lr(wr,t[3*r],t[3*r+1],t[3*r+2]);const o=hr(yr,wr,gr),a=hr(mr,pr,gr),c=function(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],c=n[2];return t[0]=i*c-s*a,t[1]=s*o-r*c,t[2]=r*a-i*o,t}(br,o,a);!function(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s)}(vr,c),i[3*e]=i[3*e]||0,i[3*n]=i[3*n]||0,i[3*r]=i[3*r]||0,i[3*e+1]=i[3*e+1]||0,i[3*n+1]=i[3*n+1]||0,i[3*r+1]=i[3*r+1]||0,i[3*e+2]=i[3*e+2]||0,i[3*n+2]=i[3*n+2]||0,i[3*r+2]=i[3*r+2]||0,i[3*e]+=vr[0],i[3*n]+=vr[0],i[3*r]+=vr[0],i[3*e+1]+=vr[1],i[3*n+1]+=vr[1],i[3*r+1]+=vr[1],i[3*e+2]+=vr[2],i[3*n+2]+=vr[2],i[3*r+2]+=vr[2],s[e]+=1,s[n]+=1,s[r]+=1}const Ar=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Tr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],_r=2*Math.PI*6378137/360,kr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Or,xr,Sr=!1;if("undefined"!=typeof OffscreenCanvas){try{xr=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}xr&&"undefined"!=typeof createImageBitmap&&(Sr=!0)}const Ir=ft([]),Er=[0,0,0],Cr=[],Ur=[],Fr=[],Nr=[],Pr={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Br={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Dr;class Rr{constructor(t,e,n,r){this.id=t,this.options=e,this.At=(...t)=>this.requestImage.call(this,...t),this.Tt=n,this._t={},r(null,{},[])}kt(t){this.Ot||(this.o=t,this.xt=new nn,this.Ot=new Qe(this.At,Q,t),this.St=new We(this.At,Q,t))}requestImage(t,e){Sr?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{Or.width=t.width,Or.height=t.height,xr.drawImage(t,0,0);const n=xr.getImageData(0,0,Or.width,Or.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.Tt("requestImage",{url:t},null,e)}loadTile(t,e){this.kt(t.supportedFormats);const{service:n,url:r,arraybuffer:i}=t,s=n.fetchOptions||{};if(s.referrer=t.referrer,s.referrerPolicy=s.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const i=t.i3sInfo,o=n.maxTextureSize||0,a=Kn(i,t.supportedFormats,this.options.projection,t.projection,o,s);return a.then((t=>{if(delete this._t[r],!t)return void e({status:404,url:r,i3sInfo:i});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:i});t.gltf.url=r;const{transferables:s}=t;t.magic="b3dm",n.createNormalIfMissed&&this.It(t.gltf),Hr(n)&&this.Et(t.gltf),e(null,t,s)})),void(this._t[r]=a.xhr)}if(i){delete this._t[r];const n=Ue(new DataView(i),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(kr){const r=new Uint8Array(t,e,n);return kr.decode(r)}return Me(new Uint8Array(t,e,n))}(i,0,i.byteLength),s=JSON.parse(n);s.accessors?this.Ct(s,r,t,"gltf",e):this.Ut(t.rootIdx,s,i,r,e)}else this.Ct(i,r,t,n,e)}else{let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);const o=r.replace(/\\+/g,"%2B");let a=C.getArrayBuffer(o+(i||""),s);const c=a.xhr;a=a.then((n=>{delete this._t[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this._t[r],e(t)})),this._t[r]=c}}Ct(t,e,n,r,i){r=r&&r.toLowerCase();const{service:s}=n;if("b3dm"===r){this.Ot.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:r}=this.Ft(t,n);s.createNormalIfMissed&&this.It(e.gltf),Hr(s)&&this.Et(e.gltf),i(null,e,r)})).catch((t=>{i(t)}))}else if("pnts"===r){const r=n.transform||Ir;this.xt.load(e,t).then((t=>{const{content:e,transferables:s}=this.Nt(t,r,n.rootIdx);this.Pt(e),i(null,e,s)}))}else if("i3dm"===r){const r=n.transform||Ir;this.St.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:o}=this.Bt(t,r,n.rootIdx);s.createNormalIfMissed&&this.It(e.gltf),Hr(s)&&this.Et(e.gltf),i(null,e,o)}))}else if("cmpt"===r){new sn(this.At,Q,this.o,s.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Dt(t,n);this.Rt(e,s),Hr(s)&&this.Lt(e),i(null,e,r)})).catch((t=>{i(t)}))}else if("gltf"===r){this.st||(this.st=Ye());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t;let a;try{a=new Q(r,o,{transferable:!0,requestImage:this.At,decoders:this.st,supportedFormats:this.o,maxTextureSize:s.maxTextureSize||0})}catch(t){i(t)}a.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.jt(t,null,n),s.createNormalIfMissed&&this.It(t),Hr(s)&&this.Et(t),i(null,{magic:"gltf",gltf:t},a.transferables)}))}else i(new Error("unsupported tile format: "+r))}Rt(t,e){t.content?t.content.forEach((t=>{this.Rt(t,e)})):e.createNormalIfMissed&&this.It(t.gltf)}Lt(t){t.content?t.content.forEach((t=>{this.Lt(t)})):this.Et(t.gltf)}zt(t,e){if(this.qt(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.Vt()?Dr.subarray(0,n):e,i=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const i=dr;i.length<t.length/3&&(i.length=t.length/3),i.fill(0,0,t.length/3);const s=void 0===e.length?e:e.length;for(let n=0;n<s/3;n++)void 0===e.length?Mr(t,3*n,3*n+1,3*n+2,r,i):Mr(t,e[3*n],e[3*n+1],e[3*n+2],r,i);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=i[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:i,byteLength:i.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:i.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}Et(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(Pr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=_r,t.compressed_int16_params.compressed_ratio=r);const i=Gr(e[n].array,r,e[n].min,e[n].max,n);if(!i)continue;const{array:s,range:o}=i;e[n].componentType=5124,e[n].array=s,t.compressed_int16_params[n]=o}}))}}It(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.zt(e,t)}))}}Pt(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(Pr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=_r,t.compressed_int16_params.compressed_ratio=r);const{array:i,range:s}=Gr(e[n].array,r,e[n].min,e[n].max,n);e[n].array=i,t.compressed_int16_params[n]=s}}Gt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const i={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(i)}return e}Ut(t,e,n,r,i){return e.capabilities,void i(null,e)}Dt(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},i=[];for(let t=0;t<n.length;t++){const{magic:s}=n[t];if("b3dm"===s){const{content:s,transferables:o}=this.Ft(n[t],e);qr(i,o),r.content.push(s)}else if("i3dm"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Bt(n[t],s,o);qr(i,c),r.content.push(a)}else if("pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Nt(n[t],s,o);qr(i,c),r.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Dt(n[t],e);qr(i,o),r.content.push(s)}}return{content:r,transferables:i}}Ft(t,e){const{gltf:n,transferables:r,featureTable:i}=t;return this.jt(n,i,e),delete t.transferables,{content:t,transferables:r}}jt(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;const e="visited";let n=1;const r=[];for(const i in t.meshes){const s=t.meshes[i],{primitives:o}=s;if(o)for(let t=0;t<o.length;t++){const i=o[t].attributes&&o[t].attributes.POSITION;if(!i||!i.array)continue;i.array.buffer[e]||(i.array.buffer[e]=n++);const s=n-1+"-"+(i.byteOffset||0);if(r.indexOf(s)>=0)return!0;r.push(s)}}return!1}(t);this.$t(t);n.service.createNormalIfMissed||this.Xt(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.Ht(t,e,n.upAxis,n.transform)):this.Jt(t,e,n.upAxis,n.transform)}Bt(t,e,n){const{featureTable:r}=t,i=t.i3dm,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&ht(Ir,e),c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};jr(i.POSITION.array,3,s,Ir,c);const u=zr(c);e&&!a&&Mt(u,u,e);const f=this.Kt(u),l=[];Ln(l,f,o),l[2]=f[2];const h=bt([],u),d=[0,0,0],y=[0,0,0],m=[0,0],b=[1/0,1/0,1/0],p=[-1/0,-1/0,-1/0];yn(i.POSITION,(t=>{d[0]=t[0]+s[0],d[1]=t[1]+s[1],d[2]=t[2]+s[2],e&&!a&&Mt(d,d,e),0===_t(d)?pt(y,0,0,-6378137):xe(y,d),Ln(m,y,o),t[0]=m[0]-l[0],t[1]=m[1]-l[1],t[2]=y[2]-l[2],t[0]<b[0]&&(b[0]=t[0]),t[1]<b[1]&&(b[1]=t[1]),t[2]<b[2]&&(b[2]=t[2]),t[0]>p[0]&&(p[0]=t[0]),t[1]>p[1]&&(p[1]=t[1]),t[2]>p[2]&&(p[2]=t[2])})),i.POSITION.min=b,i.POSITION.max=p,e&&Mt(u,u,e),t.rtcCenter=h,t.rtcCoord=f,t.projCenter=l,t.rootIdx=n;const g=t.transferables;return delete t.transferables,{content:t,transferables:g}}Nt(t,e,n){const{featureTable:r}=t,i=t.pnts,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&ht(Ir,e),c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};jr(i.POSITION.array,3,s,e,c);const u=zr(c),f=this.Yt(u),l=bt([],u),h=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];let y=[0,0,0,1];const m=[0,0,0],b=[0,0];yn(i.POSITION,(t=>(y[0]=t[0]+s[0],y[1]=t[1]+s[1],y[2]=t[2]+s[2],e&&!a&&(y=Mt(y,y,e)),0===_t(y)?pt(m,0,0,-6378137):xe(m,y),Ln(b,m,o),t[0]=b[0]-f[0],t[1]=b[1]-f[1],t[2]=m[2]-f[2],t[0]<h[0]&&(h[0]=t[0]),t[1]<h[1]&&(h[1]=t[1]),t[2]<h[2]&&(h[2]=t[2]),t[0]>d[0]&&(d[0]=t[0]),t[1]>d[1]&&(d[1]=t[1]),t[2]>d[2]&&(d[2]=t[2]),t))),i.POSITION.min=h,i.POSITION.max=d,e&&Mt(u,u,e);const p=this.Kt(u);t.rtcCenter=l,t.projCenter=f,t.rtcCoord=p,t.rootIdx=n;const g=t.transferables;return delete t.transferables,{content:t,transferables:g}}$t(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],i=n[1],s=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==i||n[t+2]!==s||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,i/255,s/255,o/255],delete e[t].image.array)}}}Xt(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const i=r.primitives;if(i)for(let e=0;e<i.length;e++){if(!i[e])continue;if(!i[e].attributes||i[e].attributes.NORMAL)continue;const n=i[e].material;if(!pe(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}abortTileLoading(t,e){const n=this._t[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._t[t.url],e(null)}Qt(t,e,n,r){const i=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let s=Ar;"X"===(n=n&&n.toUpperCase())?s=Tr:"Z"===n&&(s=Ir),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),i&&(t.extensions.CESIUM_RTC.center=i),t.extensions.MAPTALKS_RTC={};const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};on(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=ft(Cr);t.matrices&&Vr(e,t.matrices);const n=t.attributes.POSITION.array,a=t.attributes.POSITION.itemSize;lt(e,s,e),r&&lt(e,r,e),jr(n,a,i||Er,e,o,t.compressUniforms)}));const a=zr(o);return{rtcCenter:i,modelCenter:a,upAxisTransform:s}}Ht(t,e,n,r){const{modelCenter:i,upAxisTransform:s,rtcCenter:o}=this.Qt(t,e,n),a=this.Yt(i);t.extensions.MAPTALKS_RTC.projCenter=a,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i);const c=bt([],i);r&&Mt(i,i,r),t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i),o||(on(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=ft(Cr);t.matrices&&Vr(n,t.matrices),lt(n,s,n);const r=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],u=e[7],f=e[8],l=e[9],h=e[10],d=e[11],y=e[12],m=e[13],b=e[14],p=e[15],g=n*a-r*o,w=n*c-i*o,v=n*u-s*o,M=r*c-i*a,A=r*u-s*a,T=i*u-s*c,_=f*m-l*y,k=f*b-h*y,O=f*p-d*y,x=l*b-h*m,S=l*p-d*m,I=h*p-d*b,E=g*I-w*S+v*x+M*O-A*k+T*_;return E?(E=1/E,t[0]=(a*I-c*S+u*x)*E,t[1]=(i*S-r*I-s*x)*E,t[2]=(m*T-b*A+p*M)*E,t[3]=(h*A-l*T-d*M)*E,t[4]=(c*O-o*I-u*k)*E,t[5]=(n*I-i*O+s*k)*E,t[6]=(b*v-y*T-p*w)*E,t[7]=(f*T-h*v+d*w)*E,t[8]=(o*S-a*O+u*_)*E,t[9]=(r*O-n*S-s*_)*E,t[10]=(y*A-m*v+p*g)*E,t[11]=(l*v-f*A-d*g)*E,t[12]=(a*k-o*x-c*_)*E,t[13]=(n*x-r*k+i*_)*E,t[14]=(m*w-y*M-b*g)*E,t[15]=(f*M-l*w+h*g)*E,t):null}(Ur,n),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];yn(e,(t=>{Mt(t,t,n),t[0]=t[0]-c[0],t[1]=t[1]-c[1],t[2]=t[2]-c[2],Mt(t,t,r),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]>o[0]&&(o[0]=t[0]),t[1]>o[1]&&(o[1]=t[1]),t[2]>o[2]&&(o[2]=t[2])})),e.min=i,e.max=o,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=c)}Jt(t,e,n,r){const{modelCenter:i,rtcCenter:s}=this.Qt(t,e,n,r),o=this.Yt(i);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i),on(t,(e=>{if(e.attributes&&e.attributes.POSITION){const i=this.qt(e,t);if(i){const t=e.attributes.POSITION.array.length;(!Dr||Dr.length<t)&&(Dr=new Float32Array(t))}e.attributes.NORMAL&&this.Wt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.Wt(e.attributes.TANGENT,e.matrices,n);const{newPositions:o}=this.Zt(e.attributes.POSITION,e.matrices,s,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,i),{componentType:a}=e.attributes.POSITION;5126!==a&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=Ir}}Yt(t){const e=this.options.projection;"identity"===e?bt(Fr,t):0===_t(t)?pt(Fr,0,0,-6378137):xe(Fr,t),Ln(Nr,Fr,e);const n=Fr[2],r=[];return r[0]=Nr[0],r[1]=Nr[1],r[2]=n,r}Wt(t,e,n){let r;r="Y"===n?Ar:"X"===n?Tr:Ir;const i=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}([],r);if(Vr(i,e),ht(i,Ir))return;const s=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}([],i),o=[];yn(t,(t=>(function(t,e,n){var r=e[0],i=e[1],s=e[2];t[0]=r*n[0]+i*n[3]+s*n[6],t[1]=r*n[1]+i*n[4]+s*n[7],t[2]=r*n[2]+i*n[5]+s*n[8]}(o,t,s),wt(o,o),bt(t,o),o)))}Zt(t,e,n,r,i,s,o,a){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const c=ft([]);Vr(c,e);const u=this.options.projection;i=i&&i.toUpperCase();const f=n;let l=null;"Y"===i?l=Ar:"X"===i&&(l=Tr);let h=[0,0,0,1];const d=[0,0,0],y=[0,0],m=r.projCenter,b=Ln([],r.rtcCoord,"EPSG:3857"),p=s&&ht(Ir,s),g=t.min=t.min||[],w=t.max=t.max||[];pt(g,1/0,1/0,1/0),pt(w,-1/0,-1/0,-1/0);const v=o||{},{decode_position_min:M,decode_position_normConstant:A}=v;let T=[0,0,0,0],_=1;M&&(T=M),A&&(_=A);const k=[];return yn(t,((e,n)=>{if(h[0]=e[0]*_+T[0],h[1]=e[1]*_+T[1],h[2]=e[2]*_+T[2],h=Mt(h,h,c),l&&(h=Mt(h,h,l)),f&&gt(h,h,f),s&&!p&&(h=Mt(h,h,s)),0===_t(h)?pt(d,0,0,-6378137):xe(d,h),a){const t=Dr;Ln(y,d,u),t[3*n]=y[0]-b[0],t[3*n+1]=y[0]-b[1],t[3*n+2]=y[0]-b[2]}if(Ln(y,d,u),e instanceof Float32Array)e[0]=y[0]-m[0],e[1]=y[1]-m[1],e[2]=d[2]-m[2];else{const n=y[0]-m[0],r=y[1]-m[1],i=d[2]-m[2];5126!==t.componentType&&(k.push(n),k.push(r),k.push(i),k.push(e[3]))}return e[0]<g[0]&&(g[0]=e[0]),e[1]<g[1]&&(g[1]=e[1]),e[2]<g[2]&&(g[2]=e[2]),e[0]>w[0]&&(w[0]=e[0]),e[1]>w[1]&&(w[1]=e[1]),e[2]>w[2]&&(w[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:m,newPositions:k}}Kt(t){return 0===_t(t)?pt([],0,0,-6378137):xe([],t)}onRemove(){}Vt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}qt(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;return!t.attributes.TANGENT}}const Lr=[];function jr(t,e,n,r,i,s){const o=s||{},{decode_position_min:a,decode_position_normConstant:c}=o;let u=[0,0,0,0],f=1;a&&(u=a),c&&(f=c);for(let s=0,o=t.length;s<o;s+=e){const{xmin:o,ymin:a,xmax:c,ymax:l,hmin:h,hmax:d}=i;pt(Lr,t[s]*f+u[0],t[s+1]*f+u[1],t[s+2]*f+u[2]),Mt(Lr,Lr,r);const y=gt(Lr,n,Lr);y[0]<o&&(i.xmin=y[0]),y[0]>c&&(i.xmax=y[0]),y[1]<a&&(i.ymin=y[1]),y[1]>l&&(i.ymax=y[1]),e>2&&(y[2]<h&&(i.hmin=y[2]),y[2]>d&&(i.hmax=y[2]))}}function zr(t){const{xmax:e,ymax:n,xmin:r,ymin:i,hmin:s,hmax:o}=t,a=[(r+e)/2,(i+n)/2,(s+o)/2];return e===-1/0&&(a[0]=0),n===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function qr(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Vr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)lt(n,e[t],n);return n}function Gr(t,e,n,r,i){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let s,o;if(n&&r&&1===e)s=Math.min(...n),o=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);s=e,o=n}return!function(t,e,n,r){for(let i=0;i<t.length;i++){const s=$r(Xr(t[i],e,n),e,n);if(Math.abs(s-t[i])>Br[r])return!1}return!0}(t,s,o,i)&&Br[i]?null:function(t,e,n){const r=new Int16Array(t.length);for(let i=0;i<t.length;i++)r[i]=Xr(t[i],e,n);return{array:r,range:[e,n]}}(t,s,o)}function $r(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Xr(t,e,n){const r=2*(t-e)/(n-e)-1,i=Math.max(-1,Math.min(1,r));return i<0?32768*i:32767*i}function Hr(t){return void 0===t.compressGeometry||t.compressGeometry}let Jr=0;class Kr{constructor(t){this.workerId=t,this.workers={},this.te={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},i){if(this.ee(e,n))return;const s=this.ne(e,n),o=r.options;this.workers[s]=new Rr(n,o,((...e)=>this.send.call(this,t,...e)),i)}removeLayer({mapId:t,layerId:e},n){const r=this.ee(t,e),i=this.ne(t,e);delete this.workers[i],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const i=this.ee(t,e);i&&i.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const i=this.ee(t,e);i&&i.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.te[e];delete this.te[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,i){const s=i?\`${O}t}-${O}Jr++}\`:null;i&&(this.te[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(s)},r||[])}ne(t,e){return\`${O}t}-${O}e}\`}ee(t,e){const n=this.ne(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Kr(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&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`;function x(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var I={exports:{}},S={exports:{}},E=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},C=Array.prototype.concat,N=Array.prototype.slice,k=S.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];E(i)?e=C.call(e,N.call(i)):e.push(i)}return e};k.wrap=function(t){return function(){return t(k(arguments))}};var R=S.exports,L={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},P=R,B=Object.hasOwnProperty,U=Object.create(null);for(var D in L)B.call(L,D)&&(U[L[D]]=D);var F=I.exports={to:{},get:{}};function j(t,e,n){return Math.min(Math.max(e,t),n)}function z(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}F.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=F.get.hsl(t),n="hsl";break;case"hwb":e=F.get.hwb(t),n="hwb";break;default:e=F.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},F.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var s=2*n;i[n]=parseInt(e.slice(s,s+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:B.call(L,e[1])?((i=L[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=j(i[n],0,255);return i[3]=j(i[3],0,1),i},F.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},F.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},F.to.hex=function(){var t=P(arguments);return"#"+z(t[0])+z(t[1])+z(t[2])+(t[3]<1?z(Math.round(255*t[3])):"")},F.to.rgb=function(){var t=P(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},F.to.rgb.percent=function(){var t=P(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},F.to.hsl=function(){var t=P(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},F.to.hwb=function(){var t=P(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},F.to.keyword=function(t){return U[t.slice(0,3)]};var q=I.exports,H={exports:{}},G={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},V={};for(var J in G)G.hasOwnProperty(J)&&(V[G[J]]=J);var $=H.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var K in $)if($.hasOwnProperty(K)){if(!("channels"in $[K]))throw new Error("missing channels property: "+K);if(!("labels"in $[K]))throw new Error("missing channel labels property: "+K);if($[K].labels.length!==$[K].channels)throw new Error("channel and label counts mismatch: "+K);var X=$[K].channels,Y=$[K].labels;delete $[K].channels,delete $[K].labels,Object.defineProperty($[K],"channels",{value:X}),Object.defineProperty($[K],"labels",{value:Y})}$.rgb.hsl=function(t){var e,n,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),c=a-o;return a===o?e=0:r===a?e=(i-s)/c:i===a?e=2+(s-r)/c:s===a&&(e=4+(r-i)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},$.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,h=Math.max(o,a,c),l=h-Math.min(o,a,c),u=function(t){return(h-t)/6/l+.5};return 0===l?i=s=0:(s=l/h,e=u(o),n=u(a),r=u(c),o===h?i=r-n:a===h?i=1/3+e-r:c===h&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*h]},$.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[$.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},$.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-i)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-i-e)/(1-e)||0),100*e]},$.rgb.keyword=function(t){var e=V[t];if(e)return e;var n,r,i,s=1/0;for(var o in G)if(G.hasOwnProperty(o)){var a=G[o],c=(r=t,i=a,Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2)+Math.pow(r[2]-i[2],2));c<s&&(s=c,n=o)}return n},$.keyword.rgb=function(t){return G[t]},$.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},$.rgb.lab=function(t){var e=$.rgb.xyz(t),n=e[0],r=e[1],i=e[2];return r/=100,i/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},$.hsl.rgb=function(t){var e,n,r,i,s,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[s=255*c,s,s];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),i=[0,0,0];for(var h=0;h<3;h++)(r=o+1/3*-(h-1))<0&&r++,r>1&&r--,s=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,i[h]=255*s;return i},$.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,i=n,s=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[e,100*(0===r?2*i/(s+i):2*n/(r+n)),100*((r+n)/2)]},$.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),c=255*r*(1-n*(1-s));switch(r*=255,i){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},$.hsv.hsl=function(t){var e,n,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,n=s*a,[i,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(r/=2)]},$.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,h=t[1]/100,l=t[2]/100,u=h+l;switch(u>1&&(h/=u,l/=u),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=h+r*((n=1-l)-h),e){default:case 6:case 0:s=n,o=i,a=h;break;case 1:s=i,o=n,a=h;break;case 2:s=h,o=n,a=i;break;case 3:s=h,o=i,a=n;break;case 4:s=i,o=h,a=n;break;case 5:s=n,o=h,a=i}return[255*s,255*o,255*a]},$.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},$.xyz.rgb=function(t){var e,n,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,e=(e=3.2406*i+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},$.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},$.lab.xyz=function(t){var e,n,r,i=t[0];e=t[1]/500+(n=(i+16)/116),r=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=s>.008856?s:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},$.lab.lch=function(t){var e,n=t[0],r=t[1],i=t[2];return(e=360*Math.atan2(i,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+i*i),e]},$.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},$.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:$.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===i&&(s+=60),s},$.hsv.ansi16=function(t){return $.rgb.ansi16($.hsv.rgb(t),t[2])},$.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},$.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},$.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},$.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},$.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},$.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,r),i),o=Math.min(Math.min(n,r),i),a=s-o;return e=a<=0?0:s===n?(r-i)/a%6:s===r?2+(i-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},$.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,i=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},$.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},$.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var i,s=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=c,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=c,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=c}return i=(1-n)*r,[255*(n*s[0]+i),255*(n*s[1]+i),255*(n*s[2]+i)]},$.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},$.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},$.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},$.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},$.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},$.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},$.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},$.gray.hsl=$.gray.hsv=function(t){return[0,0,t[0]]},$.gray.hwb=function(t){return[0,100,t[0]]},$.gray.cmyk=function(t){return[0,0,0,t[0]]},$.gray.lab=function(t){return[t[0],0,0]},$.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},$.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Z=H.exports,W=Z;function Q(t){var e=function(){for(var t={},e=Object.keys(W),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(W[r]),s=i.length,o=0;o<s;o++){var a=i[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function tt(t,e){return function(n){return e(t(n))}}function et(t,e){for(var n=[e[t].parent,t],r=W[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=tt(W[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var nt=Z,rt=function(t){for(var e=Q(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=et(o,e))}return n},it={};Object.keys(nt).forEach((function(t){it[t]={},Object.defineProperty(it[t],"channels",{value:nt[t].channels}),Object.defineProperty(it[t],"labels",{value:nt[t].labels});var e=rt(t);Object.keys(e).forEach((function(n){var r=e[n];it[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,i=0;i<r;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),it[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var st=q,ot=it,at=[].slice,ct=["keyword","gray","hex"],ht={};Object.keys(ot).forEach((function(t){ht[at.call(ot[t].labels).sort().join("")]=t}));var lt={};function ut(t,e){if(!(this instanceof ut))return new ut(t,e);if(e&&e in ct&&(e=null),e&&!(e in ot))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ut)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=st.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=ot[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=ot[this.model].channels;var s=at.call(t,0,r);this.color=mt(s,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ht[a];var c=ot[this.model].labels,h=[];for(n=0;n<c.length;n++)h.push(t[c[n]]);this.color=mt(h)}if(lt[this.model])for(r=ot[this.model].channels,n=0;n<r;n++){var l=lt[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ft(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(lt[t]||(lt[t]=[]))[e]=n})),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),(i=this[t]()).color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function dt(t){return function(e){return Math.max(0,Math.min(t,e))}}function mt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ut.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in st.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return st.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return st.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ot[this.model].channels,n=ot[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ut(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ut(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ft("rgb",0,dt(255)),green:ft("rgb",1,dt(255)),blue:ft("rgb",2,dt(255)),hue:ft(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ft("hsl",1,dt(100)),lightness:ft("hsl",2,dt(100)),saturationv:ft("hsv",1,dt(100)),value:ft("hsv",2,dt(100)),chroma:ft("hcg",1,dt(100)),gray:ft("hcg",2,dt(100)),white:ft("hwb",1,dt(100)),wblack:ft("hwb",2,dt(100)),cyan:ft("cmyk",0,dt(100)),magenta:ft("cmyk",1,dt(100)),yellow:ft("cmyk",2,dt(100)),black:ft("cmyk",3,dt(100)),x:ft("xyz",0,dt(100)),y:ft("xyz",1,dt(100)),z:ft("xyz",2,dt(100)),l:ft("lab",0,dt(100)),a:ft("lab",1),b:ft("lab",2),keyword:function(t){return arguments.length?new ut(t):ot[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ut(t):st.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ut.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,c=1-a;return ut.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}},Object.keys(ot).forEach((function(t){if(-1===ct.indexOf(t)){var e=ot[t].channels;ut.prototype[t]=function(){if(this.model===t)return new ut(this);if(arguments.length)return new ut(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ut((n=ot[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ut[t]=function(n){return"number"==typeof n&&(n=mt(at.call(arguments),e)),new ut(n,t)}}}));var pt=x(ut);function gt(t){return null==t}function bt(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 yt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function wt(t){return"object"==typeof t&&!!t}function vt(t){return"number"==typeof t&&!isNaN(t)}function Tt(t){return t*Math.PI/180}function _t(t){return t/Math.PI*180}function Mt(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function Ot(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const At=[1,1,1,1,2,2,3,0];function xt(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=At[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 It(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function St(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function Et(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Ct(t){return 0===t.indexOf("data:")}function Nt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),i=r.length,s=new Uint8Array(i);for(let t=0;t<i;t++)s[t]=r.charCodeAt(t);return s.buffer}function kt(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}const Rt={};function Lt(t,e){if(!Array.isArray(e)){const t=e;e=Rt[t]=Rt[t]||pt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Pt=Object.freeze({__proto__:null,base64URLToArrayBuffer:Nt,extend:bt,flatArr:St,getAbsoluteURL:Mt,getBatchIdArrayType:Et,isBase64:Ct,isFunction:yt,isNil:gt,isNumber:vt,isObject:wt,normalizeColor:Lt,pushIn:kt,setColumn3:It,sign:Ot,stringFromUTF8Array:xt,toDegree:_t,toRadian:Tt});function Bt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Ut(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Dt="undefined"==typeof document?null:document.createElement("canvas");class Ft extends t.worker.Actor{constructor(t,e,n){super(t),this.mapId=e,this.i=n}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(!Dt)return void e(new Error("There is no canvas to draw image!"));const t=this.i?n:function(t){if(jt(t.width)&&jt(t.height))return t;let e=t.width,n=t.height;jt(e)||(e=zt(e));jt(n)||(n=zt(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,s=i.lastIndexOf("/")+1,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);Dt.width=t.width,Dt.height=t.height;const r=Dt.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function jt(t){return!(t&t-1)&&0!==t}function zt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function qt(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=[];Xt(r[n],i,t,e)}}}const Ht=[],Gt=[],Vt=[],Jt=[0,0,0],$t=v.identity([]),Kt=[1,1,1];function Xt(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=T.fromTranslation(Ht,t.translation||Jt),n=T.fromQuat(Gt,t.rotation||$t),r=T.fromScaling(Vt,t.scale||Kt);T.multiply(r,n,r);const s=T.multiply([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)Xt(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,r(s,e,i,n))}}}}function Yt(t,e,n){let{byteOffset:r,byteStride:i}=e;const{componentType:s,itemSize:o}=e,a=e.array.buffer,c=s?y.getTypedArrayCtor(s):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,i=i||0,!i||i===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}i||(i=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,i*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function Zt(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]}var Wt="#include <gl2_vert>\n\nconst 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#ifdef PICKING_MODE\n\n #include <fbo_picking_vert>\n\n#endif\n\n#include <draco_decode_vert>\n\nvoid main() {\n\n #ifdef HAS_POSITION\n\n vec3 localPos = decode_getPosition(POSITION);\n\n #endif\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n\n\n #ifdef PICKING_MODE\n\n fbo_picking_setData(gl_Position.w, true);\n\n #else\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_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 #endif\n\n\n\n\n\n\n\n\n\n}\n\n";const Qt=new Array(3),te=new Array(3),ee=[40680631590769,40680631590769,40408299984661.445];function ne(t,e,n,r){const i=ee,s=Math.cos(n);Qt[0]=s*Math.cos(e),Qt[1]=s*Math.sin(e),Qt[2]=Math.sin(n),de(Qt,Qt),_.multiply(te,i,Qt);const o=Math.sqrt(_.dot(Qt,te));var a,c,h;return c=te,h=o,(a=te)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,_.scale(Qt,Qt,r),_.add(t,te,Qt)}const re=[1/6378137,1/6378137,1/6356752.314245179],ie=[1/40680631590769,1/40680631590769,1/40408299984661.445],se=new Array(3),oe=new Array(3),ae=new Array(3);function ce(t,e){const n=ie,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],h=n[1],l=n[2],u=s*s*c*c,f=o*o*h*h,d=a*a*l*l,m=u+f+d,p=Math.sqrt(1/m),g=_.scale(he,e,p);if(m<i)return isFinite(p)?g:void 0;const b=r[0],y=r[1],w=r[2],v=le;v[0]=g[0]*b*2,v[1]=g[1]*y*2,v[2]=g[2]*w*2;let T,M,O,A,x,I,S,E,C,N,k,R=(1-p)*fe(e)/(.5*fe(v)),L=0;do{R-=L,O=1/(1+R*b),A=1/(1+R*y),x=1/(1+R*w),I=O*O,S=A*A,E=x*x,C=I*O,N=S*A,k=E*x,T=u*I+f*S+d*E-1,M=u*C*b+f*N*y+d*k*w;L=T/(-2*M)}while(Math.abs(T)>ue);return t[0]=s*O,t[1]=o*A,t[2]=a*x,t}(se,e,re,n,.1);let i=_.mul(oe,r,n);i=de(i,i);const s=_.sub(ae,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=Ot(_.dot(s,e))*fe(s);return t[0]=_t(o),t[1]=_t(a),t[2]=c,t}const he=new Array(3),le=new Array(3),ue=1e-12;function fe(t){return _.length(t)}function de(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function me(t,e){return _.multiply(e,t,ie),_.normalize(e,e)}function pe(t,e){const n=t[0],r=t[1],i=Math.cos(r),s=i*Math.cos(n),o=i*Math.sin(n),a=Math.sin(r);return e.x=s,e.y=o,e.z=a,_.normalize(e,e)}var ge=Object.freeze({__proto__:null,cartesian3ToDegree:ce,geodeticSurfaceNormal:me,geodeticSurfaceNormalCartographic:pe,normalizeCartesian:de,radianToCartesian3:ne});function be(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 ye(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const we="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function ve(t,e,n){const r=new Uint8Array(t,e,n);return we?JSON.parse(we.decode(r)):JSON.parse(xt(r))}function Te(t,e,n){const r=new Uint8Array(t,e,n);return we?JSON.parse(we.decode(r)):JSON.parse(xt(r))}function _e(t,e,n){return{offset:e,byteLength:n}}function Me(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=Ee(s||"UNSIGNED_SHORT"),h=Ie(o);return{byteStride:0,byteOffset:i+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+i,r*h)}}function Oe(t,e,n,r){const i=Me(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function Ae(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=Ee(s||"UNSIGNED_SHORT"),c=Ie(o),h=new a(e,i,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const xe={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ie(t){return t?xe[t]:1}const Se={"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 Ee(t){return Se[t]}function Ce(t){for(const e in Se)if(t===Se[e].ctor)return Se[e].type;throw new Error("unrecognized ctor:"+t)}function Ne(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;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 ke(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,h={},l={},u=null;r>0&&(h=ve(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(l=Te(a,e,s),e+=s);const f=_e(0,e,o);return u=a.slice(f.offset,f.offset+f.byteLength),n.push(u),{featureTable:h,featureTableBin:c,batchTable:l,batchTableBin:u}}const Re={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"}},Le={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Pe={},Be={east:[],north:[],up:[],west:[],south:[],down:[]};let Ue=[],De=[],Fe=[];const je=[0,0,0];function ze(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 qe=function(t,e){const n=Re[t][e];let r;const i=t+e;return Pe[i]?r=Pe[i]:(r=function(r,i,s){if(_.equals(r,je))_.copy(Ue,Le[t]),_.copy(De,Le[e]),_.copy(Fe,Le[n]);else if(be(r[0],0,1e-14)&&be(r[1],0,1e-14)){const i=Ot(r[2]);_.copy(Ue,Le[t]),_.copy(De,Le[e]),_.scale(De,De,i),_.copy(Fe,Le[n]),_.scale(Fe,Fe,i)}else{me(r,Be.up);const i=Be.up,s=Be.east;s[0]=-r[1],s[1]=r[0],s[2]=0,_.normalize(Be.east,s),_.cross(Be.north,i,s),_.scale(Be.down,Be.up,-1),_.scale(Be.west,Be.east,-1),_.scale(Be.south,Be.north,-1),Ue=Be[t],De=Be[e],Fe=Be[n]}return s[0]=Ue[0],s[1]=Ue[1],s[2]=Ue[2],s[3]=0,s[4]=De[0],s[5]=De[1],s[6]=De[2],s[7]=0,s[8]=Fe[0],s[9]=Fe[1],s[10]=Fe[2],s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s},Pe[i]=r),r}("east","north"),He=[],Ge=[],Ve=[],Je=[],$e=[],Ke=[],Xe=[],Ye={x:0,y:0},Ze={x:0,y:0},We=Math.PI/180;let Qe;const tn={width:100,height:10};let en=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),en=!0}catch(t){en=!1}function nn(){if(!Qe){const{width:t,height:e}=tn;en?Qe=new OffscreenCanvas(t,e):(Qe=document.createElement("canvas"),Qe.width=t,Qe.height=e)}return Qe}class rn{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e][0];n=Math.min(i,n),r=Math.max(i,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},tn,e),this.o()}getImageData(){return this.imgData}o(){const t=nn(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const i=r.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:o}=this;for(let t=0,e=s.length;t<e;t++){const[e,n]=s[t],r=(e-this.min)/o;i.addColorStop(r,n)}r.fillStyle=i,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var sn;function on(t,e){var n,r,i;if(gn(t)){var s,o=t.stops&&"object"==typeof t.stops[0][0],a=o||void 0!==t.property,c=o||!a,h=t.type||e||"exponential";if("exponential"===h)s=hn;else if("interval"===h)s=cn;else if("categorical"===h)s=an;else if("identity"===h)s=fn;else if("color-interpolate"===h)s=un;else{if("calculate-expression"!==h)throw new Error('Unknown function type "'+h+'"');s=dn}if(o){var l={},u=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===l[f[0].zoom]&&(l[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),l[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in l)u.push([l[t].zoom,on(l[t])]);n=function(e,n){const r=hn({stops:u,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,i=!1}else c?(n=function(e){const n=s(t,e);return"function"==typeof n?n(e):n},r=!0,i=!1):(n=function(e,n){const r=s(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,i=!0)}else n=function(){return t},r=!0,i=!0;return n.isZoomConstant=i,n.isFeatureConstant=r,n}function an(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function cn(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function hn(t,e){for(var n=void 0!==t.base?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:mn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(sn=new Map);const ln={width:100,height:1};function un(t,e){const n=t.stops;if(n&&n.length>1){let t;if(sn){const e=JSON.stringify(n);if(!sn.has(e)){const t=new rn(n,ln);sn.set(e,t)}t=sn.get(e)}else t=new rn(n,ln);const[r,i,s,o]=t.getColor(e);return[r/255,i/255,s/255,o/255]}return n&&1===n.length?n[0][1]:null}function fn(t,e){return n=e,r=t.default,void 0!==n?n:void 0!==r?r:null;var n,r}function dn(t,e){const n=String(t.property),r=t.expression,i=e;function s(e){return null==e||""===e||isNaN(e)?t.default:e}if(null==e||""===e||isNaN(e)||e<0)return s(t.default);{const e=function t(e,n,r){const i=Number(r),s=String(n);return Array.isArray(e)?e.map((e=>t(e,s,i))):e===s?i:e}(r,n,i);return s(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(`Unknown operator: ${r}`);const i=n.slice(1).map((t=>e(t)));switch(r){case"+":return i.reduce(((t,e)=>t+e),0);case"-":return i.reduce(((t,e)=>t-e));case"*":return i.reduce(((t,e)=>t*e),1);case"/":return i.some((t=>0===t))?t.default:i.reduce(((t,e)=>t/e));default:throw new Error(`Unsupported operator: ${r}`)}}}(e))}}function mn(t,e,n,r,i,s){return"function"==typeof i?function(){var o=i.apply(void 0,arguments),a=s.apply(void 0,arguments);return mn(t,e,n,r,o,a)}:i.length?function(t,e,n,r,i,s){var o=[];for(let a=0;a<i.length;a++)o[a]=pn(t,e,n,r,i[a],s[a]);return o}(t,e,n,r,i,s):pn(t,e,n,r,i,s)}function pn(t,e,n,r,i,s){var o,a=r-n,c=t-n;return i*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+s*o}function gn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function bn(t){return yn(t,"exponential")}function yn(t,e){if(!gn(t))return function(){return t};let n=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(gn(i[t][1])){const s=yn(i[t][1],e);n=n&&s.isZoomConstant,r=r&&s.isFeatureConstant,i[t]=[i[t][0],s]}const s=on(t,e);return s.isZoomConstant=n&&s.isZoomConstant,s.isFeatureConstant=r&&s.isFeatureConstant,s}const{getTextureMagFilter:wn,getTextureMinFilter:vn,getTextureWrap:Tn,getMaterialType:_n,getMaterialFormat:Mn,getPrimitive:On,getUniqueREGLBuffer:An}=n.REGLHelper,xn=[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:Sn,logoutIBLResOnCanvas:En,getIBLResOnCanvas:Cn,getPBRUniforms:Nn}=n.pbr.PBRUtils,kn={factor:0,units:0},Rn=[1,1,1,1],Ln=[0,0,0],Pn={specularStrength:0,materialShininess:1},Bn=[1,1,1],Un=r.identity([]),Dn=[0,0,0],Fn=[0,0],jn=[],zn=t=>t.material instanceof n.PhongMaterial,qn=t=>t.material instanceof n.pbr.StandardMaterial,Hn=[],Gn=new t.Coordinate(0,0),Vn=new t.Point(0,0),Jn=new t.Point(0,0),$n=new t.Point(0,0),Kn=[],Xn=[],Yn=[],Zn=[],Wn=[],Qn=[],tr=[],er=[],nr=[],rr=[],ir=[],sr=[],or=[],ar=[],cr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},hr=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],lr=function(t,e){const n=2*Math.PI/t,r=[],i=[];for(let i=0;i<=t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=s,r[3*i+2]=o}for(let i=t;i<=2*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=o,r[3*i+1]=t,r[3*i+2]=s}for(let i=2*t;i<=3*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=o,r[3*i+2]=s}const s=r.length/3-1;for(let e=0;e<s;e++)e!==t-1&&e!==2*t-1&&(i[2*e]=e,i[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),i.push(s+1,s+2),i.push(s+1,s+3),i.push(s+1,s+4),{vertices:r,indices:i}}
7
7
  /*!
8
- * @maptalks/gl v0.102.0
8
+ * @maptalks/gl v0.102.2
9
9
  * LICENSE : UNLICENSED
10
10
  * (c) 2016-2024 maptalks.com
11
- */(100,1),ur=[0,0,0,1],fr=[1,1,1];class dr{constructor(t,e){this.h=e,this.u=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.m=t,this.p=new n.Renderer(t),this.v={},this.T={},this._={},this.M={},this.O={},this.A={},this.I=new n.Scene,this.S=new n.Scene,this.C=new n.Scene,this.N=new n.Scene,this.k=new n.ResourceLoader(t.texture(2)),this.R=(...t)=>this.L.call(this,...t),this.P=new n.KHRTechniquesWebglManager(this.m,this.B(),this.k);const r=this.getMap();this.U=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this.M}getPNTSMeshes(){return this._}getB3DMMeshes(){return this.T}getPaintedMeshes(){return this.D}getMap(){return this.h.getMap()}paint(t,e,n,o){const a=o&&o.renderTarget,c=o&&o.sceneFilter,h=this.getMap();if(!t.length||!h)return null;const l=this.F(),u=h.projViewMatrix,f=[],d=[],m=[],g=[],b=[];for(let n=0,s=t.length;n<s;n++){const s=t[n].data.node;let a=this.j(s);if(!a)continue;const c=this.h.q(s.G),h=c.debugNodes,l=c.heightOffset||0,y=c.coordOffset||Fn;this.O[s.id]&&(a=this.O[s.id],a=St(a));let w=c.polygonOffset||kn;yt(w)&&(w=w()),Array.isArray(a)||(f[0]=a,a=f);for(let c=0,f=a.length;c<f;c++){if(!a[c]||!a[c].isValid||!a[c].isValid())continue;const f=a[c].properties.magic;if(a[c].properties.heightOffset===l&&a[c].properties.coordOffset[0]===y[0]&&a[c].properties.coordOffset[1]===y[1]||(this.H(a[c]),a[c].V=r.copy([],a[c].localTransform)),a[c].J=s,"b3dm"===f){if(a[c].getBoundingBox&&!p(u,a[c].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=a[c].geometry.properties;if(t&&e){const t=a[c].properties.node.G;this.$&&this.$[t]?i.highlightMesh(this.m,a[c],this.$[t],this.K,e):this.$&&this.$[t]||i.highlightMesh(this.m,a[c],null,this.K,e),i.showOnly(this.m,a[c],this.X&&this.X[t],this.Y,e)}if(h&&h.length&&h.indexOf(a[c].J.id)<0)continue;o&&o.bloom&&a[c].properties.hlBloomMesh&&(a[c].properties.hlBloomMesh.properties.depthFunc="always",a[c].properties.hlBloomMesh.properties.polygonOffset=w,m.push(a[c].properties.hlBloomMesh)),m.push(a[c])}else"pnts"===f?g.push(a[c]):"i3dm"===f&&b.push(a[c]);a[c].properties.isLeaf=!!e[s.id],a[c].properties.selectionDepth=255-t[n].selectionDepth,a[c].properties.polygonOffset=w,e[s.id]||d.push(a[c]),this.Z(a[c]),this.W(a[c],s)}}let y=0;const w=this.P.getExcludeFilter();s.setIncludeUniformValues(l,o),y+=this.tt(this.et,l,[c,zn,w],a,d,m,b),y+=this.tt(this.nt,l,[c,qn,w],a,d,m,b),this.P.forEachShader(((t,e,n)=>{const r=this.F(n);y+=this.tt(t,r,[c,e],a,d,m,b)})),this.S.setMeshes(g);const v=this.rt();return y+=this.p.render(this.it,v,this.S,a&&a.fbo),this.D={pntsMeshes:g,i3dmMeshes:b,b3dmMeshes:m},this.N.setMeshes(n),this.p.render(this.st,l,this.N,a&&a.fbo),y}prepareRender(t){this.ot(t)}ot(t){t&&t.states&&t.states.includesChanged&&(this.nt.dispose(),delete this.nt,this.et.dispose(),delete this.et),this.ct(t)}tt(t,e,n,r,i,s,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1;const a=r&&r.fbo;let c=0;const h=[];for(let n=0;n<s.length;n++){const{isLeaf:r,selectionDepth:i}=s[n].properties;r&&255===i?(e.stencilEnable&&(this.ht(a),this.I.setMeshes(h),c+=this.p.render(t,e,this.I,a),h.length=0,e.stencilEnable=!1),h.push(s[n])):(e.stencilEnable||(this.I.setMeshes(h),c+=this.p.render(t,e,this.I,a),h.length=0,e.stencilEnable=!0),h.push(s[n])),n===s.length-1&&(e.stencilEnable&&this.ht(a),this.I.setMeshes(h),c+=this.p.render(t,e,this.I,a))}return this.I.setMeshes(s.filter((t=>t.properties.isLeaf))),this.C.setMeshes(o),c+=this.p.render(t,e,this.C,r&&r.fbo),c}ht(t){this.m.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.I.getMeshes()}getCurrentI3DMMeshes(){return this.C.getMeshes()}lt(t,e){return e.J.ut-t.J.ut}deleteTile(t){const e=t.node;e.ft&&(e.ft.geometry.dispose(),e.ft.dispose(),delete e.ft);const n=e.id;this.dt(n)}dt(t){const e=this.T[t]||this._[t]||this.M[t]||this.O[t]||this.v[t];this.O[t]?this.gt(t):e&&(this.bt(e),delete this.T[t],delete this._[t],delete this.M[t],delete this.v[t])}gt(t){let e=this.O[t];e=St(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.dt(n)}delete this.O[t]}bt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.bt(t[e]);else{i.showOnly(this.m,t),i.highlightMesh(this.m,t);const e=t.geometry.properties.url;if(e){const n=this.A[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.A[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.h;En(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.gt(t);this.O={};for(const t in this.T)this.dt(t);this.T={};for(const t in this._)this.dt(t);this._={};for(const t in this.M)this.dt(t);this.M={};for(const t in this.v)this.dt(t);this.v={},this.et&&(this.et.dispose(),delete this.et),this.nt&&(this.nt.dispose(),delete this.nt),this.it&&(this.it.dispose(),delete this.it),this.st&&(this.st.dispose(),delete this.st),this.P.dispose(),this.picking&&this.picking.dispose()}j(t){return this.T[t.id]||this._[t.id]||this.M[t.id]||this.O[t.id]}has(t){return this.j(t)||this.v[t.id]}H(t){const e=t.properties.magic;"b3dm"===e?this.yt(t):"i3dm"===e?this.wt(t):"pnts"===e&&this.vt(t)}createPntsMesh(t,e,i,s){if(this._[e]){const t=this._[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c,compressed_int16_params:h}=t,l=a.POINTS_LENGTH;o.BATCH_ID||(o.BATCH_ID=new Uint8Array(l),o.BATCH_ID.fill(0));const u=new n.Geometry(o,null,l,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.m);const f={};o.POSITION?f.HAS_POSITION=1:o.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),o.RGB?f.HAS_RGB=1:o.RGBA?f.HAS_RGBA=1:o.RGB565&&(f.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,o.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),this.Tt(f,h),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:d,rtcCoord:m,projCenter:p}=t,g=this.h.q(c),b=new n.Mesh(u);b.properties.magic="pnts",b.properties.id=e,b.properties.node=i,b.properties.count=l,b.properties.batchTable=t.batchTable,b.properties.batchTableBin=t.batchTableBin,b.properties.serviceIndex=c,b.properties.rtcCoord=m,b.properties.rtcCenter=d,b.properties.projCenter=p,b.setDefines(f),b.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:g&&g.pointColor||[1,1,1,1]}));const y=this.getMap();let w=null,v=null;b.setFunctionUniform("pointSize",(function(){if(!g)return 2;if(gn(g.pointSize)){const t=JSON.stringify(g.pointSize);t!==w&&(v=bn(g.pointSize),w=t);return v(y.getZoom())}return g.pointSize||2}));let T=null,_=null;return b.setFunctionUniform("pointOpacity",(function(){if(!g)return 1;if(gn(g.pointOpacity)){const t=JSON.stringify(g.pointOpacity);t!==T&&(_=bn(g.pointOpacity),T=t);return _(y.getZoom())}return g.pointOpacity||1})),this._t(b,h),this.vt(b),b.V=r.copy([],b.localTransform),this._[e]=b,s(null,{id:e,mesh:[b]}),[b]}vt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:i}=t.properties;this.Mt(e,n,i,r.G),t.setLocalTransform(e)}createI3DMMesh(t,e,i,s){if(this.M[e]){const t=this.M[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.v[e]||s(null,{id:e,mesh:t}),t}const c=this.h.q(i.G),h=this.Ot(i.At),{i3dm:l,featureTable:u,gltf:f,batchTable:d,batchTableBin:m,count:p}=t,g=u.INSTANCES_LENGTH,{rtcCenter:b,rtcCoord:w,projCenter:v}=t,T=this.xt(Zn,i,b,w);ze(T,Dn,T);const _=r.getRotation(Wn,T);o.normalize(_,_);const M=r.getScaling(Qn,T),O=r.fromScaling(tr,M),A=this.It(er,v,i),x=this.St(ir),I=this.Et(sr,w),S=a.div(or,I,x),E=r.fromScaling(ar,S),{POSITION:C,NORMAL_UP:N,NORMAL_RIGHT:k,SCALE:R,SCALE_NON_UNIFORM:L}=l,P={"instance_vectorA":new Float32Array(4*g),"instance_vectorB":new Float32Array(4*g),"instance_vectorC":new Float32Array(4*g),"aPickingId":new Uint16Array(g)};for(let t=0;t<g;t++)P.aPickingId[t]=t;const B=new Float32Array(3),U=new Float32Array(3),D=[],F=new Float32Array(1),j=new Float32Array(3),z=[],q=[],G=[],H=[];!function(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?y.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*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<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);h.set(i),e(new c(h.buffer),t),i.set(h)}}(C,((t,e)=>{N?(Yt(U,k,e),Yt(B,N,e),a.cross(D,U,B),a.normalize(D,D),It(z,U,0),It(z,B,1),It(z,D,2),o.fromMat3(q,z),o.normalize(q,q),o.multiply(q,_,q)):o.identity(q),R?(Yt(F,R,e),a.set(G,F[0],F[0],F[0])):L?(Yt(j,L,e),a.set(G,...j)):a.set(G,1,1,1),r.fromRotationTranslationScale(H,q,t,G),Zt(P.instance_vectorA,e,H,0),Zt(P.instance_vectorB,e,H,1),Zt(P.instance_vectorC,e,H,2)}));const V={};for(const t in P)V[t]={buffer:this.m.buffer({dimension:P[t].length/g,data:P[t]}),divisor:1};const J=c.shader||"pbr";let $=0,K=!0;const X=[],Y=[];return qt(f,((t,s,o,a)=>{const c=this.Ct(t,s,o,a,i,!0,J,Y),{geometry:l,material:f}=c;f&&!f.isReady()&&(K=!1,$++);const y=new n.InstancedMesh(V,g,l,f);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(y.uuid)),y.properties.magic="i3dm",y.properties.id=e,y.properties.count=p,y.properties.batchTable=d,y.properties.batchTableBin=m,y.properties.serviceIndex=i.G,y.properties.rtcCoord=w,y.properties.rtcCenter=b,y.properties.projCenter=v,y.properties.node=i;const _=this.Nt(t,l,f,i.G,a);t.compressed_int16_params&&this._t(y,t.compressed_int16_params),this.kt(y,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]);r.multiply(M,h,M),r.multiply(M,E,M),u.EAST_NORTH_UP||N?r.multiply(M,O,M):r.multiply(M,T,M),y.setPositionMatrix(M),this.wt(y,A),y.setDefines(_),y.properties.polygonOffset={offset:0,factor:0},X.push(y),delete t.attributes,y.V=r.copy([],y.localTransform)})),mr(Y),K?(this.M[e]=X,s(null,{id:e,mesh:X})):(this.v[e]={meshes:X,count:$},X.Rt=s),X}wt(t,e){const{rtcCoord:n,node:i,projCenter:s}=t.properties;e||(e=this.It(er,s,i));const o=this.h.q(i.G),a=t.localTransform||[];if(o.coordOffset){const t=this.Lt(Zn,i.G,n);r.multiply(a,t,e)}else r.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||Fn}It(t,e,n){r.fromScaling(t,this.St(ir));const i=this.Pt(Xn,e,n.G);return r.multiply(t,r.fromTranslation(nr,i),t),t}createB3DMMesh(e,i,s,o){if(e.gltf&&(e.gltf.transferables=null),this.T[i]||this.v[i]){const t=this.T[i];return console.warn(`mesh with id(${i}) was already created.`),this.v[i]||o(null,{id:i,mesh:t}),t}let a;if(s.maxExtent){const e=new t.Extent(s.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:l,center:u}=c.extensions.CESIUM_RTC,f=c.asset.sharePosition,d=this.Ot(s.At),m=this.Bt(er,f,l,u,h,s),p=this.h.q(s.G);let g=p.shader||"pbr";if(p.unlit)g="phong";else 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){g="phong";break}const b=[],y=[];let w=0,v=!0;return qt(c,((t,o,c,T)=>{const _=this.Ct(t,o,c,T,s,!1,g,b),{geometry:M,material:O}=_;O&&!O.isReady()&&(v=!1,w++);const A=new n.Mesh(M,O);_.refMeshes||(_.refMeshes=new Set,_.refMeshes.add(A.uuid)),A.properties.magic="b3dm",A.properties.id=i,A.properties.node=s,e.batchTable&&(A.properties.batchTable=e.batchTable,A.properties.batchTableBin=e.batchTableBin),A.properties.count=e.featureTable&&e.featureTable.BATCH_LENGTH||0,A.properties.serviceIndex=s.G;const x=this.Nt(t,M,O,s.G,T);A.setDefines(x);const I=t.compressUniforms;if(I)for(const t in I)A.setUniform(t,I[t]);t.compressed_int16_params&&this._t(A,t.compressed_int16_params),this.kt(A,t.attributes),a&&(x.USE_MAX_EXTENT=1,A.setUniform("maxPrjExtent",a)),A.hasFunctionUniform("polygonOpacity")||A.setFunctionUniform("polygonOpacity",(function(){return vt(p.opacity)?p.opacity:1})),A.hasFunctionUniform("polygonFill")||A.setFunctionUniform("polygonFill",(function(){return Lt([],p.polygonFill||Rn)})),A.material.hasFunctionUniform("hsv")||A.material.setFunctionUniform("hsv",(function(){return p.hsv||Ln}));const S=r.identity([]);if(f&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(S,S,t.matrices[e]);f&&r.multiply(S,d,S),A.properties.node=s,A.properties.projCenter=h,A.properties.nodeMatrix=S,A.properties.isSharedPosition=f,A.properties.rtcCoord=l,A.properties.rtcCenter=u,this.yt(A,m),y.push(A),delete t.attributes,A.V=r.copy([],A.localTransform)})),mr(b),v?(this.T[i]=y,o(null,{id:i,mesh:y})):(this.v[i]={meshes:y,count:w},y.Rt=o),y}Ut(t){const e=this.h.Dt(t.id);if(!e||t.ft)return;let i,s,o,a;if(e.obbox)i=e.boxPosition,s=hr,o=e.boxCenter,a=fr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];i=lr.vertices,s=lr.indices,o=t,a=[n,n,n]}const c=new n.Geometry({POSITION:i},s,0,{primitive:"lines",positionAttribute:"POSITION"}),h=new n.Mesh(c,new n.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),l=[];r.fromRotationTranslationScale(l,ur,o,a),h.localTransform=l,h.V=r.copy([],l),h.properties.node=t,t.ft=h}Ft(t){t.ft&&(t.ft.geometry.dispose(),t.ft.dispose(),delete t.ft)}_t(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}yt(t,e){const{isSharedPosition:n,rtcCoord:i,rtcCenter:s,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Bt(e||er,n,i,s,o,c));const h=t.localTransform||r.identity([]);r.multiply(h,e,a);const l=this.h.q(c.G);if(l.coordOffset){const t=this.Lt(Zn,c.G,i);r.multiply(h,t,h)}t.setLocalTransform(h),t.properties.heightOffset=l.heightOffset||0,t.properties.coordOffset=l.coordOffset&&l.coordOffset.slice(0)||Fn}Bt(t,e,n,i,s,o){if(e){const e=this.Et(sr,n),s=r.fromScaling(Yn,e),a=this.xt(Zn,o,i,n);r.multiply(t,a,s)}else this.Mt(t,n,s,o.G);return t}kt(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)}}xt(t,e,n,i){const s=this.getMap(),o=this.h.q(e.G).heightOffset||0,c=e.matrix?r.copy(t,e.matrix):r.identity(t);if(n){ze(c,a.transformMat4(Gn,n,c),c)}const h=function(t,e,n,r,i,s,o){e=_.copy(Ge,e);const a=ne(Ge,e[0]*We,e[1]*We,e[2]),c=T.getTranslation(He,n),h=r.ellipsoid;let l;l=0===_.len(c)?_.set(Ve,0,0,-6378137):ce(Ve,c),Ye.x=l[0],Ye.y=l[1];const u=r.project(Ye,Ze);Je[0]=u.x/i,Je[1]=u.y/i,Je[2]=(l[2]+o)*s;const f=qe(a,h,$e);return ze(function(t,e,n){const r=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],h=t[8],l=t[9],u=t[10],f=e[0],d=e[1],m=e[2],p=e[3],g=e[4],b=e[5],y=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,_=i*f+a*d+l*m,M=s*f+c*d+u*m,O=r*p+o*g+h*b,A=i*p+a*g+l*b,x=s*p+c*g+u*b,I=r*y+o*w+h*v,S=i*y+a*w+l*v,E=s*y+c*w+u*v;return n[0]=T,n[1]=_,n[2]=M,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=E,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(T.invert(Ke,f),M.fromMat4(Xe,n),t),Je,t),t}(c,i,c,s.getProjection(),s.getGLRes(),this.U,o),l=function(t,e){return _.set(t,e[12],e[13],e[14]),t}(Xn,h);let u=this.h.options.offset;if(yt(u)){const t=this.h.Dt(e.id).boxCoord;u=u.call(this.h,t)}return a.set(Kn,u[0],u[1],0),a.sub(l,l,Kn),ze(h,l,h),h}Lt(t,e,n){const i=this.h.q(e);if(!i.coordOffset)return null;const s=this.getMap(),o=s.getGLRes();Hn.set(n[0],n[1]);const c=s.coordToPointAtRes(Hn,o,Jn),h=i.coordOffset,l=Hn.set(n[0]+h[0],n[1]+h[1]),u=s.coordToPointAtRes(l,o,$n),f=u.x-c.x,d=u.y-c.y,m=this.U,p=a.set(Kn,f,d,(h[2]||0)*m);return r.fromTranslation(t,p)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:r}=i[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"i3dm"===r?this.createI3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"pnts"===r?this.createPntsMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"cmpt"===r&&this.createCMPTMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)}))}return this.O[e]=s,r(null,{id:e,mesh:s}),s}Nt(t,e,n,r,i){const s=("phong"===(this.h.q(r).shader||"pbr")?this.et:this.nt).getGeometryDefines(e);i.asset&&"S3M"===i.asset.generator&&this.jt(s,e),e.data.uvRegion&&(s.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(s.VertexNormal=1),e.data[e.desc.color0Attribute]&&(s.VertexColor=1),e.data[e.desc.uv0Attribute]&&(s.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(s.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(s.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(s.TexCoord2=1),"MESHOPT"===this.h.zt&&(s.MeshOPT_Compress=1),this.hasIBL()&&(s.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(s.HAS_WEB3D_quantized_attributes_TEXCOORD=1),s.HAS_MIN_ALTITUDE=1,s.HAS_LAYER_OPACITY=1,this.Tt(s,t.compressed_int16_params);return bt(s,t.compressDefines),s}Tt(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}Z(t){const e=this.h.getRenderer();e&&e.updateMaskDefines(t)}jt(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)}Ct(t,e,r,i,s,o,a,c){let h=!1;i.asset&&"S3M"===i.asset.generator&&(h=!0,i.extensions=i.extensions||{});const l=i.url+"-"+e+"-"+r;if(this.A[l])return this.A[l];let u,f;c.push(t);const d=i.materials&&i.materials[t.material],m=i.extensions&&i.extensions.KHR_techniques_webgl,p=this.h.q(s.G);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){const e=this.qt(t,i,o,h);u=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.Gt(t,o,cr);const e=p.material;u=this.Ht(t.material,i,a,e||Pn,c,p)}u&&(u.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return gt(t)?.1:t})),u.setFunctionUniform("environmentExposure",(()=>{const t=p.ambientLight;let e=p.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),u&&!u.isReady()?u.Vt=s.id:u||(u=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const g={geometry:f,material:u};return f.properties.url=l,this.A[l]=g,g}qt(t,e,n,r){const{geometry:i,material:s}=this.P.createMesh(t,e,n,r);return{geometry:i,material:s}}Gt(t,e,r){const i=t.attributes,s="COLOR_0";let o=i._BATCHID&&i._BATCHID.array;if(o&&o.byteOffset&&(o=new o.constructor(o)),i[s]){const t=i[s].array||i[s];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[s].array?(i[s].array=e,i[s].componentType=5121):i[s]=e}}const a={};for(const t in i){const e=An(this.m,i[t],{dimension:i[t].itemSize}),n=r[t]||t;a[n]={buffer:e},i[t].quantization&&(a[n].quantization=i[t].quantization),n===r.POSITION&&(a[n].array=i[t].array,a[n].min=i[t].min,a[n].max=i[t].max)}const c=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,h=new n.Geometry(a,c,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":On(t.mode)});return o&&c&&(h.properties.batchIdData=o,h.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],s=t[i];let o=n.get(s);o||(o=[],n.set(s,o)),o.push(i)}return n}(o,c)),h.generateBuffers(this.m,{excludeElementsInVAO:e}),h}Mt(t,e,n,i){const s=r.identity(t),o=this.St(Bn);return this.Pt(Xn,n,i),r.translate(s,s,Xn),r.scale(s,s,o),s}Pt(t,e,n){const r=this.U;Hn.x=e[0],Hn.y=e[1];const i=this._prjToPoint(Hn);let s=this.h.options.offset;yt(s)&&(s=s.call(this.h,Hn));const o=this.h.q(n).heightOffset||0;return a.set(t,i.x-s[0],i.y-s[1],r*e[2]+r*o),t}W(t,e){const n=this.h.Jt(rr,e);t.localTransform=r.multiply(t.localTransform,n,t.V)}Et(t,e){const n=this.getMap();Hn.x=e[0],Hn.y=e[1];const r=n.distanceToPointAtRes(100,100,n.getGLRes(),Hn),i=this.U;return a.set(t,r.x/100,r.y/100,i),t}ct(t){if(this.nt)return;const e={x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},i=[],o=[];this.it=new n.MeshShader({vert:Wt,frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n\n if (dot(circCoord, circCoord) > 1.0) {\n\n discard;\n\n } else {\n\n gl_FragColor = vColor;\n\n }\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(o,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>c.fromMat4(i,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const a={},h=[];s.fillIncludes(a,h,t);const l=this.B();this.et=new n.PhongShader({uniforms:h,defines:a,extraCommandProps:l}),this.nt=new n.pbr.StandardShader({uniforms:h,defines:a,extraCommandProps:l}),this.st=new n.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const u=this.h;Sn(u.getRenderer().canvas,this.m,u.getMap()),this.picking=new n.FBORayPicking(this.p,{vert:this.nt.vert,extraCommandProps:l,uniforms:this.nt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.$t=new n.FBORayPicking(this.p,{vert:Wt,extraCommandProps:l,uniforms:this.it.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}B(){return{viewport:{x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},cull:{enable:!0},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.selectionDepth},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:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}rt(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:a.normalize(jn,r)}}F(){const t=this.getMap(),e=this.h,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:i}=Cn(n),s=Nn(t,r,i),o=this.h.getRenderer(),a=o.getMaskUniforms();s.minAltitude=e.options.altitude||0;const c=o.canvas.gl&&o.canvas.gl.wrap?e.options.opacity||0:1;return s.layerOpacity=c,bt(s,{czm_lightDirectionEC:s.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),bt(s,a),s}Ht(t,e,r,i,s,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=bt({},i);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Kt(t,s)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Kt(e.textures[a.normalTexture.index],s);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Kt(e.textures[a.occlusionTexture.index],s);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Kt(e.textures[a.emissiveTexture.index],s);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];if(n&&n.image&&n.image.color)c.baseColorFactor=c.baseColorFactor?h.multiply(c.baseColorFactor,c.baseColorFactor,n.image.color):n.image.color;else{const t=this.Kt(n,s);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.m))}}if(gt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),gt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Kt(e.textures[a.metallicRoughnessTexture.index],s);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){c.ambientColor=[1,1,1],c.light0_diffuse=[0,0,0,0],c.lightSpecular=[0,0,0];const t=new n.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.pbr.StandardMaterial(c);"phong"===r&&(l=n.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,f=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(l.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",f.KHR_texture_transform.rotation||0),l.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.R),l}Kt(t,e){if(!t)return null;const r={type:t.type?_n(t.type):"uint8",format:t.format?Mn(t.format):"rgba",flipY:!!t.flipY},i=t.image;if(e.push(i),i.array?r.data=i.array:i.mipmap&&(r.mipmap=i.mipmap),!r.data&&!r.mipmap)return null;if(r.width=i.width,r.height=i.height,r.mipmap&&(r.width<4||r.height<4))return null;const s=t.sampler||t.texture&&t.texture.sampler;return s&&(s.magFilter&&(r.mag=wn(s.magFilter)),s.minFilter&&(r.min=vn(s.minFilter)),s.wrapS&&(r.wrapS=Tn(s.wrapS)),s.wrapT&&(r.wrapT=Tn(s.wrapT))),new n.Texture2D(r,this.k)}L({target:t}){const e=t.Vt,n=this.v[e];if(n.count--,!n.count){const t=n.meshes;this.T[e]=t,delete this.v[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}St(t){const e=1/this.getMap().getGLRes(),n=this.U;return t[0]=t[1]=e,t[2]=n,t}Xt(t){return this.h.Xt(t)}_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(),Vn)}Ot(t){return"Y"===t?xn:"X"===t?In:Un}pick(t,e,n=3){const r=this.h;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=[],s=this.F(),o=this.Yt(this.picking,s,this.I,t,e,n);o&&i.push(o);const a=this.Yt(this.picking,s,this.C,t,e,n);a&&i.push(a);const c=this.rt(),h=this.Yt(this.$t,c,this.S,t,e,n);return h&&i.push(h),i}Yt(t,e,n,r,i,s){if(!n.getMeshes().length)return null;const o=this.h,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,i,s,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:h,pickingId:l,point:u,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.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 p={batchId:l},g=o.options.services,b=g&&g[d.properties.serviceIndex];if(b&&b.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=l;for(const i in t)void 0!==t[i].byteOffset?p[i]=Ae(t[i],e,n,r):p[i]=t[i][r]}return{service:d.properties.serviceIndex,data:p,point:u,coordinate:f}}highlight(t){this.$=t;const e=this.h.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.$=null;const t=this.h.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.X=t;const e=this.h.getRenderer();this.Y=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.X=null;const t=this.h.getRenderer();this.Y=t.getFrameTimestamp(),t.setToRedraw(!0)}Zt(){if(!this.D)return[];const t={},e=[];for(const n in this.D){const r=this.D[n];if(r)for(let n=0;n<r.length;n++){const i=r[n],s=i&&i.geometry;if(!i||!s)continue;const o=i.properties.serviceIndex;t[o]||(t[o]=new Set);const a=s.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())}}function mr(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}const pr=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")},gr=pr(),br=gr.gl_trans__coders=gr.gl_trans__coders||{};function yr(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}br.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=gr.gl_trans__coders=gr.gl_trans__coders||{};let s=`${r}\n const _____getGlobal = ${pr.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&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return s+="\n"+e.substring(r.length),s},br.registerTranscoder=function(t,e){br[t]=e},br.getTranscoder=function(t){return br[t]};const wr=[];class vr{constructor(t,e,n,r,i){this.h=r,this.Wt=t,this.G=e,this.Qt=i,this.te=n.version,t.indexOf("i3s:tileset:")<0?(this.te<=1.6?this.ee="root":this.ee=0,n.version=this.te):(this.ee=t.substring(12),this.te>1.6&&(this.ee=parseInt(this.ee))),this.Wt=t,this.ne=n}load(){const t=this.ne,e=t.layerScene.baseUrl;if(this.te<=1.6)return t[this.ee]&&t[this.ee].lodSelection?(this.re=t[this.ee],this.ie()):new Promise((n=>{let r=e+"/nodes/"+this.ee;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Qt(this.G,r,(()=>{this.re=t[this.ee],n(this.ie())}))}));if(this.te>=1.7){if(t[this.ee])return this.re=t[this.ee],this.ie();const n=Math.floor(this.ee/t.nodesPerPage);return new Promise((r=>{let i=e+"/nodepages/"+n;t.layerScene.eslpk&&(i+=".json"),this.Qt(this.G,i,(()=>{this.re=t[this.ee],r(this.ie())}))}))}return null}getTileset(){return this.se}getChildrenURL(){return this.oe}ie(){const t=this.ne,e=t.layerScene.baseUrl,n=this.re.children,r=[],i={};if(n)for(let s=0;s<n.length;s++)if(this.te<=1.6){const o=n[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Qt(this.G,r,(()=>{n()}))})),r.push(i[a]))}else{const o=n[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.Qt(this.G,r,(()=>{n()}))})),r.push(i[a]))}return r.length?Promise.all(r).then((()=>this.ae())):this.ae()}ae(){return Promise.resolve(this.ce())}he(t){yr(this.ne,t)}ce(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.le(this.re,!0)}}le(t){const e=this.h.getRenderer(),n=this.ne.projection,r=!n||n&&4326===n.wkid,i=this.te,s=this.ne,o=t,a=o.obb,c=o.mbs,h={};let l;if(c)l=_.set([],c[0],c[1],c[2]),r||(l=e.ue(l,l)),l=Tr([],l[0],l[1],l[2]),h.sphere=[...l,c[3]];else if(a){l=_.set([],a.center[0],a.center[1],a.center[2]),r||(l=e.ue(l,l)),l=Tr([],l[0],l[1],l[2]);const t=function(t,e,n){const r=M.fromQuat([],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]}(l,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],i=t[4]+t[7]+t[10],s=t[5]+t[8]+t[11];_.set(wr,n,i,s);const o=_.len(wr);h.sphere=[...l,o]}let u=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===s.lodSelectionMetricType){u=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(u=f/o.lodSelection[t].maxError);(u===1/0||isNaN(u))&&(u=1e5);const d=16*u,m=T.identity([]),p=o.children;let g;if(p){g=[];const t=this.ne;for(let e=0;e<p.length;e++){const n=i<=1.6?p[e].id:p[e];if(!t[n]){g=null;break}g.push(this.le(t[n]))}}const b={refine:"REPLACE",boundingVolume:h,transform:m,geometricError:d};return i<=1.6?t.lodSelection?t.geometryData&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}):b.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!g?b.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}),g&&g.length&&(b.children=g),b}getJSON(){return this.re}}function Tr(t,e,n,r){return ne(t,Tt(e),Tt(n),r)}const _r=!!br.ktx2,Mr=r.identity([]),Or=(()=>{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 Ar(t){return t.indexOf("i3s:mesh")>=0}const xr=9;function Ir(t,e,n,r,i){const s=e.layerScene.eslpk,o=function(t,e){const n=e.substring(xr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let l=!1;const u=Mr;let f,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;s&&(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",s&&(i+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}h.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions[f.definition],{geometryBuffers:o}=t;l=r&&2===o.length;const u=br.draco&&l?o[1]:o[0],m=br.draco&&l?1:0;let p=c+`/nodes/${f.resource}/geometries/`+m;s&&(p+=".bin");const g={geometry:{url:p,info:u}};if(i&&Or&&l&&!br.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const b=e.layerScene.materialDefinitions,y=e.layerScene.textureSetDefinitions;let w,v=0;if(d&&(v=b[d.definition]),b){w=function(t,e,n,r,i,s){const o=JSON.parse(JSON.stringify(t));return Sr(o,e,n,r,i,s),o}(v,y,c,d.resource,n,e.layerScene.eslpk)}else w={pbrMetallicRoughness:{metallicFactor:0}};g.material=w,h.push(g)}return{dracoCompression:l,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function Sr(t,e,n,r,i,s){for(const o in t)if(t[o]&&t[o].textureSetDefinitionId>=0){const a=e[t[o].textureSetDefinitionId],c="images/"+a.formats[0].format,h=Er(a.formats,i),l={url:n+`/nodes/${r}/textures/${h.name}`,factor:void 0===t[o].factor?1:t[o].factor,format:h.format,mimeType:c};if(s){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}l.url+="."+t}t[o]=l}else wt(t[o])&&Sr(t[o],e,n,r,i,s)}function Er(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&&_r)return t[n]}return null}const Cr=new t.Coordinate(0,0),Nr=new t.Coordinate(0,0),kr=new Set,Rr=[],Lr=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.fe(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}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){let t=!1;const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){!t&&this.data.get(n.value).current&&(t=!0,console.warn(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`));const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.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 this.fe(t,e),this}fe(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}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,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(t.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let Pr=0;class Br extends(l(t.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>Lr.max&&Lr.setMaxSize(e),this.tileCache=Lr,Pr++,this.tilesLoading={},this.de={},this.me=[],this.Qt=(...t)=>this.pe.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return Rr;const t=this.painter.getPaintedMeshes();if(!t)return Rr;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:i}=t;return n.length&&kt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&kt(e,r.filter((t=>!(!t||!t.geometry)))),i.length&&kt(e,i.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.me.length||super.needToRedraw())}getFrameTimestamp(){return this.ge}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.ge=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.painter.prepareRender(e),this.be(),this.ye(e);const{selectedTiles:o,leaves:a,requests:c}=this.we(r,i);c.length&&this.loadTiles(c),this.ve(o,a,e),this.Te(),c.length||this.completeRender()}we(t,e){let n=[];this._e();let r=0;const i=this.Me(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let h=!1;const l=this.getCachedTile(c.id);if(this.Oe(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):l?(this.getTileOpacity(l)<1&&(h=a=!0),o=!0,i.selected=!0,i.data=l):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this.Ae(i))o=!0;else{this.xe(i).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.Ie(t)),n.length>1&&(n.sort(Ur),i)){const t=i-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}Ie(t){const e=[],n={};let r;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.Se===i.length){s.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=i.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=s.length,e.push(t);else{if(t.selectionDepth=s.length,r=t,0===o.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}s.push(t),t.Se=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return{selectedTiles:e,leaves:n}}Ae(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.Ee+1,r=[t.node];for(;r.length>0;){const i=r.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){r.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const n=this.layer.Ce(i[s],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else i[s].Ee<=n&&r.push(i[s])}}return e}ve(t,e,n){this.tileCache.markAll(this,!1);const r=[];for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,n.renderer=this,this.tileCache.add(t[e].node.id,n);const i=n.node,s=this.layer.q(i.G);i.ft&&s.debug&&!Array.isArray(s.debug)&&r.push(i.ft)}const i=this.layer.options.services;for(let t=0;t<i.length;t++){const e=i[t],n=Array.isArray(e.debug)&&e.debug;if(n)for(const t of n){const e=this.layer.Dt(t),n=e&&e.node;n&&n.ft&&r.push(n.ft)}}const s={tiles:t,leaves:e};this.onDrawTileStart(s);const o=this.painter.paint(t,e,r,n);this.layer.fire("drawtiles",{count:o}),this.onDrawTileEnd(s),o&&this.layer.fire("canvasisdirty",{renderCount:o}),this.tileCache.shrink()}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(Ct(e)){const n=Nt(e);return this.Ne(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.G,r=this.ke[n];return new vr(e,n,r,this.layer,this.Qt).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Bt(e)&&!Ar(e)&&(e=t.baseUrl+e),this.Ne(e,null,t),null}Ne(t,e,r){let i=this.Re;i||(i=n.Util.getSupportedFormats(this.gl.gl||this.gl),this.Re=i);const s=this.layer.q(r.G);s.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),i=[];for(let t=0;t<r.length;t++)i.push(encodeURIComponent(r[t]));return e+i.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Le[r.G]),arraybuffer:e,rootIdx:r.G,upAxis:r.At,transform:r.matrix,supportedFormats:i};if(Ar(t)){const e=this.ke[r.G];if(o.projection=e.projection,o.i3sInfo=Ir(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=bt({},s),s.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:i}=n;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i||"gltf"===i?this.me.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Ut(t){this.painter&&this.painter.Ut(t)}Ft(t){this.painter&&this.painter.Ft(t)}ye(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.me.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.me.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})),n++}}Pe(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.Be(r);e.memorySize=n,this.onTileLoad(t,e)}}Be(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Be(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.Ue(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.zt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.De(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(e,n,r){if(!this.layer)return;const i=r||n.content.url,s=e&&e.message||e;e&&(404===e.status||204===e.status)||kr.has(s)||(console.warn("failed to load 3d tile: "+i),console.warn(e),kr.add(s)),delete this.tilesLoading[n.id],(!this.layer.options.onlyCacheNoContentTileWhenError||e&&!t.Util.isNoContentHttpCode(e.status))&&this.Fe(n,e),this.setToRedraw(),this.layer.fire("tileerror",{node:n,error:e})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return;const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}Fe(e,n){const r={loadTime:t.Util.now(),current:!0,error:n,node:e};r.renderer=this,this.tileCache.add(e.id,r)}Ue(e){const n={loadTime:t.Util.now(),current:!0,node:e};n.renderer=this,this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.de[e]}_e(){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.je(this.canvas,e)),this.regl=this.regl||u({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),this.prepareWorker(),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 dr(this.regl,t),this.layer.ze(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Ft("@maptalks/3dtiles",t.id,n.Util.supportNPOT(this.regl)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=bt({},r),delete r.offset;const i=t.options.spatialReference;r.projection=i&&i.coordType||i&&i.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,r,(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),Pr--,Pr||Lr.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.Te(!0),this.tileCache.reset(this),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}Te(t){this.qe||(this.qe=Date.now());const e=Date.now();if(!t&&e-this.qe<this.layer.options.retireInterval)return;this.qe=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Me(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}je(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}Oe(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 Me(t,e,0,n)}be(){if(!this.Ge)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.Ge){const i=this.Ge[r];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx,o=Ut(this.layer.q(s).fetchOptions);if(n.push(w.getJSON(r,o).then((t=>{delete this.Ge[r];const e=this.ke[s];if(e){t.nodes?yr(e,t.nodes):(e[t.id]=t,yr(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)}pe(t,e,n){this.Ge||(this.Ge={}),this.Ge[e]=this.Ge[e]||[],this.Ge[e].rootIdx=t,this.Ge[e].push(n),this.setToRedraw()}De(t,e,n){this.ke||(this.ke=[]);const r=e.G;this.ke[r]||(this.ke[r]={});const i=this.ke[r],s=this.layer.q(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),i.version=+(s.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),i.projection=t.spatialReference,function(t,e,n,r,i,s,o){if(!s.layerScene){s.layerScene=e,s.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,s.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=i;if(s.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=i.lastIndexOf("/");t=e<0?"./":i.substring(0,e)}s.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new vr(i,n,s,t,o).load()}(this.layer,t,r,0,n,i,this.Qt).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:i,height:s}=this.canvas;return!this.pickingFBO||r.width===i&&r.height===s||r.resize(i,s),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.$||(this.$=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.$[n];r||(r=this.$[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.$[e];n||(n=this.$[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.$)}cancelHighlight(t,e){if(!this.$)return;const n=this.$[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.$[t]=null),this.painter.highlight(this.$)}}cancelAllHighlight(){delete this.$,this.painter.cancelAllHighlight()}showOnly(t){if(this.X||(this.X=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.X[n];r||(r=this.X[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.X[e];n||(n=this.X[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.X)}cancelShowOnly(){delete this.X,this.painter.cancelShowOnly()}Zt(){return this.painter?this.painter.Zt():[]}ue(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.He();return Cr.set(e[0],e[1]),n.unproject(Cr,Nr),t[0]=Nr.x,t[1]=Nr.y,t}return Cr.set(e[0],e[1]),n.getProjection().unproject(Cr,Nr),t[0]=Nr.x,t[1]=Nr.y,t}Ve(t,e){const n=this.He();return Cr.set(e[0],e[1]),n.project(Cr,Nr),t[0]=Nr.x,t[1]=Nr.y,t}Je(t,e){const n=this.He();return Cr.set(e[0],e[1]),n.unproject(Cr,Nr),t[0]=Nr.x,t[1]=Nr.y,t}He(){const e=this.getMap().options.spatialReference.coordType;if(!e)throw new Error("Missing coordType in map spatialReference.");return this.$e||(this.$e=t.SpatialReference.getProjectionInstance(e)),this.$e}}function Ur(t,e){return t.ut-e.ut}function Dr(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=_.subtract(jr,n,t),i=Dr(zr,e,0),s=Dr(qr,e,1),o=Dr(Gr,e,2),a=_.len(i),c=_.len(s),h=_.len(o);_.normalize(i,i),_.normalize(s,s),_.normalize(o,o);const l=Hr;l[0]=_.dot(r,i),l[1]=_.dot(r,s),l[2]=_.dot(r,o);let u,f=0;l[0]<-a?(u=l[0]+a,f+=u*u):l[0]>a&&(u=l[0]-a,f+=u*u);l[1]<-c?(u=l[1]+c,f+=u*u):l[1]>c&&(u=l[1]-c,f+=u*u);l[2]<-h?(u=l[2]+h,f+=u*u):l[2]>h&&(u=l[2]-h,f+=u*u);return f}(t,e,n))}const jr=[],zr=[],qr=[],Gr=[],Hr=[];const Vr=2*Math.PI;class Jr{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 s=t.east;return s<i&&(s+=Vr,n<0&&(n+=Vr)),(n>i||be(n,i,1e-14))&&(n<s||be(n,s,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 $r=[0,0,1];function Kr(t,e){return ne(e,t[0],t[1],t[2])}class Xr{constructor(t,e){this.normal=a.copy([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-a.dot(e,t);return a.copy(n.normal,e),n.distance=r,n}}const Yr=[],Zr=[],Wr=[],Qr=[],ti=[],ei=[],ni=[],ri=[],ii=[],si=[],oi=new Xr([1,0,0],0),ai=[];class ci{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new Jr(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!Jr.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,r=this.northeastCornerCartesian,i=this.westNormal,s=this.southNormal,o=this.eastNormal,c=this.northNormal,h=a.subtract(ai,t,e),l=a.dot(h,i),u=a.dot(h,s),f=a.subtract(ai,t,r),d=a.dot(f,o),m=a.dot(f,c);l>0?n+=l*l:d>0&&(n+=d*d),u>0?n+=u*u:m>0&&(n+=m*m)}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;Kr(Jr.southwest(t,Zr),e.southwestCornerCartesian),Kr(Jr.northeast(t,Zr),e.northeastCornerCartesian),Yr[0]=t.west,Yr[1]=.5*(t.south+t.north),Yr[2]=0;const n=Kr(Yr,Wr),r=a.cross(ti,n,$r);a.normalize(e.westNormal,r),Yr[0]=t.east;const i=Kr(Yr,ri),s=a.cross(ti,$r,i);a.normalize(e.eastNormal,s);const o=a.subtract(ti,n,i),c=a.normalize(Qr,o),h=t.south;let l;if(h>0){Yr[0]=.5*(t.west+t.east),Yr[1]=h;const n=Kr(Yr,ii);a.copy(si,c);const r=Xr.fromPointNormal(e.southwestCornerCartesian,e.westNormal,oi);hi(ii,si,r,e.southwestCornerCartesian),l=me(n,ei)}else l=pe(Jr.southeast(t,Zr),ei);const u=a.cross(ni,l,o);a.normalize(e.southNormal,u);const f=t.north;let d;if(f<0){Yr[0]=.5*(t.west+t.east),Yr[1]=f;const n=Kr(Yr,ii);a.scale(si,c,-1);const r=Xr.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,oi);hi(ii,si,r,e.northeastCornerCartesian),d=me(n,ei)}else d=pe(Jr.northwest(t,Zr),ei);const m=a.cross(ni,o,d);a.normalize(e.northNormal,m)}}function hi(t,e,n,r){const i=t,s=e,o=n.normal,c=a.dot(o,s);if(Math.abs(c)<1e-15)return;const h=(-n.distance-a.dot(o,i))/c;return h<0?void 0:(r=a.scale(r,s,h),a.add(r,i,r))}function li(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const ui=t.BBOXUtil,fi={"services":[],"maxGPUMemory":t.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"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"]},di=[0,0,0],mi=[0,0,0],pi=[0,0,0],gi=[0,0,0],bi=[0,0,0],yi=[0,0,0],wi=[0,0,0],vi=[1,1,1],Ti=[1,1,1],_i=[0,0,0,0],Mi=[],Oi=new t.Coordinate(0,0),Ai=new t.Point(0,0),xi=[0,0,0,0,0,0,0,0,0],Ii=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Si=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ei=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ci=new t.Point(0,0),Ni=r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),ki=[0,0],Ri=[0,0,0],Li=[1,1,1],Pi=[0,0,0],Bi=[0,0,0],Ui=[0,0,0,0],Di=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class Fi extends(f(t.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new Fi(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],n=[0,0,0]){const i=ne([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),s=qe(i,null,[]),a=o.fromEuler([0,0,0,0],...n),c=r.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,[0,0,0],e);return r.multiply(c,s,c)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Ke(),this.Xe=[]}Ke(){const t=this.options.services.map((t=>t.url));this.Ye=this.Ye||{},this.Le=this.Le||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Ye[n];void 0===r&&(r=this.Ye[n]=this.Le.length),this.Le[r]=qi(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Le.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Ze(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Ke(),this.Ze(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(Vi(n[t].coordOffset,e.coordOffset)&&Vi(n[t].heightOffset,e.heightOffset)&&Vi(n[t].scale,e.scale)&&Vi(n[t].rotation,e.rotation)),bt(n[t],e));const i=n[t].url,s=this.Ye[i],o=this.Le&&this.Le[s];return o&&(gt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Ze(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Ye[n];this.Le[r]&&(this.Le[r]=null),delete this.Ye[n],e.splice(t,1)}return this.Ze(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const i=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Le.length;t++){const n=this.Le[t];if(n&&n.boundingVolume){const t=this.boundingVolumeToExtent(n);e._combine(t)}}return e}const n=this.Le[e];return n&&n.boundingVolume?this.boundingVolumeToExtent(n):null}boundingVolumeToExtent(e){const n=e.boundingVolume.We?Ni:e.matrix,r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),s=this.getRenderer();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(_t(n[0]),_t(n[1]),_t(n[2]),_t(n[3]))}if(e.boundingVolume.sphere){const o=e.boundingVolume.sphere,c=ce([],a.transformMat4([0,0,0],o,n));i&&s.Ve(c,c);const h=o[3],l=r.locate(c,-h,h),u=r.locate(c,h,-h);return new t.Extent(l,u)}if(e.boundingVolume.box){const o=e.boundingVolume.box,h=a.transformMat4([0,0,0],o,n),l=new t.Coordinate(ce([],h));i&&s.Ve(l,l);const u=o.slice(3);c.multiply(u,c.fromMat4([0,0,0,0,0,0,0,0,0],e.matrix),u);const f=a.length(u.slice(0,3)),d=a.length(u.slice(3,6)),m=a.length(u.slice(6,9)),p=Math.max(f,d,m),g=r.locate(l,-p,p),b=r.locate(l,p,-p);return new t.Extent(g,b)}return null}getRootTiles(){return this.Le}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Ze(),{tiles:Mi};const e=this.getMap(),n=e.cameraPosition,r=e.pointAtResToDistance(n[2],0,e.getGLRes()),i=this.Qe(n);this.tn=this.tn||[0,0,0],a.set(this.tn,Tt(i.x),Tt(i.y),r),this.nn=ne(this.nn||[],this.tn[0],this.tn[1],this.tn[2]),this.rn=2*Math.tan(.5*Tt(e.getFov()));const s=e.projViewMatrix;let o;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,o=li(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof d));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=li(e)}catch(t){console.error(t)}}));const h={children:[],level:-1};let l=h;const u=[];for(let e=0;e<this.Le.length;e++){const n=this.Le[e];if(!n||!n.visible)continue;const r=[n],i=this.sn(e);for(;r.length>0;){const e=r.pop();for(e.id||this.an(e);l.level>=e.Ee;)l=l.parent;const n=this.cn(e,i,s,o,c);if(!(n===Ji.VISIBLE||n!==Ji.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&Hi(e))){let t=l;for(;t&&!t.content;)t=t.parent;n===Ji.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.hn(u,t);continue}e.ut<1/0&&this.ln(e);const a=this.Ce(e,l);l.children.push(a);const h=e.children,f=h&&h.length,d=a.content;if(d&&(!f||n===Ji.SCREEN_ERROR_TOO_SMALL)&&this.hn(u,a),n!==Ji.SCREEN_ERROR_TOO_SMALL&&f){d&&"add"===e.refine&&this.hn(u,a),l=a;const n=h[0].parent;let i=!1;for(let s=0,o=h.length;s<o;s++){if(n){const e=t.getCachedTile(h[s].id);if(e&&e.error&&404!==e.error.status)continue;i=!0}else{i=!0,h[s].parent=e,h[s].At=e.At,h[s].baseUrl=e.baseUrl;const t=h[s].content&&(h[s].content.url||h[s].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?h[s].baseUrl=e.baseUrl:Bt(t)?h[s].content.url=e.baseUrl+t:h[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}r.push(h[s])}!i&&d&&this.hn(u,a)}}}return{root:h,tiles:u}}hn(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){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 ji(n,e,r)<=0;if(n.box)return 0===zi(n,e,r)}return!1}(this.tn,this.nn,n,r)||t.push(e)}Ce(t,e){return{id:t.id,node:t,children:[],level:t.Ee,parent:e,content:t.content&&t.content.url}}an(e){const n=this.getId();e.id=n+":"+t.Util.GUID(),e.matrix=e.transform||r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e.un=this.dn(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.G=e.parent.G,void 0===e.Ee&&(e.Ee=e.parent.Ee+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)}q(t){return this.Le[t].service}mn(t){const e=t.boundingVolume;if(!e||e.We&&!this.pn(t))return;const n=this.q(t.G),i=n.heightOffset||0,s=this.options.offset,o=yt(s)||s[0]||s[1],c=n.coordOffset||ki;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!e.We&&(!t.boundingVolume||!i&&r.exactEquals(t.matrix,Ni)&&!o&&c===ki))return;e.box&&e.region&&delete e.region;const{region:h,box:l,sphere:u}=e;if(e.coordOffset=[c[0],c[1]],e.heightOffset=i,h){e.originalVolume||(e.originalVolume=h.slice(0));const t=e.originalVolume,n=this.gn([_t(t[0]),_t(t[1])]);h[0]=Tt(n.x+c[0]),h[1]=Tt(n.y+c[1]);const r=this.gn([_t(t[2]),_t(t[3])]);h[2]=Tt(r.x+c[0]),h[3]=Tt(r.y+c[1]),h[4]=t[4]+i+(c[2]||0),h[5]=t[5]+i+(c[2]||0)}else if(l||u){e.originalVolume||(e.originalVolume=(l||u).slice(0));const n=l||u,r=e.originalVolume,s=a.transformMat4(di,r,t.matrix),o=ce(mi,s),h=this.gn([o[0]+c[0],o[1]+c[1]]);o[0]=h.x,o[1]=h.y,o[2]+=i+(c[2]||0),ne(n,Tt(o[0]),Tt(o[1]),o[2])}e.We=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}pn(t){const e=t.boundingVolume,n=this.q(t.G),r=n.heightOffset||0,i=n.coordOffset||ki;return e.coordOffset[0]!==i[0]||e.coordOffset[1]!==i[1]||e.heightOffset!==r}dn(t){return void 0===t.geometricError||!t.boundingVolume}ln(t){let e=t.parent;for(;e&&e.un&&!(e.ut<=t.ut);)e.ut=t.ut,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),this.Ze()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.At||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const s=n.indexOf("realspace/")>-1;0===e.Ee&&t.asset&&t.asset.s3mType&&s&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.At=i,e){const n=e.boundingVolume;bt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);const i=t.root.transform||r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);if(e.parent)o||(e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,i));else{const t=this.q(e.G);t.ecefTransform?e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,i):e.matrix=i}delete e.content,t.root.content&&(e.content=t.root.content),e.un=this.dn(e);const s=e.content&&(e.content.url||e.content.uri);s&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&s&&!Ct(s)&&Bt(s)&&(e.content.url=e.baseUrl+s),t.root&&!e.parent&&this.bn(e)}this.Ze(),this.fire("loadtileset",{tileset:t,index:e&&e.G,url:n})}yn(t,e,n){if(!t.extent||!ui)return!0;const r=t.extent;if(Ui[0]=r.xmin,Ui[1]=r.ymin,Ui[2]=r.xmax,Ui[3]=r.ymax,e){if(!ui.bboxIntersect(Ui,e))return!1}if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||ui.bboxInMask(Ui,e))return!0}return!1}return!0}cn(t,e,n,r,i){if(!this.yn(t,r,i))return Ji.OUT_OF_FRUSTUM;if(t.ut=1/0,0===t.Ee||t.un)return this.bn(t),Ji.VISIBLE;if(this.mn(t),!this.wn(t,e,n))return Ji.OUT_OF_FRUSTUM;if(0===t.geometricError)return Ji.VISIBLE;let s=this.q(t.G).maximumScreenSpaceError;null==s&&(s=16);let o=this.vn(t);return 0===o&&t.parent&&(o=.5*(t.parent.Tn||0)),o>=s?Ji.VISIBLE:Ji.SCREEN_ERROR_TOO_SMALL}Xt(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.coordToPointAtRes(e,r.getGLRes(),n)}wn(t,e,n){const r=t.id;let i=this.Xe[r];const{boundingVolume:s}=t,o=s.region,a=s.box,c=s.sphere,h=this._n(t.G),l=this.getRenderer();i&&i.version===h.version||(o?i=this.Xe[r]=this.Mn(t):a?i=this.Xe[r]=this.On(t):c&&(i=this.Xe[r]=this.An(t)),i.version=h.version,t.ft&&(l.Ft(t.ft),delete t.ft));return this.q(t.G).debug&&(this.Xe[r].node=t,l.Ut(t)),i.obbox?g(n,i.obbox):!!c&&b(n,i.sphereBox)}Mn(e){const n=this.getMap(),i=n.getGLRes(),s=e.boundingVolume.region;let{ws:o,en:c}=function(t){const e=t[0],n=t[1],r=t[2],i=t[3],s=t[4],o=t[5],a=ne([],e,n,s),c=ne([],r,i,o),h=ce(a,a),l=ce(c,c);return{ws:h,en:l}}(s);o=new t.Coordinate(o),c=new t.Coordinate(c);const h=n.coordToPointAtRes(o,i);h.z=n.altitudeToPoint(o.z,i);const l=n.coordToPointAtRes(c,i);l.z=n.altitudeToPoint(c.z,i);const u=[l.x,h.y,l.z,l.x,l.y,l.z,h.x,l.y,l.z,h.x,h.y,l.z,l.x,h.y,h.z,l.x,l.y,h.z,h.x,l.y,h.z,h.x,h.y,h.z],f=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],d=this._n(e.G);e!==d||d.xn||(d.xn=f);const m=this.Jt([],e),p=r.exactEquals(Ni,m);if(!p){a.transformMat4(f,f,m);const t=di;for(let e=0;e<u.length;e+=3){let n=a.set(t,u[e],u[e+1],u[e+2]);p||(n=a.transformMat4(n,n,m)),u[e]=n[0],u[e+1]=n[1],u[e+2]=n[2]}}const g=n.pointAtResToCoord(new t.Point(f),i);g.z=(o.z+c.z)/2;const b=this.In(u,f);for(let t=0;t<u.length;t++)u[t]-=f[t%3];return{obbox:b,boxPosition:u,boxCenter:f,boxCoord:g}}On(t){const e=this.getRenderer(),n=this.getMap(),i="identity"===n.getProjection().code.toLowerCase(),s=n.getGLRes(),{boxCenter:o,boxCoord:c}=this.Sn(t),h=t.boundingVolume.box,l=this.En(h,t.matrix),u=(d=h,function(t,e,n,r,i,s,o,a,c,h,l,u,f,d,m,p,g){return t[0]=e||0,t[1]=s||0,t[2]=h||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=l||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=u||0,t[11]=0,t[12]=i||0,t[13]=c||0,t[14]=f||0,t[15]=g,t}([],(f=l)[0],f[3],f[6],d[0],f[1],f[4],f[7],d[1],f[2],f[5],f[8],d[2],0,0,0,1));var f,d;const m=this.Jt([],t),p=r.exactEquals(Ni,m);p||a.transformMat4(o,o,m);const g=[],b=di;for(let t=0;t<Di.length;t+=3){b[0]=Di[t],b[1]=Di[t+1],b[2]=Di[t+2],a.transformMat4(b,b,u),ce(b,b),i&&e.Ve(b,b);const r=Oi.set(b[0],b[1],b[2]);n.coordToPointAtRes(r,s,Ai);let o=a.set(b,Ai.x,Ai.y,n.altitudeToPoint(r.z,s));p||(o=a.transformMat4(o,o,m)),g[t]=o[0],g[t+1]=o[1],g[t+2]=o[2]}const y=this.In(g,o);for(let t=0;t<g.length;t++)g[t]-=o[t%3];return{obbox:y,boxPosition:g,boxCenter:o,boxCoord:c}}An(e){const n=this.getMap(),r=this.getRenderer(),i="identity"===n.getProjection().code.toLowerCase(),s=e.boundingVolume.sphere,o=s;let a=di;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:ce(a,o),i&&r.Ve(a,a);const c=new t.Coordinate(a),h=this.Xt(c,Ai).toArray();h[2]=n.altitudeToPoint(c.z,n.getGLRes());const l=this.Cn(c);return{boxCenter:h,boxCoord:c,sphereBox:[h,s[3]*l[2]]}}In(t,e){const n=Gi(bi,t,0,1,4,5),r=Gi(yi,t,0,3,4,7),i=Gi(wi,t,0,1,2,3);return[...e,...a.sub(di,n,e),...a.sub(mi,r,e),...a.sub(pi,i,e)]}Sn(e){const n=this.getMap(),r=this.getRenderer(),i="identity"===n.getProjection().code.toLowerCase(),s=n.getGLRes(),o=e.boundingVolume.box.slice(0,3);ce(o,o),i&&r.Ve(o,o);const a=new t.Coordinate(o),c=n.coordToPointAtRes(a,s);return{boxCenter:[c.x,c.y,n.altitudeToPoint(a.z,s)],boxCoord:a}}Jt(t,e){const n=this._n(e.G),i=this.q(e.G),s=n.xn,c=r.fromTranslation(Ii,a.set(di,-s[0],-s[1],-s[2])),h=r.fromTranslation(Si,s),l=i.rotation||Ri,u=o.fromEuler(_i,...l),f=i.scale;let d;d=Array.isArray(f)?a.set(Pi,f[0],f[1],f[2]):f&&a.set(Pi,f,f,f)||Li;const m=r.fromRotationTranslationScale(Ei,u,Bi,d);return t=r.multiply(t,m,c),r.multiply(t,h,t)}bn(t){const e=this.q(t.G);if(!t.boundingVolume||this.Nn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,i=t.boundingVolume.sphere;let s=null;n?s=this.kn(t).boxCenter:r?s=this.Rn(t).boxCenter:i&&(s=this.An(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Ln=[a[0]||0,a[1]||0],t.Pn=o,t.xn=s}Nn(t,e){if(!t.Ln)return!1;const n=e.coordOffset||ki;return t.Ln[0]===n[0]&&t.Ln[1]===n[1]&&t.Pn===(e.heightOffset||0)}Rn(t){return this.mn(t),this.Mn(t)}kn(t){return this.mn(t),this.Sn(t)}En(t,e){let n=t.slice(3,12);const r=c.fromMat4(xi,e);return n=c.multiply(n,r,n),n}Cn(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,a.set(vi,n.x/100*1.01,n.y/100*1.01,r),vi}gn(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(yt(n)&&(n=n.call(this,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 Ai.set(n[0],n[1]),i._sub(Ai),t.pointAtResToCoord(i,r)}return e}_n(t){return this.Le[t]}sn(e){const n=this.q(e).maxExtent;if(!n)return null;const r=this.Le[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo((t=>this.Xt(t)))),r.maxExtent}vn(t){const e=this.rn,n=t.geometricError;if(0===n)return t.Tn=0,0;const i=this.q(t.G);let s=i.scale||1;if(Array.isArray(s)&&(s=a.length(s)),i.ecefTransform){const t=r.getScaling(Ti,i.ecefTransform);s*=a.len(t)}const o=this.getMap();let c;t.boundingVolume.region?c=function(t,e,n){t.Bn||(t.Bn=new ci(t.boundingVolume.region));return t.Bn.distanceToCamera(e,n)}(t,this.nn,this.tn):t.boundingVolume.sphere?c=ji(t.boundingVolume,this.nn):t.boundingVolume.box&&(c=zi(t.boundingVolume,this.nn));const h=Math.max(Math.abs(c),1e-7),l=n*s*o.height/(h*e);return t.ut=c,t.Tn=l,l}Ze(){const t=this.getRenderer();t&&t.setToRedraw()}Dt(t){return this.Xe[t]}identify(e,n={}){const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];Array.isArray(e)&&(e=new t.Coordinate(e));const s=r.coordToContainerPoint(e);return this.identifyAtPoint(s,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&kt(n,r)}const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];const s=r.getDevicePixelRatio();return kt(n,i.pick(t.x*s,t.y*s,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Zt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.$||(this.$=[]),this.$.push(t),this)}ze(){if(this.$){for(let t=0;t<this.$.length;t++)this.highlight(this.$[t]);delete this.$}}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.X||(this.X=[]),this.X.push(t),this)}Un(){if(this.X){for(let t=0;t<this.X.length;t++)this.showOnly(this.X[t]);delete this.X}}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);return this.getRenderer()?(this.Ze(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Ze(),this):this}Qe(t){const e=this.getMap(),n=e.getGLRes();Ci.set(t[0],t[1]);const r=e.pointAtResToCoord(Ci,n);return"identity"===e.getProjection().code.toLowerCase()?(mi[0]=r.x,mi[1]=r.y,this.getRenderer().Je(di,mi),r.set(di[0],di[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function ji(t,e,n){let r=t.sphere;n&&(r=a.transformMat4([0,0,0],r,n));const i=a.dist(r,e),s=t.sphere[3];return i<s?0:i-s}function zi(t,e,n){const r=t.box;let i=a.set(di,r[0],r[1],r[2]);n&&(i=a.transformMat4([0,0,0],i,n));return Fr(i,c.set(xi,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function qi(t,e,n){const i=(t=Mt(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,un:!0,service:n,visible:!!gt(n.visible)||n.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),G:e,Ee:0,domainKey:i}}function Gi(t,e,n,r,i,s){const o=a.set(di,e[3*n],e[3*n+1],e[3*n+2]),c=a.set(mi,e[3*r],e[3*r+1],e[3*r+2]),h=a.set(pi,e[3*i],e[3*i+1],e[3*i+2]),l=a.set(gi,e[3*s],e[3*s+1],e[3*s+2]);return t[0]=(o[0]+c[0]+h[0]+l[0])/4,t[1]=(o[1]+c[1]+h[1]+l[1])/4,t[2]=(o[2]+c[2]+h[2]+l[2])/4,t}function Hi(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function Vi(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?m.exactEquals(t,e):a.exactEquals(t,e):t===e}var Ji;Fi.mergeOptions(fi),Fi.registerRenderer("gl",Br),Fi.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(Ji||(Ji={}));let $i=null;function Ki(){return $i||($i={"image/crn":br.crn&&br.crn(),"image/ktx2":br.ktx2&&br.ktx2(),"image/cttf":br.ktx2&&br.ktx2(),"draco":br.draco&&br.draco()}),$i}class Xi{constructor(t,e,n){this.Dn=t,this.Fn=e||y,this.Re=n,this.jn=Ki()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.zn(t,e,n,r,i)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.zn(t,i,n,r)}))}zn(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.qn(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.Fn(a,o.glb,{transferable:!0,requestImage:this.Dn,decoders:this.jn,supportedFormats:this.Re,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}qn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", 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 o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),h=i.getUint32(20,!0),l=i.getUint32(24,!0),u=28+e;h>=570425344?(u-=8,o=a,h=c,l=0,a=0,c=0):l>=570425344&&(u-=4,o=h,h=a,l=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=ve(t,u,a),u+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(u+=c),h>0&&(m=Te(t,u,h),u+=h,l>0)){const e=_e(0,u,l);p=t.slice(e.offset,e.offset+e.byteLength),u+=l,f.push(p)}const g=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Oe(d.BATCH_ID,t,undefined.offset,g);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:b,glb:{buffer:t,byteOffset:u,byteLength:i.byteLength+i.byteOffset-u}}}Gn(){return null}}class Yi{constructor(t,e,n,r){this.Dn=t,this.Fn=e||y,this.Re=n,this.jn=Ki(),this.Hn=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.zn(t,e,n,r,i)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.zn(t,i,n,r)}))}zn(t,e,n,r,i){return this.Vn(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.Jn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}Vn(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.Dn,decoders:this.jn,supportedFormats:this.Re,maxTextureSize:s},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=xt(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?w.getArrayBuffer(r,{}).then((t=>this.$n(r,{buffer:t.data,byteOffset:0},o))):w.getJSON(r,{}).then((t=>this.$n(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.$n(t,r,o)}}$n(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.Fn(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=`${t}-${r}-${s}`,{transferables:i.transferables,gltf:n}}))}Jn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", 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 o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:l}=ke(i,32+e,o),u={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Kn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Oe(a.BATCH_ID,t,c.offset,f);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Xn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Xn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:l,featureTable:a,i3dm:u,transferables:o}}Xn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Zi(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 Ne(new Float32Array(t.length),t,e,n)}Gn(){return null}}function Zi(t,e,n,r){if(t[0]=Wi(e,r),t[1]=Wi(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]))*Qi(e),t[1]=(1-Math.abs(e))*Qi(t[1])}return _.normalize(t,t)}function Wi(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 Qi(t){return t<0?-1:1}class ts{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.zn(t,e,n,r)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.zn(t,i,n,r)}))}zn(t,e,n,r){return this.Yn(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}))}Yn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", 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 o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:l}=ke(i,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,f=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.Zn||(this.Zn=Ki().draco),this.Zn(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.Wn(t,e.attributes,c.offset,d,o,u,f);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:Ce(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=Oe(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=es(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:l,featureTable:a,pnts:r,transferables:o}}))}const g=this.Wn(t,a,c.offset,d,o,u,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?g.BATCH_ID=Oe(a.BATCH_ID,t,c.offset,d):g.BATCH_ID=es(d);const e=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:l,featureTable:a,pnts:g,transferables:o})}Wn(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:h}=e.POSITION_QUANTIZED;c=c||0;const l=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Kn(h||new Uint16Array(t,c+l,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}Kn(t,e,n){return Ne(new Float32Array(t.length),t,e,n)}Gn(){return null}}function es(t){const e=Et(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:Ce(e),array:n}}class ns{constructor(t,e,n,r){this.Re=n,this.Dn=t,this.Fn=e||y,this.Hn=r}load(t,e,n=0,r=0,i){return e?this.zn(t,e,n,r,i):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.zn(t,i,n,r)}))}zn(t,e,n,r,i){r||(r=e.byteLength);const s=this.Qn(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new Xi(this.Dn,this.Fn,this.Re);else if("i3dm"===s[n].magic)r=new Yi(this.Dn,this.Fn,this.Re,this.Hn);else if("pnts"===s[n].magic)r=new ts;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new ns(this.Dn,this.Fn,this.Re,this.Hn)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Qn(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=ye(i,c),r=i.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(A);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(A)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",A);export{Xi as B3DMLoader,ns as CMPTLoader,Fi as Geo3DTilesLayer,Pt as Geo3DTilesUtil,ge as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.102.0");
11
+ */(100,1),ur=[0,0,0,1],fr=[1,1,1];class dr{constructor(t,e){this.h=e,this.u=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.m=t,this.p=new n.Renderer(t),this.v={},this.T={},this._={},this.M={},this.O={},this.A={},this.I=new n.Scene,this.S=new n.Scene,this.C=new n.Scene,this.N=new n.Scene,this.k=new n.ResourceLoader(t.texture(2)),this.R=(...t)=>this.L.call(this,...t),this.P=new n.KHRTechniquesWebglManager(this.m,this.B(),this.k);const r=this.getMap();this.U=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this.M}getPNTSMeshes(){return this._}getB3DMMeshes(){return this.T}getPaintedMeshes(){return this.D}getMap(){return this.h.getMap()}paint(t,e,n,o){const a=o&&o.renderTarget,c=o&&o.sceneFilter,h=this.getMap();if(!t.length||!h)return null;const l=this.F(),u=h.projViewMatrix,f=[],d=[],m=[],g=[],b=[];for(let n=0,s=t.length;n<s;n++){const s=t[n].data.node;let a=this.j(s);if(!a)continue;const c=this.h.q(s.H),h=c.debugNodes,l=c.heightOffset||0,y=c.coordOffset||Fn;this.O[s.id]&&(a=this.O[s.id],a=St(a));let w=c.polygonOffset||kn;yt(w)&&(w=w()),Array.isArray(a)||(f[0]=a,a=f);for(let c=0,f=a.length;c<f;c++){if(!a[c]||!a[c].isValid||!a[c].isValid())continue;const f=a[c].properties.magic;if(a[c].properties.heightOffset===l&&a[c].properties.coordOffset[0]===y[0]&&a[c].properties.coordOffset[1]===y[1]||(this.G(a[c]),a[c].V=r.copy([],a[c].localTransform)),a[c].J=s,"b3dm"===f){if(a[c].getBoundingBox&&!p(u,a[c].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=a[c].geometry.properties;if(t&&e){const t=a[c].properties.node.H;this.$&&this.$[t]?i.highlightMesh(this.m,a[c],this.$[t],this.K,e):this.$&&this.$[t]||i.highlightMesh(this.m,a[c],null,this.K,e),i.showOnly(this.m,a[c],this.X&&this.X[t],this.Y,e)}if(h&&h.length&&h.indexOf(a[c].J.id)<0)continue;o&&o.bloom&&a[c].properties.hlBloomMesh&&(a[c].properties.hlBloomMesh.properties.depthFunc="always",a[c].properties.hlBloomMesh.properties.polygonOffset=w,m.push(a[c].properties.hlBloomMesh)),m.push(a[c])}else"pnts"===f?g.push(a[c]):"i3dm"===f&&b.push(a[c]);a[c].properties.isLeaf=!!e[s.id],a[c].properties.selectionDepth=255-t[n].selectionDepth,a[c].properties.polygonOffset=w,e[s.id]||d.push(a[c]),this.Z(a[c]),this.W(a[c],s)}}let y=0;const w=this.P.getExcludeFilter();s.setIncludeUniformValues(l,o),y+=this.tt(this.et,l,[c,zn,w],a,d,m,b),y+=this.tt(this.nt,l,[c,qn,w],a,d,m,b),this.P.forEachShader(((t,e,n)=>{const r=this.F(n);y+=this.tt(t,r,[c,e],a,d,m,b)})),this.S.setMeshes(g);const v=this.rt();return y+=this.p.render(this.it,v,this.S,a&&a.fbo),this.D={pntsMeshes:g,i3dmMeshes:b,b3dmMeshes:m},this.N.setMeshes(n),this.p.render(this.st,l,this.N,a&&a.fbo),y}prepareRender(t){this.ot(t)}ot(t){t&&t.states&&t.states.includesChanged&&(this.nt.dispose(),delete this.nt,this.et.dispose(),delete this.et),this.ct(t)}tt(t,e,n,r,i,s,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1;const a=r&&r.fbo;let c=0;const h=[];for(let n=0;n<s.length;n++){const{isLeaf:r,selectionDepth:i}=s[n].properties;r&&255===i?(e.stencilEnable&&(this.ht(a),this.I.setMeshes(h),c+=this.p.render(t,e,this.I,a),h.length=0,e.stencilEnable=!1),h.push(s[n])):(e.stencilEnable||(this.I.setMeshes(h),c+=this.p.render(t,e,this.I,a),h.length=0,e.stencilEnable=!0),h.push(s[n])),n===s.length-1&&(e.stencilEnable&&this.ht(a),this.I.setMeshes(h),c+=this.p.render(t,e,this.I,a))}return this.I.setMeshes(s.filter((t=>t.properties.isLeaf))),this.C.setMeshes(o),c+=this.p.render(t,e,this.C,r&&r.fbo),c}ht(t){this.m.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.I.getMeshes()}getCurrentI3DMMeshes(){return this.C.getMeshes()}lt(t,e){return e.J.ut-t.J.ut}deleteTile(t){const e=t.node;e.ft&&(e.ft.geometry.dispose(),e.ft.dispose(),delete e.ft);const n=e.id;this.dt(n)}dt(t){const e=this.T[t]||this._[t]||this.M[t]||this.O[t]||this.v[t];this.O[t]?this.gt(t):e&&(this.bt(e),delete this.T[t],delete this._[t],delete this.M[t],delete this.v[t])}gt(t){let e=this.O[t];e=St(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.dt(n)}delete this.O[t]}bt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.bt(t[e]);else{i.showOnly(this.m,t),i.highlightMesh(this.m,t);const e=t.geometry.properties.url;if(e){const n=this.A[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.A[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.h;En(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.gt(t);this.O={};for(const t in this.T)this.dt(t);this.T={};for(const t in this._)this.dt(t);this._={};for(const t in this.M)this.dt(t);this.M={};for(const t in this.v)this.dt(t);this.v={},this.et&&(this.et.dispose(),delete this.et),this.nt&&(this.nt.dispose(),delete this.nt),this.it&&(this.it.dispose(),delete this.it),this.st&&(this.st.dispose(),delete this.st),this.P.dispose(),this.picking&&this.picking.dispose()}j(t){return this.T[t.id]||this._[t.id]||this.M[t.id]||this.O[t.id]}has(t){return this.j(t)||this.v[t.id]}G(t){const e=t.properties.magic;"b3dm"===e?this.yt(t):"i3dm"===e?this.wt(t):"pnts"===e&&this.vt(t)}createPntsMesh(t,e,i,s){if(this._[e]){const t=this._[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c,compressed_int16_params:h}=t,l=a.POINTS_LENGTH;o.BATCH_ID||(o.BATCH_ID=new Uint8Array(l),o.BATCH_ID.fill(0));const u=new n.Geometry(o,null,l,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.m);const f={};o.POSITION?f.HAS_POSITION=1:o.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),o.RGB?f.HAS_RGB=1:o.RGBA?f.HAS_RGBA=1:o.RGB565&&(f.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,o.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),this.Tt(f,h),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:d,rtcCoord:m,projCenter:p}=t,g=this.h.q(c),b=new n.Mesh(u);b.properties.magic="pnts",b.properties.id=e,b.properties.node=i,b.properties.count=l,b.properties.batchTable=t.batchTable,b.properties.batchTableBin=t.batchTableBin,b.properties.serviceIndex=c,b.properties.rtcCoord=m,b.properties.rtcCenter=d,b.properties.projCenter=p,b.setDefines(f),b.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:g&&g.pointColor||[1,1,1,1]}));const y=this.getMap();let w=null,v=null;b.setFunctionUniform("pointSize",(function(){if(!g)return 2;if(gn(g.pointSize)){const t=JSON.stringify(g.pointSize);t!==w&&(v=bn(g.pointSize),w=t);return v(y.getZoom())}return g.pointSize||2}));let T=null,_=null;return b.setFunctionUniform("pointOpacity",(function(){if(!g)return 1;if(gn(g.pointOpacity)){const t=JSON.stringify(g.pointOpacity);t!==T&&(_=bn(g.pointOpacity),T=t);return _(y.getZoom())}return g.pointOpacity||1})),this._t(b,h),this.vt(b),b.V=r.copy([],b.localTransform),this._[e]=b,s(null,{id:e,mesh:[b]}),[b]}vt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:i}=t.properties;this.Mt(e,n,i,r.H),t.setLocalTransform(e)}createI3DMMesh(t,e,i,s){if(this.M[e]){const t=this.M[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.v[e]||s(null,{id:e,mesh:t}),t}const c=this.h.q(i.H),h=this.Ot(i.At),{i3dm:l,featureTable:u,gltf:f,batchTable:d,batchTableBin:m,count:p}=t,g=u.INSTANCES_LENGTH,{rtcCenter:b,rtcCoord:w,projCenter:v}=t,T=this.xt(Zn,i,b,w);ze(T,Dn,T);const _=r.getRotation(Wn,T);o.normalize(_,_);const M=r.getScaling(Qn,T),O=r.fromScaling(tr,M),A=this.It(er,v,i),x=this.St(ir),I=this.Et(sr,w),S=a.div(or,I,x),E=r.fromScaling(ar,S),{POSITION:C,NORMAL_UP:N,NORMAL_RIGHT:k,SCALE:R,SCALE_NON_UNIFORM:L}=l,P={"instance_vectorA":new Float32Array(4*g),"instance_vectorB":new Float32Array(4*g),"instance_vectorC":new Float32Array(4*g),"aPickingId":new Uint16Array(g)};for(let t=0;t<g;t++)P.aPickingId[t]=t;const B=new Float32Array(3),U=new Float32Array(3),D=[],F=new Float32Array(1),j=new Float32Array(3),z=[],q=[],H=[],G=[];!function(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?y.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*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<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);h.set(i),e(new c(h.buffer),t),i.set(h)}}(C,((t,e)=>{N?(Yt(U,k,e),Yt(B,N,e),a.cross(D,U,B),a.normalize(D,D),It(z,U,0),It(z,B,1),It(z,D,2),o.fromMat3(q,z),o.normalize(q,q),o.multiply(q,_,q)):o.identity(q),R?(Yt(F,R,e),a.set(H,F[0],F[0],F[0])):L?(Yt(j,L,e),a.set(H,...j)):a.set(H,1,1,1),r.fromRotationTranslationScale(G,q,t,H),Zt(P.instance_vectorA,e,G,0),Zt(P.instance_vectorB,e,G,1),Zt(P.instance_vectorC,e,G,2)}));const V={};for(const t in P)V[t]={buffer:this.m.buffer({dimension:P[t].length/g,data:P[t]}),divisor:1};const J=c.shader||"pbr";let $=0,K=!0;const X=[],Y=[];return qt(f,((t,s,o,a)=>{const c=this.Ct(t,s,o,a,i,!0,J,Y),{geometry:l,material:f}=c;f&&!f.isReady()&&(K=!1,$++);const y=new n.InstancedMesh(V,g,l,f);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(y.uuid)),y.properties.magic="i3dm",y.properties.id=e,y.properties.count=p,y.properties.batchTable=d,y.properties.batchTableBin=m,y.properties.serviceIndex=i.H,y.properties.rtcCoord=w,y.properties.rtcCenter=b,y.properties.projCenter=v,y.properties.node=i;const _=this.Nt(t,l,f,i.H,a);t.compressed_int16_params&&this._t(y,t.compressed_int16_params),this.kt(y,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]);r.multiply(M,h,M),r.multiply(M,E,M),u.EAST_NORTH_UP||N?r.multiply(M,O,M):r.multiply(M,T,M),y.setPositionMatrix(M),this.wt(y,A),y.setDefines(_),y.properties.polygonOffset={offset:0,factor:0},X.push(y),delete t.attributes,y.V=r.copy([],y.localTransform)})),mr(Y),K?(this.M[e]=X,s(null,{id:e,mesh:X})):(this.v[e]={meshes:X,count:$},X.Rt=s),X}wt(t,e){const{rtcCoord:n,node:i,projCenter:s}=t.properties;e||(e=this.It(er,s,i));const o=this.h.q(i.H),a=t.localTransform||[];if(o.coordOffset){const t=this.Lt(Zn,i.H,n);r.multiply(a,t,e)}else r.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||Fn}It(t,e,n){r.fromScaling(t,this.St(ir));const i=this.Pt(Xn,e,n.H);return r.multiply(t,r.fromTranslation(nr,i),t),t}createB3DMMesh(e,i,s,o){if(e.gltf&&(e.gltf.transferables=null),this.T[i]||this.v[i]){const t=this.T[i];return console.warn(`mesh with id(${i}) was already created.`),this.v[i]||o(null,{id:i,mesh:t}),t}let a;if(s.maxExtent){const e=new t.Extent(s.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:l,center:u}=c.extensions.CESIUM_RTC,f=c.asset.sharePosition,d=this.Ot(s.At),m=this.Bt(er,f,l,u,h,s),p=this.h.q(s.H);let g=p.shader||"pbr";if(p.unlit)g="phong";else 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){g="phong";break}const b=[],y=[];let w=0,v=!0;return qt(c,((t,o,c,T)=>{const _=this.Ct(t,o,c,T,s,!1,g,b),{geometry:M,material:O}=_;O&&!O.isReady()&&(v=!1,w++);const A=new n.Mesh(M,O);_.refMeshes||(_.refMeshes=new Set,_.refMeshes.add(A.uuid)),A.properties.magic="b3dm",A.properties.id=i,A.properties.node=s,e.batchTable&&(A.properties.batchTable=e.batchTable,A.properties.batchTableBin=e.batchTableBin),A.properties.count=e.featureTable&&e.featureTable.BATCH_LENGTH||0,A.properties.serviceIndex=s.H;const x=this.Nt(t,M,O,s.H,T);A.setDefines(x);const I=t.compressUniforms;if(I)for(const t in I)A.setUniform(t,I[t]);t.compressed_int16_params&&this._t(A,t.compressed_int16_params),this.kt(A,t.attributes),a&&(x.USE_MAX_EXTENT=1,A.setUniform("maxPrjExtent",a)),A.hasFunctionUniform("polygonOpacity")||A.setFunctionUniform("polygonOpacity",(function(){return vt(p.opacity)?p.opacity:1})),A.hasFunctionUniform("polygonFill")||A.setFunctionUniform("polygonFill",(function(){return Lt([],p.polygonFill||Rn)})),A.material.hasFunctionUniform("hsv")||A.material.setFunctionUniform("hsv",(function(){return p.hsv||Ln}));const S=r.identity([]);if(f&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(S,S,t.matrices[e]);f&&r.multiply(S,d,S),A.properties.node=s,A.properties.projCenter=h,A.properties.nodeMatrix=S,A.properties.isSharedPosition=f,A.properties.rtcCoord=l,A.properties.rtcCenter=u,this.yt(A,m),y.push(A),delete t.attributes,A.V=r.copy([],A.localTransform)})),mr(b),v?(this.T[i]=y,o(null,{id:i,mesh:y})):(this.v[i]={meshes:y,count:w},y.Rt=o),y}Ut(t){const e=this.h.Dt(t.id);if(!e||t.ft)return;let i,s,o,a;if(e.obbox)i=e.boxPosition,s=hr,o=e.boxCenter,a=fr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];i=lr.vertices,s=lr.indices,o=t,a=[n,n,n]}const c=new n.Geometry({POSITION:i},s,0,{primitive:"lines",positionAttribute:"POSITION"}),h=new n.Mesh(c,new n.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),l=[];r.fromRotationTranslationScale(l,ur,o,a),h.localTransform=l,h.V=r.copy([],l),h.properties.node=t,t.ft=h}Ft(t){t.ft&&(t.ft.geometry.dispose(),t.ft.dispose(),delete t.ft)}_t(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}yt(t,e){const{isSharedPosition:n,rtcCoord:i,rtcCenter:s,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Bt(e||er,n,i,s,o,c));const h=t.localTransform||r.identity([]);r.multiply(h,e,a);const l=this.h.q(c.H);if(l.coordOffset){const t=this.Lt(Zn,c.H,i);r.multiply(h,t,h)}t.setLocalTransform(h),t.properties.heightOffset=l.heightOffset||0,t.properties.coordOffset=l.coordOffset&&l.coordOffset.slice(0)||Fn}Bt(t,e,n,i,s,o){if(e){const e=this.Et(sr,n),s=r.fromScaling(Yn,e),a=this.xt(Zn,o,i,n);r.multiply(t,a,s)}else this.Mt(t,n,s,o.H);return t}kt(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)}}xt(t,e,n,i){const s=this.getMap(),o=this.h.q(e.H).heightOffset||0,c=e.matrix?r.copy(t,e.matrix):r.identity(t);if(n){ze(c,a.transformMat4(Hn,n,c),c)}const h=function(t,e,n,r,i,s,o){e=_.copy(He,e);const a=ne(He,e[0]*We,e[1]*We,e[2]),c=T.getTranslation(Ge,n),h=r.ellipsoid;let l;l=0===_.len(c)?_.set(Ve,0,0,-6378137):ce(Ve,c),Ye.x=l[0],Ye.y=l[1];const u=r.project(Ye,Ze);Je[0]=u.x/i,Je[1]=u.y/i,Je[2]=(l[2]+o)*s;const f=qe(a,h,$e);return ze(function(t,e,n){const r=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],h=t[8],l=t[9],u=t[10],f=e[0],d=e[1],m=e[2],p=e[3],g=e[4],b=e[5],y=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,_=i*f+a*d+l*m,M=s*f+c*d+u*m,O=r*p+o*g+h*b,A=i*p+a*g+l*b,x=s*p+c*g+u*b,I=r*y+o*w+h*v,S=i*y+a*w+l*v,E=s*y+c*w+u*v;return n[0]=T,n[1]=_,n[2]=M,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=E,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(T.invert(Ke,f),M.fromMat4(Xe,n),t),Je,t),t}(c,i,c,s.getProjection(),s.getGLRes(),this.U,o),l=function(t,e){return _.set(t,e[12],e[13],e[14]),t}(Xn,h);let u=this.h.options.offset;if(yt(u)){const t=this.h.Dt(e.id).boxCoord;u=u.call(this.h,t)}return a.set(Kn,u[0],u[1],0),a.sub(l,l,Kn),ze(h,l,h),h}Lt(t,e,n){const i=this.h.q(e);if(!i.coordOffset)return null;const s=this.getMap(),o=s.getGLRes();Gn.set(n[0],n[1]);const c=s.coordToPointAtRes(Gn,o,Jn),h=i.coordOffset,l=Gn.set(n[0]+h[0],n[1]+h[1]),u=s.coordToPointAtRes(l,o,$n),f=u.x-c.x,d=u.y-c.y,m=this.U,p=a.set(Kn,f,d,(h[2]||0)*m);return r.fromTranslation(t,p)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:r}=i[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"i3dm"===r?this.createI3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"pnts"===r?this.createPntsMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"cmpt"===r&&this.createCMPTMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)}))}return this.O[e]=s,r(null,{id:e,mesh:s}),s}Nt(t,e,n,r,i){const s=("phong"===(this.h.q(r).shader||"pbr")?this.et:this.nt).getGeometryDefines(e);i.asset&&"S3M"===i.asset.generator&&this.jt(s,e),e.data.uvRegion&&(s.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(s.VertexNormal=1),e.data[e.desc.color0Attribute]&&(s.VertexColor=1),e.data[e.desc.uv0Attribute]&&(s.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(s.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(s.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(s.TexCoord2=1),"MESHOPT"===this.h.zt&&(s.MeshOPT_Compress=1),this.hasIBL()&&(s.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(s.HAS_WEB3D_quantized_attributes_TEXCOORD=1),s.HAS_MIN_ALTITUDE=1,s.HAS_LAYER_OPACITY=1,this.Tt(s,t.compressed_int16_params);return bt(s,t.compressDefines),s}Tt(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}Z(t){const e=this.h.getRenderer();e&&e.updateMaskDefines(t)}jt(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)}Ct(t,e,r,i,s,o,a,c){let h=!1;i.asset&&"S3M"===i.asset.generator&&(h=!0,i.extensions=i.extensions||{});const l=i.url+"-"+e+"-"+r;if(this.A[l])return this.A[l];let u,f;c.push(t);const d=i.materials&&i.materials[t.material],m=i.extensions&&i.extensions.KHR_techniques_webgl,p=this.h.q(s.H);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){const e=this.qt(t,i,o,h);u=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.Ht(t,o,cr);const e=p.material;u=this.Gt(t.material,i,a,e||Pn,c,p)}u&&(u.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return gt(t)?.1:t})),u.setFunctionUniform("environmentExposure",(()=>{const t=p.ambientLight;let e=p.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),u&&!u.isReady()?u.Vt=s.id:u||(u=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const g={geometry:f,material:u};return f.properties.url=l,this.A[l]=g,g}qt(t,e,n,r){const{geometry:i,material:s}=this.P.createMesh(t,e,n,r);return{geometry:i,material:s}}Ht(t,e,r){const i=t.attributes,s="COLOR_0";let o=i._BATCHID&&i._BATCHID.array;if(o&&o.byteOffset&&(o=new o.constructor(o)),i[s]){const t=i[s].array||i[s];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[s].array?(i[s].array=e,i[s].componentType=5121):i[s]=e}}const a={};for(const t in i){const e=An(this.m,i[t],{dimension:i[t].itemSize}),n=r[t]||t;a[n]={buffer:e},i[t].quantization&&(a[n].quantization=i[t].quantization),n===r.POSITION&&(a[n].array=i[t].array,a[n].min=i[t].min,a[n].max=i[t].max)}const c=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,h=new n.Geometry(a,c,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":On(t.mode)});return o&&c&&(h.properties.batchIdData=o,h.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],s=t[i];let o=n.get(s);o||(o=[],n.set(s,o)),o.push(i)}return n}(o,c)),h.generateBuffers(this.m,{excludeElementsInVAO:e}),h}Mt(t,e,n,i){const s=r.identity(t),o=this.St(Bn);return this.Pt(Xn,n,i),r.translate(s,s,Xn),r.scale(s,s,o),s}Pt(t,e,n){const r=this.U;Gn.x=e[0],Gn.y=e[1];const i=this._prjToPoint(Gn);let s=this.h.options.offset;yt(s)&&(s=s.call(this.h,Gn));const o=this.h.q(n).heightOffset||0;return a.set(t,i.x-s[0],i.y-s[1],r*e[2]+r*o),t}W(t,e){const n=this.h.Jt(rr,e);t.localTransform=r.multiply(t.localTransform,n,t.V)}Et(t,e){const n=this.getMap();Gn.x=e[0],Gn.y=e[1];const r=n.distanceToPointAtRes(100,100,n.getGLRes(),Gn),i=this.U;return a.set(t,r.x/100,r.y/100,i),t}ct(t){if(this.nt)return;const e={x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},i=[],o=[];this.it=new n.MeshShader({vert:Wt,frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n\n if (dot(circCoord, circCoord) > 1.0) {\n\n discard;\n\n } else {\n\n gl_FragColor = vColor;\n\n }\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(o,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>c.fromMat4(i,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"<"}}});const a={},h=[];s.fillIncludes(a,h,t);const l=this.B();this.et=new n.PhongShader({uniforms:h,defines:a,extraCommandProps:l}),this.nt=new n.pbr.StandardShader({uniforms:h,defines:a,extraCommandProps:l}),this.st=new n.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const u=this.h;Sn(u.getRenderer().canvas,this.m,u.getMap()),this.picking=new n.FBORayPicking(this.p,{vert:this.nt.vert,extraCommandProps:l,uniforms:this.nt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.$t=new n.FBORayPicking(this.p,{vert:Wt,extraCommandProps:l,uniforms:this.it.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}B(){return{viewport:{x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},cull:{enable:!0},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.selectionDepth},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}rt(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:a.normalize(jn,r)}}F(){const t=this.getMap(),e=this.h,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:i}=Cn(n),s=Nn(t,r,i),o=this.h.getRenderer(),a=o.getMaskUniforms();s.minAltitude=e.options.altitude||0;const c=o.canvas.gl&&o.canvas.gl.wrap?e.options.opacity||0:1;return s.layerOpacity=c,bt(s,{czm_lightDirectionEC:s.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),bt(s,a),s}Gt(t,e,r,i,s,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=bt({},i);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Kt(t,s)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Kt(e.textures[a.normalTexture.index],s);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Kt(e.textures[a.occlusionTexture.index],s);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Kt(e.textures[a.emissiveTexture.index],s);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];if(n&&n.image&&n.image.color)c.baseColorFactor=c.baseColorFactor?h.multiply(c.baseColorFactor,c.baseColorFactor,n.image.color):n.image.color;else{const t=this.Kt(n,s);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.m))}}if(gt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),gt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Kt(e.textures[a.metallicRoughnessTexture.index],s);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){c.ambientColor=[1,1,1],c.light0_diffuse=[0,0,0,0],c.lightSpecular=[0,0,0];const t=new n.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.pbr.StandardMaterial(c);"phong"===r&&(l=n.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,f=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(l.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",f.KHR_texture_transform.rotation||0),l.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.R),l}Kt(t,e){if(!t)return null;const r={type:t.type?_n(t.type):"uint8",format:t.format?Mn(t.format):"rgba",flipY:!!t.flipY},i=t.image;if(e.push(i),i.array?r.data=i.array:i.mipmap&&(r.mipmap=i.mipmap),!r.data&&!r.mipmap)return null;if(r.width=i.width,r.height=i.height,r.mipmap&&(r.width<4||r.height<4))return null;const s=t.sampler||t.texture&&t.texture.sampler;return s&&(s.magFilter&&(r.mag=wn(s.magFilter)),s.minFilter&&(r.min=vn(s.minFilter)),s.wrapS&&(r.wrapS=Tn(s.wrapS)),s.wrapT&&(r.wrapT=Tn(s.wrapT))),new n.Texture2D(r,this.k)}L({target:t}){const e=t.Vt,n=this.v[e];if(n.count--,!n.count){const t=n.meshes;this.T[e]=t,delete this.v[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}St(t){const e=1/this.getMap().getGLRes(),n=this.U;return t[0]=t[1]=e,t[2]=n,t}Xt(t){return this.h.Xt(t)}_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(),Vn)}Ot(t){return"Y"===t?xn:"X"===t?In:Un}pick(t,e,n=3){const r=this.h;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=[],s=this.F(),o=this.Yt(this.picking,s,this.I,t,e,n);o&&i.push(o);const a=this.Yt(this.picking,s,this.C,t,e,n);a&&i.push(a);const c=this.rt(),h=this.Yt(this.$t,c,this.S,t,e,n);return h&&i.push(h),i}Yt(t,e,n,r,i,s){if(!n.getMeshes().length)return null;const o=this.h,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,i,s,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:h,pickingId:l,point:u,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.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 p={batchId:l},g=o.options.services,b=g&&g[d.properties.serviceIndex];if(b&&b.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=l;for(const i in t)void 0!==t[i].byteOffset?p[i]=Ae(t[i],e,n,r):p[i]=t[i][r]}return{service:d.properties.serviceIndex,data:p,point:u,coordinate:f}}highlight(t){this.$=t;const e=this.h.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.$=null;const t=this.h.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.X=t;const e=this.h.getRenderer();this.Y=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.X=null;const t=this.h.getRenderer();this.Y=t.getFrameTimestamp(),t.setToRedraw(!0)}Zt(){if(!this.D)return[];const t={},e=[];for(const n in this.D){const r=this.D[n];if(r)for(let n=0;n<r.length;n++){const i=r[n],s=i&&i.geometry;if(!i||!s)continue;const o=i.properties.serviceIndex;t[o]||(t[o]=new Set);const a=s.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())}}function mr(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}const pr=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")},gr=pr(),br=gr.gl_trans__coders=gr.gl_trans__coders||{};function yr(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}br.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=gr.gl_trans__coders=gr.gl_trans__coders||{};let s=`${r}\n const _____getGlobal = ${pr.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&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return s+="\n"+e.substring(r.length),s},br.registerTranscoder=function(t,e){br[t]=e},br.getTranscoder=function(t){return br[t]};const wr=[];class vr{constructor(t,e,n,r,i){this.h=r,this.Wt=t,this.H=e,this.Qt=i,this.te=n.version,t.indexOf("i3s:tileset:")<0?(this.te<=1.6?this.ee="root":this.ee=0,n.version=this.te):(this.ee=t.substring(12),this.te>1.6&&(this.ee=parseInt(this.ee))),this.Wt=t,this.ne=n}load(){const t=this.ne,e=t.layerScene.baseUrl;if(this.te<=1.6)return t[this.ee]&&t[this.ee].lodSelection?(this.re=t[this.ee],this.ie()):new Promise((n=>{let r=e+"/nodes/"+this.ee;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Qt(this.H,r,(()=>{this.re=t[this.ee],n(this.ie())}))}));if(this.te>=1.7){if(t[this.ee])return this.re=t[this.ee],this.ie();const n=Math.floor(this.ee/t.nodesPerPage);return new Promise((r=>{let i=e+"/nodepages/"+n;t.layerScene.eslpk&&(i+=".json"),this.Qt(this.H,i,(()=>{this.re=t[this.ee],r(this.ie())}))}))}return null}getTileset(){return this.se}getChildrenURL(){return this.oe}ie(){const t=this.ne,e=t.layerScene.baseUrl,n=this.re.children,r=[],i={};if(n)for(let s=0;s<n.length;s++)if(this.te<=1.6){const o=n[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Qt(this.H,r,(()=>{n()}))})),r.push(i[a]))}else{const o=n[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.Qt(this.H,r,(()=>{n()}))})),r.push(i[a]))}return r.length?Promise.all(r).then((()=>this.ae())):this.ae()}ae(){return Promise.resolve(this.ce())}he(t){yr(this.ne,t)}ce(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.le(this.re,!0)}}le(t){const e=this.h.getRenderer(),n=this.ne.projection,r=!n||n&&4326===n.wkid,i=this.te,s=this.ne,o=t,a=o.obb,c=o.mbs,h={};let l;if(c)l=_.set([],c[0],c[1],c[2]),r||(l=e.ue(l,l)),l=Tr([],l[0],l[1],l[2]),h.sphere=[...l,c[3]];else if(a){l=_.set([],a.center[0],a.center[1],a.center[2]),r||(l=e.ue(l,l)),l=Tr([],l[0],l[1],l[2]);const t=function(t,e,n){const r=M.fromQuat([],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]}(l,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],i=t[4]+t[7]+t[10],s=t[5]+t[8]+t[11];_.set(wr,n,i,s);const o=_.len(wr);h.sphere=[...l,o]}let u=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===s.lodSelectionMetricType){u=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(u=f/o.lodSelection[t].maxError);(u===1/0||isNaN(u))&&(u=1e5);const d=16*u,m=T.identity([]),p=o.children;let g;if(p){g=[];const t=this.ne;for(let e=0;e<p.length;e++){const n=i<=1.6?p[e].id:p[e];if(!t[n]){g=null;break}g.push(this.le(t[n]))}}const b={refine:"REPLACE",boundingVolume:h,transform:m,geometricError:d};return i<=1.6?t.lodSelection?t.geometryData&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}):b.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!g?b.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}),g&&g.length&&(b.children=g),b}getJSON(){return this.re}}function Tr(t,e,n,r){return ne(t,Tt(e),Tt(n),r)}const _r=!!br.ktx2,Mr=r.identity([]),Or=(()=>{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 Ar(t){return t.indexOf("i3s:mesh")>=0}const xr=9;function Ir(t,e,n,r,i){const s=e.layerScene.eslpk,o=function(t,e){const n=e.substring(xr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let l=!1;const u=Mr;let f,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;s&&(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",s&&(i+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}h.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions,o=(e.layerScene.store||{}).textureEncoding,u=t[f.definition],{geometryBuffers:m}=u;l=r&&2===m.length;const p=br.draco&&l?m[1]:m[0],g=br.draco&&l?1:0;let b=c+`/nodes/${f.resource}/geometries/`+g;s&&(b+=".bin");const y={geometry:{url:b,info:p}};if(i&&Or&&l&&!br.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const w=e.layerScene.materialDefinitions,v=e.layerScene.textureSetDefinitions;let T,_=0;if(d&&(_=w[d.definition]),w){T=function(t,e,n,r,i,s,o){const a=JSON.parse(JSON.stringify(e));return Sr(t,a,n,r,i,s,o),a}(o,_,v,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};y.material=T,h.push(y)}return{dracoCompression:l,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function Sr(t,e,n,r,i,s,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const c=n[e[a].textureSetDefinitionId],h="images/"+c.formats[0].format,l=Cr(c.formats,s,t),u={url:r+`/nodes/${i}/textures/${l.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:l.format,mimeType:h};if(o){let t="";switch(l.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=l.format}u.url+="."+t}e[a]=u}else wt(e[a])&&Sr(t,e[a],n,r,i,s,o)}const Er={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function Cr(t,e,n){if(n&&n.length){const e=n[n.length-1],r=Er[e];if(r)for(let e=0,n=t.length;e<n;e++){if(t[e].format===r)return t[e]}else console.error("i3s not find texture format type from:",Er,"current textureEncoding:",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&&_r)return t[n]}return null}const Nr=new t.Coordinate(0,0),kr=new t.Coordinate(0,0),Rr=new Set,Lr=[],Pr=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.fe(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}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){let t=!1;const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){!t&&this.data.get(n.value).current&&(t=!0,console.warn(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`));const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.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 this.fe(t,e),this}fe(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}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,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(t.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let Br=0;class Ur extends(l(t.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>Pr.max&&Pr.setMaxSize(e),this.tileCache=Pr,Br++,this.tilesLoading={},this.de={},this.me=[],this.Qt=(...t)=>this.pe.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return Lr;const t=this.painter.getPaintedMeshes();if(!t)return Lr;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:i}=t;return n.length&&kt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&kt(e,r.filter((t=>!(!t||!t.geometry)))),i.length&&kt(e,i.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.me.length||super.needToRedraw())}getFrameTimestamp(){return this.ge}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.ge=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.painter.prepareRender(e),this.be(),this.ye(e);const{selectedTiles:o,leaves:a,requests:c}=this.we(r,i);c.length&&this.loadTiles(c),this.ve(o,a,e),this.Te(),c.length||this.completeRender()}we(t,e){let n=[];this._e();let r=0;const i=this.Me(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let h=!1;const l=this.getCachedTile(c.id);if(this.Oe(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):l?(this.getTileOpacity(l)<1&&(h=a=!0),o=!0,i.selected=!0,i.data=l):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this.Ae(i))o=!0;else{this.xe(i).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.Ie(t)),n.length>1&&(n.sort(Dr),i)){const t=i-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}Ie(t){const e=[],n={};let r;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.Se===i.length){s.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=i.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=s.length,e.push(t);else{if(t.selectionDepth=s.length,r=t,0===o.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}s.push(t),t.Se=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return{selectedTiles:e,leaves:n}}Ae(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.Ee+1,r=[t.node];for(;r.length>0;){const i=r.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){r.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const n=this.layer.Ce(i[s],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else i[s].Ee<=n&&r.push(i[s])}}return e}ve(t,e,n){this.tileCache.markAll(this,!1);const r=[];for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,n.renderer=this,this.tileCache.add(t[e].node.id,n);const i=n.node,s=this.layer.q(i.H);i.ft&&s.debug&&!Array.isArray(s.debug)&&r.push(i.ft)}const i=this.layer.options.services;for(let t=0;t<i.length;t++){const e=i[t],n=Array.isArray(e.debug)&&e.debug;if(n)for(const t of n){const e=this.layer.Dt(t),n=e&&e.node;n&&n.ft&&r.push(n.ft)}}const s={tiles:t,leaves:e};this.onDrawTileStart(s);const o=this.painter.paint(t,e,r,n);this.layer.fire("drawtiles",{count:o}),this.onDrawTileEnd(s),o&&this.layer.fire("canvasisdirty",{renderCount:o}),this.tileCache.shrink()}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(Ct(e)){const n=Nt(e);return this.Ne(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.H,r=this.ke[n];return new vr(e,n,r,this.layer,this.Qt).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Bt(e)&&!Ar(e)&&(e=t.baseUrl+e),this.Ne(e,null,t),null}Ne(t,e,r){let i=this.Re;i||(i=n.Util.getSupportedFormats(this.gl.gl||this.gl),this.Re=i);const s=this.layer.q(r.H);s.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),i=[];for(let t=0;t<r.length;t++)i.push(encodeURIComponent(r[t]));return e+i.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Le[r.H]),arraybuffer:e,rootIdx:r.H,upAxis:r.At,transform:r.matrix,supportedFormats:i};if(Ar(t)){const e=this.ke[r.H];if(o.projection=e.projection,o.i3sInfo=Ir(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=bt({},s),s.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:i}=n;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i||"gltf"===i?this.me.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Ut(t){this.painter&&this.painter.Ut(t)}Ft(t){this.painter&&this.painter.Ft(t)}ye(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.me.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.me.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})),n++}}Pe(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.Be(r);e.memorySize=n,this.onTileLoad(t,e)}}Be(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Be(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.Ue(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.zt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.De(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(e,n,r){if(!this.layer)return;const i=r||n.content.url,s=e&&e.message||e;e&&(404===e.status||204===e.status)||Rr.has(s)||(console.warn("failed to load 3d tile: "+i),console.warn(e),Rr.add(s)),delete this.tilesLoading[n.id],(!this.layer.options.onlyCacheNoContentTileWhenError||e&&!t.Util.isNoContentHttpCode(e.status))&&this.Fe(n,e),this.setToRedraw(),this.layer.fire("tileerror",{node:n,error:e})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return[];const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}Fe(e,n){const r={loadTime:t.Util.now(),current:!0,error:n,node:e};r.renderer=this,this.tileCache.add(e.id,r)}Ue(e){const n={loadTime:t.Util.now(),current:!0,node:e};n.renderer=this,this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.de[e]}_e(){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.je(this.canvas,e)),this.regl=this.regl||u({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),this.prepareWorker(),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 dr(this.regl,t),this.layer.ze(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Ft("@maptalks/3dtiles",t.id,n.Util.supportNPOT(this.regl)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=bt({},r),delete r.offset;const i=t.options.spatialReference;r.projection=i&&i.coordType||i&&i.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,r,(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),Br--,Br||Pr.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.Te(!0),this.tileCache.reset(this),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}Te(t){this.qe||(this.qe=Date.now());const e=Date.now();if(!t&&e-this.qe<this.layer.options.retireInterval)return;this.qe=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Me(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}je(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}Oe(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 Me(t,e,0,n)}be(){if(!this.He)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.He){const i=this.He[r];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx,o=Ut(this.layer.q(s).fetchOptions);if(n.push(w.getJSON(r,o).then((t=>{delete this.He[r];const e=this.ke[s];if(e){t.nodes?yr(e,t.nodes):(e[t.id]=t,yr(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)}pe(t,e,n){this.He||(this.He={}),this.He[e]=this.He[e]||[],this.He[e].rootIdx=t,this.He[e].push(n),this.setToRedraw()}De(t,e,n){this.ke||(this.ke=[]);const r=e.H;this.ke[r]||(this.ke[r]={});const i=this.ke[r],s=this.layer.q(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),i.version=+(s.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),t.spatialReference&&4490===t.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),t.spatialReference.wkid=4326),i.projection=t.spatialReference,function(t,e,n,r,i,s,o){if(!s.layerScene){s.layerScene=e,s.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,s.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=i;if(s.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=i.lastIndexOf("/");t=e<0?"./":i.substring(0,e)}s.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new vr(i,n,s,t,o).load()}(this.layer,t,r,0,n,i,this.Qt).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:i,height:s}=this.canvas;return!this.pickingFBO||r.width===i&&r.height===s||r.resize(i,s),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.$||(this.$=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.$[n];r||(r=this.$[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.$[e];n||(n=this.$[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.$)}cancelHighlight(t,e){if(!this.$)return;const n=this.$[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.$[t]=null),this.painter.highlight(this.$)}}cancelAllHighlight(){delete this.$,this.painter.cancelAllHighlight()}showOnly(t){if(this.X||(this.X=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.X[n];r||(r=this.X[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.X[e];n||(n=this.X[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.X)}cancelShowOnly(){delete this.X,this.painter.cancelShowOnly()}Zt(){return this.painter?this.painter.Zt():[]}ue(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.Ge();return Nr.set(e[0],e[1]),n.unproject(Nr,kr),t[0]=kr.x,t[1]=kr.y,t}return Nr.set(e[0],e[1]),n.getProjection().unproject(Nr,kr),t[0]=kr.x,t[1]=kr.y,t}Ve(t,e){const n=this.Ge();return Nr.set(e[0],e[1]),n.project(Nr,kr),t[0]=kr.x,t[1]=kr.y,t}Je(t,e){const n=this.Ge();return Nr.set(e[0],e[1]),n.unproject(Nr,kr),t[0]=kr.x,t[1]=kr.y,t}Ge(){const e=this.getMap().options.spatialReference.coordType;if(!e)throw new Error("Missing coordType in map spatialReference.");return this.$e||(this.$e=t.SpatialReference.getProjectionInstance(e)),this.$e}}function Dr(t,e){return t.ut-e.ut}function Fr(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function jr(t,e,n){return Math.sqrt(function(t,e,n){const r=_.subtract(zr,n,t),i=Fr(qr,e,0),s=Fr(Hr,e,1),o=Fr(Gr,e,2),a=_.len(i),c=_.len(s),h=_.len(o);_.normalize(i,i),_.normalize(s,s),_.normalize(o,o);const l=Vr;l[0]=_.dot(r,i),l[1]=_.dot(r,s),l[2]=_.dot(r,o);let u,f=0;l[0]<-a?(u=l[0]+a,f+=u*u):l[0]>a&&(u=l[0]-a,f+=u*u);l[1]<-c?(u=l[1]+c,f+=u*u):l[1]>c&&(u=l[1]-c,f+=u*u);l[2]<-h?(u=l[2]+h,f+=u*u):l[2]>h&&(u=l[2]-h,f+=u*u);return f}(t,e,n))}const zr=[],qr=[],Hr=[],Gr=[],Vr=[];const Jr=2*Math.PI;class $r{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 s=t.east;return s<i&&(s+=Jr,n<0&&(n+=Jr)),(n>i||be(n,i,1e-14))&&(n<s||be(n,s,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 Kr=[0,0,1];function Xr(t,e){return ne(e,t[0],t[1],t[2])}class Yr{constructor(t,e){this.normal=a.copy([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-a.dot(e,t);return a.copy(n.normal,e),n.distance=r,n}}const Zr=[],Wr=[],Qr=[],ti=[],ei=[],ni=[],ri=[],ii=[],si=[],oi=[],ai=new Yr([1,0,0],0),ci=[];class hi{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new $r(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!$r.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,r=this.northeastCornerCartesian,i=this.westNormal,s=this.southNormal,o=this.eastNormal,c=this.northNormal,h=a.subtract(ci,t,e),l=a.dot(h,i),u=a.dot(h,s),f=a.subtract(ci,t,r),d=a.dot(f,o),m=a.dot(f,c);l>0?n+=l*l:d>0&&(n+=d*d),u>0?n+=u*u:m>0&&(n+=m*m)}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;Xr($r.southwest(t,Wr),e.southwestCornerCartesian),Xr($r.northeast(t,Wr),e.northeastCornerCartesian),Zr[0]=t.west,Zr[1]=.5*(t.south+t.north),Zr[2]=0;const n=Xr(Zr,Qr),r=a.cross(ei,n,Kr);a.normalize(e.westNormal,r),Zr[0]=t.east;const i=Xr(Zr,ii),s=a.cross(ei,Kr,i);a.normalize(e.eastNormal,s);const o=a.subtract(ei,n,i),c=a.normalize(ti,o),h=t.south;let l;if(h>0){Zr[0]=.5*(t.west+t.east),Zr[1]=h;const n=Xr(Zr,si);a.copy(oi,c);const r=Yr.fromPointNormal(e.southwestCornerCartesian,e.westNormal,ai);li(si,oi,r,e.southwestCornerCartesian),l=me(n,ni)}else l=pe($r.southeast(t,Wr),ni);const u=a.cross(ri,l,o);a.normalize(e.southNormal,u);const f=t.north;let d;if(f<0){Zr[0]=.5*(t.west+t.east),Zr[1]=f;const n=Xr(Zr,si);a.scale(oi,c,-1);const r=Yr.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,ai);li(si,oi,r,e.northeastCornerCartesian),d=me(n,ni)}else d=pe($r.northwest(t,Wr),ni);const m=a.cross(ri,o,d);a.normalize(e.northNormal,m)}}function li(t,e,n,r){const i=t,s=e,o=n.normal,c=a.dot(o,s);if(Math.abs(c)<1e-15)return;const h=(-n.distance-a.dot(o,i))/c;return h<0?void 0:(r=a.scale(r,s,h),a.add(r,i,r))}function ui(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const fi=t.BBOXUtil,di={"services":[],"maxGPUMemory":t.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"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"]},mi=[0,0,0],pi=[0,0,0],gi=[0,0,0],bi=[0,0,0],yi=[0,0,0],wi=[0,0,0],vi=[0,0,0],Ti=[1,1,1],_i=[1,1,1],Mi=[0,0,0,0],Oi=[],Ai=new t.Coordinate(0,0),xi=new t.Point(0,0),Ii=[0,0,0,0,0,0,0,0,0],Si=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ei=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ci=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ni=new t.Point(0,0),ki=r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Ri=[0,0],Li=[0,0,0],Pi=[1,1,1],Bi=[0,0,0],Ui=[0,0,0],Di=[0,0,0,0],Fi=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class ji extends(f(t.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new ji(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],n=[0,0,0]){const i=ne([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),s=qe(i,null,[]),a=o.fromEuler([0,0,0,0],...n),c=r.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,[0,0,0],e);return r.multiply(c,s,c)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Ke(),this.Xe=[]}Ke(){const t=this.options.services.map((t=>t.url));this.Ye=this.Ye||{},this.Le=this.Le||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Ye[n];void 0===r&&(r=this.Ye[n]=this.Le.length),this.Le[r]=Hi(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Le.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Ze(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Ke(),this.Ze(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(Ji(n[t].coordOffset,e.coordOffset)&&Ji(n[t].heightOffset,e.heightOffset)&&Ji(n[t].scale,e.scale)&&Ji(n[t].rotation,e.rotation)),bt(n[t],e));const i=n[t].url,s=this.Ye[i],o=this.Le&&this.Le[s];return o&&(gt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Ze(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Ye[n];this.Le[r]&&(this.Le[r]=null),delete this.Ye[n],e.splice(t,1)}return this.Ze(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const i=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Le.length;t++){const n=this.Le[t];if(n&&n.boundingVolume){const t=this.boundingVolumeToExtent(n);e._combine(t)}}return e}const n=this.Le[e];return n&&n.boundingVolume?this.boundingVolumeToExtent(n):null}boundingVolumeToExtent(e){const n=e.boundingVolume.We?ki:e.matrix,r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),s=this.getRenderer();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(_t(n[0]),_t(n[1]),_t(n[2]),_t(n[3]))}if(e.boundingVolume.sphere){const o=e.boundingVolume.sphere,c=ce([],a.transformMat4([0,0,0],o,n));i&&s.Ve(c,c);const h=o[3],l=r.locate(c,-h,h),u=r.locate(c,h,-h);return new t.Extent(l,u)}if(e.boundingVolume.box){const o=e.boundingVolume.box,h=a.transformMat4([0,0,0],o,n),l=new t.Coordinate(ce([],h));i&&s.Ve(l,l);const u=o.slice(3);c.multiply(u,c.fromMat4([0,0,0,0,0,0,0,0,0],e.matrix),u);const f=a.length(u.slice(0,3)),d=a.length(u.slice(3,6)),m=a.length(u.slice(6,9)),p=Math.max(f,d,m),g=r.locate(l,-p,p),b=r.locate(l,p,-p);return new t.Extent(g,b)}return null}getRootTiles(){return this.Le}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Ze(),{tiles:Oi};const e=this.getMap(),n=e.cameraPosition,r=e.pointAtResToDistance(n[2],0,e.getGLRes()),i=this.Qe(n);this.tn=this.tn||[0,0,0],a.set(this.tn,Tt(i.x),Tt(i.y),r),this.nn=ne(this.nn||[],this.tn[0],this.tn[1],this.tn[2]),this.rn=2*Math.tan(.5*Tt(e.getFov()));const s=e.projViewMatrix;let o;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,o=ui(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof d));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=ui(e)}catch(t){console.error(t)}}));const h={children:[],level:-1};let l=h;const u=[];for(let e=0;e<this.Le.length;e++){const n=this.Le[e];if(!n||!n.visible)continue;const r=n.service,i=[n],a=this.sn(e);for(;i.length>0;){const e=i.pop();for(e.id||this.an(e);l.level>=e.Ee;)l=l.parent;const n=this.cn(e,a,s,o,c);if(e.service=r,!(n===$i.VISIBLE||n!==$i.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&Vi(e))){let t=l;for(;t&&!t.content;)t=t.parent;n===$i.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.hn(u,t);continue}e.ut<1/0&&this.ln(e);const h=this.Ce(e,l);l.children.push(h);const f=e.children,d=f&&f.length,m=h.content;if(m&&(!d||n===$i.SCREEN_ERROR_TOO_SMALL)&&this.hn(u,h),n!==$i.SCREEN_ERROR_TOO_SMALL&&d){m&&"add"===e.refine&&this.hn(u,h),l=h;const n=f[0].parent;let r=!1;for(let s=0,o=f.length;s<o;s++){if(n){const e=t.getCachedTile(f[s].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,f[s].parent=e,f[s].At=e.At,f[s].baseUrl=e.baseUrl;const t=f[s].content&&(f[s].content.url||f[s].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?f[s].baseUrl=e.baseUrl:Bt(t)?f[s].content.url=e.baseUrl+t:f[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}i.push(f[s])}!r&&m&&this.hn(u,h)}}}return{root:h,tiles:u}}hn(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){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 zi(n,e,r)<=0;if(n.box)return 0===qi(n,e,r)}return!1}(this.tn,this.nn,n,r)||t.push(e)}Ce(t,e){return{id:t.id,node:t,children:[],level:t.Ee,parent:e,content:t.content&&t.content.url}}an(e){const n=this.getId();e.id=n+":"+t.Util.GUID(),e.matrix=e.transform||r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e.un=this.dn(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.H=e.parent.H,void 0===e.Ee&&(e.Ee=e.parent.Ee+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)}q(t){return this.Le[t].service}mn(t){const e=t.boundingVolume;if(!e||e.We&&!this.pn(t))return;const n=this.q(t.H),i=n.heightOffset||0,s=this.options.offset,o=yt(s)||s[0]||s[1],c=n.coordOffset||Ri;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!e.We&&(!t.boundingVolume||!i&&r.exactEquals(t.matrix,ki)&&!o&&c===Ri))return;e.box&&e.region&&delete e.region;const{region:h,box:l,sphere:u}=e;if(e.coordOffset=[c[0],c[1]],e.heightOffset=i,h){e.originalVolume||(e.originalVolume=h.slice(0));const t=e.originalVolume,n=this.gn([_t(t[0]),_t(t[1])]);h[0]=Tt(n.x+c[0]),h[1]=Tt(n.y+c[1]);const r=this.gn([_t(t[2]),_t(t[3])]);h[2]=Tt(r.x+c[0]),h[3]=Tt(r.y+c[1]),h[4]=t[4]+i+(c[2]||0),h[5]=t[5]+i+(c[2]||0)}else if(l||u){e.originalVolume||(e.originalVolume=(l||u).slice(0));const n=l||u,r=e.originalVolume,s=a.transformMat4(mi,r,t.matrix),o=ce(pi,s),h=this.gn([o[0]+c[0],o[1]+c[1]]);o[0]=h.x,o[1]=h.y,o[2]+=i+(c[2]||0),ne(n,Tt(o[0]),Tt(o[1]),o[2])}e.We=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}pn(t){const e=t.boundingVolume,n=this.q(t.H),r=n.heightOffset||0,i=n.coordOffset||Ri;return e.coordOffset[0]!==i[0]||e.coordOffset[1]!==i[1]||e.heightOffset!==r}dn(t){return void 0===t.geometricError||!t.boundingVolume}ln(t){let e=t.parent;for(;e&&e.un&&!(e.ut<=t.ut);)e.ut=t.ut,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),this.Ze()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.At||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const s=n.indexOf("realspace/")>-1;0===e.Ee&&t.asset&&t.asset.s3mType&&s&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.At=i,e){const n=e.boundingVolume,i=e.bn;i&&delete e.bn,bt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);let s=t.root.transform;if(i){const t=this.q(e.H);t.ecefTransform&&(s=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,s||ki))}s&&(e.parent?o||(e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,s)):e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.matrix,s)),delete e.content,t.root.content&&(e.content=t.root.content),e.un=this.dn(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),!o&&a&&!Ct(a)&&Bt(a)&&(e.content.url=e.baseUrl+a),t.root&&!e.parent&&this.yn(e)}this.Ze(),this.fire("loadtileset",{tileset:t,index:e&&e.H,url:n})}wn(t,e,n){if(!t.extent||!fi)return!0;const r=t.extent;if(Di[0]=r.xmin,Di[1]=r.ymin,Di[2]=r.xmax,Di[3]=r.ymax,e){if(!fi.bboxIntersect(Di,e))return!1}if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||fi.bboxInMask(Di,e))return!0}return!1}return!0}cn(t,e,n,r,i){if(!this.wn(t,r,i))return $i.OUT_OF_FRUSTUM;if(t.ut=1/0,0===t.Ee||t.un)return this.yn(t),$i.VISIBLE;if(this.mn(t),!this.vn(t,e,n))return $i.OUT_OF_FRUSTUM;if(0===t.geometricError)return $i.VISIBLE;let s=this.q(t.H).maximumScreenSpaceError;null==s&&(s=16);let o=this.Tn(t);return 0===o&&t.parent&&(o=.5*(t.parent._n||0)),o>=s?$i.VISIBLE:$i.SCREEN_ERROR_TOO_SMALL}Xt(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.coordToPointAtRes(e,r.getGLRes(),n)}vn(t,e,n){const r=t.id;let i=this.Xe[r];const{boundingVolume:s}=t,o=s.region,a=s.box,c=s.sphere,h=this.Mn(t.H),l=this.getRenderer();i&&i.version===h.version||(o?i=this.Xe[r]=this.On(t):a?i=this.Xe[r]=this.An(t):c&&(i=this.Xe[r]=this.xn(t)),i.version=h.version,t.ft&&(l.Ft(t.ft),delete t.ft));return this.q(t.H).debug&&(this.Xe[r].node=t,l.Ut(t)),i.obbox?g(n,i.obbox):!!c&&b(n,i.sphereBox)}On(e){const n=this.getMap(),i=n.getGLRes(),s=e.boundingVolume.region;let{ws:o,en:c}=function(t){const e=t[0],n=t[1],r=t[2],i=t[3],s=t[4],o=t[5],a=ne([],e,n,s),c=ne([],r,i,o),h=ce(a,a),l=ce(c,c);return{ws:h,en:l}}(s);o=new t.Coordinate(o),c=new t.Coordinate(c);const h=n.coordToPointAtRes(o,i);h.z=n.altitudeToPoint(o.z,i);const l=n.coordToPointAtRes(c,i);l.z=n.altitudeToPoint(c.z,i);const u=[l.x,h.y,l.z,l.x,l.y,l.z,h.x,l.y,l.z,h.x,h.y,l.z,l.x,h.y,h.z,l.x,l.y,h.z,h.x,l.y,h.z,h.x,h.y,h.z],f=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],d=this.Mn(e.H);e!==d||d.In||(d.In=f);const m=this.Jt([],e),p=r.exactEquals(ki,m);if(!p){a.transformMat4(f,f,m);const t=mi;for(let e=0;e<u.length;e+=3){let n=a.set(t,u[e],u[e+1],u[e+2]);p||(n=a.transformMat4(n,n,m)),u[e]=n[0],u[e+1]=n[1],u[e+2]=n[2]}}const g=n.pointAtResToCoord(new t.Point(f),i);g.z=(o.z+c.z)/2;const b=this.Sn(u,f);for(let t=0;t<u.length;t++)u[t]-=f[t%3];return{obbox:b,boxPosition:u,boxCenter:f,boxCoord:g}}An(t){const e=this.getRenderer(),n=this.getMap(),i="identity"===n.getProjection().code.toLowerCase(),s=n.getGLRes(),{boxCenter:o,boxCoord:c}=this.En(t),h=t.boundingVolume.box,l=this.Cn(h,t.matrix),u=(d=h,function(t,e,n,r,i,s,o,a,c,h,l,u,f,d,m,p,g){return t[0]=e||0,t[1]=s||0,t[2]=h||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=l||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=u||0,t[11]=0,t[12]=i||0,t[13]=c||0,t[14]=f||0,t[15]=g,t}([],(f=l)[0],f[3],f[6],d[0],f[1],f[4],f[7],d[1],f[2],f[5],f[8],d[2],0,0,0,1));var f,d;const m=this.Jt([],t),p=r.exactEquals(ki,m);p||a.transformMat4(o,o,m);const g=[],b=mi;for(let t=0;t<Fi.length;t+=3){b[0]=Fi[t],b[1]=Fi[t+1],b[2]=Fi[t+2],a.transformMat4(b,b,u),ce(b,b),i&&e.Ve(b,b);const r=Ai.set(b[0],b[1],b[2]);n.coordToPointAtRes(r,s,xi);let o=a.set(b,xi.x,xi.y,n.altitudeToPoint(r.z,s));p||(o=a.transformMat4(o,o,m)),g[t]=o[0],g[t+1]=o[1],g[t+2]=o[2]}const y=this.Sn(g,o);for(let t=0;t<g.length;t++)g[t]-=o[t%3];return{obbox:y,boxPosition:g,boxCenter:o,boxCoord:c}}xn(e){const n=this.getMap(),r=this.getRenderer(),i="identity"===n.getProjection().code.toLowerCase(),s=e.boundingVolume.sphere,o=s;let a=mi;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:ce(a,o),i&&r.Ve(a,a);const c=new t.Coordinate(a),h=this.Xt(c,xi).toArray();h[2]=n.altitudeToPoint(c.z,n.getGLRes());const l=this.Nn(c);return{boxCenter:h,boxCoord:c,sphereBox:[h,s[3]*l[2]]}}Sn(t,e){const n=Gi(yi,t,0,1,4,5),r=Gi(wi,t,0,3,4,7),i=Gi(vi,t,0,1,2,3);return[...e,...a.sub(mi,n,e),...a.sub(pi,r,e),...a.sub(gi,i,e)]}En(e){const n=this.getMap(),r=this.getRenderer(),i="identity"===n.getProjection().code.toLowerCase(),s=n.getGLRes(),o=e.boundingVolume.box.slice(0,3);ce(o,o),i&&r.Ve(o,o);const a=new t.Coordinate(o),c=n.coordToPointAtRes(a,s);return{boxCenter:[c.x,c.y,n.altitudeToPoint(a.z,s)],boxCoord:a}}Jt(t,e){const n=this.Mn(e.H),i=this.q(e.H),s=n.In,c=r.fromTranslation(Si,a.set(mi,-s[0],-s[1],-s[2])),h=r.fromTranslation(Ei,s),l=i.rotation||Li,u=o.fromEuler(Mi,...l),f=i.scale;let d;d=Array.isArray(f)?a.set(Bi,f[0],f[1],f[2]):f&&a.set(Bi,f,f,f)||Pi;const m=r.fromRotationTranslationScale(Ci,u,Ui,d);return t=r.multiply(t,m,c),r.multiply(t,h,t)}yn(t){const e=this.q(t.H);if(!t.boundingVolume||this.kn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,i=t.boundingVolume.sphere;let s=null;n?s=this.Rn(t).boxCenter:r?s=this.Ln(t).boxCenter:i&&(s=this.xn(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Pn=[a[0]||0,a[1]||0],t.Bn=o,t.In=s}kn(t,e){if(!t.Pn)return!1;const n=e.coordOffset||Ri;return t.Pn[0]===n[0]&&t.Pn[1]===n[1]&&t.Bn===(e.heightOffset||0)}Ln(t){return this.mn(t),this.On(t)}Rn(t){return this.mn(t),this.En(t)}Cn(t,e){let n=t.slice(3,12);const r=c.fromMat4(Ii,e);return n=c.multiply(n,r,n),n}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,a.set(Ti,n.x/100*1.01,n.y/100*1.01,r),Ti}gn(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(yt(n)&&(n=n.call(this,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 xi.set(n[0],n[1]),i._sub(xi),t.pointAtResToCoord(i,r)}return e}Mn(t){return this.Le[t]}sn(e){const n=this.q(e).maxExtent;if(!n)return null;const r=this.Le[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo((t=>this.Xt(t)))),r.maxExtent}Tn(t){const e=this.rn,n=t.geometricError;if(0===n)return t._n=0,0;const i=this.q(t.H);let s=i.scale||1;if(Array.isArray(s)&&(s=a.length(s)),i.ecefTransform){const t=r.getScaling(_i,i.ecefTransform);s*=a.len(t)}const o=this.getMap();let c;t.boundingVolume.region?c=function(t,e,n){t.Un||(t.Un=new hi(t.boundingVolume.region));return t.Un.distanceToCamera(e,n)}(t,this.nn,this.tn):t.boundingVolume.sphere?c=zi(t.boundingVolume,this.nn):t.boundingVolume.box&&(c=qi(t.boundingVolume,this.nn));const h=Math.max(Math.abs(c),1e-7),l=n*s*o.height/(h*e);return t.ut=c,t._n=l,l}Ze(){const t=this.getRenderer();t&&t.setToRedraw()}Dt(t){return this.Xe[t]}identify(e,n={}){const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];Array.isArray(e)&&(e=new t.Coordinate(e));const s=r.coordToContainerPoint(e);return this.identifyAtPoint(s,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&kt(n,r)}const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];const s=r.getDevicePixelRatio();return kt(n,i.pick(t.x*s,t.y*s,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Zt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.$||(this.$=[]),this.$.push(t),this)}ze(){if(this.$){for(let t=0;t<this.$.length;t++)this.highlight(this.$[t]);delete this.$}}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.X||(this.X=[]),this.X.push(t),this)}Dn(){if(this.X){for(let t=0;t<this.X.length;t++)this.showOnly(this.X[t]);delete this.X}}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);return this.getRenderer()?(this.Ze(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Ze(),this):this}Qe(t){const e=this.getMap(),n=e.getGLRes();Ni.set(t[0],t[1]);const r=e.pointAtResToCoord(Ni,n);return"identity"===e.getProjection().code.toLowerCase()?(pi[0]=r.x,pi[1]=r.y,this.getRenderer().Je(mi,pi),r.set(mi[0],mi[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function zi(t,e,n){let r=t.sphere;n&&(r=a.transformMat4([0,0,0],r,n));const i=a.dist(r,e),s=t.sphere[3];return i<s?0:i-s}function qi(t,e,n){const r=t.box;let i=a.set(mi,r[0],r[1],r[2]);n&&(i=a.transformMat4([0,0,0],i,n));return jr(i,c.set(Ii,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function Hi(t,e,n){const i=(t=Mt(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,un:!0,service:n,visible:!!gt(n.visible)||n.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),H:e,Ee:0,bn:!0,domainKey:i}}function Gi(t,e,n,r,i,s){const o=a.set(mi,e[3*n],e[3*n+1],e[3*n+2]),c=a.set(pi,e[3*r],e[3*r+1],e[3*r+2]),h=a.set(gi,e[3*i],e[3*i+1],e[3*i+2]),l=a.set(bi,e[3*s],e[3*s+1],e[3*s+2]);return t[0]=(o[0]+c[0]+h[0]+l[0])/4,t[1]=(o[1]+c[1]+h[1]+l[1])/4,t[2]=(o[2]+c[2]+h[2]+l[2])/4,t}function Vi(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function Ji(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?m.exactEquals(t,e):a.exactEquals(t,e):t===e}var $i;ji.mergeOptions(di),ji.registerRenderer("gl",Ur),ji.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}($i||($i={}));let Ki=null;function Xi(){return Ki||(Ki={"image/crn":br.crn&&br.crn(),"image/ktx2":br.ktx2&&br.ktx2(),"image/cttf":br.ktx2&&br.ktx2(),"draco":br.draco&&br.draco()}),Ki}class Yi{constructor(t,e,n){this.Fn=t,this.jn=e||y,this.Re=n,this.zn=Xi()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,i)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.Hn(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.jn(a,o.glb,{transferable:!0,requestImage:this.Fn,decoders:this.zn,supportedFormats:this.Re,maxTextureSize:s})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}Hn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", 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 o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),h=i.getUint32(20,!0),l=i.getUint32(24,!0),u=28+e;h>=570425344?(u-=8,o=a,h=c,l=0,a=0,c=0):l>=570425344&&(u-=4,o=h,h=a,l=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=ve(t,u,a),u+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(u+=c),h>0&&(m=Te(t,u,h),u+=h,l>0)){const e=_e(0,u,l);p=t.slice(e.offset,e.offset+e.byteLength),u+=l,f.push(p)}const g=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Oe(d.BATCH_ID,t,undefined.offset,g);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:b,glb:{buffer:t,byteOffset:u,byteLength:i.byteLength+i.byteOffset-u}}}Gn(){return null}}class Zi{constructor(t,e,n,r){this.Fn=t,this.jn=e||y,this.Re=n,this.zn=Xi(),this.Vn=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,i)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(t,e,n,r,i){return this.Jn(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.$n(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}Jn(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.Fn,decoders:this.zn,supportedFormats:this.Re,maxTextureSize:s},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=xt(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?w.getArrayBuffer(r,{}).then((t=>this.Kn(r,{buffer:t.data,byteOffset:0},o))):w.getJSON(r,{}).then((t=>this.Kn(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Kn(t,r,o)}}Kn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.jn(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=`${t}-${r}-${s}`,{transferables:i.transferables,gltf:n}}))}$n(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", 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 o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:l}=ke(i,32+e,o),u={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Xn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Oe(a.BATCH_ID,t,c.offset,f);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Yn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Yn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:l,featureTable:a,i3dm:u,transferables:o}}Yn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Wi(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}Xn(t,e,n){return Ne(new Float32Array(t.length),t,e,n)}Gn(){return null}}function Wi(t,e,n,r){if(t[0]=Qi(e,r),t[1]=Qi(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]))*ts(e),t[1]=(1-Math.abs(e))*ts(t[1])}return _.normalize(t,t)}function Qi(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 ts(t){return t<0?-1:1}class es{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.qn(t,e,n,r)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.qn(t,i,n,r)}))}qn(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 i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", 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 o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:l}=ke(i,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,f=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.Wn||(this.Wn=Xi().draco),this.Wn(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.Qn(t,e.attributes,c.offset,d,o,u,f);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:Ce(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=Oe(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=ns(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:l,featureTable:a,pnts:r,transferables:o}}))}const g=this.Qn(t,a,c.offset,d,o,u,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?g.BATCH_ID=Oe(a.BATCH_ID,t,c.offset,d):g.BATCH_ID=ns(d);const e=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:l,featureTable:a,pnts:g,transferables:o})}Qn(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:h}=e.POSITION_QUANTIZED;c=c||0;const l=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Xn(h||new Uint16Array(t,c+l,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}Xn(t,e,n){return Ne(new Float32Array(t.length),t,e,n)}Gn(){return null}}function ns(t){const e=Et(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:Ce(e),array:n}}class rs{constructor(t,e,n,r){this.Re=n,this.Fn=t,this.jn=e||y,this.Vn=r}load(t,e,n=0,r=0,i){return e?this.qn(t,e,n,r,i):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.qn(t,i,n,r)}))}qn(t,e,n,r,i){r||(r=e.byteLength);const s=this.tr(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new Yi(this.Fn,this.jn,this.Re);else if("i3dm"===s[n].magic)r=new Zi(this.Fn,this.jn,this.Re,this.Vn);else if("pnts"===s[n].magic)r=new es;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new rs(this.Fn,this.jn,this.Re,this.Vn)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}tr(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=ye(i,c),r=i.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(A);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(A)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",A);export{Yi as B3DMLoader,rs as CMPTLoader,ji as Geo3DTilesLayer,Pt as Geo3DTilesUtil,ge as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.102.2");
12
12
  //# sourceMappingURL=maptalks.3dtiles.es.js.map